[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 02:07:04 +0000 (UTC)
commit 6400ee620d6643aa2024e007953dd1bc8314a705
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.
docs/reference/gtk/gtk4-sections.txt | 2 ++
gtk/gtkspinner.c | 68 +++++++++++++++++++++++-------------
gtk/gtkspinner.h | 13 ++++---
3 files changed, 54 insertions(+), 29 deletions(-)
---
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/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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]