forked from AuroraMiddleware/gtk
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;
|
GtkWidget *widget;
|
||||||
GtkButton *button;
|
GtkButton *button;
|
||||||
GtkToggleButton *toggle_button;
|
|
||||||
GtkStateFlags state = 0;
|
GtkStateFlags state = 0;
|
||||||
gint x, y;
|
gint x, y;
|
||||||
gint indicator_size;
|
gint indicator_size;
|
||||||
@ -541,7 +540,6 @@ gtk_real_check_button_draw_indicator (GtkCheckButton *check_button,
|
|||||||
|
|
||||||
widget = GTK_WIDGET (check_button);
|
widget = GTK_WIDGET (check_button);
|
||||||
button = GTK_BUTTON (check_button);
|
button = GTK_BUTTON (check_button);
|
||||||
toggle_button = GTK_TOGGLE_BUTTON (check_button);
|
|
||||||
|
|
||||||
gtk_widget_get_allocation (widget, &allocation);
|
gtk_widget_get_allocation (widget, &allocation);
|
||||||
baseline = gtk_widget_get_allocated_baseline (widget);
|
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,
|
y = CLAMP (baseline - indicator_size * button->priv->baseline_align,
|
||||||
0, allocation.height - indicator_size);
|
0, allocation.height - indicator_size);
|
||||||
|
|
||||||
state &= ~(GTK_STATE_FLAG_INCONSISTENT |
|
state &= ~(GTK_STATE_FLAG_ACTIVE |
|
||||||
GTK_STATE_FLAG_ACTIVE |
|
|
||||||
GTK_STATE_FLAG_PRELIGHT);
|
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))
|
if (button->priv->activate_timeout || (button->priv->button_down && button->priv->in_button))
|
||||||
state |= GTK_STATE_FLAG_ACTIVE;
|
state |= GTK_STATE_FLAG_ACTIVE;
|
||||||
|
|
||||||
|
@ -830,7 +830,6 @@ gtk_radio_button_draw_indicator (GtkCheckButton *check_button,
|
|||||||
GtkAllocation allocation;
|
GtkAllocation allocation;
|
||||||
GtkWidget *widget;
|
GtkWidget *widget;
|
||||||
GtkButton *button;
|
GtkButton *button;
|
||||||
GtkToggleButton *toggle_button;
|
|
||||||
GtkStyleContext *context;
|
GtkStyleContext *context;
|
||||||
GtkStateFlags state = 0;
|
GtkStateFlags state = 0;
|
||||||
gint x, y;
|
gint x, y;
|
||||||
@ -840,7 +839,6 @@ gtk_radio_button_draw_indicator (GtkCheckButton *check_button,
|
|||||||
|
|
||||||
widget = GTK_WIDGET (check_button);
|
widget = GTK_WIDGET (check_button);
|
||||||
button = GTK_BUTTON (check_button);
|
button = GTK_BUTTON (check_button);
|
||||||
toggle_button = GTK_TOGGLE_BUTTON (check_button);
|
|
||||||
context = gtk_widget_get_style_context (widget);
|
context = gtk_widget_get_style_context (widget);
|
||||||
state = gtk_widget_get_state_flags (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,
|
y = CLAMP (baseline - indicator_size * button->priv->baseline_align,
|
||||||
0, allocation.height - indicator_size);
|
0, allocation.height - indicator_size);
|
||||||
|
|
||||||
state &= ~(GTK_STATE_FLAG_INCONSISTENT |
|
state &= ~(GTK_STATE_FLAG_ACTIVE |
|
||||||
GTK_STATE_FLAG_ACTIVE |
|
|
||||||
GTK_STATE_FLAG_PRELIGHT);
|
GTK_STATE_FLAG_PRELIGHT);
|
||||||
|
|
||||||
if (gtk_toggle_button_get_inconsistent (toggle_button))
|
|
||||||
state |= GTK_STATE_FLAG_INCONSISTENT;
|
|
||||||
|
|
||||||
if (button->priv->activate_timeout ||
|
if (button->priv->activate_timeout ||
|
||||||
(button->priv->button_down && button->priv->in_button))
|
(button->priv->button_down && button->priv->in_button))
|
||||||
state |= GTK_STATE_FLAG_ACTIVE;
|
state |= GTK_STATE_FLAG_ACTIVE;
|
||||||
|
@ -559,8 +559,10 @@ gtk_toggle_button_set_inconsistent (GtkToggleButton *toggle_button,
|
|||||||
{
|
{
|
||||||
priv->inconsistent = setting;
|
priv->inconsistent = setting;
|
||||||
|
|
||||||
gtk_toggle_button_update_state (GTK_BUTTON (toggle_button));
|
if (setting)
|
||||||
gtk_widget_queue_draw (GTK_WIDGET (toggle_button));
|
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");
|
g_object_notify (G_OBJECT (toggle_button), "inconsistent");
|
||||||
}
|
}
|
||||||
@ -653,17 +655,12 @@ static void
|
|||||||
gtk_toggle_button_update_state (GtkButton *button)
|
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;
|
|
||||||
GtkStateFlags new_state = 0;
|
GtkStateFlags new_state = 0;
|
||||||
|
|
||||||
new_state = gtk_widget_get_state_flags (GTK_WIDGET (button)) &
|
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);
|
GTK_STATE_FLAG_ACTIVE);
|
||||||
|
|
||||||
if (priv->inconsistent)
|
|
||||||
new_state |= GTK_STATE_FLAG_INCONSISTENT;
|
|
||||||
|
|
||||||
if (button->priv->in_button && button->priv->button_down)
|
if (button->priv->in_button && button->priv->button_down)
|
||||||
new_state |= GTK_STATE_FLAG_ACTIVE;
|
new_state |= GTK_STATE_FLAG_ACTIVE;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user