[libadwaita/wip/exalm/docs: 4/4] Unify property and accessor ordering
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libadwaita/wip/exalm/docs: 4/4] Unify property and accessor ordering
- Date: Wed, 10 Aug 2022 16:54:15 +0000 (UTC)
commit 7e59620a8713097433576c41370bfa486220d530
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Wed Aug 10 20:53:10 2022 +0400
Unify property and accessor ordering
It was inconsistent and it made going through the API for the previous
commit harder than it could have been.
src/adw-action-row.c | 202 +++++++++----------
src/adw-action-row.h | 20 +-
src/adw-animation.c | 38 ++--
src/adw-combo-row.c | 38 ++--
src/adw-expander-row.c | 238 +++++++++++-----------
src/adw-expander-row.h | 28 +--
src/adw-flap.c | 98 ++++-----
src/adw-flap.h | 12 +-
src/adw-header-bar.c | 138 ++++++-------
src/adw-header-bar.h | 12 +-
src/adw-leaflet.c | 468 +++++++++++++++++++++----------------------
src/adw-leaflet.h | 23 ++-
src/adw-preferences-group.c | 236 +++++++++++-----------
src/adw-preferences-group.h | 14 +-
src/adw-preferences-page.c | 136 ++++++-------
src/adw-preferences-page.h | 14 +-
src/adw-preferences-window.c | 292 +++++++++++++--------------
src/adw-preferences-window.h | 36 ++--
src/adw-squeezer.c | 68 +++----
src/adw-squeezer.h | 6 +-
src/adw-toast.c | 40 ++--
src/adw-view-stack.c | 390 ++++++++++++++++++------------------
src/adw-view-stack.h | 59 +++---
23 files changed, 1304 insertions(+), 1302 deletions(-)
---
diff --git a/src/adw-action-row.c b/src/adw-action-row.c
index 06e631db..b5cdb5dd 100644
--- a/src/adw-action-row.c
+++ b/src/adw-action-row.c
@@ -79,9 +79,9 @@ static GtkBuildableIface *parent_buildable_iface;
enum {
PROP_0,
+ PROP_SUBTITLE,
PROP_ICON_NAME,
PROP_ACTIVATABLE_WIDGET,
- PROP_SUBTITLE,
PROP_TITLE_LINES,
PROP_SUBTITLE_LINES,
LAST_PROP,
@@ -139,15 +139,15 @@ adw_action_row_get_property (GObject *object,
AdwActionRow *self = ADW_ACTION_ROW (object);
switch (prop_id) {
+ case PROP_SUBTITLE:
+ g_value_set_string (value, adw_action_row_get_subtitle (self));
+ break;
case PROP_ICON_NAME:
g_value_set_string (value, adw_action_row_get_icon_name (self));
break;
case PROP_ACTIVATABLE_WIDGET:
g_value_set_object (value, (GObject *) adw_action_row_get_activatable_widget (self));
break;
- case PROP_SUBTITLE:
- g_value_set_string (value, adw_action_row_get_subtitle (self));
- break;
case PROP_SUBTITLE_LINES:
g_value_set_int (value, adw_action_row_get_subtitle_lines (self));
break;
@@ -168,15 +168,15 @@ adw_action_row_set_property (GObject *object,
AdwActionRow *self = ADW_ACTION_ROW (object);
switch (prop_id) {
+ case PROP_SUBTITLE:
+ adw_action_row_set_subtitle (self, g_value_get_string (value));
+ break;
case PROP_ICON_NAME:
adw_action_row_set_icon_name (self, g_value_get_string (value));
break;
case PROP_ACTIVATABLE_WIDGET:
adw_action_row_set_activatable_widget (self, (GtkWidget*) g_value_get_object (value));
break;
- case PROP_SUBTITLE:
- adw_action_row_set_subtitle (self, g_value_get_string (value));
- break;
case PROP_SUBTITLE_LINES:
adw_action_row_set_subtitle_lines (self, g_value_get_int (value));
break;
@@ -227,6 +227,21 @@ adw_action_row_class_init (AdwActionRowClass *klass)
klass->activate = adw_action_row_activate_real;
+ /**
+ * AdwActionRow:subtitle: (attributes org.gtk.Property.get=adw_action_row_get_subtitle
org.gtk.Property.set=adw_action_row_set_subtitle)
+ *
+ * The subtitle for this row.
+ *
+ * The subtitle is interpreted as Pango markup unless
+ * [property@PreferencesRow:use-markup] is set to `FALSE`.
+ *
+ * Since: 1.0
+ */
+ props[PROP_SUBTITLE] =
+ g_param_spec_string ("subtitle", NULL, NULL,
+ "",
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
+
/**
* AdwActionRow:icon-name: (attributes org.gtk.Property.get=adw_action_row_get_icon_name
org.gtk.Property.set=adw_action_row_set_icon_name)
*
@@ -259,21 +274,6 @@ adw_action_row_class_init (AdwActionRowClass *klass)
GTK_TYPE_WIDGET,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
- /**
- * AdwActionRow:subtitle: (attributes org.gtk.Property.get=adw_action_row_get_subtitle
org.gtk.Property.set=adw_action_row_set_subtitle)
- *
- * The subtitle for this row.
- *
- * The subtitle is interpreted as Pango markup unless
- * [property@PreferencesRow:use-markup] is set to `FALSE`.
- *
- * Since: 1.0
- */
- props[PROP_SUBTITLE] =
- g_param_spec_string ("subtitle", NULL, NULL,
- "",
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
-
/**
* AdwActionRow:title-lines: (attributes org.gtk.Property.get=adw_action_row_get_title_lines
org.gtk.Property.set=adw_action_row_set_title_lines)
*
@@ -386,6 +386,85 @@ adw_action_row_new (void)
return g_object_new (ADW_TYPE_ACTION_ROW, NULL);
}
+/**
+ * adw_action_row_add_prefix:
+ * @self: an action row
+ * @widget: a widget
+ *
+ * Adds a prefix widget to @self.
+ *
+ * Since: 1.0
+ */
+void
+adw_action_row_add_prefix (AdwActionRow *self,
+ GtkWidget *widget)
+{
+ AdwActionRowPrivate *priv;
+
+ g_return_if_fail (ADW_IS_ACTION_ROW (self));
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+
+ priv = adw_action_row_get_instance_private (self);
+
+ gtk_box_prepend (priv->prefixes, widget);
+ gtk_widget_show (GTK_WIDGET (priv->prefixes));
+}
+
+/**
+ * adw_action_row_add_suffix:
+ * @self: an action row
+ * @widget: a widget
+ *
+ * Adds a suffix widget to @self.
+ *
+ * Since: 1.0
+ */
+void
+adw_action_row_add_suffix (AdwActionRow *self,
+ GtkWidget *widget)
+{
+ AdwActionRowPrivate *priv;
+
+ g_return_if_fail (ADW_IS_ACTION_ROW (self));
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+
+ priv = adw_action_row_get_instance_private (self);
+
+ gtk_box_append (priv->suffixes, widget);
+ gtk_widget_show (GTK_WIDGET (priv->suffixes));
+}
+
+/**
+ * adw_action_row_remove:
+ * @self: an action row
+ * @widget: the child to be removed
+ *
+ * Removes a child from @self.
+ *
+ * Since: 1.0
+ */
+void
+adw_action_row_remove (AdwActionRow *self,
+ GtkWidget *child)
+{
+ AdwActionRowPrivate *priv;
+ GtkWidget *parent;
+
+ g_return_if_fail (ADW_IS_ACTION_ROW (self));
+ g_return_if_fail (GTK_IS_WIDGET (child));
+
+ priv = adw_action_row_get_instance_private (self);
+
+ parent = gtk_widget_get_parent (child);
+
+ if (parent == GTK_WIDGET (priv->prefixes))
+ gtk_box_remove (priv->prefixes, child);
+ else if (parent == GTK_WIDGET (priv->suffixes))
+ gtk_box_remove (priv->suffixes, child);
+ else
+ ADW_CRITICAL_CANNOT_REMOVE_CHILD (self, child);
+}
+
/**
* adw_action_row_get_subtitle: (attributes org.gtk.Method.get_property=subtitle)
* @self: an action row
@@ -704,85 +783,6 @@ adw_action_row_set_subtitle_lines (AdwActionRow *self,
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_SUBTITLE_LINES]);
}
-/**
- * adw_action_row_add_prefix:
- * @self: an action row
- * @widget: a widget
- *
- * Adds a prefix widget to @self.
- *
- * Since: 1.0
- */
-void
-adw_action_row_add_prefix (AdwActionRow *self,
- GtkWidget *widget)
-{
- AdwActionRowPrivate *priv;
-
- g_return_if_fail (ADW_IS_ACTION_ROW (self));
- g_return_if_fail (GTK_IS_WIDGET (widget));
-
- priv = adw_action_row_get_instance_private (self);
-
- gtk_box_prepend (priv->prefixes, widget);
- gtk_widget_show (GTK_WIDGET (priv->prefixes));
-}
-
-/**
- * adw_action_row_add_suffix:
- * @self: an action row
- * @widget: a widget
- *
- * Adds a suffix widget to @self.
- *
- * Since: 1.0
- */
-void
-adw_action_row_add_suffix (AdwActionRow *self,
- GtkWidget *widget)
-{
- AdwActionRowPrivate *priv;
-
- g_return_if_fail (ADW_IS_ACTION_ROW (self));
- g_return_if_fail (GTK_IS_WIDGET (widget));
-
- priv = adw_action_row_get_instance_private (self);
-
- gtk_box_append (priv->suffixes, widget);
- gtk_widget_show (GTK_WIDGET (priv->suffixes));
-}
-
-/**
- * adw_action_row_remove:
- * @self: an action row
- * @widget: the child to be removed
- *
- * Removes a child from @self.
- *
- * Since: 1.0
- */
-void
-adw_action_row_remove (AdwActionRow *self,
- GtkWidget *child)
-{
- AdwActionRowPrivate *priv;
- GtkWidget *parent;
-
- g_return_if_fail (ADW_IS_ACTION_ROW (self));
- g_return_if_fail (GTK_IS_WIDGET (child));
-
- priv = adw_action_row_get_instance_private (self);
-
- parent = gtk_widget_get_parent (child);
-
- if (parent == GTK_WIDGET (priv->prefixes))
- gtk_box_remove (priv->prefixes, child);
- else if (parent == GTK_WIDGET (priv->suffixes))
- gtk_box_remove (priv->suffixes, child);
- else
- ADW_CRITICAL_CANNOT_REMOVE_CHILD (self, child);
-}
-
/**
* adw_action_row_activate:
* @self: an action row
diff --git a/src/adw-action-row.h b/src/adw-action-row.h
index 7ed1eae2..337c48bd 100644
--- a/src/adw-action-row.h
+++ b/src/adw-action-row.h
@@ -39,6 +39,16 @@ struct _AdwActionRowClass
ADW_AVAILABLE_IN_ALL
GtkWidget *adw_action_row_new (void) G_GNUC_WARN_UNUSED_RESULT;
+ADW_AVAILABLE_IN_ALL
+void adw_action_row_add_prefix (AdwActionRow *self,
+ GtkWidget *widget);
+ADW_AVAILABLE_IN_ALL
+void adw_action_row_add_suffix (AdwActionRow *self,
+ GtkWidget *widget);
+ADW_AVAILABLE_IN_ALL
+void adw_action_row_remove (AdwActionRow *self,
+ GtkWidget *widget);
+
ADW_AVAILABLE_IN_ALL
const char *adw_action_row_get_subtitle (AdwActionRow *self);
ADW_AVAILABLE_IN_ALL
@@ -69,16 +79,6 @@ ADW_AVAILABLE_IN_ALL
void adw_action_row_set_subtitle_lines (AdwActionRow *self,
int subtitle_lines);
-ADW_AVAILABLE_IN_ALL
-void adw_action_row_add_prefix (AdwActionRow *self,
- GtkWidget *widget);
-ADW_AVAILABLE_IN_ALL
-void adw_action_row_add_suffix (AdwActionRow *self,
- GtkWidget *widget);
-ADW_AVAILABLE_IN_ALL
-void adw_action_row_remove (AdwActionRow *self,
- GtkWidget *widget);
-
ADW_AVAILABLE_IN_ALL
void adw_action_row_activate (AdwActionRow *self);
diff --git a/src/adw-animation.c b/src/adw-animation.c
index bb839805..5d31cf56 100644
--- a/src/adw-animation.c
+++ b/src/adw-animation.c
@@ -101,9 +101,9 @@ G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (AdwAnimation, adw_animation, G_TYPE_OBJECT)
enum {
PROP_0,
- PROP_VALUE,
PROP_WIDGET,
PROP_TARGET,
+ PROP_VALUE,
PROP_STATE,
LAST_PROP,
};
@@ -284,10 +284,6 @@ adw_animation_get_property (GObject *object,
AdwAnimation *self = ADW_ANIMATION (object);
switch (prop_id) {
- case PROP_VALUE:
- g_value_set_double (value, adw_animation_get_value (self));
- break;
-
case PROP_WIDGET:
g_value_set_object (value, adw_animation_get_widget (self));
break;
@@ -296,6 +292,10 @@ adw_animation_get_property (GObject *object,
g_value_set_object (value, adw_animation_get_target (self));
break;
+ case PROP_VALUE:
+ g_value_set_double (value, adw_animation_get_value (self));
+ break;
+
case PROP_STATE:
g_value_set_enum (value, adw_animation_get_state (self));
break;
@@ -340,20 +340,6 @@ adw_animation_class_init (AdwAnimationClass *klass)
klass->estimate_duration = adw_animation_estimate_duration;
klass->calculate_value = adw_animation_calculate_value;
- /**
- * AdwAnimation:value: (attributes org.gtk.Property.get=adw_animation_get_value)
- *
- * The current value of the animation.
- *
- * Since: 1.0
- */
- props[PROP_VALUE] =
- g_param_spec_double ("value", NULL, NULL,
- -G_MAXDOUBLE,
- G_MAXDOUBLE,
- 0,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
-
/**
* AdwAnimation:widget: (attributes org.gtk.Property.get=adw_animation_get_widget)
*
@@ -385,6 +371,20 @@ adw_animation_class_init (AdwAnimationClass *klass)
ADW_TYPE_ANIMATION_TARGET,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS |
G_PARAM_EXPLICIT_NOTIFY);
+ /**
+ * AdwAnimation:value: (attributes org.gtk.Property.get=adw_animation_get_value)
+ *
+ * The current value of the animation.
+ *
+ * Since: 1.0
+ */
+ props[PROP_VALUE] =
+ g_param_spec_double ("value", NULL, NULL,
+ -G_MAXDOUBLE,
+ G_MAXDOUBLE,
+ 0,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+
/**
* AdwAnimation:state: (attributes org.gtk.Property.get=adw_animation_get_state)
*
diff --git a/src/adw-combo-row.c b/src/adw-combo-row.c
index 94045896..f89c8412 100644
--- a/src/adw-combo-row.c
+++ b/src/adw-combo-row.c
@@ -93,9 +93,9 @@ G_DEFINE_TYPE_WITH_PRIVATE (AdwComboRow, adw_combo_row, ADW_TYPE_ACTION_ROW)
enum {
PROP_0,
- PROP_MODEL,
PROP_SELECTED,
PROP_SELECTED_ITEM,
+ PROP_MODEL,
PROP_FACTORY,
PROP_LIST_FACTORY,
PROP_EXPRESSION,
@@ -308,15 +308,15 @@ adw_combo_row_get_property (GObject *object,
AdwComboRow *self = ADW_COMBO_ROW (object);
switch (prop_id) {
- case PROP_MODEL:
- g_value_set_object (value, adw_combo_row_get_model (self));
- break;
case PROP_SELECTED:
g_value_set_uint (value, adw_combo_row_get_selected (self));
break;
case PROP_SELECTED_ITEM:
g_value_set_object (value, adw_combo_row_get_selected_item (self));
break;
+ case PROP_MODEL:
+ g_value_set_object (value, adw_combo_row_get_model (self));
+ break;
case PROP_FACTORY:
g_value_set_object (value, adw_combo_row_get_factory (self));
break;
@@ -343,12 +343,12 @@ adw_combo_row_set_property (GObject *object,
AdwComboRow *self = ADW_COMBO_ROW (object);
switch (prop_id) {
- case PROP_MODEL:
- adw_combo_row_set_model (self, g_value_get_object (value));
- break;
case PROP_SELECTED:
adw_combo_row_set_selected (self, g_value_get_uint (value));
break;
+ case PROP_MODEL:
+ adw_combo_row_set_model (self, g_value_get_object (value));
+ break;
case PROP_FACTORY:
adw_combo_row_set_factory (self, g_value_get_object (value));
break;
@@ -435,18 +435,6 @@ adw_combo_row_class_init (AdwComboRowClass *klass)
row_class->activate = adw_combo_row_activate;
- /**
- * AdwComboRow:model: (attributes org.gtk.Property.get=adw_combo_row_get_model
org.gtk.Property.set=adw_combo_row_set_model)
- *
- * The model that provides the displayed items.
- *
- * Since: 1.0
- */
- props[PROP_MODEL] =
- g_param_spec_object ("model", NULL, NULL,
- G_TYPE_LIST_MODEL,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
-
/**
* AdwComboRow:selected: (attributes org.gtk.Property.get=adw_combo_row_get_selected
org.gtk.Property.set=adw_combo_row_set_selected)
*
@@ -474,6 +462,18 @@ adw_combo_row_class_init (AdwComboRowClass *klass)
G_TYPE_OBJECT,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+ /**
+ * AdwComboRow:model: (attributes org.gtk.Property.get=adw_combo_row_get_model
org.gtk.Property.set=adw_combo_row_set_model)
+ *
+ * The model that provides the displayed items.
+ *
+ * Since: 1.0
+ */
+ props[PROP_MODEL] =
+ g_param_spec_object ("model", NULL, NULL,
+ G_TYPE_LIST_MODEL,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
+
/**
* AdwComboRow:factory: (attributes org.gtk.Property.get=adw_combo_row_get_factory
org.gtk.Property.set=adw_combo_row_set_factory)
*
diff --git a/src/adw-expander-row.c b/src/adw-expander-row.c
index d1cda5d1..62c5f3cc 100644
--- a/src/adw-expander-row.c
+++ b/src/adw-expander-row.c
@@ -322,6 +322,125 @@ adw_expander_row_new (void)
return g_object_new (ADW_TYPE_EXPANDER_ROW, NULL);
}
+/**
+ * adw_expander_row_add_action:
+ * @self: an expander row
+ * @widget: a widget
+ *
+ * Adds an action widget to @self.
+ *
+ * Since: 1.0
+ */
+void
+adw_expander_row_add_action (AdwExpanderRow *self,
+ GtkWidget *widget)
+{
+ AdwExpanderRowPrivate *priv;
+
+ g_return_if_fail (ADW_IS_EXPANDER_ROW (self));
+ g_return_if_fail (GTK_IS_WIDGET (self));
+
+ priv = adw_expander_row_get_instance_private (self);
+
+ gtk_box_prepend (priv->actions, widget);
+ gtk_widget_show (GTK_WIDGET (priv->actions));
+}
+
+/**
+ * adw_expander_row_add_prefix:
+ * @self: an expander row
+ * @widget: a widget
+ *
+ * Adds a prefix widget to @self.
+ *
+ * Since: 1.0
+ */
+void
+adw_expander_row_add_prefix (AdwExpanderRow *self,
+ GtkWidget *widget)
+{
+ AdwExpanderRowPrivate *priv;
+
+ g_return_if_fail (ADW_IS_EXPANDER_ROW (self));
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+
+ priv = adw_expander_row_get_instance_private (self);
+
+ if (priv->prefixes == NULL) {
+ priv->prefixes = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12));
+ adw_action_row_add_prefix (ADW_ACTION_ROW (priv->action_row), GTK_WIDGET (priv->prefixes));
+ }
+ gtk_box_append (priv->prefixes, widget);
+}
+
+/**
+ * adw_expander_row_add_row:
+ * @self: an expander row
+ * @child: a widget
+ *
+ * Adds a widget to @self.
+ *
+ * The widget will appear in the expanding list below @self.
+ *
+ * Since: 1.0
+ */
+void
+adw_expander_row_add_row (AdwExpanderRow *self,
+ GtkWidget *child)
+{
+ AdwExpanderRowPrivate *priv;
+
+ g_return_if_fail (ADW_IS_EXPANDER_ROW (self));
+ g_return_if_fail (GTK_IS_WIDGET (child));
+
+ priv = adw_expander_row_get_instance_private (self);
+
+ /* When constructing the widget, we want the box to be added as the child of
+ * the GtkListBoxRow, as an implementation detail.
+ */
+ gtk_list_box_append (priv->list, child);
+
+ gtk_widget_remove_css_class (GTK_WIDGET (self), "empty");
+}
+
+/**
+ * adw_action_row_expander:
+ * @self: an expander row
+ * @widget: the child to be removed
+ *
+ * Removes a child from @self.
+ *
+ * Since: 1.0
+ */
+void
+adw_expander_row_remove (AdwExpanderRow *self,
+ GtkWidget *child)
+{
+ AdwExpanderRowPrivate *priv;
+ GtkWidget *parent;
+
+ g_return_if_fail (ADW_IS_EXPANDER_ROW (self));
+ g_return_if_fail (GTK_IS_WIDGET (child));
+
+ priv = adw_expander_row_get_instance_private (self);
+
+ parent = gtk_widget_get_parent (child);
+
+ if (parent == GTK_WIDGET (priv->actions))
+ gtk_box_remove (priv->actions, child);
+ else if (parent == GTK_WIDGET (priv->prefixes))
+ gtk_box_remove (priv->prefixes, child);
+ else if (parent == GTK_WIDGET (priv->list) ||
+ (GTK_IS_WIDGET (parent) && (gtk_widget_get_parent (parent) == GTK_WIDGET (priv->list)))) {
+ gtk_list_box_remove (priv->list, child);
+
+ if (!gtk_widget_get_first_child (GTK_WIDGET (priv->list)))
+ gtk_widget_add_css_class (GTK_WIDGET (self), "empty");
+ }
+ else
+ ADW_CRITICAL_CANNOT_REMOVE_CHILD (self, child);
+}
+
/**
* adw_expander_row_get_subtitle: (attributes org.gtk.Method.get_property=subtitle)
* @self: an expander row
@@ -572,122 +691,3 @@ adw_expander_row_set_show_enable_switch (AdwExpanderRow *self,
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_SHOW_ENABLE_SWITCH]);
}
-
-/**
- * adw_expander_row_add_action:
- * @self: an expander row
- * @widget: a widget
- *
- * Adds an action widget to @self.
- *
- * Since: 1.0
- */
-void
-adw_expander_row_add_action (AdwExpanderRow *self,
- GtkWidget *widget)
-{
- AdwExpanderRowPrivate *priv;
-
- g_return_if_fail (ADW_IS_EXPANDER_ROW (self));
- g_return_if_fail (GTK_IS_WIDGET (self));
-
- priv = adw_expander_row_get_instance_private (self);
-
- gtk_box_prepend (priv->actions, widget);
- gtk_widget_show (GTK_WIDGET (priv->actions));
-}
-
-/**
- * adw_expander_row_add_prefix:
- * @self: an expander row
- * @widget: a widget
- *
- * Adds a prefix widget to @self.
- *
- * Since: 1.0
- */
-void
-adw_expander_row_add_prefix (AdwExpanderRow *self,
- GtkWidget *widget)
-{
- AdwExpanderRowPrivate *priv;
-
- g_return_if_fail (ADW_IS_EXPANDER_ROW (self));
- g_return_if_fail (GTK_IS_WIDGET (widget));
-
- priv = adw_expander_row_get_instance_private (self);
-
- if (priv->prefixes == NULL) {
- priv->prefixes = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12));
- adw_action_row_add_prefix (ADW_ACTION_ROW (priv->action_row), GTK_WIDGET (priv->prefixes));
- }
- gtk_box_append (priv->prefixes, widget);
-}
-
-/**
- * adw_expander_row_add_row:
- * @self: an expander row
- * @child: a widget
- *
- * Adds a widget to @self.
- *
- * The widget will appear in the expanding list below @self.
- *
- * Since: 1.0
- */
-void
-adw_expander_row_add_row (AdwExpanderRow *self,
- GtkWidget *child)
-{
- AdwExpanderRowPrivate *priv;
-
- g_return_if_fail (ADW_IS_EXPANDER_ROW (self));
- g_return_if_fail (GTK_IS_WIDGET (child));
-
- priv = adw_expander_row_get_instance_private (self);
-
- /* When constructing the widget, we want the box to be added as the child of
- * the GtkListBoxRow, as an implementation detail.
- */
- gtk_list_box_append (priv->list, child);
-
- gtk_widget_remove_css_class (GTK_WIDGET (self), "empty");
-}
-
-/**
- * adw_action_row_expander:
- * @self: an expander row
- * @widget: the child to be removed
- *
- * Removes a child from @self.
- *
- * Since: 1.0
- */
-void
-adw_expander_row_remove (AdwExpanderRow *self,
- GtkWidget *child)
-{
- AdwExpanderRowPrivate *priv;
- GtkWidget *parent;
-
- g_return_if_fail (ADW_IS_EXPANDER_ROW (self));
- g_return_if_fail (GTK_IS_WIDGET (child));
-
- priv = adw_expander_row_get_instance_private (self);
-
- parent = gtk_widget_get_parent (child);
-
- if (parent == GTK_WIDGET (priv->actions))
- gtk_box_remove (priv->actions, child);
- else if (parent == GTK_WIDGET (priv->prefixes))
- gtk_box_remove (priv->prefixes, child);
- else if (parent == GTK_WIDGET (priv->list) ||
- (GTK_IS_WIDGET (parent) && (gtk_widget_get_parent (parent) == GTK_WIDGET (priv->list)))) {
- gtk_list_box_remove (priv->list, child);
-
- if (!gtk_widget_get_first_child (GTK_WIDGET (priv->list)))
- gtk_widget_add_css_class (GTK_WIDGET (self), "empty");
- }
- else
- ADW_CRITICAL_CANNOT_REMOVE_CHILD (self, child);
-}
diff --git a/src/adw-expander-row.h b/src/adw-expander-row.h
index afd691e4..917ecf66 100644
--- a/src/adw-expander-row.h
+++ b/src/adw-expander-row.h
@@ -37,6 +37,20 @@ struct _AdwExpanderRowClass
ADW_AVAILABLE_IN_ALL
GtkWidget *adw_expander_row_new (void) G_GNUC_WARN_UNUSED_RESULT;
+ADW_AVAILABLE_IN_ALL
+void adw_expander_row_add_action (AdwExpanderRow *self,
+ GtkWidget *widget);
+ADW_AVAILABLE_IN_ALL
+void adw_expander_row_add_prefix (AdwExpanderRow *self,
+ GtkWidget *widget);
+
+ADW_AVAILABLE_IN_ALL
+void adw_expander_row_add_row (AdwExpanderRow *self,
+ GtkWidget *child);
+ADW_AVAILABLE_IN_ALL
+void adw_expander_row_remove (AdwExpanderRow *self,
+ GtkWidget *child);
+
ADW_AVAILABLE_IN_ALL
const char *adw_expander_row_get_subtitle (AdwExpanderRow *self);
ADW_AVAILABLE_IN_ALL
@@ -67,18 +81,4 @@ ADW_AVAILABLE_IN_ALL
void adw_expander_row_set_show_enable_switch (AdwExpanderRow *self,
gboolean show_enable_switch);
-ADW_AVAILABLE_IN_ALL
-void adw_expander_row_add_action (AdwExpanderRow *self,
- GtkWidget *widget);
-ADW_AVAILABLE_IN_ALL
-void adw_expander_row_add_prefix (AdwExpanderRow *self,
- GtkWidget *widget);
-
-ADW_AVAILABLE_IN_ALL
-void adw_expander_row_add_row (AdwExpanderRow *self,
- GtkWidget *child);
-ADW_AVAILABLE_IN_ALL
-void adw_expander_row_remove (AdwExpanderRow *self,
- GtkWidget *child);
-
G_END_DECLS
diff --git a/src/adw-flap.c b/src/adw-flap.c
index 1128047c..aab2c897 100644
--- a/src/adw-flap.c
+++ b/src/adw-flap.c
@@ -2175,6 +2175,55 @@ adw_flap_set_fold_policy (AdwFlap *self,
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_FOLD_POLICY]);
}
+/**
+ * adw_flap_get_fold_threshold_policy: (attributes org.gtk.Method.get_property=fold-threshold-policy)
+ * @self: a flap
+ *
+ * Gets the fold threshold policy for @self.
+ *
+ * Since: 1.0
+ */
+AdwFoldThresholdPolicy
+adw_flap_get_fold_threshold_policy (AdwFlap *self)
+{
+ g_return_val_if_fail (ADW_IS_FLAP (self), ADW_FOLD_THRESHOLD_POLICY_MINIMUM);
+
+ return self->fold_threshold_policy;
+}
+
+/**
+ * adw_flap_set_fold_threshold_policy: (attributes org.gtk.Method.set_property=fold-threshold-policy)
+ * @self: a flap
+ * @policy: the policy to use
+ *
+ * Sets the fold threshold policy for @self.
+ *
+ * If set to `ADW_FOLD_THRESHOLD_POLICY_MINIMUM`, flap will only fold when the
+ * children cannot fit anymore. With `ADW_FOLD_THRESHOLD_POLICY_NATURAL`, it
+ * will fold as soon as children don't get their natural size.
+ *
+ * This can be useful if you have a long ellipsizing label and want to let it
+ * ellipsize instead of immediately folding.
+ *
+ * Since: 1.0
+ */
+void
+adw_flap_set_fold_threshold_policy (AdwFlap *self,
+ AdwFoldThresholdPolicy policy)
+{
+ g_return_if_fail (ADW_IS_FLAP (self));
+ g_return_if_fail (policy <= ADW_FOLD_THRESHOLD_POLICY_NATURAL);
+
+ if (self->fold_threshold_policy == policy)
+ return;
+
+ self->fold_threshold_policy = policy;
+
+ gtk_widget_queue_allocate (GTK_WIDGET (self));
+
+ g_object_notify_by_pspec (G_OBJECT (self), props[PROP_FOLD_THRESHOLD_POLICY]);
+}
+
/**
* adw_flap_get_fold_duration: (attributes org.gtk.Method.get_property=fold-duration)
* @self: a flap
@@ -2482,52 +2531,3 @@ adw_flap_set_swipe_to_close (AdwFlap *self,
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_SWIPE_TO_CLOSE]);
}
-
-/**
- * adw_flap_get_fold_threshold_policy: (attributes org.gtk.Method.get_property=fold-threshold-policy)
- * @self: a flap
- *
- * Gets the fold threshold policy for @self.
- *
- * Since: 1.0
- */
-AdwFoldThresholdPolicy
-adw_flap_get_fold_threshold_policy (AdwFlap *self)
-{
- g_return_val_if_fail (ADW_IS_FLAP (self), ADW_FOLD_THRESHOLD_POLICY_MINIMUM);
-
- return self->fold_threshold_policy;
-}
-
-/**
- * adw_flap_set_fold_threshold_policy: (attributes org.gtk.Method.set_property=fold-threshold-policy)
- * @self: a flap
- * @policy: the policy to use
- *
- * Sets the fold threshold policy for @self.
- *
- * If set to `ADW_FOLD_THRESHOLD_POLICY_MINIMUM`, flap will only fold when the
- * children cannot fit anymore. With `ADW_FOLD_THRESHOLD_POLICY_NATURAL`, it
- * will fold as soon as children don't get their natural size.
- *
- * This can be useful if you have a long ellipsizing label and want to let it
- * ellipsize instead of immediately folding.
- *
- * Since: 1.0
- */
-void
-adw_flap_set_fold_threshold_policy (AdwFlap *self,
- AdwFoldThresholdPolicy policy)
-{
- g_return_if_fail (ADW_IS_FLAP (self));
- g_return_if_fail (policy <= ADW_FOLD_THRESHOLD_POLICY_NATURAL);
-
- if (self->fold_threshold_policy == policy)
- return;
-
- self->fold_threshold_policy = policy;
-
- gtk_widget_queue_allocate (GTK_WIDGET (self));
-
- g_object_notify_by_pspec (G_OBJECT (self), props[PROP_FOLD_THRESHOLD_POLICY]);
-}
diff --git a/src/adw-flap.h b/src/adw-flap.h
index 25dc2da1..67592d8e 100644
--- a/src/adw-flap.h
+++ b/src/adw-flap.h
@@ -84,6 +84,12 @@ ADW_AVAILABLE_IN_ALL
void adw_flap_set_fold_policy (AdwFlap *self,
AdwFlapFoldPolicy policy);
+ADW_AVAILABLE_IN_ALL
+AdwFoldThresholdPolicy adw_flap_get_fold_threshold_policy (AdwFlap *self);
+ADW_AVAILABLE_IN_ALL
+void adw_flap_set_fold_threshold_policy (AdwFlap *self,
+ AdwFoldThresholdPolicy policy);
+
ADW_AVAILABLE_IN_ALL
guint adw_flap_get_fold_duration (AdwFlap *self);
ADW_AVAILABLE_IN_ALL
@@ -123,10 +129,4 @@ ADW_AVAILABLE_IN_ALL
void adw_flap_set_swipe_to_close (AdwFlap *self,
gboolean swipe_to_close);
-ADW_AVAILABLE_IN_ALL
-AdwFoldThresholdPolicy adw_flap_get_fold_threshold_policy (AdwFlap *self);
-ADW_AVAILABLE_IN_ALL
-void adw_flap_set_fold_threshold_policy (AdwFlap *self,
- AdwFoldThresholdPolicy policy);
-
G_END_DECLS
diff --git a/src/adw-header-bar.c b/src/adw-header-bar.c
index 4466047c..6f60c0fc 100644
--- a/src/adw-header-bar.c
+++ b/src/adw-header-bar.c
@@ -607,6 +607,57 @@ adw_header_bar_pack_end (AdwHeaderBar *self,
gtk_box_prepend (GTK_BOX (self->end_box), child);
}
+/**
+ * adw_header_bar_remove:
+ * @self: a header bar
+ * @child: the child to remove
+ *
+ * Removes a child from @self.
+ *
+ * The child must have been added with [method@HeaderBar.pack_start],
+ * [method@HeaderBar.pack_end] or [property@HeaderBar:title-widget].
+ *
+ * Since: 1.0
+ */
+void
+adw_header_bar_remove (AdwHeaderBar *self,
+ GtkWidget *child)
+{
+ GtkWidget *parent;
+
+ g_return_if_fail (ADW_IS_HEADER_BAR (self));
+ g_return_if_fail (GTK_IS_WIDGET (child));
+
+ parent = gtk_widget_get_parent (child);
+
+ if (parent == self->start_box)
+ gtk_box_remove (GTK_BOX (self->start_box), child);
+ else if (parent == self->end_box)
+ gtk_box_remove (GTK_BOX (self->end_box), child);
+ else if (parent == self->center_box)
+ gtk_center_box_set_center_widget (GTK_CENTER_BOX (self->center_box), NULL);
+ else
+ ADW_CRITICAL_CANNOT_REMOVE_CHILD (self, child);
+}
+
+/**
+ * adw_header_bar_get_title_widget: (attributes org.gtk.Method.get_property=title-widget)
+ * @self: a header bar
+ *
+ * Gets the title widget widget of @self.
+ *
+ * Returns: (nullable) (transfer none): the title widget
+ *
+ * Since: 1.0
+ */
+GtkWidget *
+adw_header_bar_get_title_widget (AdwHeaderBar *self)
+{
+ g_return_val_if_fail (ADW_IS_HEADER_BAR (self), NULL);
+
+ return self->title_widget;
+}
+
/**
* adw_header_bar_set_title_widget: (attributes org.gtk.Method.set_property=title-widget)
* @self: a header bar
@@ -659,57 +710,6 @@ adw_header_bar_set_title_widget (AdwHeaderBar *self,
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_TITLE_WIDGET]);
}
-/**
- * adw_header_bar_get_title_widget: (attributes org.gtk.Method.get_property=title-widget)
- * @self: a header bar
- *
- * Gets the title widget widget of @self.
- *
- * Returns: (nullable) (transfer none): the title widget
- *
- * Since: 1.0
- */
-GtkWidget *
-adw_header_bar_get_title_widget (AdwHeaderBar *self)
-{
- g_return_val_if_fail (ADW_IS_HEADER_BAR (self), NULL);
-
- return self->title_widget;
-}
-
-/**
- * adw_header_bar_remove:
- * @self: a header bar
- * @child: the child to remove
- *
- * Removes a child from @self.
- *
- * The child must have been added with [method@HeaderBar.pack_start],
- * [method@HeaderBar.pack_end] or [property@HeaderBar:title-widget].
- *
- * Since: 1.0
- */
-void
-adw_header_bar_remove (AdwHeaderBar *self,
- GtkWidget *child)
-{
- GtkWidget *parent;
-
- g_return_if_fail (ADW_IS_HEADER_BAR (self));
- g_return_if_fail (GTK_IS_WIDGET (child));
-
- parent = gtk_widget_get_parent (child);
-
- if (parent == self->start_box)
- gtk_box_remove (GTK_BOX (self->start_box), child);
- else if (parent == self->end_box)
- gtk_box_remove (GTK_BOX (self->end_box), child);
- else if (parent == self->center_box)
- gtk_center_box_set_center_widget (GTK_CENTER_BOX (self->center_box), NULL);
- else
- ADW_CRITICAL_CANNOT_REMOVE_CHILD (self, child);
-}
-
/**
* adw_header_bar_get_show_start_title_buttons: (attributes
org.gtk.Method.get_property=show-start-title-buttons)
* @self: a header bar
@@ -826,6 +826,24 @@ adw_header_bar_set_show_end_title_buttons (AdwHeaderBar *self,
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_SHOW_END_TITLE_BUTTONS]);
}
+/**
+ * adw_header_bar_get_decoration_layout: (attributes org.gtk.Method.get_property=decoration-layout)
+ * @self: a header bar
+ *
+ * Gets the decoration layout for @self.
+ *
+ * Returns: (nullable): the decoration layout
+ *
+ * Since: 1.0
+ */
+const char *
+adw_header_bar_get_decoration_layout (AdwHeaderBar *self)
+{
+ g_return_val_if_fail (ADW_IS_HEADER_BAR (self), NULL);
+
+ return self->decoration_layout;
+}
+
/**
* adw_header_bar_set_decoration_layout: (attributes org.gtk.Method.set_property=decoration-layout)
* @self: a header bar
@@ -858,24 +876,6 @@ adw_header_bar_set_decoration_layout (AdwHeaderBar *self,
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_DECORATION_LAYOUT]);
}
-/**
- * adw_header_bar_get_decoration_layout: (attributes org.gtk.Method.get_property=decoration-layout)
- * @self: a header bar
- *
- * Gets the decoration layout for @self.
- *
- * Returns: (nullable): the decoration layout
- *
- * Since: 1.0
- */
-const char *
-adw_header_bar_get_decoration_layout (AdwHeaderBar *self)
-{
- g_return_val_if_fail (ADW_IS_HEADER_BAR (self), NULL);
-
- return self->decoration_layout;
-}
-
/**
* adw_header_bar_get_centering_policy: (attributes org.gtk.Method.get_property=centering-policy)
* @self: a header bar
diff --git a/src/adw-header-bar.h b/src/adw-header-bar.h
index cb2b5dd9..cd18885e 100644
--- a/src/adw-header-bar.h
+++ b/src/adw-header-bar.h
@@ -44,12 +44,6 @@ typedef enum {
ADW_AVAILABLE_IN_ALL
GtkWidget *adw_header_bar_new (void) G_GNUC_WARN_UNUSED_RESULT;
-ADW_AVAILABLE_IN_ALL
-GtkWidget *adw_header_bar_get_title_widget (AdwHeaderBar *self);
-ADW_AVAILABLE_IN_ALL
-void adw_header_bar_set_title_widget (AdwHeaderBar *self,
- GtkWidget *title_widget);
-
ADW_AVAILABLE_IN_ALL
void adw_header_bar_pack_start (AdwHeaderBar *self,
GtkWidget *child);
@@ -60,6 +54,12 @@ ADW_AVAILABLE_IN_ALL
void adw_header_bar_remove (AdwHeaderBar *self,
GtkWidget *child);
+ADW_AVAILABLE_IN_ALL
+GtkWidget *adw_header_bar_get_title_widget (AdwHeaderBar *self);
+ADW_AVAILABLE_IN_ALL
+void adw_header_bar_set_title_widget (AdwHeaderBar *self,
+ GtkWidget *title_widget);
+
ADW_AVAILABLE_IN_ALL
gboolean adw_header_bar_get_show_start_title_buttons (AdwHeaderBar *self);
ADW_AVAILABLE_IN_ALL
diff --git a/src/adw-leaflet.c b/src/adw-leaflet.c
index 10df330e..f2f566e8 100644
--- a/src/adw-leaflet.c
+++ b/src/adw-leaflet.c
@@ -78,6 +78,7 @@
enum {
PROP_0,
+ PROP_CAN_UNFOLD,
PROP_FOLDED,
PROP_FOLD_THRESHOLD_POLICY,
PROP_HOMOGENEOUS,
@@ -89,7 +90,6 @@ enum {
PROP_CHILD_TRANSITION_RUNNING,
PROP_CAN_NAVIGATE_BACK,
PROP_CAN_NAVIGATE_FORWARD,
- PROP_CAN_UNFOLD,
PROP_PAGES,
/* orientable */
@@ -2032,6 +2032,9 @@ adw_leaflet_get_property (GObject *object,
AdwLeaflet *self = ADW_LEAFLET (object);
switch (prop_id) {
+ case PROP_CAN_UNFOLD:
+ g_value_set_boolean (value, adw_leaflet_get_can_unfold (self));
+ break;
case PROP_FOLDED:
g_value_set_boolean (value, adw_leaflet_get_folded (self));
break;
@@ -2065,9 +2068,6 @@ adw_leaflet_get_property (GObject *object,
case PROP_CAN_NAVIGATE_FORWARD:
g_value_set_boolean (value, adw_leaflet_get_can_navigate_forward (self));
break;
- case PROP_CAN_UNFOLD:
- g_value_set_boolean (value, adw_leaflet_get_can_unfold (self));
- break;
case PROP_PAGES:
g_value_take_object (value, adw_leaflet_get_pages (self));
break;
@@ -2088,6 +2088,9 @@ adw_leaflet_set_property (GObject *object,
AdwLeaflet *self = ADW_LEAFLET (object);
switch (prop_id) {
+ case PROP_CAN_UNFOLD:
+ adw_leaflet_set_can_unfold (self, g_value_get_boolean (value));
+ break;
case PROP_FOLD_THRESHOLD_POLICY:
adw_leaflet_set_fold_threshold_policy (self, g_value_get_enum (value));
break;
@@ -2115,9 +2118,6 @@ adw_leaflet_set_property (GObject *object,
case PROP_CAN_NAVIGATE_FORWARD:
adw_leaflet_set_can_navigate_forward (self, g_value_get_boolean (value));
break;
- case PROP_CAN_UNFOLD:
- adw_leaflet_set_can_unfold (self, g_value_get_boolean (value));
- break;
case PROP_ORIENTATION:
set_orientation (self, g_value_get_enum (value));
break;
@@ -2183,6 +2183,18 @@ adw_leaflet_class_init (AdwLeafletClass *klass)
PROP_ORIENTATION,
"orientation");
+ /**
+ * AdwLeaflet:can-unfold: (attributes org.gtk.Property.get=adw_leaflet_get_can_unfold
org.gtk.Property.set=adw_leaflet_set_can_unfold)
+ *
+ * Whether or not the leaflet can unfold.
+ *
+ * Since: 1.0
+ */
+ props[PROP_CAN_UNFOLD] =
+ g_param_spec_boolean ("can-unfold", NULL, NULL,
+ TRUE,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
+
/**
* AdwLeaflet:folded: (attributes org.gtk.Property.get=adw_leaflet_get_folded)
*
@@ -2379,18 +2391,6 @@ adw_leaflet_class_init (AdwLeafletClass *klass)
FALSE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
- /**
- * AdwLeaflet:can-unfold: (attributes org.gtk.Property.get=adw_leaflet_get_can_unfold
org.gtk.Property.set=adw_leaflet_set_can_unfold)
- *
- * Whether or not the leaflet can unfold.
- *
- * Since: 1.0
- */
- props[PROP_CAN_UNFOLD] =
- g_param_spec_boolean ("can-unfold", NULL, NULL,
- TRUE,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
-
/**
* AdwLeaflet:pages: (attributes org.gtk.Property.get=adw_leaflet_get_pages)
*
@@ -3038,6 +3038,51 @@ adw_leaflet_get_page (AdwLeaflet *self,
return find_page_for_widget (self, child);
}
+/**
+ * adw_leaflet_set_can_unfold: (attributes org.gtk.Method.set_property=can-unfold)
+ * @self: a leaflet
+ * @can_unfold: whether @self can unfold
+ *
+ * Sets whether @self can unfold.
+ *
+ * Since: 1.0
+ */
+void
+adw_leaflet_set_can_unfold (AdwLeaflet *self,
+ gboolean can_unfold)
+{
+ g_return_if_fail (ADW_IS_LEAFLET (self));
+
+ can_unfold = !!can_unfold;
+
+ if (self->can_unfold == can_unfold)
+ return;
+
+ self->can_unfold = can_unfold;
+
+ gtk_widget_queue_allocate (GTK_WIDGET (self));
+
+ g_object_notify_by_pspec (G_OBJECT (self), props[PROP_CAN_UNFOLD]);
+}
+
+/**
+ * adw_leaflet_get_can_unfold: (attributes org.gtk.Method.get_property=can-unfold)
+ * @self: a leaflet
+ *
+ * Gets whether @self can unfold.
+ *
+ * Returns: whether @self can unfold
+ *
+ * Since: 1.0
+ */
+gboolean
+adw_leaflet_get_can_unfold (AdwLeaflet *self)
+{
+ g_return_val_if_fail (ADW_IS_LEAFLET (self), FALSE);
+
+ return self->can_unfold;
+}
+
/**
* adw_leaflet_get_folded: (attributes org.gtk.Method.get_property=folded)
* @self: a leaflet
@@ -3060,6 +3105,56 @@ adw_leaflet_get_folded (AdwLeaflet *self)
return self->folded;
}
+/**
+ * adw_leaflet_get_fold_threshold_policy: (attributes org.gtk.Method.get_property=fold-threshold-policy)
+ * @self: a leaflet
+ *
+ * Gets the fold threshold policy for @self.
+ *
+ * Since: 1.0
+ */
+AdwFoldThresholdPolicy
+adw_leaflet_get_fold_threshold_policy (AdwLeaflet *self)
+{
+ g_return_val_if_fail (ADW_IS_LEAFLET (self), ADW_FOLD_THRESHOLD_POLICY_MINIMUM);
+
+ return self->fold_threshold_policy;
+}
+
+
+/**
+ * adw_leaflet_set_fold_threshold_policy: (attributes org.gtk.Method.set_property=fold-threshold-policy)
+ * @self: a leaflet
+ * @policy: the policy to use
+ *
+ * Sets the fold threshold policy for @self.
+ *
+ * If set to `ADW_FOLD_THRESHOLD_POLICY_MINIMUM`, it will only fold when the
+ * children cannot fit anymore. With `ADW_FOLD_THRESHOLD_POLICY_NATURAL`, it
+ * will fold as soon as children don't get their natural size.
+ *
+ * This can be useful if you have a long ellipsizing label and want to let it
+ * ellipsize instead of immediately folding.
+ *
+ * Since: 1.0
+ */
+void
+adw_leaflet_set_fold_threshold_policy (AdwLeaflet *self,
+ AdwFoldThresholdPolicy policy)
+{
+ g_return_if_fail (ADW_IS_LEAFLET (self));
+ g_return_if_fail (policy <= ADW_FOLD_THRESHOLD_POLICY_NATURAL);
+
+ if (self->fold_threshold_policy == policy)
+ return;
+
+ self->fold_threshold_policy = policy;
+
+ gtk_widget_queue_allocate (GTK_WIDGET (self));
+
+ g_object_notify_by_pspec (G_OBJECT (self), props[PROP_FOLD_THRESHOLD_POLICY]);
+}
+
/**
* adw_leaflet_get_homogeneous: (attributes org.gtk.Method.get_property=homogeneous)
* @self: a leaflet
@@ -3108,6 +3203,110 @@ adw_leaflet_set_homogeneous (AdwLeaflet *self,
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_HOMOGENEOUS]);
}
+/**
+ * adw_leaflet_get_visible_child: (attributes org.gtk.Method.get_property=visible-child)
+ * @self: a leaflet
+ *
+ * Gets the widget currently visible when the leaflet is folded.
+ *
+ * Returns: (nullable) (transfer none): the visible child
+ *
+ * Since: 1.0
+ */
+GtkWidget *
+adw_leaflet_get_visible_child (AdwLeaflet *self)
+{
+ g_return_val_if_fail (ADW_IS_LEAFLET (self), NULL);
+
+ if (self->visible_child == NULL)
+ return NULL;
+
+ return self->visible_child->widget;
+}
+
+/**
+ * adw_leaflet_set_visible_child: (attributes org.gtk.Method.set_property=visible-child)
+ * @self: a leaflet
+ * @visible_child: the new child
+ *
+ * Sets the widget currently visible when the leaflet is folded.
+ *
+ * The transition is determined by [property@Leaflet:transition-type] and
+ * [property@Leaflet:child-transition-params]. The transition can be cancelled
+ * by the user, in which case visible child will change back to the previously
+ * visible child.
+ *
+ * Since: 1.0
+ */
+void
+adw_leaflet_set_visible_child (AdwLeaflet *self,
+ GtkWidget *visible_child)
+{
+ AdwLeafletPage *page;
+ gboolean contains_child;
+
+ g_return_if_fail (ADW_IS_LEAFLET (self));
+ g_return_if_fail (GTK_IS_WIDGET (visible_child));
+
+ page = find_page_for_widget (self, visible_child);
+
+ contains_child = page != NULL;
+
+ g_return_if_fail (contains_child);
+
+ set_visible_child (self, page);
+}
+
+/**
+ * adw_leaflet_get_visible_child_name: (attributes org.gtk.Method.get_property=visible-child-name)
+ * @self: a leaflet
+ *
+ * Gets the name of the currently visible child widget.
+ *
+ * Returns: (nullable) (transfer none): the name of the visible child
+ *
+ * Since: 1.0
+ */
+const char *
+adw_leaflet_get_visible_child_name (AdwLeaflet *self)
+{
+ g_return_val_if_fail (ADW_IS_LEAFLET (self), NULL);
+
+ if (self->visible_child == NULL)
+ return NULL;
+
+ return self->visible_child->name;
+}
+
+/**
+ * adw_leaflet_set_visible_child_name: (attributes org.gtk.Method.set_property=visible-child-name)
+ * @self: a leaflet
+ * @name: the name of a child
+ *
+ * Makes the child with the name @name visible.
+ *
+ * See [property@Leaflet:visible-child].
+ *
+ * Since: 1.0
+ */
+void
+adw_leaflet_set_visible_child_name (AdwLeaflet *self,
+ const char *name)
+{
+ AdwLeafletPage *page;
+ gboolean contains_child;
+
+ g_return_if_fail (ADW_IS_LEAFLET (self));
+ g_return_if_fail (name != NULL);
+
+ page = find_page_for_name (self, name);
+ contains_child = page != NULL;
+
+ g_return_if_fail (contains_child);
+
+ set_visible_child (self, page);
+}
+
/**
* adw_leaflet_get_transition_type: (attributes org.gtk.Method.get_property=transition-type)
* @self: a leaflet
@@ -3261,125 +3460,39 @@ adw_leaflet_set_child_transition_params (AdwLeaflet *self,
}
/**
- * adw_leaflet_get_visible_child: (attributes org.gtk.Method.get_property=visible-child)
- * @self: a leaflet
- *
- * Gets the widget currently visible when the leaflet is folded.
- *
- * Returns: (nullable) (transfer none): the visible child
- *
- * Since: 1.0
- */
-GtkWidget *
-adw_leaflet_get_visible_child (AdwLeaflet *self)
-{
- g_return_val_if_fail (ADW_IS_LEAFLET (self), NULL);
-
- if (self->visible_child == NULL)
- return NULL;
-
- return self->visible_child->widget;
-}
-
-/**
- * adw_leaflet_set_visible_child: (attributes org.gtk.Method.set_property=visible-child)
- * @self: a leaflet
- * @visible_child: the new child
- *
- * Sets the widget currently visible when the leaflet is folded.
- *
- * The transition is determined by [property@Leaflet:transition-type] and
- * [property@Leaflet:child-transition-params]. The transition can be cancelled
- * by the user, in which case visible child will change back to the previously
- * visible child.
- *
- * Since: 1.0
- */
-void
-adw_leaflet_set_visible_child (AdwLeaflet *self,
- GtkWidget *visible_child)
-{
- AdwLeafletPage *page;
- gboolean contains_child;
-
- g_return_if_fail (ADW_IS_LEAFLET (self));
- g_return_if_fail (GTK_IS_WIDGET (visible_child));
-
- page = find_page_for_widget (self, visible_child);
-
- contains_child = page != NULL;
-
- g_return_if_fail (contains_child);
-
- set_visible_child (self, page);
-}
-
-/**
- * adw_leaflet_get_visible_child_name: (attributes org.gtk.Method.get_property=visible-child-name)
- * @self: a leaflet
- *
- * Gets the name of the currently visible child widget.
- *
- * Returns: (nullable) (transfer none): the name of the visible child
- *
- * Since: 1.0
- */
-const char *
-adw_leaflet_get_visible_child_name (AdwLeaflet *self)
-{
- g_return_val_if_fail (ADW_IS_LEAFLET (self), NULL);
-
- if (self->visible_child == NULL)
- return NULL;
-
- return self->visible_child->name;
-}
-
-/**
- * adw_leaflet_set_visible_child_name: (attributes org.gtk.Method.set_property=visible-child-name)
+ * adw_leaflet_get_child_transition_running: (attributes
org.gtk.Method.get_property=child-transition-running)
* @self: a leaflet
- * @name: the name of a child
*
- * Makes the child with the name @name visible.
+ * Gets whether a child transition is currently running for @self.
*
- * See [property@Leaflet:visible-child].
+ * Returns: whether a transition is currently running
*
* Since: 1.0
*/
-void
-adw_leaflet_set_visible_child_name (AdwLeaflet *self,
- const char *name)
+gboolean
+adw_leaflet_get_child_transition_running (AdwLeaflet *self)
{
- AdwLeafletPage *page;
- gboolean contains_child;
-
- g_return_if_fail (ADW_IS_LEAFLET (self));
- g_return_if_fail (name != NULL);
-
- page = find_page_for_name (self, name);
- contains_child = page != NULL;
-
- g_return_if_fail (contains_child);
+ g_return_val_if_fail (ADW_IS_LEAFLET (self), FALSE);
- set_visible_child (self, page);
+ return self->child_transition.transition_running;
}
/**
- * adw_leaflet_get_child_transition_running: (attributes
org.gtk.Method.get_property=child-transition-running)
+ * adw_leaflet_get_can_navigate_back: (attributes org.gtk.Method.get_property=can-navigate-back)
* @self: a leaflet
*
- * Gets whether a child transition is currently running for @self.
+ * Gets whether gestures and shortcuts for navigating backward are enabled.
*
- * Returns: whether a transition is currently running
+ * Returns: Whether gestures and shortcuts are enabled.
*
* Since: 1.0
*/
gboolean
-adw_leaflet_get_child_transition_running (AdwLeaflet *self)
+adw_leaflet_get_can_navigate_back (AdwLeaflet *self)
{
g_return_val_if_fail (ADW_IS_LEAFLET (self), FALSE);
- return self->child_transition.transition_running;
+ return self->child_transition.can_navigate_back;
}
/**
@@ -3425,21 +3538,21 @@ adw_leaflet_set_can_navigate_back (AdwLeaflet *self,
}
/**
- * adw_leaflet_get_can_navigate_back: (attributes org.gtk.Method.get_property=can-navigate-back)
+ * adw_leaflet_get_can_navigate_forward: (attributes org.gtk.Method.get_property=can-navigate-forward)
* @self: a leaflet
*
- * Gets whether gestures and shortcuts for navigating backward are enabled.
+ * Gets whether gestures and shortcuts for navigating forward are enabled.
*
* Returns: Whether gestures and shortcuts are enabled.
*
* Since: 1.0
*/
gboolean
-adw_leaflet_get_can_navigate_back (AdwLeaflet *self)
+adw_leaflet_get_can_navigate_forward (AdwLeaflet *self)
{
g_return_val_if_fail (ADW_IS_LEAFLET (self), FALSE);
- return self->child_transition.can_navigate_back;
+ return self->child_transition.can_navigate_forward;
}
/**
@@ -3484,24 +3597,6 @@ adw_leaflet_set_can_navigate_forward (AdwLeaflet *self,
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_CAN_NAVIGATE_FORWARD]);
}
-/**
- * adw_leaflet_get_can_navigate_forward: (attributes org.gtk.Method.get_property=can-navigate-forward)
- * @self: a leaflet
- *
- * Gets whether gestures and shortcuts for navigating forward are enabled.
- *
- * Returns: Whether gestures and shortcuts are enabled.
- *
- * Since: 1.0
- */
-gboolean
-adw_leaflet_get_can_navigate_forward (AdwLeaflet *self)
-{
- g_return_val_if_fail (ADW_IS_LEAFLET (self), FALSE);
-
- return self->child_transition.can_navigate_forward;
-}
-
/**
* adw_leaflet_get_adjacent_child:
* @self: a leaflet
@@ -3599,51 +3694,6 @@ adw_leaflet_get_child_by_name (AdwLeaflet *self,
return page ? page->widget : NULL;
}
-/**
- * adw_leaflet_set_can_unfold: (attributes org.gtk.Method.set_property=can-unfold)
- * @self: a leaflet
- * @can_unfold: whether @self can unfold
- *
- * Sets whether @self can unfold.
- *
- * Since: 1.0
- */
-void
-adw_leaflet_set_can_unfold (AdwLeaflet *self,
- gboolean can_unfold)
-{
- g_return_if_fail (ADW_IS_LEAFLET (self));
-
- can_unfold = !!can_unfold;
-
- if (self->can_unfold == can_unfold)
- return;
-
- self->can_unfold = can_unfold;
-
- gtk_widget_queue_allocate (GTK_WIDGET (self));
-
- g_object_notify_by_pspec (G_OBJECT (self), props[PROP_CAN_UNFOLD]);
-}
-
-/**
- * adw_leaflet_get_can_unfold: (attributes org.gtk.Method.get_property=can-unfold)
- * @self: a leaflet
- *
- * Gets whether @self can unfold.
- *
- * Returns: whether @self can unfold
- *
- * Since: 1.0
- */
-gboolean
-adw_leaflet_get_can_unfold (AdwLeaflet *self)
-{
- g_return_val_if_fail (ADW_IS_LEAFLET (self), FALSE);
-
- return self->can_unfold;
-}
-
/**
* adw_leaflet_get_pages: (attributes org.gtk.Method.get_property=pages)
* @self: a leaflet
@@ -3671,53 +3721,3 @@ adw_leaflet_get_pages (AdwLeaflet *self)
return self->pages;
}
-
-/**
- * adw_leaflet_get_fold_threshold_policy: (attributes org.gtk.Method.get_property=fold-threshold-policy)
- * @self: a leaflet
- *
- * Gets the fold threshold policy for @self.
- *
- * Since: 1.0
- */
-AdwFoldThresholdPolicy
-adw_leaflet_get_fold_threshold_policy (AdwLeaflet *self)
-{
- g_return_val_if_fail (ADW_IS_LEAFLET (self), ADW_FOLD_THRESHOLD_POLICY_MINIMUM);
-
- return self->fold_threshold_policy;
-}
-
-
-/**
- * adw_leaflet_set_fold_threshold_policy: (attributes org.gtk.Method.set_property=fold-threshold-policy)
- * @self: a leaflet
- * @policy: the policy to use
- *
- * Sets the fold threshold policy for @self.
- *
- * If set to `ADW_FOLD_THRESHOLD_POLICY_MINIMUM`, it will only fold when the
- * children cannot fit anymore. With `ADW_FOLD_THRESHOLD_POLICY_NATURAL`, it
- * will fold as soon as children don't get their natural size.
- *
- * This can be useful if you have a long ellipsizing label and want to let it
- * ellipsize instead of immediately folding.
- *
- * Since: 1.0
- */
-void
-adw_leaflet_set_fold_threshold_policy (AdwLeaflet *self,
- AdwFoldThresholdPolicy policy)
-{
- g_return_if_fail (ADW_IS_LEAFLET (self));
- g_return_if_fail (policy <= ADW_FOLD_THRESHOLD_POLICY_NATURAL);
-
- if (self->fold_threshold_policy == policy)
- return;
-
- self->fold_threshold_policy = policy;
-
- gtk_widget_queue_allocate (GTK_WIDGET (self));
-
- g_object_notify_by_pspec (G_OBJECT (self), props[PROP_FOLD_THRESHOLD_POLICY]);
-}
diff --git a/src/adw-leaflet.h b/src/adw-leaflet.h
index 5301851a..352c0c83 100644
--- a/src/adw-leaflet.h
+++ b/src/adw-leaflet.h
@@ -78,9 +78,21 @@ ADW_AVAILABLE_IN_ALL
AdwLeafletPage *adw_leaflet_get_page (AdwLeaflet *self,
GtkWidget *child);
+ADW_AVAILABLE_IN_ALL
+gboolean adw_leaflet_get_can_unfold (AdwLeaflet *self);
+ADW_AVAILABLE_IN_ALL
+void adw_leaflet_set_can_unfold (AdwLeaflet *self,
+ gboolean can_unfold);
+
ADW_AVAILABLE_IN_ALL
gboolean adw_leaflet_get_folded (AdwLeaflet *self);
+ADW_AVAILABLE_IN_ALL
+AdwFoldThresholdPolicy adw_leaflet_get_fold_threshold_policy (AdwLeaflet *self);
+ADW_AVAILABLE_IN_ALL
+void adw_leaflet_set_fold_threshold_policy (AdwLeaflet *self,
+ AdwFoldThresholdPolicy policy);
+
ADW_AVAILABLE_IN_ALL
gboolean adw_leaflet_get_homogeneous (AdwLeaflet *self);
ADW_AVAILABLE_IN_ALL
@@ -143,18 +155,7 @@ ADW_AVAILABLE_IN_ALL
GtkWidget *adw_leaflet_get_child_by_name (AdwLeaflet *self,
const char *name);
-ADW_AVAILABLE_IN_ALL
-gboolean adw_leaflet_get_can_unfold (AdwLeaflet *self);
-ADW_AVAILABLE_IN_ALL
-void adw_leaflet_set_can_unfold (AdwLeaflet *self,
- gboolean can_unfold);
-
ADW_AVAILABLE_IN_ALL
GtkSelectionModel *adw_leaflet_get_pages (AdwLeaflet *self) G_GNUC_WARN_UNUSED_RESULT;
-ADW_AVAILABLE_IN_ALL
-AdwFoldThresholdPolicy adw_leaflet_get_fold_threshold_policy (AdwLeaflet *self);
-ADW_AVAILABLE_IN_ALL
-void adw_leaflet_set_fold_threshold_policy (AdwLeaflet *self,
- AdwFoldThresholdPolicy policy);
G_END_DECLS
diff --git a/src/adw-preferences-group.c b/src/adw-preferences-group.c
index 45fd3585..97e119c2 100644
--- a/src/adw-preferences-group.c
+++ b/src/adw-preferences-group.c
@@ -74,8 +74,8 @@ static GtkBuildableIface *parent_buildable_iface;
enum {
PROP_0,
- PROP_DESCRIPTION,
PROP_TITLE,
+ PROP_DESCRIPTION,
PROP_HEADER_SUFFIX,
LAST_PROP,
};
@@ -165,6 +165,22 @@ listbox_keynav_failed_cb (AdwPreferencesGroup *self,
GTK_DIR_TAB_BACKWARD : GTK_DIR_TAB_FORWARD);
}
+static gboolean
+row_has_title (AdwPreferencesRow *row,
+ gpointer user_data)
+{
+ const char *title;
+
+ g_assert (ADW_IS_PREFERENCES_ROW (row));
+
+ if (!gtk_widget_get_visible (GTK_WIDGET (row)))
+ return FALSE;
+
+ title = adw_preferences_row_get_title (row);
+
+ return title && *title;
+}
+
static void
adw_preferences_group_get_property (GObject *object,
guint prop_id,
@@ -174,12 +190,12 @@ adw_preferences_group_get_property (GObject *object,
AdwPreferencesGroup *self = ADW_PREFERENCES_GROUP (object);
switch (prop_id) {
- case PROP_DESCRIPTION:
- g_value_set_string (value, adw_preferences_group_get_description (self));
- break;
case PROP_TITLE:
g_value_set_string (value, adw_preferences_group_get_title (self));
break;
+ case PROP_DESCRIPTION:
+ g_value_set_string (value, adw_preferences_group_get_description (self));
+ break;
case PROP_HEADER_SUFFIX:
g_value_set_object (value, adw_preferences_group_get_header_suffix (self));
break;
@@ -197,12 +213,12 @@ adw_preferences_group_set_property (GObject *object,
AdwPreferencesGroup *self = ADW_PREFERENCES_GROUP (object);
switch (prop_id) {
- case PROP_DESCRIPTION:
- adw_preferences_group_set_description (self, g_value_get_string (value));
- break;
case PROP_TITLE:
adw_preferences_group_set_title (self, g_value_get_string (value));
break;
+ case PROP_DESCRIPTION:
+ adw_preferences_group_set_description (self, g_value_get_string (value));
+ break;
case PROP_HEADER_SUFFIX:
adw_preferences_group_set_header_suffix (self, g_value_get_object (value));
break;
@@ -236,26 +252,26 @@ adw_preferences_group_class_init (AdwPreferencesGroupClass *klass)
widget_class->compute_expand = adw_widget_compute_expand;
/**
- * AdwPreferencesGroup:description: (attributes org.gtk.Property.get=adw_preferences_group_get_description
org.gtk.Property.set=adw_preferences_group_set_description)
+ * AdwPreferencesGroup:title: (attributes org.gtk.Property.get=adw_preferences_group_get_title
org.gtk.Property.set=adw_preferences_group_set_title)
*
- * The description for this group of preferences.
+ * The title for this group of preferences.
*
* Since: 1.0
*/
- props[PROP_DESCRIPTION] =
- g_param_spec_string ("description", NULL, NULL,
+ props[PROP_TITLE] =
+ g_param_spec_string ("title", NULL, NULL,
"",
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
/**
- * AdwPreferencesGroup:title: (attributes org.gtk.Property.get=adw_preferences_group_get_title
org.gtk.Property.set=adw_preferences_group_set_title)
+ * AdwPreferencesGroup:description: (attributes org.gtk.Property.get=adw_preferences_group_get_description
org.gtk.Property.set=adw_preferences_group_set_description)
*
- * The title for this group of preferences.
+ * The description for this group of preferences.
*
* Since: 1.0
*/
- props[PROP_TITLE] =
- g_param_spec_string ("title", NULL, NULL,
+ props[PROP_DESCRIPTION] =
+ g_param_spec_string ("description", NULL, NULL,
"",
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
@@ -352,68 +368,74 @@ adw_preferences_group_new (void)
}
/**
- * adw_preferences_group_get_title: (attributes org.gtk.Method.get_property=title)
+ * adw_preferences_group_add:
* @self: a preferences group
+ * @child: the widget to add
*
- * Gets the title of @self.
- *
- * Returns: the title of @self
+ * Adds a child to @self.
*
* Since: 1.0
*/
-const char *
-adw_preferences_group_get_title (AdwPreferencesGroup *self)
+void
+adw_preferences_group_add (AdwPreferencesGroup *self,
+ GtkWidget *child)
{
AdwPreferencesGroupPrivate *priv;
- g_return_val_if_fail (ADW_IS_PREFERENCES_GROUP (self), NULL);
+ g_return_if_fail (ADW_IS_PREFERENCES_GROUP (self));
+ g_return_if_fail (GTK_IS_WIDGET (child));
priv = adw_preferences_group_get_instance_private (self);
- return gtk_label_get_text (priv->title);
+ if (ADW_IS_PREFERENCES_ROW (child))
+ gtk_list_box_append (priv->listbox, child);
+ else
+ gtk_box_append (priv->listbox_box, child);
}
/**
- * adw_preferences_group_set_title: (attributes org.gtk.Method.set_property=title)
+ * adw_preferences_group_remove:
* @self: a preferences group
- * @title: the title
+ * @child: the child to remove
*
- * Sets the title for @self.
+ * Removes a child from @self.
*
* Since: 1.0
*/
void
-adw_preferences_group_set_title (AdwPreferencesGroup *self,
- const char *title)
+adw_preferences_group_remove (AdwPreferencesGroup *self,
+ GtkWidget *child)
{
AdwPreferencesGroupPrivate *priv;
+ GtkWidget *parent;
g_return_if_fail (ADW_IS_PREFERENCES_GROUP (self));
+ g_return_if_fail (GTK_IS_WIDGET (child));
priv = adw_preferences_group_get_instance_private (self);
- if (g_strcmp0 (gtk_label_get_label (priv->title), title) == 0)
- return;
-
- gtk_label_set_label (priv->title, title);
- update_title_visibility (self);
- update_header_visibility (self);
+ parent = gtk_widget_get_parent (child);
- g_object_notify_by_pspec (G_OBJECT (self), props[PROP_TITLE]);
+ if (parent == GTK_WIDGET (priv->listbox))
+ gtk_list_box_remove (priv->listbox, child);
+ else if (parent == GTK_WIDGET (priv->listbox_box))
+ gtk_box_remove (priv->listbox_box, child);
+ else
+ ADW_CRITICAL_CANNOT_REMOVE_CHILD (self, child);
}
/**
- * adw_preferences_group_get_description: (attributes org.gtk.Method.get_property=description)
+ * adw_preferences_group_get_title: (attributes org.gtk.Method.get_property=title)
* @self: a preferences group
*
- * Gets the description of @self.
+ * Gets the title of @self.
*
- * Returns: (nullable): the description of @self
+ * Returns: the title of @self
*
* Since: 1.0
*/
const char *
-adw_preferences_group_get_description (AdwPreferencesGroup *self)
+adw_preferences_group_get_title (AdwPreferencesGroup *self)
{
AdwPreferencesGroupPrivate *priv;
@@ -421,21 +443,21 @@ adw_preferences_group_get_description (AdwPreferencesGroup *self)
priv = adw_preferences_group_get_instance_private (self);
- return gtk_label_get_text (priv->description);
+ return gtk_label_get_text (priv->title);
}
/**
- * adw_preferences_group_set_description: (attributes org.gtk.Method.set_property=description)
+ * adw_preferences_group_set_title: (attributes org.gtk.Method.set_property=title)
* @self: a preferences group
- * @description: (nullable): the description
+ * @title: the title
*
- * Sets the description for @self.
+ * Sets the title for @self.
*
* Since: 1.0
*/
void
-adw_preferences_group_set_description (AdwPreferencesGroup *self,
- const char *description)
+adw_preferences_group_set_title (AdwPreferencesGroup *self,
+ const char *title)
{
AdwPreferencesGroupPrivate *priv;
@@ -443,117 +465,65 @@ adw_preferences_group_set_description (AdwPreferencesGroup *self,
priv = adw_preferences_group_get_instance_private (self);
- if (g_strcmp0 (gtk_label_get_label (priv->description), description) == 0)
+ if (g_strcmp0 (gtk_label_get_label (priv->title), title) == 0)
return;
- gtk_label_set_label (priv->description, description);
- update_description_visibility (self);
+ gtk_label_set_label (priv->title, title);
+ update_title_visibility (self);
update_header_visibility (self);
- g_object_notify_by_pspec (G_OBJECT (self), props[PROP_DESCRIPTION]);
-}
-
-static gboolean
-row_has_title (AdwPreferencesRow *row,
- gpointer user_data)
-{
- const char *title;
-
- g_assert (ADW_IS_PREFERENCES_ROW (row));
-
- if (!gtk_widget_get_visible (GTK_WIDGET (row)))
- return FALSE;
-
- title = adw_preferences_row_get_title (row);
-
- return title && *title;
+ g_object_notify_by_pspec (G_OBJECT (self), props[PROP_TITLE]);
}
/**
- * adw_preferences_group_get_rows:
+ * adw_preferences_group_get_description: (attributes org.gtk.Method.get_property=description)
* @self: a preferences group
*
- * Gets a [iface@Gio.ListModel] that contains the rows of the group.
- *
- * This can be used to keep an up-to-date view.
+ * Gets the description of @self.
*
- * Returns: (transfer full): a list model for the group's rows
+ * Returns: (nullable): the description of @self
*
* Since: 1.0
*/
-GListModel *
-adw_preferences_group_get_rows (AdwPreferencesGroup *self)
+const char *
+adw_preferences_group_get_description (AdwPreferencesGroup *self)
{
AdwPreferencesGroupPrivate *priv;
- GtkCustomFilter *filter;
- GListModel *model;
g_return_val_if_fail (ADW_IS_PREFERENCES_GROUP (self), NULL);
priv = adw_preferences_group_get_instance_private (self);
- filter = gtk_custom_filter_new ((GtkCustomFilterFunc) row_has_title, NULL, NULL);
- model = gtk_widget_observe_children (GTK_WIDGET (priv->listbox));
- model = G_LIST_MODEL (gtk_filter_list_model_new (model, GTK_FILTER (filter)));
-
- return model;
+ return gtk_label_get_text (priv->description);
}
/**
- * adw_preferences_group_add:
+ * adw_preferences_group_set_description: (attributes org.gtk.Method.set_property=description)
* @self: a preferences group
- * @child: the widget to add
+ * @description: (nullable): the description
*
- * Adds a child to @self.
+ * Sets the description for @self.
*
* Since: 1.0
*/
void
-adw_preferences_group_add (AdwPreferencesGroup *self,
- GtkWidget *child)
+adw_preferences_group_set_description (AdwPreferencesGroup *self,
+ const char *description)
{
AdwPreferencesGroupPrivate *priv;
g_return_if_fail (ADW_IS_PREFERENCES_GROUP (self));
- g_return_if_fail (GTK_IS_WIDGET (child));
priv = adw_preferences_group_get_instance_private (self);
- if (ADW_IS_PREFERENCES_ROW (child))
- gtk_list_box_append (priv->listbox, child);
- else
- gtk_box_append (priv->listbox_box, child);
-}
-
-/**
- * adw_preferences_group_remove:
- * @self: a preferences group
- * @child: the child to remove
- *
- * Removes a child from @self.
- *
- * Since: 1.0
- */
-void
-adw_preferences_group_remove (AdwPreferencesGroup *self,
- GtkWidget *child)
-{
- AdwPreferencesGroupPrivate *priv;
- GtkWidget *parent;
-
- g_return_if_fail (ADW_IS_PREFERENCES_GROUP (self));
- g_return_if_fail (GTK_IS_WIDGET (child));
-
- priv = adw_preferences_group_get_instance_private (self);
+ if (g_strcmp0 (gtk_label_get_label (priv->description), description) == 0)
+ return;
- parent = gtk_widget_get_parent (child);
+ gtk_label_set_label (priv->description, description);
+ update_description_visibility (self);
+ update_header_visibility (self);
- if (parent == GTK_WIDGET (priv->listbox))
- gtk_list_box_remove (priv->listbox, child);
- else if (parent == GTK_WIDGET (priv->listbox_box))
- gtk_box_remove (priv->listbox_box, child);
- else
- ADW_CRITICAL_CANNOT_REMOVE_CHILD (self, child);
+ g_object_notify_by_pspec (G_OBJECT (self), props[PROP_DESCRIPTION]);
}
/**
@@ -615,3 +585,33 @@ adw_preferences_group_set_header_suffix (AdwPreferencesGroup *self,
update_header_visibility (self);
}
+
+/**
+ * adw_preferences_group_get_rows:
+ * @self: a preferences group
+ *
+ * Gets a [iface@Gio.ListModel] that contains the rows of the group.
+ *
+ * This can be used to keep an up-to-date view.
+ *
+ * Returns: (transfer full): a list model for the group's rows
+ *
+ * Since: 1.0
+ */
+GListModel *
+adw_preferences_group_get_rows (AdwPreferencesGroup *self)
+{
+ AdwPreferencesGroupPrivate *priv;
+ GtkCustomFilter *filter;
+ GListModel *model;
+
+ g_return_val_if_fail (ADW_IS_PREFERENCES_GROUP (self), NULL);
+
+ priv = adw_preferences_group_get_instance_private (self);
+
+ filter = gtk_custom_filter_new ((GtkCustomFilterFunc) row_has_title, NULL, NULL);
+ model = gtk_widget_observe_children (GTK_WIDGET (priv->listbox));
+ model = G_LIST_MODEL (gtk_filter_list_model_new (model, GTK_FILTER (filter)));
+
+ return model;
+}
diff --git a/src/adw-preferences-group.h b/src/adw-preferences-group.h
index f6afb995..70adba5a 100644
--- a/src/adw-preferences-group.h
+++ b/src/adw-preferences-group.h
@@ -36,6 +36,13 @@ struct _AdwPreferencesGroupClass
ADW_AVAILABLE_IN_ALL
GtkWidget *adw_preferences_group_new (void) G_GNUC_WARN_UNUSED_RESULT;
+ADW_AVAILABLE_IN_ALL
+void adw_preferences_group_add (AdwPreferencesGroup *self,
+ GtkWidget *child);
+ADW_AVAILABLE_IN_ALL
+void adw_preferences_group_remove (AdwPreferencesGroup *self,
+ GtkWidget *child);
+
ADW_AVAILABLE_IN_ALL
const char *adw_preferences_group_get_title (AdwPreferencesGroup *self);
ADW_AVAILABLE_IN_ALL
@@ -48,13 +55,6 @@ ADW_AVAILABLE_IN_ALL
void adw_preferences_group_set_description (AdwPreferencesGroup *self,
const char *description);
-ADW_AVAILABLE_IN_ALL
-void adw_preferences_group_add (AdwPreferencesGroup *self,
- GtkWidget *child);
-ADW_AVAILABLE_IN_ALL
-void adw_preferences_group_remove (AdwPreferencesGroup *self,
- GtkWidget *child);
-
ADW_AVAILABLE_IN_1_1
GtkWidget *adw_preferences_group_get_header_suffix (AdwPreferencesGroup *self);
ADW_AVAILABLE_IN_1_1
diff --git a/src/adw-preferences-page.c b/src/adw-preferences-page.c
index 82f1e2c2..41be6ddc 100644
--- a/src/adw-preferences-page.c
+++ b/src/adw-preferences-page.c
@@ -264,6 +264,55 @@ adw_preferences_page_new (void)
return g_object_new (ADW_TYPE_PREFERENCES_PAGE, NULL);
}
+/**
+ * adw_preferences_page_add:
+ * @self: a preferences page
+ * @group: the group to add
+ *
+ * Adds a preferences group to @self.
+ *
+ * Since: 1.0
+ */
+void
+adw_preferences_page_add (AdwPreferencesPage *self,
+ AdwPreferencesGroup *group)
+{
+ AdwPreferencesPagePrivate *priv;
+
+ g_return_if_fail (ADW_IS_PREFERENCES_PAGE (self));
+ g_return_if_fail (ADW_IS_PREFERENCES_GROUP (group));
+
+ priv = adw_preferences_page_get_instance_private (self);
+
+ gtk_box_append (priv->box, GTK_WIDGET (group));
+}
+
+/**
+ * adw_preferences_page_remove:
+ * @self: a preferences page
+ * @group: the group to remove
+ *
+ * Removes a group from @self.
+ *
+ * Since: 1.0
+ */
+void
+adw_preferences_page_remove (AdwPreferencesPage *self,
+ AdwPreferencesGroup *group)
+{
+ AdwPreferencesPagePrivate *priv;
+
+ g_return_if_fail (ADW_IS_PREFERENCES_PAGE (self));
+ g_return_if_fail (ADW_IS_PREFERENCES_GROUP (group));
+
+ priv = adw_preferences_page_get_instance_private (self);
+
+ if (gtk_widget_get_parent (GTK_WIDGET (group)) == GTK_WIDGET (priv->box))
+ gtk_box_remove (priv->box, GTK_WIDGET (group));
+ else
+ ADW_CRITICAL_CANNOT_REMOVE_CHILD (self, group);
+}
+
/**
* adw_preferences_page_get_icon_name: (attributes org.gtk.Method.get_property=icon-name)
* @self: a preferences page
@@ -414,41 +463,6 @@ adw_preferences_page_set_name (AdwPreferencesPage *self,
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_NAME]);
}
-/**
- * adw_preferences_page_get_rows:
- * @self: a preferences page
- *
- * Gets a [iface@Gio.ListModel] that contains the rows of the page.
- *
- * This can be used to keep an up-to-date view.
- *
- * Returns: (transfer full): a list model for the page's rows
- *
- * Since: 1.0
- */
-GListModel *
-adw_preferences_page_get_rows (AdwPreferencesPage *self)
-{
- AdwPreferencesPagePrivate *priv;
- GListModel *model;
- GtkExpression *expr;
-
- g_return_val_if_fail (ADW_IS_PREFERENCES_PAGE (self), NULL);
-
- priv = adw_preferences_page_get_instance_private (self);
-
- expr = gtk_property_expression_new (GTK_TYPE_WIDGET, NULL, "visible");
-
- model = gtk_widget_observe_children (GTK_WIDGET (priv->box));
- model = G_LIST_MODEL (gtk_filter_list_model_new (model, GTK_FILTER (gtk_bool_filter_new (expr))));
- model = G_LIST_MODEL (gtk_map_list_model_new (model,
- (GtkMapListModelMapFunc) adw_preferences_group_get_rows,
- NULL,
- NULL));
-
- return G_LIST_MODEL (gtk_flatten_list_model_new (model));
-}
-
/**
* adw_preferences_page_get_use_underline: (attributes org.gtk.Method.get_property=use-underline)
* @self: a preferences page
@@ -501,50 +515,36 @@ adw_preferences_page_set_use_underline (AdwPreferencesPage *self,
}
/**
- * adw_preferences_page_add:
+ * adw_preferences_page_get_rows:
* @self: a preferences page
- * @group: the group to add
*
- * Adds a preferences group to @self.
+ * Gets a [iface@Gio.ListModel] that contains the rows of the page.
*
- * Since: 1.0
- */
-void
-adw_preferences_page_add (AdwPreferencesPage *self,
- AdwPreferencesGroup *group)
-{
- AdwPreferencesPagePrivate *priv;
-
- g_return_if_fail (ADW_IS_PREFERENCES_PAGE (self));
- g_return_if_fail (ADW_IS_PREFERENCES_GROUP (group));
-
- priv = adw_preferences_page_get_instance_private (self);
-
- gtk_box_append (priv->box, GTK_WIDGET (group));
-}
-
-/**
- * adw_preferences_page_remove:
- * @self: a preferences page
- * @group: the group to remove
+ * This can be used to keep an up-to-date view.
*
- * Removes a group from @self.
+ * Returns: (transfer full): a list model for the page's rows
*
* Since: 1.0
*/
-void
-adw_preferences_page_remove (AdwPreferencesPage *self,
- AdwPreferencesGroup *group)
+GListModel *
+adw_preferences_page_get_rows (AdwPreferencesPage *self)
{
AdwPreferencesPagePrivate *priv;
+ GListModel *model;
+ GtkExpression *expr;
- g_return_if_fail (ADW_IS_PREFERENCES_PAGE (self));
- g_return_if_fail (ADW_IS_PREFERENCES_GROUP (group));
+ g_return_val_if_fail (ADW_IS_PREFERENCES_PAGE (self), NULL);
priv = adw_preferences_page_get_instance_private (self);
- if (gtk_widget_get_parent (GTK_WIDGET (group)) == GTK_WIDGET (priv->box))
- gtk_box_remove (priv->box, GTK_WIDGET (group));
- else
- ADW_CRITICAL_CANNOT_REMOVE_CHILD (self, group);
+ expr = gtk_property_expression_new (GTK_TYPE_WIDGET, NULL, "visible");
+
+ model = gtk_widget_observe_children (GTK_WIDGET (priv->box));
+ model = G_LIST_MODEL (gtk_filter_list_model_new (model, GTK_FILTER (gtk_bool_filter_new (expr))));
+ model = G_LIST_MODEL (gtk_map_list_model_new (model,
+ (GtkMapListModelMapFunc) adw_preferences_group_get_rows,
+ NULL,
+ NULL));
+
+ return G_LIST_MODEL (gtk_flatten_list_model_new (model));
}
diff --git a/src/adw-preferences-page.h b/src/adw-preferences-page.h
index 28541580..da0856cc 100644
--- a/src/adw-preferences-page.h
+++ b/src/adw-preferences-page.h
@@ -37,6 +37,13 @@ struct _AdwPreferencesPageClass
ADW_AVAILABLE_IN_ALL
GtkWidget *adw_preferences_page_new (void) G_GNUC_WARN_UNUSED_RESULT;
+ADW_AVAILABLE_IN_ALL
+void adw_preferences_page_add (AdwPreferencesPage *self,
+ AdwPreferencesGroup *group);
+ADW_AVAILABLE_IN_ALL
+void adw_preferences_page_remove (AdwPreferencesPage *self,
+ AdwPreferencesGroup *group);
+
ADW_AVAILABLE_IN_ALL
const char *adw_preferences_page_get_icon_name (AdwPreferencesPage *self);
ADW_AVAILABLE_IN_ALL
@@ -61,11 +68,4 @@ ADW_AVAILABLE_IN_ALL
void adw_preferences_page_set_use_underline (AdwPreferencesPage *self,
gboolean use_underline);
-ADW_AVAILABLE_IN_ALL
-void adw_preferences_page_add (AdwPreferencesPage *self,
- AdwPreferencesGroup *group);
-ADW_AVAILABLE_IN_ALL
-void adw_preferences_page_remove (AdwPreferencesPage *self,
- AdwPreferencesGroup *group);
-
G_END_DECLS
diff --git a/src/adw-preferences-window.c b/src/adw-preferences-window.c
index 4f2387c0..8fbe0e2f 100644
--- a/src/adw-preferences-window.c
+++ b/src/adw-preferences-window.c
@@ -716,174 +716,141 @@ adw_preferences_window_new (void)
}
/**
- * adw_preferences_window_get_search_enabled: (attributes org.gtk.Method.get_property=search-enabled)
+ * adw_preferences_window_add:
* @self: a preferences window
+ * @page: the page to add
*
- * Gets whether search is enabled for @self.
- *
- * Returns: whether search is enabled for @self.
+ * Adds a preferences page to @self.
*
* Since: 1.0
*/
-gboolean
-adw_preferences_window_get_search_enabled (AdwPreferencesWindow *self)
+void
+adw_preferences_window_add (AdwPreferencesWindow *self,
+ AdwPreferencesPage *page)
{
AdwPreferencesWindowPrivate *priv;
+ AdwViewStackPage *stack_page;
- g_return_val_if_fail (ADW_IS_PREFERENCES_WINDOW (self), FALSE);
+ g_return_if_fail (ADW_IS_PREFERENCES_WINDOW (self));
+ g_return_if_fail (ADW_IS_PREFERENCES_PAGE (page));
priv = adw_preferences_window_get_instance_private (self);
- return priv->search_enabled;
+ stack_page = adw_view_stack_add_named (priv->pages_stack, GTK_WIDGET (page), adw_preferences_page_get_name
(page));
+
+ g_object_bind_property (page, "icon-name", stack_page, "icon-name", G_BINDING_SYNC_CREATE);
+ g_object_bind_property (page, "title", stack_page, "title", G_BINDING_SYNC_CREATE);
+ g_object_bind_property (page, "use-underline", stack_page, "use-underline", G_BINDING_SYNC_CREATE);
+ g_object_bind_property (page, "name", stack_page, "name", G_BINDING_SYNC_CREATE);
}
/**
- * adw_preferences_window_set_search_enabled: (attributes org.gtk.Method.set_property=search-enabled)
+ * adw_preferences_window_remove:
* @self: a preferences window
- * @search_enabled: whether search is enabled
+ * @page: the page to remove
*
- * Sets whether search is enabled for @self.
+ * Removes a page from @self.
*
* Since: 1.0
*/
void
-adw_preferences_window_set_search_enabled (AdwPreferencesWindow *self,
- gboolean search_enabled)
+adw_preferences_window_remove (AdwPreferencesWindow *self,
+ AdwPreferencesPage *page)
{
AdwPreferencesWindowPrivate *priv;
g_return_if_fail (ADW_IS_PREFERENCES_WINDOW (self));
+ g_return_if_fail (ADW_IS_PREFERENCES_PAGE (page));
priv = adw_preferences_window_get_instance_private (self);
- search_enabled = !!search_enabled;
-
- if (priv->search_enabled == search_enabled)
- return;
-
- priv->search_enabled = search_enabled;
- gtk_widget_set_visible (GTK_WIDGET (priv->search_button), search_enabled);
- if (search_enabled) {
- gtk_search_entry_set_key_capture_widget (priv->search_entry, GTK_WIDGET (self));
- } else {
- gtk_toggle_button_set_active (priv->search_button, FALSE);
- gtk_search_entry_set_key_capture_widget (priv->search_entry, NULL);
- }
-
- g_object_notify_by_pspec (G_OBJECT (self), props[PROP_SEARCH_ENABLED]);
+ if (gtk_widget_get_parent (GTK_WIDGET (page)) == GTK_WIDGET (priv->pages_stack))
+ adw_view_stack_remove (priv->pages_stack, GTK_WIDGET (page));
+ else
+ ADW_CRITICAL_CANNOT_REMOVE_CHILD (self, page);
}
/**
- * adw_preferences_window_set_can_navigate_back: (attributes org.gtk.Method.set_property=can-navigate-back)
+ * adw_preferences_window_get_visible_page:
* @self: a preferences window
- * @can_navigate_back: the new value
- *
- * Sets whether gestures and shortcuts for closing subpages are enabled.
- *
- * The supported gestures are:
- *
- * - One-finger swipe on touchscreens
- * - Horizontal scrolling on touchpads (usually two-finger swipe)
- * - Back mouse button
*
- * The keyboard back key is also supported, as well as the
- * <kbd>Alt</kbd>+<kbd>←</kbd> shortcut.
+ * Gets the currently visible page of @self.
*
- * For right-to-left locales, gestures and shortcuts are reversed.
+ * Returns: (transfer none) (nullable): the visible page
*
* Since: 1.0
*/
-void
-adw_preferences_window_set_can_navigate_back (AdwPreferencesWindow *self,
- gboolean can_navigate_back)
+AdwPreferencesPage *
+adw_preferences_window_get_visible_page (AdwPreferencesWindow *self)
{
AdwPreferencesWindowPrivate *priv;
- g_return_if_fail (ADW_IS_PREFERENCES_WINDOW (self));
+ g_return_val_if_fail (ADW_IS_PREFERENCES_WINDOW (self), NULL);
priv = adw_preferences_window_get_instance_private (self);
- can_navigate_back = !!can_navigate_back;
-
- if (priv->can_navigate_back == can_navigate_back)
- return;
-
- priv->can_navigate_back = can_navigate_back;
-
- g_object_notify_by_pspec (G_OBJECT (self), props[PROP_CAN_NAVIGATE_BACK]);
+ return ADW_PREFERENCES_PAGE (adw_view_stack_get_visible_child (priv->pages_stack));
}
/**
- * adw_preferences_window_get_can_navigate_back: (attributes org.gtk.Method.get_property=can-navigate-back)
+ * adw_preferences_window_set_visible_page:
* @self: a preferences window
+ * @page: a page of @self
*
- * Gets whether gestures and shortcuts for closing subpages are enabled.
- *
- * Returns: whether gestures and shortcuts are enabled.
+ * Makes @page the visible page of @self.
*
* Since: 1.0
*/
-gboolean
-adw_preferences_window_get_can_navigate_back (AdwPreferencesWindow *self)
+void
+adw_preferences_window_set_visible_page (AdwPreferencesWindow *self,
+ AdwPreferencesPage *page)
{
AdwPreferencesWindowPrivate *priv;
- g_return_val_if_fail (ADW_IS_PREFERENCES_WINDOW (self), FALSE);
+ g_return_if_fail (ADW_IS_PREFERENCES_WINDOW (self));
+ g_return_if_fail (ADW_IS_PREFERENCES_PAGE (page));
priv = adw_preferences_window_get_instance_private (self);
- return priv->can_navigate_back;
+ adw_view_stack_set_visible_child (priv->pages_stack, GTK_WIDGET (page));
}
/**
- * adw_preferences_window_present_subpage:
+ * adw_preferences_window_get_visible_page_name:
* @self: a preferences window
- * @subpage: the subpage
*
- * Sets @subpage as the window's subpage and opens it.
+ * Gets the name of currently visible page of @self.
*
- * The transition can be cancelled by the user, in which case visible child will
- * change back to the previously visible child.
+ * Returns: (transfer none) (nullable): the name of the visible page
*
* Since: 1.0
*/
-void
-adw_preferences_window_present_subpage (AdwPreferencesWindow *self,
- GtkWidget *subpage)
+const char *
+adw_preferences_window_get_visible_page_name (AdwPreferencesWindow *self)
{
AdwPreferencesWindowPrivate *priv;
- g_return_if_fail (ADW_IS_PREFERENCES_WINDOW (self));
- g_return_if_fail (GTK_IS_WIDGET (subpage));
+ g_return_val_if_fail (ADW_IS_PREFERENCES_WINDOW (self), NULL);
priv = adw_preferences_window_get_instance_private (self);
- if (priv->subpage == subpage)
- return;
-
- priv->subpage = subpage;
-
- /* The check below avoids a warning when re-entering a subpage during the
- * transition between the that subpage to the preferences.
- */
- if (gtk_widget_get_parent (subpage) != GTK_WIDGET (priv->subpages_leaflet))
- adw_leaflet_append (priv->subpages_leaflet, subpage);
-
- adw_leaflet_set_visible_child (priv->subpages_leaflet, subpage);
+ return adw_view_stack_get_visible_child_name (priv->pages_stack);
}
/**
- * adw_preferences_window_close_subpage:
+ * adw_preferences_window_set_visible_page_name:
* @self: a preferences window
+ * @name: the name of the page to make visible
*
- * Closes the current subpage.
+ * Makes the page with the given name visible.
*
- * If there is no presented subpage, this does nothing.
+ * See [property@ViewStack:visible-child].
*
* Since: 1.0
*/
void
-adw_preferences_window_close_subpage (AdwPreferencesWindow *self)
+adw_preferences_window_set_visible_page_name (AdwPreferencesWindow *self,
+ const char *name)
{
AdwPreferencesWindowPrivate *priv;
@@ -891,148 +858,178 @@ adw_preferences_window_close_subpage (AdwPreferencesWindow *self)
priv = adw_preferences_window_get_instance_private (self);
- if (priv->subpage == NULL)
- return;
-
- adw_leaflet_set_visible_child (priv->subpages_leaflet, priv->preferences);
+ adw_view_stack_set_visible_child_name (priv->pages_stack, name);
}
/**
- * adw_preferences_window_add:
+ * adw_preferences_window_get_search_enabled: (attributes org.gtk.Method.get_property=search-enabled)
* @self: a preferences window
- * @page: the page to add
*
- * Adds a preferences page to @self.
+ * Gets whether search is enabled for @self.
+ *
+ * Returns: whether search is enabled for @self.
*
* Since: 1.0
*/
-void
-adw_preferences_window_add (AdwPreferencesWindow *self,
- AdwPreferencesPage *page)
+gboolean
+adw_preferences_window_get_search_enabled (AdwPreferencesWindow *self)
{
AdwPreferencesWindowPrivate *priv;
- AdwViewStackPage *stack_page;
- g_return_if_fail (ADW_IS_PREFERENCES_WINDOW (self));
- g_return_if_fail (ADW_IS_PREFERENCES_PAGE (page));
+ g_return_val_if_fail (ADW_IS_PREFERENCES_WINDOW (self), FALSE);
priv = adw_preferences_window_get_instance_private (self);
- stack_page = adw_view_stack_add_named (priv->pages_stack, GTK_WIDGET (page), adw_preferences_page_get_name
(page));
-
- g_object_bind_property (page, "icon-name", stack_page, "icon-name", G_BINDING_SYNC_CREATE);
- g_object_bind_property (page, "title", stack_page, "title", G_BINDING_SYNC_CREATE);
- g_object_bind_property (page, "use-underline", stack_page, "use-underline", G_BINDING_SYNC_CREATE);
- g_object_bind_property (page, "name", stack_page, "name", G_BINDING_SYNC_CREATE);
+ return priv->search_enabled;
}
/**
- * adw_preferences_window_remove:
+ * adw_preferences_window_set_search_enabled: (attributes org.gtk.Method.set_property=search-enabled)
* @self: a preferences window
- * @page: the page to remove
+ * @search_enabled: whether search is enabled
*
- * Removes a page from @self.
+ * Sets whether search is enabled for @self.
*
* Since: 1.0
*/
void
-adw_preferences_window_remove (AdwPreferencesWindow *self,
- AdwPreferencesPage *page)
+adw_preferences_window_set_search_enabled (AdwPreferencesWindow *self,
+ gboolean search_enabled)
{
AdwPreferencesWindowPrivate *priv;
g_return_if_fail (ADW_IS_PREFERENCES_WINDOW (self));
- g_return_if_fail (ADW_IS_PREFERENCES_PAGE (page));
priv = adw_preferences_window_get_instance_private (self);
- if (gtk_widget_get_parent (GTK_WIDGET (page)) == GTK_WIDGET (priv->pages_stack))
- adw_view_stack_remove (priv->pages_stack, GTK_WIDGET (page));
- else
- ADW_CRITICAL_CANNOT_REMOVE_CHILD (self, page);
+ search_enabled = !!search_enabled;
+
+ if (priv->search_enabled == search_enabled)
+ return;
+
+ priv->search_enabled = search_enabled;
+ gtk_widget_set_visible (GTK_WIDGET (priv->search_button), search_enabled);
+ if (search_enabled) {
+ gtk_search_entry_set_key_capture_widget (priv->search_entry, GTK_WIDGET (self));
+ } else {
+ gtk_toggle_button_set_active (priv->search_button, FALSE);
+ gtk_search_entry_set_key_capture_widget (priv->search_entry, NULL);
+ }
+
+ g_object_notify_by_pspec (G_OBJECT (self), props[PROP_SEARCH_ENABLED]);
}
/**
- * adw_preferences_window_get_visible_page:
+ * adw_preferences_window_set_can_navigate_back: (attributes org.gtk.Method.set_property=can-navigate-back)
* @self: a preferences window
+ * @can_navigate_back: the new value
*
- * Gets the currently visible page of @self.
+ * Sets whether gestures and shortcuts for closing subpages are enabled.
*
- * Returns: (transfer none) (nullable): the visible page
+ * The supported gestures are:
+ *
+ * - One-finger swipe on touchscreens
+ * - Horizontal scrolling on touchpads (usually two-finger swipe)
+ * - Back mouse button
+ *
+ * The keyboard back key is also supported, as well as the
+ * <kbd>Alt</kbd>+<kbd>←</kbd> shortcut.
+ *
+ * For right-to-left locales, gestures and shortcuts are reversed.
*
* Since: 1.0
*/
-AdwPreferencesPage *
-adw_preferences_window_get_visible_page (AdwPreferencesWindow *self)
+void
+adw_preferences_window_set_can_navigate_back (AdwPreferencesWindow *self,
+ gboolean can_navigate_back)
{
AdwPreferencesWindowPrivate *priv;
- g_return_val_if_fail (ADW_IS_PREFERENCES_WINDOW (self), NULL);
+ g_return_if_fail (ADW_IS_PREFERENCES_WINDOW (self));
priv = adw_preferences_window_get_instance_private (self);
- return ADW_PREFERENCES_PAGE (adw_view_stack_get_visible_child (priv->pages_stack));
+ can_navigate_back = !!can_navigate_back;
+
+ if (priv->can_navigate_back == can_navigate_back)
+ return;
+
+ priv->can_navigate_back = can_navigate_back;
+
+ g_object_notify_by_pspec (G_OBJECT (self), props[PROP_CAN_NAVIGATE_BACK]);
}
/**
- * adw_preferences_window_set_visible_page:
+ * adw_preferences_window_get_can_navigate_back: (attributes org.gtk.Method.get_property=can-navigate-back)
* @self: a preferences window
- * @page: a page of @self
*
- * Makes @page the visible page of @self.
+ * Gets whether gestures and shortcuts for closing subpages are enabled.
+ *
+ * Returns: whether gestures and shortcuts are enabled.
*
* Since: 1.0
*/
-void
-adw_preferences_window_set_visible_page (AdwPreferencesWindow *self,
- AdwPreferencesPage *page)
+gboolean
+adw_preferences_window_get_can_navigate_back (AdwPreferencesWindow *self)
{
AdwPreferencesWindowPrivate *priv;
- g_return_if_fail (ADW_IS_PREFERENCES_WINDOW (self));
- g_return_if_fail (ADW_IS_PREFERENCES_PAGE (page));
+ g_return_val_if_fail (ADW_IS_PREFERENCES_WINDOW (self), FALSE);
priv = adw_preferences_window_get_instance_private (self);
- adw_view_stack_set_visible_child (priv->pages_stack, GTK_WIDGET (page));
+ return priv->can_navigate_back;
}
/**
- * adw_preferences_window_get_visible_page_name:
+ * adw_preferences_window_present_subpage:
* @self: a preferences window
+ * @subpage: the subpage
*
- * Gets the name of currently visible page of @self.
+ * Sets @subpage as the window's subpage and opens it.
*
- * Returns: (transfer none) (nullable): the name of the visible page
+ * The transition can be cancelled by the user, in which case visible child will
+ * change back to the previously visible child.
*
* Since: 1.0
*/
-const char *
-adw_preferences_window_get_visible_page_name (AdwPreferencesWindow *self)
+void
+adw_preferences_window_present_subpage (AdwPreferencesWindow *self,
+ GtkWidget *subpage)
{
AdwPreferencesWindowPrivate *priv;
- g_return_val_if_fail (ADW_IS_PREFERENCES_WINDOW (self), NULL);
+ g_return_if_fail (ADW_IS_PREFERENCES_WINDOW (self));
+ g_return_if_fail (GTK_IS_WIDGET (subpage));
priv = adw_preferences_window_get_instance_private (self);
- return adw_view_stack_get_visible_child_name (priv->pages_stack);
+ if (priv->subpage == subpage)
+ return;
+
+ priv->subpage = subpage;
+
+ /* The check below avoids a warning when re-entering a subpage during the
+ * transition between the that subpage to the preferences.
+ */
+ if (gtk_widget_get_parent (subpage) != GTK_WIDGET (priv->subpages_leaflet))
+ adw_leaflet_append (priv->subpages_leaflet, subpage);
+
+ adw_leaflet_set_visible_child (priv->subpages_leaflet, subpage);
}
/**
- * adw_preferences_window_set_visible_page_name:
+ * adw_preferences_window_close_subpage:
* @self: a preferences window
- * @name: the name of the page to make visible
*
- * Makes the page with the given name visible.
+ * Closes the current subpage.
*
- * See [property@ViewStack:visible-child].
+ * If there is no presented subpage, this does nothing.
*
* Since: 1.0
*/
void
-adw_preferences_window_set_visible_page_name (AdwPreferencesWindow *self,
- const char *name)
+adw_preferences_window_close_subpage (AdwPreferencesWindow *self)
{
AdwPreferencesWindowPrivate *priv;
@@ -1040,7 +1037,10 @@ adw_preferences_window_set_visible_page_name (AdwPreferencesWindow *self,
priv = adw_preferences_window_get_instance_private (self);
- adw_view_stack_set_visible_child_name (priv->pages_stack, name);
+ if (priv->subpage == NULL)
+ return;
+
+ adw_leaflet_set_visible_child (priv->subpages_leaflet, priv->preferences);
}
/**
diff --git a/src/adw-preferences-window.h b/src/adw-preferences-window.h
index 4add1c23..8bce6423 100644
--- a/src/adw-preferences-window.h
+++ b/src/adw-preferences-window.h
@@ -39,24 +39,6 @@ struct _AdwPreferencesWindowClass
ADW_AVAILABLE_IN_ALL
GtkWidget *adw_preferences_window_new (void) G_GNUC_WARN_UNUSED_RESULT;
-ADW_AVAILABLE_IN_ALL
-gboolean adw_preferences_window_get_search_enabled (AdwPreferencesWindow *self);
-ADW_AVAILABLE_IN_ALL
-void adw_preferences_window_set_search_enabled (AdwPreferencesWindow *self,
- gboolean search_enabled);
-
-ADW_AVAILABLE_IN_ALL
-gboolean adw_preferences_window_get_can_navigate_back (AdwPreferencesWindow *self);
-ADW_AVAILABLE_IN_ALL
-void adw_preferences_window_set_can_navigate_back (AdwPreferencesWindow *self,
- gboolean can_navigate_back);
-
-ADW_AVAILABLE_IN_ALL
-void adw_preferences_window_present_subpage (AdwPreferencesWindow *self,
- GtkWidget *subpage);
-ADW_AVAILABLE_IN_ALL
-void adw_preferences_window_close_subpage (AdwPreferencesWindow *self);
-
ADW_AVAILABLE_IN_ALL
void adw_preferences_window_add (AdwPreferencesWindow *self,
AdwPreferencesPage *page);
@@ -76,6 +58,24 @@ ADW_AVAILABLE_IN_ALL
void adw_preferences_window_set_visible_page_name (AdwPreferencesWindow *self,
const char *name);
+ADW_AVAILABLE_IN_ALL
+gboolean adw_preferences_window_get_search_enabled (AdwPreferencesWindow *self);
+ADW_AVAILABLE_IN_ALL
+void adw_preferences_window_set_search_enabled (AdwPreferencesWindow *self,
+ gboolean search_enabled);
+
+ADW_AVAILABLE_IN_ALL
+gboolean adw_preferences_window_get_can_navigate_back (AdwPreferencesWindow *self);
+ADW_AVAILABLE_IN_ALL
+void adw_preferences_window_set_can_navigate_back (AdwPreferencesWindow *self,
+ gboolean can_navigate_back);
+
+ADW_AVAILABLE_IN_ALL
+void adw_preferences_window_present_subpage (AdwPreferencesWindow *self,
+ GtkWidget *subpage);
+ADW_AVAILABLE_IN_ALL
+void adw_preferences_window_close_subpage (AdwPreferencesWindow *self);
+
ADW_AVAILABLE_IN_ALL
void adw_preferences_window_add_toast (AdwPreferencesWindow *self,
AdwToast *toast);
diff --git a/src/adw-squeezer.c b/src/adw-squeezer.c
index b64729e9..6bd803bd 100644
--- a/src/adw-squeezer.c
+++ b/src/adw-squeezer.c
@@ -123,9 +123,9 @@ struct _AdwSqueezer
enum {
PROP_0,
+ PROP_VISIBLE_CHILD,
PROP_HOMOGENEOUS,
PROP_SWITCH_THRESHOLD_POLICY,
- PROP_VISIBLE_CHILD,
PROP_ALLOW_NONE,
PROP_TRANSITION_DURATION,
PROP_TRANSITION_TYPE,
@@ -650,15 +650,15 @@ adw_squeezer_get_property (GObject *object,
AdwSqueezer *self = ADW_SQUEEZER (object);
switch (property_id) {
+ case PROP_VISIBLE_CHILD:
+ g_value_set_object (value, adw_squeezer_get_visible_child (self));
+ break;
case PROP_HOMOGENEOUS:
g_value_set_boolean (value, adw_squeezer_get_homogeneous (self));
break;
case PROP_SWITCH_THRESHOLD_POLICY:
g_value_set_enum (value, adw_squeezer_get_switch_threshold_policy (self));
break;
- case PROP_VISIBLE_CHILD:
- g_value_set_object (value, adw_squeezer_get_visible_child (self));
- break;
case PROP_ALLOW_NONE:
g_value_set_boolean (value, adw_squeezer_get_allow_none (self));
break;
@@ -1038,6 +1038,18 @@ adw_squeezer_class_init (AdwSqueezerClass *klass)
PROP_ORIENTATION,
"orientation");
+ /**
+ * AdwSqueezer:visible-child: (attributes org.gtk.Property.get=adw_squeezer_get_visible_child)
+ *
+ * The currently visible child.
+ *
+ * Since: 1.0
+ */
+ props[PROP_VISIBLE_CHILD] =
+ g_param_spec_object ("visible-child", NULL, NULL,
+ GTK_TYPE_WIDGET,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+
/**
* AdwSqueezer:homogeneous: (attributes org.gtk.Property.get=adw_squeezer_get_homogeneous
org.gtk.Property.set=adw_squeezer_set_homogeneous)
*
@@ -1076,18 +1088,6 @@ adw_squeezer_class_init (AdwSqueezerClass *klass)
ADW_FOLD_THRESHOLD_POLICY_NATURAL,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
- /**
- * AdwSqueezer:visible-child: (attributes org.gtk.Property.get=adw_squeezer_get_visible_child)
- *
- * The currently visible child.
- *
- * Since: 1.0
- */
- props[PROP_VISIBLE_CHILD] =
- g_param_spec_object ("visible-child", NULL, NULL,
- GTK_TYPE_WIDGET,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
-
/**
* AdwSqueezer:allow-none: (attributes org.gtk.Property.get=adw_squeezer_get_allow_none
org.gtk.Property.set=adw_squeezer_set_allow_none)
*
@@ -1440,6 +1440,24 @@ adw_squeezer_get_page (AdwSqueezer *self,
return find_page_for_widget (self, child);
}
+/**
+ * adw_squeezer_get_visible_child: (attributes org.gtk.Method.get_property=visible-child)
+ * @self: a squeezer
+ *
+ * Gets the currently visible child of @self.
+ *
+ * Returns: (transfer none) (nullable): the visible child
+ *
+ * Since: 1.0
+ */
+GtkWidget *
+adw_squeezer_get_visible_child (AdwSqueezer *self)
+{
+ g_return_val_if_fail (ADW_IS_SQUEEZER (self), NULL);
+
+ return self->visible_child ? self->visible_child->widget : NULL;
+}
+
/**
* adw_squeezer_get_homogeneous: (attributes org.gtk.Method.get_property=homogeneous)
* @self: a squeezer
@@ -1741,24 +1759,6 @@ adw_squeezer_set_interpolate_size (AdwSqueezer *self,
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_INTERPOLATE_SIZE]);
}
-/**
- * adw_squeezer_get_visible_child: (attributes org.gtk.Method.get_property=visible-child)
- * @self: a squeezer
- *
- * Gets the currently visible child of @self.
- *
- * Returns: (transfer none) (nullable): the visible child
- *
- * Since: 1.0
- */
-GtkWidget *
-adw_squeezer_get_visible_child (AdwSqueezer *self)
-{
- g_return_val_if_fail (ADW_IS_SQUEEZER (self), NULL);
-
- return self->visible_child ? self->visible_child->widget : NULL;
-}
-
/**
* adw_squeezer_get_xalign: (attributes org.gtk.Method.get_property=xalign)
* @self: a squeezer
diff --git a/src/adw-squeezer.h b/src/adw-squeezer.h
index 6e5b47a2..64a08c23 100644
--- a/src/adw-squeezer.h
+++ b/src/adw-squeezer.h
@@ -56,6 +56,9 @@ ADW_AVAILABLE_IN_ALL
AdwSqueezerPage *adw_squeezer_get_page (AdwSqueezer *self,
GtkWidget *child);
+ADW_AVAILABLE_IN_ALL
+GtkWidget *adw_squeezer_get_visible_child (AdwSqueezer *self);
+
ADW_AVAILABLE_IN_ALL
gboolean adw_squeezer_get_homogeneous (AdwSqueezer *self);
ADW_AVAILABLE_IN_ALL
@@ -95,9 +98,6 @@ ADW_AVAILABLE_IN_ALL
void adw_squeezer_set_interpolate_size (AdwSqueezer *self,
gboolean interpolate_size);
-ADW_AVAILABLE_IN_ALL
-GtkWidget *adw_squeezer_get_visible_child (AdwSqueezer *self);
-
ADW_AVAILABLE_IN_ALL
float adw_squeezer_get_xalign (AdwSqueezer *self);
ADW_AVAILABLE_IN_ALL
diff --git a/src/adw-toast.c b/src/adw-toast.c
index d4fb52f0..7efcfd5b 100644
--- a/src/adw-toast.c
+++ b/src/adw-toast.c
@@ -900,25 +900,21 @@ adw_toast_set_timeout (AdwToast *self,
}
/**
- * adw_toast_dismiss:
+ * adw_toast_get_custom_title: (attributes org.gtk.Method.get_property=custom-title)
* @self: a toast
*
- * Dismisses @self.
+ * Gets the custom title widget of @self.
*
- * Does nothing if @self has already been dismissed, or hasn't been added to an
- * [class@ToastOverlay].
+ * Returns: (nullable) (transfer none): the custom title widget
*
- * Since: 1.0
+ * Since: 1.2
*/
-void
-adw_toast_dismiss (AdwToast *self)
+GtkWidget *
+adw_toast_get_custom_title (AdwToast *self)
{
- g_return_if_fail (ADW_IS_TOAST (self));
-
- if (!self->overlay)
- return;
+ g_return_val_if_fail (ADW_IS_TOAST (self), NULL);
- g_signal_emit (self, signals[SIGNAL_DISMISSED], 0, NULL);
+ return self->custom_title;
}
/**
@@ -957,21 +953,25 @@ adw_toast_set_custom_title (AdwToast *self,
}
/**
- * adw_toast_get_custom_title: (attributes org.gtk.Method.get_property=custom-title)
+ * adw_toast_dismiss:
* @self: a toast
*
- * Gets the custom title widget of @self.
+ * Dismisses @self.
*
- * Returns: (nullable) (transfer none): the custom title widget
+ * Does nothing if @self has already been dismissed, or hasn't been added to an
+ * [class@ToastOverlay].
*
- * Since: 1.2
+ * Since: 1.0
*/
-GtkWidget *
-adw_toast_get_custom_title (AdwToast *self)
+void
+adw_toast_dismiss (AdwToast *self)
{
- g_return_val_if_fail (ADW_IS_TOAST (self), NULL);
+ g_return_if_fail (ADW_IS_TOAST (self));
- return self->custom_title;
+ if (!self->overlay)
+ return;
+
+ g_signal_emit (self, signals[SIGNAL_DISMISSED], 0, NULL);
}
AdwToastOverlay *
diff --git a/src/adw-view-stack.c b/src/adw-view-stack.c
index fe0b8cb8..4ca55eb9 100644
--- a/src/adw-view-stack.c
+++ b/src/adw-view-stack.c
@@ -117,11 +117,11 @@ enum {
PAGE_PROP_CHILD,
PAGE_PROP_NAME,
PAGE_PROP_TITLE,
+ PAGE_PROP_USE_UNDERLINE,
PAGE_PROP_ICON_NAME,
PAGE_PROP_NEEDS_ATTENTION,
PAGE_PROP_BADGE_NUMBER,
PAGE_PROP_VISIBLE,
- PAGE_PROP_USE_UNDERLINE,
LAST_PAGE_PROP
};
@@ -166,6 +166,9 @@ adw_view_stack_page_get_property (GObject *object,
case PAGE_PROP_TITLE:
g_value_set_string (value, adw_view_stack_page_get_title (self));
break;
+ case PAGE_PROP_USE_UNDERLINE:
+ g_value_set_boolean (value, adw_view_stack_page_get_use_underline (self));
+ break;
case PAGE_PROP_ICON_NAME:
g_value_set_string (value, adw_view_stack_page_get_icon_name (self));
break;
@@ -178,9 +181,6 @@ adw_view_stack_page_get_property (GObject *object,
case PAGE_PROP_VISIBLE:
g_value_set_boolean (value, adw_view_stack_page_get_visible (self));
break;
- case PAGE_PROP_USE_UNDERLINE:
- g_value_set_boolean (value, adw_view_stack_page_get_use_underline (self));
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@@ -205,6 +205,9 @@ adw_view_stack_page_set_property (GObject *object,
case PAGE_PROP_TITLE:
adw_view_stack_page_set_title (self, g_value_get_string (value));
break;
+ case PAGE_PROP_USE_UNDERLINE:
+ adw_view_stack_page_set_use_underline (self, g_value_get_boolean (value));
+ break;
case PAGE_PROP_ICON_NAME:
adw_view_stack_page_set_icon_name (self, g_value_get_string (value));
break;
@@ -217,9 +220,6 @@ adw_view_stack_page_set_property (GObject *object,
case PAGE_PROP_VISIBLE:
adw_view_stack_page_set_visible (self, g_value_get_boolean (value));
break;
- case PAGE_PROP_USE_UNDERLINE:
- adw_view_stack_page_set_use_underline (self, g_value_get_boolean (value));
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@@ -288,6 +288,18 @@ adw_view_stack_page_class_init (AdwViewStackPageClass *class)
NULL,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
+ /**
+ * AdwViewStackPage:use-underline: (attributes org.gtk.Property.get=adw_view_stack_page_get_use_underline
org.gtk.Property.set=adw_view_stack_page_set_use_underline)
+ *
+ * Whether an embedded underline in the title indicates a mnemonic.
+ *
+ * Since: 1.0
+ */
+ page_props[PAGE_PROP_USE_UNDERLINE] =
+ g_param_spec_boolean ("use-underline", NULL, NULL,
+ FALSE,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
+
/**
* AdwViewStackPage:icon-name: (attributes org.gtk.Property.get=adw_view_stack_page_get_icon_name
org.gtk.Property.set=adw_view_stack_page_set_icon_name)
*
@@ -346,18 +358,6 @@ adw_view_stack_page_class_init (AdwViewStackPageClass *class)
TRUE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
- /**
- * AdwViewStackPage:use-underline: (attributes org.gtk.Property.get=adw_view_stack_page_get_use_underline
org.gtk.Property.set=adw_view_stack_page_set_use_underline)
- *
- * Whether an embedded underline in the title indicates a mnemonic.
- *
- * Since: 1.0
- */
- page_props[PAGE_PROP_USE_UNDERLINE] =
- g_param_spec_boolean ("use-underline", NULL, NULL,
- FALSE,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
-
g_object_class_install_properties (object_class, LAST_PAGE_PROP, page_props);
}
@@ -1027,337 +1027,337 @@ adw_view_stack_page_get_child (AdwViewStackPage *self)
}
/**
- * adw_view_stack_page_get_visible: (attributes org.gtk.Method.get_property=visible)
+ * adw_view_stack_page_get_name: (attributes org.gtk.Method.get_property=name)
* @self: a view stack page
*
- * Gets whether @self is visible in its `AdwViewStack`.
- *
- * This is independent from the [property@Gtk.Widget:visible]
- * property of its widget.
+ * Gets the name of the page.
*
- * Returns: whether @self is visible
+ * Returns: (nullable): the name of the page
*
* Since: 1.0
*/
-gboolean
-adw_view_stack_page_get_visible (AdwViewStackPage *self)
+const char *
+adw_view_stack_page_get_name (AdwViewStackPage *self)
{
- g_return_val_if_fail (ADW_IS_VIEW_STACK_PAGE (self), FALSE);
+ g_return_val_if_fail (ADW_IS_VIEW_STACK_PAGE (self), NULL);
- return self->visible;
+ return self->name;
}
/**
- * adw_view_stack_page_set_visible: (attributes org.gtk.Method.set_property=visible)
+ * adw_view_stack_page_set_name: (attributes org.gtk.Method.set_property=name)
* @self: a view stack page
- * @visible: whether @self is visible
- *
- * Sets whether @page is visible in its `AdwViewStack`.
+ * @name: (nullable): the page name
*
- * This is independent from the [property@Gtk.Widget:visible] property of
- * [property@ViewStackPage:child].
+ * Sets the name of the page.
*
* Since: 1.0
*/
void
-adw_view_stack_page_set_visible (AdwViewStackPage *self,
- gboolean visible)
+adw_view_stack_page_set_name (AdwViewStackPage *self,
+ const char *name)
{
+ AdwViewStack *stack = NULL;
+
g_return_if_fail (ADW_IS_VIEW_STACK_PAGE (self));
- visible = !!visible;
+ if (self->widget &&
+ gtk_widget_get_parent (self->widget) &&
+ ADW_IS_VIEW_STACK (gtk_widget_get_parent (self->widget)) &&
+ name) {
+ GList *l;
- if (visible == self->visible)
+ stack = ADW_VIEW_STACK (gtk_widget_get_parent (self->widget));
+
+ for (l = stack->children; l; l = l->next) {
+ AdwViewStackPage *p = l->data;
+ if (self == p)
+ continue;
+
+ if (g_strcmp0 (p->name, name) == 0) {
+ g_warning ("Duplicate child name in AdwViewStack: %s", name);
+ break;
+ }
+ }
+ }
+
+ if (name == self->name)
return;
- self->visible = visible;
+ g_free (self->name);
+ self->name = g_strdup (name);
- if (self->widget && gtk_widget_get_parent (self->widget))
- update_child_visible (ADW_VIEW_STACK (gtk_widget_get_parent (self->widget)), self);
+ g_object_notify_by_pspec (G_OBJECT (self), page_props[PAGE_PROP_NAME]);
- g_object_notify_by_pspec (G_OBJECT (self), page_props[PAGE_PROP_VISIBLE]);
+ if (stack && stack->visible_child == self)
+ g_object_notify_by_pspec (G_OBJECT (stack),
+ props[PROP_VISIBLE_CHILD_NAME]);
}
/**
- * adw_view_stack_page_get_needs_attention: (attributes org.gtk.Method.get_property=needs-attention)
+ * adw_view_stack_page_get_title: (attributes org.gtk.Method.get_property=title)
* @self: a view stack page
*
- * Gets whether the page requires the user attention.
+ * Gets the page title.
*
- * Returns: whether the page needs attention
+ * Returns: (nullable): the page title
*
* Since: 1.0
*/
-gboolean
-adw_view_stack_page_get_needs_attention (AdwViewStackPage *self)
+const char *
+adw_view_stack_page_get_title (AdwViewStackPage *self)
{
- g_return_val_if_fail (ADW_IS_VIEW_STACK_PAGE (self), FALSE);
+ g_return_val_if_fail (ADW_IS_VIEW_STACK_PAGE (self), NULL);
- return self->needs_attention;
+ return self->title;
}
/**
- * adw_view_stack_page_set_needs_attention: (attributes org.gtk.Method.set_property=needs-attention)
+ * adw_view_stack_page_set_title: (attributes org.gtk.Method.set_property=title)
* @self: a view stack page
- * @needs_attention: the new value to set
- *
- * Sets whether the page requires the user attention.
+ * @title: (nullable): the page title
*
- * [class@ViewSwitcher] will display it as a dot next to the page icon.
+ * Sets the page title.
*
* Since: 1.0
*/
void
-adw_view_stack_page_set_needs_attention (AdwViewStackPage *self,
- gboolean needs_attention)
+adw_view_stack_page_set_title (AdwViewStackPage *self,
+ const char *title)
{
g_return_if_fail (ADW_IS_VIEW_STACK_PAGE (self));
- needs_attention = !!needs_attention;
-
- if (needs_attention == self->needs_attention)
+ if (title == self->title)
return;
- self->needs_attention = needs_attention;
+ g_free (self->title);
+ self->title = g_strdup (title);
- g_object_notify_by_pspec (G_OBJECT (self), page_props[PAGE_PROP_NEEDS_ATTENTION]);
+ g_object_notify_by_pspec (G_OBJECT (self), page_props[PAGE_PROP_TITLE]);
}
/**
- * adw_view_stack_page_get_badge_number: (attributes org.gtk.Method.get_property=badge-number)
+ * adw_view_stack_page_get_use_underline: (attributes org.gtk.Method.get_property=use-underline)
* @self: a view stack page
*
- * Gets the badge number for this page.
+ * Gets whether underlines in the page title indicate mnemonics.
*
- * Returns: the badge number for this page
+ * Returns: whether underlines in the page title indicate mnemonics
*
* Since: 1.0
*/
-guint
-adw_view_stack_page_get_badge_number (AdwViewStackPage *self)
+gboolean
+adw_view_stack_page_get_use_underline (AdwViewStackPage *self)
{
- g_return_val_if_fail (ADW_IS_VIEW_STACK_PAGE (self), 0);
-
- return self->badge_number;
+ return self->use_underline;
}
/**
- * adw_view_stack_page_set_badge_number: (attributes org.gtk.Method.set_property=badge-number)
+ * adw_view_stack_page_set_use_underline: (attributes org.gtk.Method.set_property=use-underline)
* @self: a view stack page
- * @badge_number: the new value to set
- *
- * Sets the badge number for this page.
- *
- * [class@ViewSwitcher] can display it as a badge next to the page icon. It is
- * commonly used to display a number of unread items within the page.
+ * @use_underline: the new value to set
*
- * It can be used together with [property@ViewStack{age}:needs-attention].
+ * Sets whether underlines in the page title indicate mnemonics.
*
* Since: 1.0
*/
void
-adw_view_stack_page_set_badge_number (AdwViewStackPage *self,
- guint badge_number)
+adw_view_stack_page_set_use_underline (AdwViewStackPage *self,
+ gboolean use_underline)
{
- g_return_if_fail (ADW_IS_VIEW_STACK_PAGE (self));
+ use_underline = !!use_underline;
- if (badge_number == self->badge_number)
+ if (use_underline == self->use_underline)
return;
- self->badge_number = badge_number;
+ self->use_underline = use_underline;
- g_object_notify_by_pspec (G_OBJECT (self), page_props[PAGE_PROP_BADGE_NUMBER]);
+ g_object_notify_by_pspec (G_OBJECT (self), page_props[PAGE_PROP_USE_UNDERLINE]);
}
/**
- * adw_view_stack_page_get_use_underline: (attributes org.gtk.Method.get_property=use-underline)
+ * adw_view_stack_page_get_icon_name: (attributes org.gtk.Method.get_property=icon-name)
* @self: a view stack page
*
- * Gets whether underlines in the page title indicate mnemonics.
+ * Gets the icon name of the page.
*
- * Returns: whether underlines in the page title indicate mnemonics
+ * Returns: (nullable): the icon name of the page
*
* Since: 1.0
*/
-gboolean
-adw_view_stack_page_get_use_underline (AdwViewStackPage *self)
+const char *
+adw_view_stack_page_get_icon_name (AdwViewStackPage *self)
{
- return self->use_underline;
+ g_return_val_if_fail (ADW_IS_VIEW_STACK_PAGE (self), NULL);
+
+ return self->icon_name;
}
/**
- * adw_view_stack_page_set_use_underline: (attributes org.gtk.Method.set_property=use-underline)
+ * adw_view_stack_page_set_icon_name: (attributes org.gtk.Method.set_property=icon-name)
* @self: a view stack page
- * @use_underline: the new value to set
+ * @icon_name: (nullable): the icon name
*
- * Sets whether underlines in the page title indicate mnemonics.
+ * Sets the icon name of the page.
*
* Since: 1.0
*/
void
-adw_view_stack_page_set_use_underline (AdwViewStackPage *self,
- gboolean use_underline)
+adw_view_stack_page_set_icon_name (AdwViewStackPage *self,
+ const char *icon_name)
{
- use_underline = !!use_underline;
+ g_return_if_fail (ADW_IS_VIEW_STACK_PAGE (self));
- if (use_underline == self->use_underline)
+ if (icon_name == self->icon_name)
return;
- self->use_underline = use_underline;
+ g_free (self->icon_name);
+ self->icon_name = g_strdup (icon_name);
- g_object_notify_by_pspec (G_OBJECT (self), page_props[PAGE_PROP_USE_UNDERLINE]);
+ g_object_notify_by_pspec (G_OBJECT (self), page_props[PAGE_PROP_ICON_NAME]);
}
/**
- * adw_view_stack_page_get_name: (attributes org.gtk.Method.get_property=name)
+ * adw_view_stack_page_get_needs_attention: (attributes org.gtk.Method.get_property=needs-attention)
* @self: a view stack page
*
- * Gets the name of the page.
+ * Gets whether the page requires the user attention.
*
- * Returns: (nullable): the name of the page
+ * Returns: whether the page needs attention
*
* Since: 1.0
*/
-const char *
-adw_view_stack_page_get_name (AdwViewStackPage *self)
+gboolean
+adw_view_stack_page_get_needs_attention (AdwViewStackPage *self)
{
- g_return_val_if_fail (ADW_IS_VIEW_STACK_PAGE (self), NULL);
+ g_return_val_if_fail (ADW_IS_VIEW_STACK_PAGE (self), FALSE);
- return self->name;
+ return self->needs_attention;
}
/**
- * adw_view_stack_page_set_name: (attributes org.gtk.Method.set_property=name)
+ * adw_view_stack_page_set_needs_attention: (attributes org.gtk.Method.set_property=needs-attention)
* @self: a view stack page
- * @name: (nullable): the page name
+ * @needs_attention: the new value to set
*
- * Sets the name of the page.
+ * Sets whether the page requires the user attention.
+ *
+ * [class@ViewSwitcher] will display it as a dot next to the page icon.
*
* Since: 1.0
*/
void
-adw_view_stack_page_set_name (AdwViewStackPage *self,
- const char *name)
+adw_view_stack_page_set_needs_attention (AdwViewStackPage *self,
+ gboolean needs_attention)
{
- AdwViewStack *stack = NULL;
-
g_return_if_fail (ADW_IS_VIEW_STACK_PAGE (self));
- if (self->widget &&
- gtk_widget_get_parent (self->widget) &&
- ADW_IS_VIEW_STACK (gtk_widget_get_parent (self->widget)) &&
- name) {
- GList *l;
-
- stack = ADW_VIEW_STACK (gtk_widget_get_parent (self->widget));
-
- for (l = stack->children; l; l = l->next) {
- AdwViewStackPage *p = l->data;
- if (self == p)
- continue;
-
- if (g_strcmp0 (p->name, name) == 0) {
- g_warning ("Duplicate child name in AdwViewStack: %s", name);
- break;
- }
- }
- }
+ needs_attention = !!needs_attention;
- if (name == self->name)
+ if (needs_attention == self->needs_attention)
return;
- g_free (self->name);
- self->name = g_strdup (name);
-
- g_object_notify_by_pspec (G_OBJECT (self), page_props[PAGE_PROP_NAME]);
+ self->needs_attention = needs_attention;
- if (stack && stack->visible_child == self)
- g_object_notify_by_pspec (G_OBJECT (stack),
- props[PROP_VISIBLE_CHILD_NAME]);
+ g_object_notify_by_pspec (G_OBJECT (self), page_props[PAGE_PROP_NEEDS_ATTENTION]);
}
/**
- * adw_view_stack_page_get_title: (attributes org.gtk.Method.get_property=title)
+ * adw_view_stack_page_get_badge_number: (attributes org.gtk.Method.get_property=badge-number)
* @self: a view stack page
*
- * Gets the page title.
+ * Gets the badge number for this page.
*
- * Returns: (nullable): the page title
+ * Returns: the badge number for this page
*
* Since: 1.0
*/
-const char *
-adw_view_stack_page_get_title (AdwViewStackPage *self)
+guint
+adw_view_stack_page_get_badge_number (AdwViewStackPage *self)
{
- g_return_val_if_fail (ADW_IS_VIEW_STACK_PAGE (self), NULL);
+ g_return_val_if_fail (ADW_IS_VIEW_STACK_PAGE (self), 0);
- return self->title;
+ return self->badge_number;
}
/**
- * adw_view_stack_page_set_title: (attributes org.gtk.Method.set_property=title)
+ * adw_view_stack_page_set_badge_number: (attributes org.gtk.Method.set_property=badge-number)
* @self: a view stack page
- * @title: (nullable): the page title
+ * @badge_number: the new value to set
*
- * Sets the page title.
+ * Sets the badge number for this page.
+ *
+ * [class@ViewSwitcher] can display it as a badge next to the page icon. It is
+ * commonly used to display a number of unread items within the page.
+ *
+ * It can be used together with [property@ViewStack{age}:needs-attention].
*
* Since: 1.0
*/
void
-adw_view_stack_page_set_title (AdwViewStackPage *self,
- const char *title)
+adw_view_stack_page_set_badge_number (AdwViewStackPage *self,
+ guint badge_number)
{
g_return_if_fail (ADW_IS_VIEW_STACK_PAGE (self));
- if (title == self->title)
+ if (badge_number == self->badge_number)
return;
- g_free (self->title);
- self->title = g_strdup (title);
+ self->badge_number = badge_number;
- g_object_notify_by_pspec (G_OBJECT (self), page_props[PAGE_PROP_TITLE]);
+ g_object_notify_by_pspec (G_OBJECT (self), page_props[PAGE_PROP_BADGE_NUMBER]);
}
/**
- * adw_view_stack_page_get_icon_name: (attributes org.gtk.Method.get_property=icon-name)
+ * adw_view_stack_page_get_visible: (attributes org.gtk.Method.get_property=visible)
* @self: a view stack page
*
- * Gets the icon name of the page.
+ * Gets whether @self is visible in its `AdwViewStack`.
*
- * Returns: (nullable): the icon name of the page
+ * This is independent from the [property@Gtk.Widget:visible]
+ * property of its widget.
+ *
+ * Returns: whether @self is visible
*
* Since: 1.0
*/
-const char *
-adw_view_stack_page_get_icon_name (AdwViewStackPage *self)
+gboolean
+adw_view_stack_page_get_visible (AdwViewStackPage *self)
{
- g_return_val_if_fail (ADW_IS_VIEW_STACK_PAGE (self), NULL);
+ g_return_val_if_fail (ADW_IS_VIEW_STACK_PAGE (self), FALSE);
- return self->icon_name;
+ return self->visible;
}
/**
- * adw_view_stack_page_set_icon_name: (attributes org.gtk.Method.set_property=icon-name)
+ * adw_view_stack_page_set_visible: (attributes org.gtk.Method.set_property=visible)
* @self: a view stack page
- * @icon_name: (nullable): the icon name
+ * @visible: whether @self is visible
*
- * Sets the icon name of the page.
+ * Sets whether @page is visible in its `AdwViewStack`.
+ *
+ * This is independent from the [property@Gtk.Widget:visible] property of
+ * [property@ViewStackPage:child].
*
* Since: 1.0
*/
void
-adw_view_stack_page_set_icon_name (AdwViewStackPage *self,
- const char *icon_name)
+adw_view_stack_page_set_visible (AdwViewStackPage *self,
+ gboolean visible)
{
g_return_if_fail (ADW_IS_VIEW_STACK_PAGE (self));
- if (icon_name == self->icon_name)
+ visible = !!visible;
+
+ if (visible == self->visible)
return;
- g_free (self->icon_name);
- self->icon_name = g_strdup (icon_name);
+ self->visible = visible;
- g_object_notify_by_pspec (G_OBJECT (self), page_props[PAGE_PROP_ICON_NAME]);
+ if (self->widget && gtk_widget_get_parent (self->widget))
+ update_child_visible (ADW_VIEW_STACK (gtk_widget_get_parent (self->widget)), self);
+
+ g_object_notify_by_pspec (G_OBJECT (self), page_props[PAGE_PROP_VISIBLE]);
}
/**
@@ -1658,6 +1658,24 @@ adw_view_stack_set_visible_child_name (AdwViewStack *self,
set_visible_child (self, page);
}
+/**
+ * adw_view_stack_get_hhomogeneous: (attributes org.gtk.Method.get_property=hhomogeneous)
+ * @self: a view stack
+ *
+ * Gets whether @self is horizontally homogeneous.
+ *
+ * Returns: whether @self is horizontally homogeneous
+ *
+ * Since: 1.0
+ */
+gboolean
+adw_view_stack_get_hhomogeneous (AdwViewStack *self)
+{
+ g_return_val_if_fail (ADW_IS_VIEW_STACK (self), FALSE);
+
+ return self->homogeneous[GTK_ORIENTATION_HORIZONTAL];
+}
+
/**
* adw_view_stack_set_hhomogeneous: (attributes org.gtk.Method.set_property=hhomogeneous)
* @self: a view stack
@@ -1693,21 +1711,21 @@ adw_view_stack_set_hhomogeneous (AdwViewStack *self,
}
/**
- * adw_view_stack_get_hhomogeneous: (attributes org.gtk.Method.get_property=hhomogeneous)
+ * adw_view_stack_get_vhomogeneous: (attributes org.gtk.Method.get_property=vhomogeneous)
* @self: a view stack
*
- * Gets whether @self is horizontally homogeneous.
+ * Gets whether @self is vertically homogeneous.
*
- * Returns: whether @self is horizontally homogeneous
+ * Returns: whether @self is vertically homogeneous
*
* Since: 1.0
*/
gboolean
-adw_view_stack_get_hhomogeneous (AdwViewStack *self)
+adw_view_stack_get_vhomogeneous (AdwViewStack *self)
{
g_return_val_if_fail (ADW_IS_VIEW_STACK (self), FALSE);
- return self->homogeneous[GTK_ORIENTATION_HORIZONTAL];
+ return self->homogeneous[GTK_ORIENTATION_VERTICAL];
}
/**
@@ -1744,24 +1762,6 @@ adw_view_stack_set_vhomogeneous (AdwViewStack *self,
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_VHOMOGENEOUS]);
}
-/**
- * adw_view_stack_get_vhomogeneous: (attributes org.gtk.Method.get_property=vhomogeneous)
- * @self: a view stack
- *
- * Gets whether @self is vertically homogeneous.
- *
- * Returns: whether @self is vertically homogeneous
- *
- * Since: 1.0
- */
-gboolean
-adw_view_stack_get_vhomogeneous (AdwViewStack *self)
-{
- g_return_val_if_fail (ADW_IS_VIEW_STACK (self), FALSE);
-
- return self->homogeneous[GTK_ORIENTATION_VERTICAL];
-}
-
/**
* adw_view_stack_get_pages: (attributes org.gtk.Method.get_property=pages)
* @self: a view stack
diff --git a/src/adw-view-stack.h b/src/adw-view-stack.h
index ae55ee23..5f3364fc 100644
--- a/src/adw-view-stack.h
+++ b/src/adw-view-stack.h
@@ -31,22 +31,16 @@ ADW_AVAILABLE_IN_ALL
GtkWidget *adw_view_stack_page_get_child (AdwViewStackPage *self);
ADW_AVAILABLE_IN_ALL
-gboolean adw_view_stack_page_get_visible (AdwViewStackPage *self);
-ADW_AVAILABLE_IN_ALL
-void adw_view_stack_page_set_visible (AdwViewStackPage *self,
- gboolean visible);
-
-ADW_AVAILABLE_IN_ALL
-gboolean adw_view_stack_page_get_needs_attention (AdwViewStackPage *self);
+const char *adw_view_stack_page_get_name (AdwViewStackPage *self);
ADW_AVAILABLE_IN_ALL
-void adw_view_stack_page_set_needs_attention (AdwViewStackPage *self,
- gboolean needs_attention);
+void adw_view_stack_page_set_name (AdwViewStackPage *self,
+ const char *name);
ADW_AVAILABLE_IN_ALL
-guint adw_view_stack_page_get_badge_number (AdwViewStackPage *self);
+const char *adw_view_stack_page_get_title (AdwViewStackPage *self);
ADW_AVAILABLE_IN_ALL
-void adw_view_stack_page_set_badge_number (AdwViewStackPage *self,
- guint badge_number);
+void adw_view_stack_page_set_title (AdwViewStackPage *self,
+ const char *title);
ADW_AVAILABLE_IN_ALL
gboolean adw_view_stack_page_get_use_underline (AdwViewStackPage *self);
@@ -55,21 +49,28 @@ void adw_view_stack_page_set_use_underline (AdwViewStackPage *self,
gboolean use_underline);
ADW_AVAILABLE_IN_ALL
-const char *adw_view_stack_page_get_name (AdwViewStackPage *self);
+const char *adw_view_stack_page_get_icon_name (AdwViewStackPage *self);
ADW_AVAILABLE_IN_ALL
-void adw_view_stack_page_set_name (AdwViewStackPage *self,
- const char *name);
+void adw_view_stack_page_set_icon_name (AdwViewStackPage *self,
+ const char *icon_name);
ADW_AVAILABLE_IN_ALL
-const char *adw_view_stack_page_get_title (AdwViewStackPage *self);
+gboolean adw_view_stack_page_get_needs_attention (AdwViewStackPage *self);
ADW_AVAILABLE_IN_ALL
-void adw_view_stack_page_set_title (AdwViewStackPage *self,
- const char *title);
+void adw_view_stack_page_set_needs_attention (AdwViewStackPage *self,
+ gboolean needs_attention);
+
ADW_AVAILABLE_IN_ALL
-const char *adw_view_stack_page_get_icon_name (AdwViewStackPage *self);
+guint adw_view_stack_page_get_badge_number (AdwViewStackPage *self);
ADW_AVAILABLE_IN_ALL
-void adw_view_stack_page_set_icon_name (AdwViewStackPage *self,
- const char *icon_name);
+void adw_view_stack_page_set_badge_number (AdwViewStackPage *self,
+ guint badge_number);
+
+ADW_AVAILABLE_IN_ALL
+gboolean adw_view_stack_page_get_visible (AdwViewStackPage *self);
+ADW_AVAILABLE_IN_ALL
+void adw_view_stack_page_set_visible (AdwViewStackPage *self,
+ gboolean visible);
#define ADW_TYPE_VIEW_STACK (adw_view_stack_get_type())
@@ -110,29 +111,29 @@ ADW_AVAILABLE_IN_ALL
GtkWidget *adw_view_stack_get_child_by_name (AdwViewStack *self,
const char *name);
+ADW_AVAILABLE_IN_ALL
+GtkWidget *adw_view_stack_get_visible_child (AdwViewStack *self);
ADW_AVAILABLE_IN_ALL
void adw_view_stack_set_visible_child (AdwViewStack *self,
GtkWidget *child);
-ADW_AVAILABLE_IN_ALL
-GtkWidget *adw_view_stack_get_visible_child (AdwViewStack *self);
+ADW_AVAILABLE_IN_ALL
+const char *adw_view_stack_get_visible_child_name (AdwViewStack *self);
ADW_AVAILABLE_IN_ALL
void adw_view_stack_set_visible_child_name (AdwViewStack *self,
const char *name);
-ADW_AVAILABLE_IN_ALL
-const char *adw_view_stack_get_visible_child_name (AdwViewStack *self);
+ADW_AVAILABLE_IN_ALL
+gboolean adw_view_stack_get_hhomogeneous (AdwViewStack *self);
ADW_AVAILABLE_IN_ALL
void adw_view_stack_set_hhomogeneous (AdwViewStack *self,
gboolean hhomogeneous);
-ADW_AVAILABLE_IN_ALL
-gboolean adw_view_stack_get_hhomogeneous (AdwViewStack *self);
+ADW_AVAILABLE_IN_ALL
+gboolean adw_view_stack_get_vhomogeneous (AdwViewStack *self);
ADW_AVAILABLE_IN_ALL
void adw_view_stack_set_vhomogeneous (AdwViewStack *self,
gboolean vhomogeneous);
-ADW_AVAILABLE_IN_ALL
-gboolean adw_view_stack_get_vhomogeneous (AdwViewStack *self);
ADW_AVAILABLE_IN_ALL
GtkSelectionModel *adw_view_stack_get_pages (AdwViewStack *self);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]