[gtk+] button: Handle :inconsistent in GtkToggleButton
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] button: Handle :inconsistent in GtkToggleButton
- Date: Sat, 16 Aug 2014 15:10:05 +0000 (UTC)
commit db1ab7ddf8ff86240b49e4c17ab56691bada77eb
Author: Benjamin Otte <otte redhat com>
Date: Fri Aug 15 18:26:35 2014 +0200
button: Handle :inconsistent in GtkToggleButton
gtk/gtkcheckbutton.c | 8 +-------
gtk/gtkradiobutton.c | 8 +-------
gtk/gtktogglebutton.c | 13 +++++--------
3 files changed, 7 insertions(+), 22 deletions(-)
---
diff --git a/gtk/gtkcheckbutton.c b/gtk/gtkcheckbutton.c
index 1221200..9591e77 100644
--- a/gtk/gtkcheckbutton.c
+++ b/gtk/gtkcheckbutton.c
@@ -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;
diff --git a/gtk/gtkradiobutton.c b/gtk/gtkradiobutton.c
index e4a01a5..86c7ca3 100644
--- a/gtk/gtkradiobutton.c
+++ b/gtk/gtkradiobutton.c
@@ -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;
diff --git a/gtk/gtktogglebutton.c b/gtk/gtktogglebutton.c
index ba97368..b12fbf2 100644
--- a/gtk/gtktogglebutton.c
+++ b/gtk/gtktogglebutton.c
@@ -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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]