GtkToggleButton: Set widget state as state flags.

This commit is contained in:
Carlos Garnacho 2010-10-31 14:45:19 +01:00
parent 80d1ce9f67
commit 1c2f27fe11

View File

@ -551,12 +551,15 @@ gtk_toggle_button_update_state (GtkButton *button)
GtkToggleButton *toggle_button = GTK_TOGGLE_BUTTON (button); GtkToggleButton *toggle_button = GTK_TOGGLE_BUTTON (button);
GtkToggleButtonPrivate *priv = toggle_button->priv; GtkToggleButtonPrivate *priv = toggle_button->priv;
gboolean depressed, touchscreen; gboolean depressed, touchscreen;
GtkStateType new_state; GtkStateFlags new_state = 0;
g_object_get (gtk_widget_get_settings (GTK_WIDGET (button)), g_object_get (gtk_widget_get_settings (GTK_WIDGET (button)),
"gtk-touchscreen-mode", &touchscreen, "gtk-touchscreen-mode", &touchscreen,
NULL); NULL);
if (priv->inconsistent)
new_state |= GTK_STATE_FLAG_INCONSISTENT;
if (priv->inconsistent) if (priv->inconsistent)
depressed = FALSE; depressed = FALSE;
else if (button->priv->in_button && button->priv->button_down) else if (button->priv->in_button && button->priv->button_down)
@ -565,10 +568,10 @@ gtk_toggle_button_update_state (GtkButton *button)
depressed = priv->active; depressed = priv->active;
if (!touchscreen && button->priv->in_button && (!button->priv->button_down || priv->draw_indicator)) if (!touchscreen && button->priv->in_button && (!button->priv->button_down || priv->draw_indicator))
new_state = GTK_STATE_PRELIGHT; new_state |= GTK_STATE_FLAG_PRELIGHT;
else else if (depressed)
new_state = depressed ? GTK_STATE_ACTIVE : GTK_STATE_NORMAL; new_state |= GTK_STATE_FLAG_ACTIVE;
_gtk_button_set_depressed (button, depressed); _gtk_button_set_depressed (button, depressed);
gtk_widget_set_state (GTK_WIDGET (toggle_button), new_state); gtk_widget_set_state_flags (GTK_WIDGET (toggle_button), new_state, TRUE);
} }