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

View File

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