diff options
author | Benjamin Otte <otte@redhat.com> | 2012-03-30 01:51:04 +0200 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2012-04-17 08:59:15 +0200 |
commit | 8e17f9c2338c2e64ced679dc11cc9d2c3d76daf6 (patch) | |
tree | 8e4d686af41d62c2b2f2285c58664c160fa7a098 | |
parent | 40982eabbb6bc7515cf045c4c85eb18df42c125b (diff) | |
download | gtk+-8e17f9c2338c2e64ced679dc11cc9d2c3d76daf6.tar.gz |
switch: Set ACTIVE state flag with is_active property
-rw-r--r-- | gtk/gtkswitch.c | 34 |
1 files changed, 8 insertions, 26 deletions
diff --git a/gtk/gtkswitch.c b/gtk/gtkswitch.c index 90e688b428..d81a68cca0 100644 --- a/gtk/gtkswitch.c +++ b/gtk/gtkswitch.c @@ -308,7 +308,6 @@ gtk_switch_get_preferred_width (GtkWidget *widget, gint *minimum, gint *natural) { - GtkSwitchPrivate *priv = GTK_SWITCH (widget)->priv; GtkStyleContext *context; GtkStateFlags state; GtkBorder padding; @@ -317,14 +316,10 @@ gtk_switch_get_preferred_width (GtkWidget *widget, PangoRectangle logical_rect; context = gtk_widget_get_style_context (widget); - state = gtk_widget_get_state_flags (widget); - - if (priv->is_active) - state |= GTK_STATE_FLAG_ACTIVE; + state = gtk_style_context_get_state (context); gtk_style_context_save (context); - gtk_style_context_set_state (context, state); gtk_style_context_add_class (context, GTK_STYLE_CLASS_SLIDER); gtk_style_context_get_padding (context, state, &padding); @@ -371,7 +366,6 @@ gtk_switch_get_preferred_height (GtkWidget *widget, gint *minimum, gint *natural) { - GtkSwitchPrivate *priv = GTK_SWITCH (widget)->priv; GtkStyleContext *context; GtkStateFlags state; GtkBorder padding; @@ -381,14 +375,10 @@ gtk_switch_get_preferred_height (GtkWidget *widget, gchar *str; context = gtk_widget_get_style_context (widget); - state = gtk_widget_get_state_flags (widget); - - if (priv->is_active) - state |= GTK_STATE_FLAG_ACTIVE; + state = gtk_style_context_get_state (context); gtk_style_context_save (context); - gtk_style_context_set_state (context, state); gtk_style_context_add_class (context, GTK_STYLE_CLASS_SLIDER); gtk_style_context_get_padding (context, state, &padding); @@ -518,17 +508,9 @@ gtk_switch_paint_handle (GtkWidget *widget, cairo_t *cr, GdkRectangle *box) { - GtkSwitchPrivate *priv = GTK_SWITCH (widget)->priv; GtkStyleContext *context = gtk_widget_get_style_context (widget); - GtkStateFlags state; - - state = gtk_widget_get_state_flags (widget); - - if (priv->is_active) - state |= GTK_STATE_FLAG_ACTIVE; gtk_style_context_save (context); - gtk_style_context_set_state (context, state); gtk_style_context_add_class (context, GTK_STYLE_CLASS_SLIDER); gtk_render_slider (context, cr, @@ -551,8 +533,8 @@ gtk_switch_draw (GtkWidget *widget, const PangoFontDescription *style_desc; PangoRectangle rect; gint label_x, label_y; - GtkStateFlags state; GtkBorder padding; + GtkStateFlags state; gint focus_width, focus_pad; gint x, y, width, height; gint font_size, style_font_size; @@ -565,12 +547,8 @@ gtk_switch_draw (GtkWidget *widget, context = gtk_widget_get_style_context (widget); state = gtk_widget_get_state_flags (widget); - if (priv->is_active) - state |= GTK_STATE_FLAG_ACTIVE; - gtk_style_context_save (context); - gtk_style_context_set_state (context, state); gtk_style_context_add_class (context, GTK_STYLE_CLASS_SLIDER); gtk_style_context_get_padding (context, state, &padding); @@ -592,7 +570,6 @@ gtk_switch_draw (GtkWidget *widget, gtk_style_context_save (context); gtk_style_context_add_class (context, GTK_STYLE_CLASS_TROUGH); - gtk_style_context_set_state (context, state); gtk_render_background (context, cr, x, y, width, height); gtk_render_frame (context, cr, x, y, width, height); @@ -1069,6 +1046,11 @@ gtk_switch_set_active (GtkSwitch *sw, NULL, GTK_STATE_ACTIVE, is_active); } + if (priv->is_active) + gtk_widget_set_state_flags (GTK_WIDGET (sw), GTK_STATE_FLAG_ACTIVE, FALSE); + else + gtk_widget_unset_state_flags (GTK_WIDGET (sw), GTK_STATE_FLAG_ACTIVE); + gtk_widget_queue_draw (GTK_WIDGET (sw)); } } |