[gtk/nbpage: 7/21] Make GtkNotebookPage an object



commit 85fb368834d73ee04e8ebb36b3f67855f1b9a416
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Feb 19 18:44:40 2019 -0500

    Make GtkNotebookPage an object

 gtk/gtknotebook.c | 34 ++++++++++++++++++++++++++++++++--
 gtk/gtknotebook.h | 19 +++++++++++++++++++
 2 files changed, 51 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c
index b60d5cd73b..7210d92706 100644
--- a/gtk/gtknotebook.c
+++ b/gtk/gtknotebook.c
@@ -292,6 +292,8 @@ enum {
 
 struct _GtkNotebookPage
 {
+  GObject *instance;
+
   GtkWidget *child;
   GtkWidget *tab_label;
   GtkWidget *menu_label;
@@ -312,6 +314,34 @@ struct _GtkNotebookPage
   gulong notify_visible_handler;
 };
 
+struct _GtkNotebookPageClass
+{
+  GObjectClass parent_class;
+};
+
+G_DEFINE_TYPE (GtkNotebookPage, gtk_notebook_page, G_TYPE_OBJECT)
+
+static void
+gtk_notebook_page_init (GtkNotebookPage *page)
+{
+}
+
+static void
+gtk_notebook_page_finalize (GObject *object)
+{
+  GtkNotebookPage *page = GTK_NOTEBOOK_PAGE (object);
+
+  G_OBJECT_CLASS (gtk_notebook_page_parent_class)->finalize (object);
+}
+
+static void
+gtk_notebook_page_class_init (GtkNotebookPageClass *class)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (class);
+
+  object_class->finalize = gtk_notebook_page_finalize;
+}
+
 static const char *src_notebook_targets [] = {
   "GTK_NOTEBOOK_TAB",
   "application/x-rootwindow-drop"
@@ -3947,7 +3977,7 @@ gtk_notebook_real_insert_page (GtkNotebook *notebook,
 
   gtk_widget_freeze_child_notify (child);
 
-  page = g_slice_new0 (GtkNotebookPage);
+  page = g_object_new (GTK_TYPE_NOTEBOOK_PAGE, NULL);
   page->child = child;
 
   nchildren = g_list_length (priv->children);
@@ -4228,7 +4258,7 @@ gtk_notebook_real_remove (GtkNotebook *notebook,
 
   gtk_widget_unparent (page->tab_widget);
 
-  g_slice_free (GtkNotebookPage, page);
+  g_object_unref (page);
 
   gtk_notebook_update_labels (notebook);
   if (need_resize)
diff --git a/gtk/gtknotebook.h b/gtk/gtknotebook.h
index 6de9d8c09b..ec8e0681ff 100644
--- a/gtk/gtknotebook.h
+++ b/gtk/gtknotebook.h
@@ -43,6 +43,16 @@ G_BEGIN_DECLS
 #define GTK_IS_NOTEBOOK_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_NOTEBOOK))
 #define GTK_NOTEBOOK_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_NOTEBOOK, 
GtkNotebookClass))
 
+#define GTK_TYPE_NOTEBOOK_PAGE (gtk_notebook_page_get_type ())
+#define GTK_NOTEBOOK_PAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_NOTEBOOK_PAGE, GtkNotebookPage))
+#define GTK_NOTEBOOK_PAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_NOTEBOOK_PAGE, 
GtkNotebookPageClass))
+#define GTK_IS_NOTEBOOK_PAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_NOTEBOOK_PAGE))
+#define GTK_IS_NOTEBOOK_PAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_NOTEBOOK_PAGE))
+#define GTK_NOTEBOOK_PAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_NOTEBOOK_PAGE, 
GtkNotebookPageClass))
+
+typedef struct _GtkNotebookPage GtkNotebookPage;
+typedef struct _GtkNotebookPageClass GtkNotebookPageClass;
+
 
 typedef enum
 {
@@ -289,6 +299,15 @@ void       gtk_notebook_set_action_widget (GtkNotebook *notebook,
                                            GtkWidget   *widget,
                                            GtkPackType  pack_type);
 
+GDK_AVAILABLE_IN_ALL
+GType   gtk_notebook_page_get_type  (void) G_GNUC_CONST;
+
+GDK_AVAILABLE_IN_ALL
+GtkNotebookPage *gtk_notebook_get_page (GtkNotebook *notebook,
+                                        GtkWidget   *child);
+GDK_AVAILABLE_IN_ALL
+GtkWidget *gtk_notebook_page_get_child (GtkNotebookPage *page);
+
 G_END_DECLS
 
 #endif /* __GTK_NOTEBOOK_H__ */


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