Use the new style context API in GtkButton
Mostly replaces gtk_widget_style_get with gtk_style_context_get_style
This commit is contained in:
parent
4a7e746bbc
commit
b36cb87df9
118
gtk/gtkbutton.c
118
gtk/gtkbutton.c
@ -971,6 +971,7 @@ static void
|
|||||||
gtk_button_construct_child (GtkButton *button)
|
gtk_button_construct_child (GtkButton *button)
|
||||||
{
|
{
|
||||||
GtkButtonPrivate *priv = button->priv;
|
GtkButtonPrivate *priv = button->priv;
|
||||||
|
GtkStyleContext *context;
|
||||||
GtkStockItem item;
|
GtkStockItem item;
|
||||||
GtkWidget *child;
|
GtkWidget *child;
|
||||||
GtkWidget *label;
|
GtkWidget *label;
|
||||||
@ -986,9 +987,11 @@ gtk_button_construct_child (GtkButton *button)
|
|||||||
if (!priv->label_text && !priv->image)
|
if (!priv->label_text && !priv->image)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
gtk_widget_style_get (GTK_WIDGET (button),
|
context = gtk_widget_get_style_context (GTK_WIDGET (button));
|
||||||
"image-spacing", &image_spacing,
|
|
||||||
NULL);
|
gtk_style_context_get_style (context,
|
||||||
|
"image-spacing", &image_spacing,
|
||||||
|
NULL);
|
||||||
|
|
||||||
if (priv->image && !priv->image_is_stock)
|
if (priv->image && !priv->image_is_stock)
|
||||||
{
|
{
|
||||||
@ -1302,8 +1305,6 @@ gtk_button_realize (GtkWidget *widget)
|
|||||||
priv->event_window = gdk_window_new (window,
|
priv->event_window = gdk_window_new (window,
|
||||||
&attributes, attributes_mask);
|
&attributes, attributes_mask);
|
||||||
gdk_window_set_user_data (priv->event_window, button);
|
gdk_window_set_user_data (priv->event_window, button);
|
||||||
|
|
||||||
gtk_widget_style_attach (widget);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1350,7 +1351,8 @@ gtk_button_unmap (GtkWidget *widget)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_button_update_image_spacing (GtkButton *button)
|
gtk_button_update_image_spacing (GtkButton *button,
|
||||||
|
GtkStyleContext *context)
|
||||||
{
|
{
|
||||||
GtkButtonPrivate *priv = button->priv;
|
GtkButtonPrivate *priv = button->priv;
|
||||||
GtkWidget *child;
|
GtkWidget *child;
|
||||||
@ -1369,19 +1371,23 @@ gtk_button_update_image_spacing (GtkButton *button)
|
|||||||
child = gtk_bin_get_child (GTK_BIN (child));
|
child = gtk_bin_get_child (GTK_BIN (child));
|
||||||
if (GTK_IS_BOX (child))
|
if (GTK_IS_BOX (child))
|
||||||
{
|
{
|
||||||
gtk_widget_style_get (GTK_WIDGET (button),
|
gtk_style_context_get_style (context,
|
||||||
"image-spacing", &spacing,
|
"image-spacing", &spacing,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
gtk_box_set_spacing (GTK_BOX (child), spacing);
|
gtk_box_set_spacing (GTK_BOX (child), spacing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_button_style_updated (GtkWidget *widget)
|
gtk_button_style_updated (GtkWidget *widget)
|
||||||
{
|
{
|
||||||
gtk_button_update_image_spacing (GTK_BUTTON (widget));
|
GtkStyleContext *context;
|
||||||
|
|
||||||
|
context = gtk_widget_get_style_context (widget);
|
||||||
|
|
||||||
|
gtk_button_update_image_spacing (GTK_BUTTON (widget), context);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1391,12 +1397,16 @@ gtk_button_get_props (GtkButton *button,
|
|||||||
GtkBorder *inner_border,
|
GtkBorder *inner_border,
|
||||||
gboolean *interior_focus)
|
gboolean *interior_focus)
|
||||||
{
|
{
|
||||||
GtkWidget *widget = GTK_WIDGET (button);
|
GtkStyleContext *context;
|
||||||
GtkBorder *tmp_border;
|
GtkBorder *tmp_border;
|
||||||
|
|
||||||
|
context = gtk_widget_get_style_context (GTK_WIDGET (button));
|
||||||
|
|
||||||
if (default_border)
|
if (default_border)
|
||||||
{
|
{
|
||||||
gtk_widget_style_get (widget, "default-border", &tmp_border, NULL);
|
gtk_style_context_get_style (context,
|
||||||
|
"default-border", &tmp_border,
|
||||||
|
NULL);
|
||||||
|
|
||||||
if (tmp_border)
|
if (tmp_border)
|
||||||
{
|
{
|
||||||
@ -1409,7 +1419,9 @@ gtk_button_get_props (GtkButton *button,
|
|||||||
|
|
||||||
if (default_outside_border)
|
if (default_outside_border)
|
||||||
{
|
{
|
||||||
gtk_widget_style_get (widget, "default-outside-border", &tmp_border, NULL);
|
gtk_style_context_get_style (context,
|
||||||
|
"default-outside-border", &tmp_border,
|
||||||
|
NULL);
|
||||||
|
|
||||||
if (tmp_border)
|
if (tmp_border)
|
||||||
{
|
{
|
||||||
@ -1422,7 +1434,9 @@ gtk_button_get_props (GtkButton *button,
|
|||||||
|
|
||||||
if (inner_border)
|
if (inner_border)
|
||||||
{
|
{
|
||||||
gtk_widget_style_get (widget, "inner-border", &tmp_border, NULL);
|
gtk_style_context_get_style (context,
|
||||||
|
"inner-border", &tmp_border,
|
||||||
|
NULL);
|
||||||
|
|
||||||
if (tmp_border)
|
if (tmp_border)
|
||||||
{
|
{
|
||||||
@ -1434,7 +1448,11 @@ gtk_button_get_props (GtkButton *button,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (interior_focus)
|
if (interior_focus)
|
||||||
gtk_widget_style_get (widget, "interior-focus", interior_focus, NULL);
|
{
|
||||||
|
gtk_style_context_get_style (context,
|
||||||
|
"interior-focus", interior_focus,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1447,25 +1465,25 @@ gtk_button_size_allocate (GtkWidget *widget,
|
|||||||
GtkStyleContext *context;
|
GtkStyleContext *context;
|
||||||
GtkStateFlags state;
|
GtkStateFlags state;
|
||||||
GtkWidget *child;
|
GtkWidget *child;
|
||||||
|
|
||||||
GtkBorder default_border;
|
GtkBorder default_border;
|
||||||
GtkBorder inner_border, *border;
|
GtkBorder inner_border;
|
||||||
|
GtkBorder *border;
|
||||||
gint focus_width;
|
gint focus_width;
|
||||||
gint focus_pad;
|
gint focus_pad;
|
||||||
|
|
||||||
context = gtk_widget_get_style_context (widget);
|
context = gtk_widget_get_style_context (widget);
|
||||||
state = gtk_widget_get_state_flags (widget);
|
state = gtk_widget_get_state_flags (widget);
|
||||||
|
|
||||||
|
gtk_button_get_props (button, &default_border, NULL, &inner_border, NULL);
|
||||||
|
gtk_style_context_get_style (context,
|
||||||
|
"focus-line-width", &focus_width,
|
||||||
|
"focus-padding", &focus_pad,
|
||||||
|
NULL);
|
||||||
|
|
||||||
gtk_style_context_get (context, state,
|
gtk_style_context_get (context, state,
|
||||||
"border-width", &border,
|
"border-width", &border,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
gtk_button_get_props (button, &default_border, NULL, &inner_border, NULL);
|
|
||||||
gtk_widget_style_get (GTK_WIDGET (widget),
|
|
||||||
"focus-line-width", &focus_width,
|
|
||||||
"focus-padding", &focus_pad,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
gtk_widget_set_allocation (widget, allocation);
|
gtk_widget_set_allocation (widget, allocation);
|
||||||
|
|
||||||
if (gtk_widget_get_realized (widget))
|
if (gtk_widget_get_realized (widget))
|
||||||
@ -1513,11 +1531,11 @@ gtk_button_size_allocate (GtkWidget *widget,
|
|||||||
{
|
{
|
||||||
gint child_displacement_x;
|
gint child_displacement_x;
|
||||||
gint child_displacement_y;
|
gint child_displacement_y;
|
||||||
|
|
||||||
gtk_widget_style_get (widget,
|
gtk_style_context_get_style (context,
|
||||||
"child-displacement-x", &child_displacement_x,
|
"child-displacement-x", &child_displacement_x,
|
||||||
"child-displacement-y", &child_displacement_y,
|
"child-displacement-y", &child_displacement_y,
|
||||||
NULL);
|
NULL);
|
||||||
child_allocation.x += child_displacement_x;
|
child_allocation.x += child_displacement_x;
|
||||||
child_allocation.y += child_displacement_y;
|
child_allocation.y += child_displacement_y;
|
||||||
}
|
}
|
||||||
@ -1556,14 +1574,16 @@ _gtk_button_paint (GtkButton *button,
|
|||||||
|
|
||||||
widget = GTK_WIDGET (button);
|
widget = GTK_WIDGET (button);
|
||||||
|
|
||||||
|
context = gtk_widget_get_style_context (widget);
|
||||||
|
state = gtk_widget_get_state_flags (widget);
|
||||||
|
|
||||||
gtk_button_get_props (button, &default_border, &default_outside_border, NULL, &interior_focus);
|
gtk_button_get_props (button, &default_border, &default_outside_border, NULL, &interior_focus);
|
||||||
gtk_widget_style_get (widget,
|
gtk_style_context_get_style (context,
|
||||||
"focus-line-width", &focus_width,
|
"focus-line-width", &focus_width,
|
||||||
"focus-padding", &focus_pad,
|
"focus-padding", &focus_pad,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
gtk_widget_get_allocation (widget, &allocation);
|
gtk_widget_get_allocation (widget, &allocation);
|
||||||
context = gtk_widget_get_style_context (widget);
|
|
||||||
window = gtk_widget_get_window (widget);
|
window = gtk_widget_get_window (widget);
|
||||||
|
|
||||||
x = 0;
|
x = 0;
|
||||||
@ -1614,15 +1634,15 @@ _gtk_button_paint (GtkButton *button,
|
|||||||
gboolean displace_focus;
|
gboolean displace_focus;
|
||||||
GtkBorder *border;
|
GtkBorder *border;
|
||||||
|
|
||||||
gtk_widget_style_get (widget,
|
gtk_style_context_get_style (context,
|
||||||
"child-displacement-y", &child_displacement_y,
|
"child-displacement-y", &child_displacement_y,
|
||||||
"child-displacement-x", &child_displacement_x,
|
"child-displacement-x", &child_displacement_x,
|
||||||
"displace-focus", &displace_focus,
|
"displace-focus", &displace_focus,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
gtk_style_context_get (context, state,
|
gtk_style_context_get (context, state,
|
||||||
"border-width", &border,
|
"border-width", &border,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
if (interior_focus)
|
if (interior_focus)
|
||||||
{
|
{
|
||||||
@ -1906,23 +1926,23 @@ gtk_button_get_size (GtkWidget *widget,
|
|||||||
{
|
{
|
||||||
GtkButton *button = GTK_BUTTON (widget);
|
GtkButton *button = GTK_BUTTON (widget);
|
||||||
GtkStyleContext *context;
|
GtkStyleContext *context;
|
||||||
|
GtkStateFlags state;
|
||||||
GtkWidget *child;
|
GtkWidget *child;
|
||||||
GtkBorder default_border;
|
GtkBorder default_border;
|
||||||
GtkBorder inner_border;
|
GtkBorder inner_border;
|
||||||
GtkStateFlags state;
|
|
||||||
GtkBorder *border;
|
GtkBorder *border;
|
||||||
gint focus_width;
|
gint focus_width;
|
||||||
gint focus_pad;
|
gint focus_pad;
|
||||||
gint minimum, natural;
|
gint minimum, natural;
|
||||||
|
|
||||||
gtk_button_get_props (button, &default_border, NULL, &inner_border, NULL);
|
context = gtk_widget_get_style_context (widget);
|
||||||
gtk_widget_style_get (GTK_WIDGET (widget),
|
state = gtk_widget_get_state_flags (widget);
|
||||||
"focus-line-width", &focus_width,
|
|
||||||
"focus-padding", &focus_pad,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
context = gtk_widget_get_style_context (GTK_WIDGET (widget));
|
gtk_button_get_props (button, &default_border, NULL, &inner_border, NULL);
|
||||||
state = gtk_widget_get_state_flags (GTK_WIDGET (widget));
|
gtk_style_context_get_style (context,
|
||||||
|
"focus-line-width", &focus_width,
|
||||||
|
"focus-padding", &focus_pad,
|
||||||
|
NULL);
|
||||||
|
|
||||||
gtk_style_context_get (context, state,
|
gtk_style_context_get (context, state,
|
||||||
"border-width", &border,
|
"border-width", &border,
|
||||||
|
Loading…
Reference in New Issue
Block a user