mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 19:00:08 +00:00
button: Handle :inconsistent in GtkToggleButton
This commit is contained in:
parent
cd349dcd48
commit
db1ab7ddf8
@ -529,7 +529,6 @@ gtk_real_check_button_draw_indicator (GtkCheckButton *check_button,
|
||||
{
|
||||
GtkWidget *widget;
|
||||
GtkButton *button;
|
||||
GtkToggleButton *toggle_button;
|
||||
GtkStateFlags state = 0;
|
||||
gint x, y;
|
||||
gint indicator_size;
|
||||
@ -541,7 +540,6 @@ gtk_real_check_button_draw_indicator (GtkCheckButton *check_button,
|
||||
|
||||
widget = GTK_WIDGET (check_button);
|
||||
button = GTK_BUTTON (check_button);
|
||||
toggle_button = GTK_TOGGLE_BUTTON (check_button);
|
||||
|
||||
gtk_widget_get_allocation (widget, &allocation);
|
||||
baseline = gtk_widget_get_allocated_baseline (widget);
|
||||
@ -559,13 +557,9 @@ gtk_real_check_button_draw_indicator (GtkCheckButton *check_button,
|
||||
y = CLAMP (baseline - indicator_size * button->priv->baseline_align,
|
||||
0, allocation.height - indicator_size);
|
||||
|
||||
state &= ~(GTK_STATE_FLAG_INCONSISTENT |
|
||||
GTK_STATE_FLAG_ACTIVE |
|
||||
state &= ~(GTK_STATE_FLAG_ACTIVE |
|
||||
GTK_STATE_FLAG_PRELIGHT);
|
||||
|
||||
if (gtk_toggle_button_get_inconsistent (toggle_button))
|
||||
state |= GTK_STATE_FLAG_INCONSISTENT;
|
||||
|
||||
if (button->priv->activate_timeout || (button->priv->button_down && button->priv->in_button))
|
||||
state |= GTK_STATE_FLAG_ACTIVE;
|
||||
|
||||
|
@ -830,7 +830,6 @@ gtk_radio_button_draw_indicator (GtkCheckButton *check_button,
|
||||
GtkAllocation allocation;
|
||||
GtkWidget *widget;
|
||||
GtkButton *button;
|
||||
GtkToggleButton *toggle_button;
|
||||
GtkStyleContext *context;
|
||||
GtkStateFlags state = 0;
|
||||
gint x, y;
|
||||
@ -840,7 +839,6 @@ gtk_radio_button_draw_indicator (GtkCheckButton *check_button,
|
||||
|
||||
widget = GTK_WIDGET (check_button);
|
||||
button = GTK_BUTTON (check_button);
|
||||
toggle_button = GTK_TOGGLE_BUTTON (check_button);
|
||||
context = gtk_widget_get_style_context (widget);
|
||||
state = gtk_widget_get_state_flags (widget);
|
||||
|
||||
@ -857,13 +855,9 @@ gtk_radio_button_draw_indicator (GtkCheckButton *check_button,
|
||||
y = CLAMP (baseline - indicator_size * button->priv->baseline_align,
|
||||
0, allocation.height - indicator_size);
|
||||
|
||||
state &= ~(GTK_STATE_FLAG_INCONSISTENT |
|
||||
GTK_STATE_FLAG_ACTIVE |
|
||||
state &= ~(GTK_STATE_FLAG_ACTIVE |
|
||||
GTK_STATE_FLAG_PRELIGHT);
|
||||
|
||||
if (gtk_toggle_button_get_inconsistent (toggle_button))
|
||||
state |= GTK_STATE_FLAG_INCONSISTENT;
|
||||
|
||||
if (button->priv->activate_timeout ||
|
||||
(button->priv->button_down && button->priv->in_button))
|
||||
state |= GTK_STATE_FLAG_ACTIVE;
|
||||
|
@ -559,8 +559,10 @@ gtk_toggle_button_set_inconsistent (GtkToggleButton *toggle_button,
|
||||
{
|
||||
priv->inconsistent = setting;
|
||||
|
||||
gtk_toggle_button_update_state (GTK_BUTTON (toggle_button));
|
||||
gtk_widget_queue_draw (GTK_WIDGET (toggle_button));
|
||||
if (setting)
|
||||
gtk_widget_set_state_flags (GTK_WIDGET (toggle_button), GTK_STATE_FLAG_INCONSISTENT, FALSE);
|
||||
else
|
||||
gtk_widget_unset_state_flags (GTK_WIDGET (toggle_button), GTK_STATE_FLAG_INCONSISTENT);
|
||||
|
||||
g_object_notify (G_OBJECT (toggle_button), "inconsistent");
|
||||
}
|
||||
@ -653,17 +655,12 @@ static void
|
||||
gtk_toggle_button_update_state (GtkButton *button)
|
||||
{
|
||||
GtkToggleButton *toggle_button = GTK_TOGGLE_BUTTON (button);
|
||||
GtkToggleButtonPrivate *priv = toggle_button->priv;
|
||||
GtkStateFlags new_state = 0;
|
||||
|
||||
new_state = gtk_widget_get_state_flags (GTK_WIDGET (button)) &
|
||||
~(GTK_STATE_FLAG_INCONSISTENT |
|
||||
GTK_STATE_FLAG_PRELIGHT |
|
||||
~(GTK_STATE_FLAG_PRELIGHT |
|
||||
GTK_STATE_FLAG_ACTIVE);
|
||||
|
||||
if (priv->inconsistent)
|
||||
new_state |= GTK_STATE_FLAG_INCONSISTENT;
|
||||
|
||||
if (button->priv->in_button && button->priv->button_down)
|
||||
new_state |= GTK_STATE_FLAG_ACTIVE;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user