Update _gtk_button_paint() arguments to GtkStyleContext

The detail strings weren't in use anymore, and the state
argument is now a GtkStateFlags. GtkToggleButton has been
updated as well.
This commit is contained in:
Carlos Garnacho 2011-01-10 02:26:28 +01:00
parent f506fc3e93
commit e0e36b621f
3 changed files with 14 additions and 30 deletions

View File

@ -1555,10 +1555,7 @@ _gtk_button_paint (GtkButton *button,
cairo_t *cr, cairo_t *cr,
int width, int width,
int height, int height,
GtkStateType state_type, GtkStateFlags state)
GtkShadowType shadow_type,
const gchar *main_detail,
const gchar *default_detail)
{ {
GtkButtonPrivate *priv = button->priv; GtkButtonPrivate *priv = button->priv;
GtkWidget *widget; GtkWidget *widget;
@ -1571,12 +1568,12 @@ _gtk_button_paint (GtkButton *button,
GtkAllocation allocation; GtkAllocation allocation;
GdkWindow *window; GdkWindow *window;
GtkStyleContext *context; GtkStyleContext *context;
GtkStateFlags state;
widget = GTK_WIDGET (button); widget = GTK_WIDGET (button);
context = gtk_widget_get_style_context (widget); context = gtk_widget_get_style_context (widget);
state = gtk_widget_get_state_flags (widget);
gtk_style_context_save (context);
gtk_style_context_set_state (context, state);
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_style_context_get_style (context, gtk_style_context_get_style (context,
@ -1616,9 +1613,6 @@ _gtk_button_paint (GtkButton *button,
height -= 2 * (focus_width + focus_pad); height -= 2 * (focus_width + focus_pad);
} }
state = gtk_widget_get_state_flags (widget);
gtk_style_context_set_state (context, state);
if (priv->relief != GTK_RELIEF_NONE || priv->depressed || if (priv->relief != GTK_RELIEF_NONE || priv->depressed ||
state & GTK_STATE_FLAG_PRELIGHT) state & GTK_STATE_FLAG_PRELIGHT)
{ {
@ -1671,6 +1665,8 @@ _gtk_button_paint (GtkButton *button,
gtk_border_free (border); gtk_border_free (border);
} }
gtk_style_context_restore (context);
} }
static gboolean static gboolean
@ -1678,14 +1674,11 @@ gtk_button_draw (GtkWidget *widget,
cairo_t *cr) cairo_t *cr)
{ {
GtkButton *button = GTK_BUTTON (widget); GtkButton *button = GTK_BUTTON (widget);
GtkButtonPrivate *priv = button->priv;
_gtk_button_paint (button, cr, _gtk_button_paint (button, cr,
gtk_widget_get_allocated_width (widget), gtk_widget_get_allocated_width (widget),
gtk_widget_get_allocated_height (widget), gtk_widget_get_allocated_height (widget),
gtk_widget_get_state (widget), gtk_widget_get_state_flags (widget));
priv->depressed ? GTK_SHADOW_IN : GTK_SHADOW_OUT,
"button", "buttondefault");
GTK_WIDGET_CLASS (gtk_button_parent_class)->draw (widget, cr); GTK_WIDGET_CLASS (gtk_button_parent_class)->draw (widget, cr);

View File

@ -127,10 +127,7 @@ void _gtk_button_paint (GtkButton *button,
cairo_t *cr, cairo_t *cr,
int width, int width,
int height, int height,
GtkStateType state_type, GtkStateFlags state);
GtkShadowType shadow_type,
const gchar *main_detail,
const gchar *default_detail);
G_END_DECLS G_END_DECLS

View File

@ -471,25 +471,19 @@ gtk_toggle_button_draw (GtkWidget *widget,
GtkToggleButtonPrivate *priv = toggle_button->priv; GtkToggleButtonPrivate *priv = toggle_button->priv;
GtkWidget *child = gtk_bin_get_child (GTK_BIN (widget)); GtkWidget *child = gtk_bin_get_child (GTK_BIN (widget));
GtkButton *button = GTK_BUTTON (widget); GtkButton *button = GTK_BUTTON (widget);
GtkStateType state_type; GtkStateType state;
GtkShadowType shadow_type;
state_type = gtk_widget_get_state (widget); state = gtk_widget_get_state_flags (widget);
if (priv->inconsistent) if (priv->inconsistent)
{ state |= GTK_STATE_FLAG_INCONSISTENT;
if (state_type == GTK_STATE_ACTIVE) else if (button->priv->depressed)
state_type = GTK_STATE_NORMAL; state |= GTK_STATE_FLAG_ACTIVE;
shadow_type = GTK_SHADOW_ETCHED_IN;
}
else
shadow_type = button->priv->depressed ? GTK_SHADOW_IN : GTK_SHADOW_OUT;
_gtk_button_paint (button, cr, _gtk_button_paint (button, cr,
gtk_widget_get_allocated_width (widget), gtk_widget_get_allocated_width (widget),
gtk_widget_get_allocated_height (widget), gtk_widget_get_allocated_height (widget),
state_type, shadow_type, state);
"togglebutton", "togglebuttondefault");
if (child) if (child)
gtk_container_propagate_draw (GTK_CONTAINER (widget), child, cr); gtk_container_propagate_draw (GTK_CONTAINER (widget), child, cr);