summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorTimm Bäder <mail@baedert.org>2017-01-28 08:11:14 +0100
committerTimm Bäder <mail@baedert.org>2017-01-30 18:11:00 +0100
commit2aea8dfee97b514e1fca7f577fefdac4e449e906 (patch)
tree360d39b86a452010535d60769109fe3dd1ac2d8e /gtk
parent66d584ce6e298a016e90a80091a5fc1f6f07ff2f (diff)
downloadgtk+-2aea8dfee97b514e1fca7f577fefdac4e449e906.tar.gz
togglebutton: Move :inconsistent to GtkCheckButton
Diffstat (limited to 'gtk')
-rw-r--r--gtk/a11y/gtktogglebuttonaccessible.c17
-rw-r--r--gtk/gtkcheckbutton.c67
-rw-r--r--gtk/gtkcheckbutton.h5
-rw-r--r--gtk/gtktogglebutton.c71
-rw-r--r--gtk/gtktogglebutton.h6
5 files changed, 74 insertions, 92 deletions
diff --git a/gtk/a11y/gtktogglebuttonaccessible.c b/gtk/a11y/gtktogglebuttonaccessible.c
index 8b85f27bb8..761b43d56d 100644
--- a/gtk/a11y/gtktogglebuttonaccessible.c
+++ b/gtk/a11y/gtktogglebuttonaccessible.c
@@ -56,22 +56,15 @@ gtk_toggle_button_accessible_notify_gtk (GObject *obj,
GtkToggleButton *toggle_button = GTK_TOGGLE_BUTTON (obj);
AtkObject *atk_obj;
gboolean sensitive;
- gboolean inconsistent;
atk_obj = gtk_widget_get_accessible (GTK_WIDGET (toggle_button));
sensitive = gtk_widget_get_sensitive (GTK_WIDGET (toggle_button));
- inconsistent = gtk_toggle_button_get_inconsistent (toggle_button);
- if (strcmp (pspec->name, "inconsistent") == 0)
- {
- atk_object_notify_state_change (atk_obj, ATK_STATE_INDETERMINATE, inconsistent);
- atk_object_notify_state_change (atk_obj, ATK_STATE_ENABLED, (sensitive && !inconsistent));
- }
- else if (strcmp (pspec->name, "sensitive") == 0)
+ if (strcmp (pspec->name, "sensitive") == 0)
{
/* Need to override gailwidget behavior of notifying for ENABLED */
atk_object_notify_state_change (atk_obj, ATK_STATE_SENSITIVE, sensitive);
- atk_object_notify_state_change (atk_obj, ATK_STATE_ENABLED, (sensitive && !inconsistent));
+ atk_object_notify_state_change (atk_obj, ATK_STATE_ENABLED, sensitive);
}
else
GTK_WIDGET_ACCESSIBLE_CLASS (gtk_toggle_button_accessible_parent_class)->notify_gtk (obj, pspec);
@@ -94,12 +87,6 @@ gtk_toggle_button_accessible_ref_state_set (AtkObject *accessible)
if (gtk_toggle_button_get_active (toggle_button))
atk_state_set_add_state (state_set, ATK_STATE_CHECKED);
- if (gtk_toggle_button_get_inconsistent (toggle_button))
- {
- atk_state_set_remove_state (state_set, ATK_STATE_ENABLED);
- atk_state_set_add_state (state_set, ATK_STATE_INDETERMINATE);
- }
-
return state_set;
}
diff --git a/gtk/gtkcheckbutton.c b/gtk/gtkcheckbutton.c
index 08fbcdf5e5..66f597beff 100644
--- a/gtk/gtkcheckbutton.c
+++ b/gtk/gtkcheckbutton.c
@@ -88,11 +88,13 @@ typedef struct {
GtkCssGadget *indicator_gadget;
guint draw_indicator : 1;
+ guint inconsistent : 1;
} GtkCheckButtonPrivate;
enum {
PROP_0,
PROP_DRAW_INDICATOR,
+ PROP_INCONSISTENT,
NUM_PROPERTIES
};
@@ -222,6 +224,10 @@ gtk_check_button_set_property (GObject *object,
g_value_get_boolean (value));
break;
+ case PROP_INCONSISTENT:
+ gtk_check_button_set_inconsistent (GTK_CHECK_BUTTON (object),
+ g_value_get_boolean (value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -239,6 +245,9 @@ gtk_check_button_get_property (GObject *object,
case PROP_DRAW_INDICATOR:
g_value_set_boolean (value, gtk_check_button_get_draw_indicator (GTK_CHECK_BUTTON (object)));
break;
+ case PROP_INCONSISTENT:
+ g_value_set_boolean (value, gtk_check_button_get_inconsistent (GTK_CHECK_BUTTON (object)));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -272,6 +281,13 @@ gtk_check_button_class_init (GtkCheckButtonClass *class)
TRUE,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
+ props[PROP_INCONSISTENT] =
+ g_param_spec_boolean ("inconsistent",
+ P_("Inconsistent"),
+ P_("If the check button is in an “in between” state"),
+ FALSE,
+ GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
+
g_object_class_install_properties (object_class, NUM_PROPERTIES, props);
gtk_widget_class_set_accessible_role (widget_class, ATK_ROLE_CHECK_BOX);
@@ -501,3 +517,54 @@ gtk_check_button_get_draw_indicator (GtkCheckButton *check_button)
return priv->draw_indicator;
}
+
+/**
+ * gtk_check_button_set_inconsistent:
+ * @check_button: a #GtkCheckButton
+ * @inconsistent: %TRUE if state is inconsistent
+ *
+ * If the user has selected a range of elements (such as some text or
+ * spreadsheet cells) that are affected by a check button, and the
+ * current values in that range are inconsistent, you may want to
+ * display the toggle in an "in between" state. Normally you would
+ * turn off the inconsistent state again if the user checks the
+ * check button. This has to be done manually,
+ * gtk_check_button_set_inconsistent only affects visual appearance,
+ * not the semantics of the button.
+ */
+void
+gtk_check_button_set_inconsistent (GtkCheckButton *check_button,
+ gboolean inconsistent)
+{
+ GtkCheckButtonPrivate *priv = gtk_check_button_get_instance_private (check_button);
+
+ g_return_if_fail (GTK_IS_CHECK_BUTTON (check_button));
+
+ inconsistent = !!inconsistent;
+ if (inconsistent != priv->inconsistent)
+ {
+ if (inconsistent)
+ gtk_widget_set_state_flags (GTK_WIDGET (check_button), GTK_STATE_FLAG_INCONSISTENT, FALSE);
+ else
+ gtk_widget_unset_state_flags (GTK_WIDGET (check_button), GTK_STATE_FLAG_INCONSISTENT);
+
+ g_object_notify_by_pspec (G_OBJECT (check_button), props[PROP_INCONSISTENT]);
+ }
+}
+
+/**
+ * gtk_check_button_get_inconsistent:
+ * @check_button: a #GtkCheckButton
+ *
+ * Returns: %TRUE if @check_button is currently in an 'in between' state,
+ * %FALSE otherwise.
+ */
+gboolean
+gtk_check_button_get_inconsistent (GtkCheckButton *check_button)
+{
+ GtkCheckButtonPrivate *priv = gtk_check_button_get_instance_private (check_button);
+
+ g_return_val_if_fail (GTK_IS_CHECK_BUTTON (check_button), FALSE);
+
+ return priv->inconsistent;
+}
diff --git a/gtk/gtkcheckbutton.h b/gtk/gtkcheckbutton.h
index fff8cad0d4..2c3f54b8b6 100644
--- a/gtk/gtkcheckbutton.h
+++ b/gtk/gtkcheckbutton.h
@@ -76,6 +76,11 @@ void gtk_check_button_set_draw_indicator (GtkCheckButton *check_button,
gboolean draw_indicator);
GDK_AVAILABLE_IN_3_90
gboolean gtk_check_button_get_draw_indicator (GtkCheckButton *check_button);
+GDK_AVAILABLE_IN_3_90
+void gtk_check_button_set_inconsistent (GtkCheckButton *check_button,
+ gboolean inconsistent);
+GDK_AVAILABLE_IN_3_90
+gboolean gtk_check_button_get_inconsistent (GtkCheckButton *check_button);
G_END_DECLS
diff --git a/gtk/gtktogglebutton.c b/gtk/gtktogglebutton.c
index 95e18d1d85..14fca8e5e6 100644
--- a/gtk/gtktogglebutton.c
+++ b/gtk/gtktogglebutton.c
@@ -98,7 +98,6 @@
struct _GtkToggleButtonPrivate
{
guint active : 1;
- guint inconsistent : 1;
};
enum {
@@ -109,7 +108,6 @@ enum {
enum {
PROP_0,
PROP_ACTIVE,
- PROP_INCONSISTENT,
NUM_PROPERTIES
};
@@ -160,13 +158,6 @@ gtk_toggle_button_class_init (GtkToggleButtonClass *class)
FALSE,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
- toggle_button_props[PROP_INCONSISTENT] =
- g_param_spec_boolean ("inconsistent",
- P_("Inconsistent"),
- P_("If the toggle button is in an “in between” state"),
- FALSE,
- GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
-
g_object_class_install_properties (gobject_class, NUM_PROPERTIES, toggle_button_props);
/**
@@ -264,9 +255,6 @@ gtk_toggle_button_set_property (GObject *object,
case PROP_ACTIVE:
gtk_toggle_button_set_active (tb, g_value_get_boolean (value));
break;
- case PROP_INCONSISTENT:
- gtk_toggle_button_set_inconsistent (tb, g_value_get_boolean (value));
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -287,9 +275,6 @@ gtk_toggle_button_get_property (GObject *object,
case PROP_ACTIVE:
g_value_set_boolean (value, priv->active);
break;
- case PROP_INCONSISTENT:
- g_value_set_boolean (value, priv->inconsistent);
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -371,62 +356,6 @@ gtk_toggle_button_toggled (GtkToggleButton *toggle_button)
g_signal_emit (toggle_button, toggle_button_signals[TOGGLED], 0);
}
-/**
- * gtk_toggle_button_set_inconsistent:
- * @toggle_button: a #GtkToggleButton
- * @setting: %TRUE if state is inconsistent
- *
- * If the user has selected a range of elements (such as some text or
- * spreadsheet cells) that are affected by a toggle button, and the
- * current values in that range are inconsistent, you may want to
- * display the toggle in an “in between” state. This function turns on
- * “in between” display. Normally you would turn off the inconsistent
- * state again if the user toggles the toggle button. This has to be
- * done manually, gtk_toggle_button_set_inconsistent() only affects
- * visual appearance, it doesn’t affect the semantics of the button.
- *
- **/
-void
-gtk_toggle_button_set_inconsistent (GtkToggleButton *toggle_button,
- gboolean setting)
-{
- GtkToggleButtonPrivate *priv;
-
- g_return_if_fail (GTK_IS_TOGGLE_BUTTON (toggle_button));
-
- priv = toggle_button->priv;
-
- setting = setting != FALSE;
-
- if (setting != priv->inconsistent)
- {
- priv->inconsistent = setting;
-
- 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_by_pspec (G_OBJECT (toggle_button), toggle_button_props[PROP_INCONSISTENT]);
- }
-}
-
-/**
- * gtk_toggle_button_get_inconsistent:
- * @toggle_button: a #GtkToggleButton
- *
- * Gets the value set by gtk_toggle_button_set_inconsistent().
- *
- * Returns: %TRUE if the button is displayed as inconsistent, %FALSE otherwise
- **/
-gboolean
-gtk_toggle_button_get_inconsistent (GtkToggleButton *toggle_button)
-{
- g_return_val_if_fail (GTK_IS_TOGGLE_BUTTON (toggle_button), FALSE);
-
- return toggle_button->priv->inconsistent;
-}
-
static gboolean
gtk_toggle_button_mnemonic_activate (GtkWidget *widget,
gboolean group_cycling)
diff --git a/gtk/gtktogglebutton.h b/gtk/gtktogglebutton.h
index cc582f88b2..d060c63000 100644
--- a/gtk/gtktogglebutton.h
+++ b/gtk/gtktogglebutton.h
@@ -84,12 +84,6 @@ GDK_AVAILABLE_IN_ALL
gboolean gtk_toggle_button_get_active (GtkToggleButton *toggle_button);
GDK_AVAILABLE_IN_ALL
void gtk_toggle_button_toggled (GtkToggleButton *toggle_button);
-GDK_AVAILABLE_IN_ALL
-void gtk_toggle_button_set_inconsistent (GtkToggleButton *toggle_button,
- gboolean setting);
-GDK_AVAILABLE_IN_ALL
-gboolean gtk_toggle_button_get_inconsistent (GtkToggleButton *toggle_button);
-
G_END_DECLS