[gtk/wip/otte/listmodels: 18/18] assistant: Add ::item-type and ::n-items to the pages list




commit 0b2aab0f559076d8836a9366e3bbbd6924fb705d
Author: Benjamin Otte <otte redhat com>
Date:   Sat Jun 11 07:34:36 2022 +0200

    assistant: Add ::item-type and ::n-items to the pages list

 gtk/gtkassistant.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 51 insertions(+), 1 deletion(-)
---
diff --git a/gtk/gtkassistant.c b/gtk/gtkassistant.c
index 81934c815a..cb741d519c 100644
--- a/gtk/gtkassistant.c
+++ b/gtk/gtkassistant.c
@@ -2198,6 +2198,16 @@ struct _GtkAssistantPagesClass
   GObjectClass parent_class;
 };
 
+enum {
+  PAGES_PROP_0,
+  PAGES_PROP_ITEM_TYPE,
+  PAGES_PROP_N_ITEMS,
+
+  PAGES_N_PROPS
+};
+
+static GParamSpec *pages_properties[PAGES_N_PROPS] = { NULL, };
+
 static GType
 gtk_assistant_pages_get_item_type (GListModel *model)
 {
@@ -2231,17 +2241,57 @@ gtk_assistant_pages_list_model_init (GListModelInterface *iface)
   iface->get_n_items = gtk_assistant_pages_get_n_items;
   iface->get_item = gtk_assistant_pages_get_item;
 }
+
 G_DEFINE_TYPE_WITH_CODE (GtkAssistantPages, gtk_assistant_pages, G_TYPE_OBJECT,
                          G_IMPLEMENT_INTERFACE (G_TYPE_LIST_MODEL, gtk_assistant_pages_list_model_init))
 
+static void
+gtk_assistant_pages_get_property (GObject    *object,
+                                  guint       prop_id,
+                                  GValue     *value,
+                                  GParamSpec *pspec)
+{
+  GtkAssistantPages *self = GTK_ASSISTANT_PAGES (object);
+
+  switch (prop_id)
+    {
+    case PAGES_PROP_ITEM_TYPE:
+      g_value_set_gtype (value, GTK_TYPE_ASSISTANT_PAGE);
+      break;
+
+    case PAGES_PROP_N_ITEMS:
+      g_value_set_uint (value, gtk_assistant_pages_get_n_items (G_LIST_MODEL (self)));
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
 static void
 gtk_assistant_pages_init (GtkAssistantPages *pages)
 {
 }
 
 static void
-gtk_assistant_pages_class_init (GtkAssistantPagesClass *class)
+gtk_assistant_pages_class_init (GtkAssistantPagesClass *klass)
 {
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  object_class->get_property = gtk_assistant_pages_get_property;
+
+  pages_properties[PAGES_PROP_ITEM_TYPE] =
+    g_param_spec_gtype ("item-type", NULL, NULL,
+                        GTK_TYPE_STACK_PAGE,
+                        G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+
+  pages_properties[PAGES_PROP_N_ITEMS] =
+    g_param_spec_uint ("n-items", NULL, NULL,
+                       0, G_MAXUINT, 0,
+                       G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+
+  g_object_class_install_properties (object_class, PAGES_N_PROPS, pages_properties);
 }
 
 static GtkAssistantPages *


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]