[gtk/wip/baedert/for-master: 15/16] stack: Add GtkStackPage:visible accessors
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/baedert/for-master: 15/16] stack: Add GtkStackPage:visible accessors
- Date: Tue, 18 Feb 2020 08:33:00 +0000 (UTC)
commit 12e62f8fee751165d2ce718d2a31179b66ea5655
Author: Timm Bäder <mail baedert org>
Date: Tue Feb 18 09:27:42 2020 +0100
stack: Add GtkStackPage:visible accessors
docs/reference/gtk/gtk4-sections.txt | 6 ++--
gtk/gtkstack.c | 55 ++++++++++++++++++++++++++++++++----
gtk/gtkstack.h | 10 +++++--
3 files changed, 60 insertions(+), 11 deletions(-)
---
diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt
index a7b1be5e5e..8e7d3e8b46 100644
--- a/docs/reference/gtk/gtk4-sections.txt
+++ b/docs/reference/gtk/gtk4-sections.txt
@@ -5780,15 +5780,17 @@ gtk_header_bar_get_type
<SECTION>
<FILE>gtkstack</FILE>
<TITLE>GtkStack</TITLE>
-GtkStack
GtkStackPage
+gtk_stack_page_get_visible
+gtk_stack_page_set_visible
+gtk_stack_page_get_child
+GtkStack
gtk_stack_new
gtk_stack_add_named
gtk_stack_add_titled
gtk_stack_get_child_by_name
gtk_stack_get_page
gtk_stack_get_pages
-gtk_stack_page_get_child
gtk_stack_set_visible_child
gtk_stack_get_visible_child
gtk_stack_set_visible_child_name
diff --git a/gtk/gtkstack.c b/gtk/gtkstack.c
index 71e3ad4297..16927ff043 100644
--- a/gtk/gtkstack.c
+++ b/gtk/gtkstack.c
@@ -189,19 +189,22 @@ enum
LAST_CHILD_PROP
};
-struct _GtkStackPage {
- GObject instance;
+struct _GtkStackPage
+{
+ GObject parent_instance;
+
GtkWidget *widget;
- gchar *name;
- gchar *title;
- gchar *icon_name;
+ char *name;
+ char *title;
+ char *icon_name;
gboolean needs_attention;
gboolean visible;
GtkWidget *last_focus;
};
typedef struct _GtkStackPageClass GtkStackPageClass;
-struct _GtkStackPageClass {
+struct _GtkStackPageClass
+{
GObjectClass parent_class;
};
@@ -2592,3 +2595,43 @@ gtk_stack_get_pages (GtkStack *stack)
return priv->pages;
}
+
+/**
+ * gtk_stack_page_get_visible:
+ * @page: a #GtkStackPage
+ *
+ * Returns whether @page is visible in its #GtkStack.
+ * This is independent from the #GtkWidget:visible value of its
+ * #GtkWidget.
+ */
+gboolean
+gtk_stack_page_get_visible (GtkStackPage *page)
+{
+ g_return_val_if_fail (GTK_IS_STACK_PAGE (page), FALSE);
+
+ return page->visible;
+}
+
+/**
+ * gtk_stack_page_set_visible:
+ * @page: a #GtkStackPage
+ * @visible: The new property value
+ *
+ * Sets the new value of the #GtkStackPage:visible property
+ * to @visible.
+ */
+void
+gtk_stack_page_set_visible (GtkStackPage *page,
+ gboolean visible)
+{
+ g_return_if_fail (GTK_IS_STACK_PAGE (page));
+
+ visible = !!visible;
+
+ if (visible != page->visible)
+ {
+ page->visible = visible;
+
+ g_object_notify_by_pspec (G_OBJECT (page), stack_child_props[CHILD_PROP_VISIBLE]);
+ }
+}
diff --git a/gtk/gtkstack.h b/gtk/gtkstack.h
index 75a8d6871e..ad8b4cb697 100644
--- a/gtk/gtkstack.h
+++ b/gtk/gtkstack.h
@@ -72,6 +72,13 @@ typedef enum {
GDK_AVAILABLE_IN_ALL
GType gtk_stack_page_get_type (void) G_GNUC_CONST;
+GDK_AVAILABLE_IN_ALL
+GtkWidget * gtk_stack_page_get_child (GtkStackPage *page);
+GDK_AVAILABLE_IN_ALL
+gboolean gtk_stack_page_get_visible (GtkStackPage *page);
+GDK_AVAILABLE_IN_ALL
+void gtk_stack_page_set_visible (GtkStackPage *page,
+ gboolean visible);
GDK_AVAILABLE_IN_ALL
GType gtk_stack_get_type (void) G_GNUC_CONST;
@@ -91,9 +98,6 @@ GtkStackPage * gtk_stack_add_titled (GtkStack
GDK_AVAILABLE_IN_ALL
GtkStackPage * gtk_stack_get_page (GtkStack *stack,
GtkWidget *child);
-GDK_AVAILABLE_IN_ALL
-GtkWidget * gtk_stack_page_get_child (GtkStackPage *page);
-
GDK_AVAILABLE_IN_ALL
GtkWidget * gtk_stack_get_child_by_name (GtkStack *stack,
const gchar *name);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]