[gtk/spinning-spinner] Rename GtkSpinner::active to ::spinning
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/spinning-spinner] Rename GtkSpinner::active to ::spinning
- Date: Tue, 25 Feb 2020 03:38:06 +0000 (UTC)
commit e73a40733f08b3d1d9cd5ce9927b6bdebbb6e8cf
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Feb 24 21:04:49 2020 -0500
Rename GtkSpinner::active to ::spinning
And add a setter and getter. The old name was
confusing with the widget state of the same
name. 'Active' is just too overloaded.
demos/gtk-demo/dnd.c | 8 ++--
demos/widget-factory/widget-factory.ui | 4 +-
docs/reference/gtk/gtk4-sections.txt | 2 +
gtk/gtkplacesview.c | 2 +-
gtk/gtkspinner.c | 68 +++++++++++++++++++++-------------
gtk/gtkspinner.h | 13 +++++--
gtk/ui/gtksidebarrow.ui | 2 +-
tests/testtooltips.c | 4 +-
8 files changed, 64 insertions(+), 39 deletions(-)
---
diff --git a/demos/gtk-demo/dnd.c b/demos/gtk-demo/dnd.c
index bf82ccf37a..92403f1def 100644
--- a/demos/gtk-demo/dnd.c
+++ b/demos/gtk-demo/dnd.c
@@ -59,7 +59,7 @@ serialize_widget (GtkWidget *widget)
}
else if (GTK_IS_SPINNER (widget))
{
- g_object_get (widget, "active", &demo->active, NULL);
+ g_object_get (widget, "spinning", &demo->active, NULL);
}
else
{
@@ -80,7 +80,7 @@ deserialize_widget (GtkDemoWidget *demo)
}
else if (demo->type == GTK_TYPE_SPINNER)
{
- widget = g_object_new (demo->type, "active", demo->active, NULL);
+ widget = g_object_new (demo->type, "spinning", demo->active, NULL);
gtk_style_context_add_class (gtk_widget_get_style_context (widget), "demo");
}
else
@@ -240,8 +240,8 @@ edit_cb (GtkWidget *button, GtkWidget *child)
{
gboolean active;
- g_object_get (child, "active", &active, NULL);
- g_object_set (child, "active", !active, NULL);
+ g_object_get (child, "spinning", &active, NULL);
+ g_object_set (child, "spinning", !active, NULL);
}
if (button)
diff --git a/demos/widget-factory/widget-factory.ui b/demos/widget-factory/widget-factory.ui
index a800b45b2c..b2766d46ee 100644
--- a/demos/widget-factory/widget-factory.ui
+++ b/demos/widget-factory/widget-factory.ui
@@ -733,7 +733,7 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
</child>
<child>
<object class="GtkSpinner" id="spinner1">
- <property name="active">1</property>
+ <property name="spinning">1</property>
<layout>
<property name="left-attach">2</property>
</layout>
@@ -749,7 +749,7 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
</child>
<child>
<object class="GtkSpinner" id="spinner3">
- <property name="active">1</property>
+ <property name="spinning">1</property>
<property name="sensitive">0</property>
<layout>
<property name="left-attach">2</property>
diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt
index d186f6ffb9..f2f35646d0 100644
--- a/docs/reference/gtk/gtk4-sections.txt
+++ b/docs/reference/gtk/gtk4-sections.txt
@@ -2505,6 +2505,8 @@ GtkSpinner
gtk_spinner_new
gtk_spinner_start
gtk_spinner_stop
+gtk_spinner_set_spinning
+gtk_spinner_get_spinning
<SUBSECTION Standard>
GTK_SPINNER
diff --git a/gtk/gtkplacesview.c b/gtk/gtkplacesview.c
index 8a54c1b3f3..cae1273bc7 100644
--- a/gtk/gtkplacesview.c
+++ b/gtk/gtkplacesview.c
@@ -2050,7 +2050,7 @@ listbox_header_func (GtkListBoxRow *row,
g_object_bind_property (GTK_PLACES_VIEW (user_data),
"fetching-networks",
network_header_spinner,
- "active",
+ "spinning",
G_BINDING_SYNC_CREATE);
gtk_container_add (GTK_CONTAINER (header_name), label);
diff --git a/gtk/gtkspinner.c b/gtk/gtkspinner.c
index 65e5b5c6d0..cb83e568f0 100644
--- a/gtk/gtkspinner.c
+++ b/gtk/gtkspinner.c
@@ -57,8 +57,9 @@
*
* # CSS nodes
*
- * GtkSpinner has a single CSS node with the name spinner. When the animation is
- * active, the :checked pseudoclass is added to this node.
+ * GtkSpinner has a single CSS node with the name spinner.
+ * When the animation is active, the :checked pseudoclass is
+ * added to this node.
*/
typedef struct _GtkSpinnerClass GtkSpinnerClass;
@@ -76,7 +77,7 @@ struct _GtkSpinnerClass
enum {
PROP_0,
- PROP_ACTIVE
+ PROP_SPINNING
};
G_DEFINE_TYPE (GtkSpinner, gtk_spinner, GTK_TYPE_WIDGET)
@@ -138,25 +139,42 @@ gtk_spinner_css_changed (GtkWidget *widget,
}
}
-static gboolean
-gtk_spinner_get_active (GtkSpinner *spinner)
+/**
+ * gtk_spinner_get_spinning:
+ * @spinner: a #GtkSpinner
+ *
+ * Returns whether the spinner is spinning.
+ *
+ * Returns: %TRUE if the spinner is active
+ */
+gboolean
+gtk_spinner_get_spinning (GtkSpinner *spinner)
{
+ g_return_val_if_fail (GTK_IS_SPINNER (spinner), FALSE);
+
return (gtk_widget_get_state_flags ((GtkWidget *)spinner) & GTK_STATE_FLAG_CHECKED) > 0;
}
-static void
-gtk_spinner_set_active (GtkSpinner *spinner,
- gboolean active)
+/**
+ * gtk_spinner_set_spinning:
+ * @spinner: a #GtkSpinner
+ * @spinning: whether the spinner should be spinning
+ *
+ * Sets the activity of the spinner.
+ */
+void
+gtk_spinner_set_spinning (GtkSpinner *spinner,
+ gboolean spinning)
{
- gboolean current_active = gtk_spinner_get_active (spinner);
+ g_return_if_fail (GTK_IS_SPINNER (spinner));
- active = !!active;
+ spinning = !!spinning;
- if (active != current_active)
+ if (spinning != gtk_spinner_get_spinning (spinner))
{
- g_object_notify (G_OBJECT (spinner), "active");
+ g_object_notify (G_OBJECT (spinner), "spinning");
- if (active)
+ if (spinning)
gtk_widget_set_state_flags (GTK_WIDGET (spinner),
GTK_STATE_FLAG_CHECKED, FALSE);
else
@@ -173,8 +191,8 @@ gtk_spinner_get_property (GObject *object,
{
switch (param_id)
{
- case PROP_ACTIVE:
- g_value_set_boolean (value, gtk_spinner_get_active (GTK_SPINNER (object)));
+ case PROP_SPINNING:
+ g_value_set_boolean (value, gtk_spinner_get_spinning (GTK_SPINNER (object)));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
@@ -189,8 +207,8 @@ gtk_spinner_set_property (GObject *object,
{
switch (param_id)
{
- case PROP_ACTIVE:
- gtk_spinner_set_active (GTK_SPINNER (object), g_value_get_boolean (value));
+ case PROP_SPINNING:
+ gtk_spinner_set_spinning (GTK_SPINNER (object), g_value_get_boolean (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
@@ -212,15 +230,15 @@ gtk_spinner_class_init (GtkSpinnerClass *klass)
widget_class->measure = gtk_spinner_measure;
widget_class->css_changed = gtk_spinner_css_changed;
- /* GtkSpinner:active:
+ /* GtkSpinner:spinning:
*
- * Whether the spinner is active
+ * Whether the spinner is spinning
*/
g_object_class_install_property (gobject_class,
- PROP_ACTIVE,
- g_param_spec_boolean ("active",
- P_("Active"),
- P_("Whether the spinner is active"),
+ PROP_SPINNING,
+ g_param_spec_boolean ("spinning",
+ P_("Spinning"),
+ P_("Whether the spinner is spinning"),
FALSE,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
@@ -257,7 +275,7 @@ gtk_spinner_start (GtkSpinner *spinner)
{
g_return_if_fail (GTK_IS_SPINNER (spinner));
- gtk_spinner_set_active (spinner, TRUE);
+ gtk_spinner_set_spinning (spinner, TRUE);
}
/**
@@ -271,5 +289,5 @@ gtk_spinner_stop (GtkSpinner *spinner)
{
g_return_if_fail (GTK_IS_SPINNER (spinner));
- gtk_spinner_set_active (spinner, FALSE);
+ gtk_spinner_set_spinning (spinner, FALSE);
}
diff --git a/gtk/gtkspinner.h b/gtk/gtkspinner.h
index b223147f6a..5da918d49e 100644
--- a/gtk/gtkspinner.h
+++ b/gtk/gtkspinner.h
@@ -39,13 +39,18 @@ typedef struct _GtkSpinner GtkSpinner;
GDK_AVAILABLE_IN_ALL
-GType gtk_spinner_get_type (void) G_GNUC_CONST;
+GType gtk_spinner_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
-GtkWidget *gtk_spinner_new (void);
+GtkWidget *gtk_spinner_new (void);
GDK_AVAILABLE_IN_ALL
-void gtk_spinner_start (GtkSpinner *spinner);
+void gtk_spinner_start (GtkSpinner *spinner);
GDK_AVAILABLE_IN_ALL
-void gtk_spinner_stop (GtkSpinner *spinner);
+void gtk_spinner_stop (GtkSpinner *spinner);
+GDK_AVAILABLE_IN_ALL
+void gtk_spinner_set_spinning (GtkSpinner *spinner,
+ gboolean spinning);
+GDK_AVAILABLE_IN_ALL
+gboolean gtk_spinner_get_spinning (GtkSpinner *spinner);
G_END_DECLS
diff --git a/gtk/ui/gtksidebarrow.ui b/gtk/ui/gtksidebarrow.ui
index 5b71724e29..0fdbc0e37c 100644
--- a/gtk/ui/gtksidebarrow.ui
+++ b/gtk/ui/gtksidebarrow.ui
@@ -56,7 +56,7 @@
</child>
<child>
<object class="GtkSpinner" id="busy_spinner">
- <property name="active">1</property>
+ <property name="spinning">1</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="margin-start">4px</property>
diff --git a/tests/testtooltips.c b/tests/testtooltips.c
index 9b48d6e5a2..6139eca138 100644
--- a/tests/testtooltips.c
+++ b/tests/testtooltips.c
@@ -428,7 +428,7 @@ main (int argc, char *argv[])
button = gtk_label_new ("Hidden here");
custom = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
gtk_container_add (GTK_CONTAINER (custom), gtk_label_new ("See, custom"));
- gtk_container_add (GTK_CONTAINER (custom), g_object_new (GTK_TYPE_SPINNER, "active", TRUE, NULL));
+ gtk_container_add (GTK_CONTAINER (custom), g_object_new (GTK_TYPE_SPINNER, "spinning", TRUE, NULL));
g_object_ref_sink (custom);
g_object_set (button, "has-tooltip", TRUE, NULL);
gtk_container_add (GTK_CONTAINER (box2), button);
@@ -438,7 +438,7 @@ main (int argc, char *argv[])
button = gtk_label_new ("Custom tooltip II");
custom = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
gtk_container_add (GTK_CONTAINER (custom), gtk_label_new ("See, custom too"));
- gtk_container_add (GTK_CONTAINER (custom), g_object_new (GTK_TYPE_SPINNER, "active", TRUE, NULL));
+ gtk_container_add (GTK_CONTAINER (custom), g_object_new (GTK_TYPE_SPINNER, "spinning", TRUE, NULL));
g_object_ref_sink (custom);
g_object_set (button, "has-tooltip", TRUE, NULL);
g_signal_connect (button, "query-tooltip",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]