[gtk/kill-containers: 42/55] notebook: Derive from GtkWidget



commit a0437628e3a776990bd35a455977f11da6a66c41
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri May 8 11:22:16 2020 -0400

    notebook: Derive from GtkWidget

 gtk/a11y/gtknotebookaccessible.c |  7 +----
 gtk/a11y/gtknotebookaccessible.h |  6 ++--
 gtk/gtknotebook.c                | 66 +++++-----------------------------------
 gtk/gtknotebook.h                |  2 +-
 4 files changed, 13 insertions(+), 68 deletions(-)
---
diff --git a/gtk/a11y/gtknotebookaccessible.c b/gtk/a11y/gtknotebookaccessible.c
index 685b7bfa50..75d8188213 100644
--- a/gtk/a11y/gtknotebookaccessible.c
+++ b/gtk/a11y/gtknotebookaccessible.c
@@ -36,7 +36,7 @@ struct _GtkNotebookAccessiblePrivate
 
 static void atk_selection_interface_init (AtkSelectionIface *iface);
 
-G_DEFINE_TYPE_WITH_CODE (GtkNotebookAccessible, gtk_notebook_accessible, GTK_TYPE_CONTAINER_ACCESSIBLE,
+G_DEFINE_TYPE_WITH_CODE (GtkNotebookAccessible, gtk_notebook_accessible, GTK_TYPE_WIDGET_ACCESSIBLE,
                          G_ADD_PRIVATE (GtkNotebookAccessible)
                          G_IMPLEMENT_INTERFACE (ATK_TYPE_SELECTION, atk_selection_interface_init))
 
@@ -231,7 +231,6 @@ gtk_notebook_accessible_class_init (GtkNotebookAccessibleClass *klass)
   GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
   AtkObjectClass  *class = ATK_OBJECT_CLASS (klass);
   GtkWidgetAccessibleClass *widget_class = (GtkWidgetAccessibleClass*)klass;
-  GtkContainerAccessibleClass *container_class = (GtkContainerAccessibleClass*)klass;
 
   gobject_class->finalize = gtk_notebook_accessible_finalize;
 
@@ -239,10 +238,6 @@ gtk_notebook_accessible_class_init (GtkNotebookAccessibleClass *klass)
   class->initialize = gtk_notebook_accessible_initialize;
 
   widget_class->notify_gtk = gtk_notebook_accessible_notify_gtk;
-
-  /* we listen to page-added/-removed, so we don't care about these */
-  container_class->add_gtk = NULL;
-  container_class->remove_gtk = NULL;
 }
 
 static void
diff --git a/gtk/a11y/gtknotebookaccessible.h b/gtk/a11y/gtknotebookaccessible.h
index 84b3a279eb..bd34be6902 100644
--- a/gtk/a11y/gtknotebookaccessible.h
+++ b/gtk/a11y/gtknotebookaccessible.h
@@ -22,7 +22,7 @@
 #error "Only <gtk/gtk-a11y.h> can be included directly."
 #endif
 
-#include <gtk/a11y/gtkcontaineraccessible.h>
+#include <gtk/a11y/gtkwidgetaccessible.h>
 
 G_BEGIN_DECLS
 
@@ -39,14 +39,14 @@ typedef struct _GtkNotebookAccessiblePrivate GtkNotebookAccessiblePrivate;
 
 struct _GtkNotebookAccessible
 {
-  GtkContainerAccessible parent;
+  GtkWidgetAccessible parent;
 
   GtkNotebookAccessiblePrivate *priv;
 };
 
 struct _GtkNotebookAccessibleClass
 {
-  GtkContainerAccessibleClass parent_class;
+  GtkWidgetAccessibleClass parent_class;
 };
 
 GDK_AVAILABLE_IN_ALL
diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c
index 62ff10a72e..89d3aa43ea 100644
--- a/gtk/gtknotebook.c
+++ b/gtk/gtknotebook.c
@@ -180,7 +180,7 @@ typedef struct _GtkNotebookClass         GtkNotebookClass;
 
 struct _GtkNotebookClass
 {
-  GtkContainerClass parent_class;
+  GtkWidgetClass parent_class;
 
   void (* switch_page)       (GtkNotebook     *notebook,
                               GtkWidget       *page,
@@ -223,7 +223,7 @@ struct _GtkNotebookClass
 
 struct _GtkNotebook
 {
-  GtkContainer container;
+  GtkWidget container;
 
   GtkNotebookDragOperation   operation;
   GtkNotebookPage           *cur_page;
@@ -799,15 +799,8 @@ static gboolean gtk_notebook_drag_drop       (GtkDropTarget    *dest,
                                               double            y,
                                               GtkNotebook      *notebook);
 
-/*** GtkContainer Methods ***/
-static void gtk_notebook_add                 (GtkContainer     *container,
+static void gtk_notebook_remove              (GtkNotebook      *notebook,
                                               GtkWidget        *widget);
-static void gtk_notebook_remove              (GtkContainer     *container,
-                                              GtkWidget        *widget);
-static GType gtk_notebook_child_type       (GtkContainer     *container);
-static void gtk_notebook_forall              (GtkContainer     *container,
-                                              GtkCallback       callback,
-                                              gpointer          callback_data);
 
 /*** GtkNotebook Methods ***/
 static gint gtk_notebook_real_insert_page    (GtkNotebook      *notebook,
@@ -923,7 +916,7 @@ static void gtk_notebook_gesture_released (GtkGestureClick *gesture,
 
 static guint notebook_signals[LAST_SIGNAL] = { 0 };
 
-G_DEFINE_TYPE_WITH_CODE (GtkNotebook, gtk_notebook, GTK_TYPE_CONTAINER,
+G_DEFINE_TYPE_WITH_CODE (GtkNotebook, gtk_notebook, GTK_TYPE_WIDGET,
                          G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
                                                 gtk_notebook_buildable_init))
 
@@ -1030,7 +1023,6 @@ gtk_notebook_class_init (GtkNotebookClass *class)
 {
   GObjectClass   *gobject_class = G_OBJECT_CLASS (class);
   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
-  GtkContainerClass *container_class = GTK_CONTAINER_CLASS (class);
 
   gobject_class->set_property = gtk_notebook_set_property;
   gobject_class->get_property = gtk_notebook_get_property;
@@ -1046,11 +1038,6 @@ gtk_notebook_class_init (GtkNotebookClass *class)
   widget_class->set_focus_child = gtk_notebook_set_focus_child;
   widget_class->compute_expand = gtk_notebook_compute_expand;
 
-  container_class->add = gtk_notebook_add;
-  container_class->remove = gtk_notebook_remove;
-  container_class->forall = gtk_notebook_forall;
-  container_class->child_type = gtk_notebook_child_type;
-
   class->switch_page = gtk_notebook_real_switch_page;
   class->insert_page = gtk_notebook_real_insert_page;
 
@@ -1924,7 +1911,7 @@ gtk_notebook_dispose (GObject *object)
       GtkNotebookPage *page = l->data;
       l = l->next;
 
-      gtk_notebook_remove (GTK_CONTAINER (notebook), page->child);
+      gtk_notebook_remove (notebook, page->child);
     }
 
   G_OBJECT_CLASS (gtk_notebook_parent_class)->dispose (object);
@@ -3400,26 +3387,14 @@ do_detach_tab (GtkNotebook *from,
 
 /* Private GtkContainer Methods :
  *
- * gtk_notebook_add
  * gtk_notebook_remove
  * gtk_notebook_focus
  * gtk_notebook_set_focus_child
- * gtk_notebook_child_type
- * gtk_notebook_forall
  */
 static void
-gtk_notebook_add (GtkContainer *container,
-                  GtkWidget    *widget)
-{
-  gtk_notebook_insert_page_menu (GTK_NOTEBOOK (container), widget,
-                                 NULL, NULL, -1);
-}
-
-static void
-gtk_notebook_remove (GtkContainer *container,
-                     GtkWidget    *widget)
+gtk_notebook_remove (GtkNotebook *notebook,
+                     GtkWidget   *widget)
 {
-  GtkNotebook *notebook = GTK_NOTEBOOK (container);
   GtkNotebookPage *page;
   GList *children, *list;
   gint page_num = 0;
@@ -3782,31 +3757,6 @@ gtk_notebook_set_focus_child (GtkWidget *widget,
   GTK_WIDGET_CLASS (gtk_notebook_parent_class)->set_focus_child (widget, child);
 }
 
-static void
-gtk_notebook_forall (GtkContainer *container,
-                     GtkCallback   callback,
-                     gpointer      callback_data)
-{
-  GtkNotebook *notebook = GTK_NOTEBOOK (container);
-  GList *children;
-
-  children = notebook->children;
-  while (children)
-    {
-      GtkNotebookPage *page;
-
-      page = children->data;
-      children = children->next;
-      (* callback) (page->child, callback_data);
-    }
-}
-
-static GType
-gtk_notebook_child_type (GtkContainer     *container)
-{
-  return GTK_TYPE_WIDGET;
-}
-
 /* Private GtkNotebook Methods:
  *
  * gtk_notebook_real_insert_page
@@ -6626,7 +6576,7 @@ gtk_notebook_set_menu_label (GtkNotebook *notebook,
   if (page->menu_label)
     {
       if (notebook->menu)
-        gtk_widget_destroy (gtk_widget_get_parent (page->menu_label));
+        gtk_widget_unparent (gtk_widget_get_parent (page->menu_label));
 
       g_clear_object (&page->menu_label);
     }
diff --git a/gtk/gtknotebook.h b/gtk/gtknotebook.h
index d29cada205..54a0b8a8ee 100644
--- a/gtk/gtknotebook.h
+++ b/gtk/gtknotebook.h
@@ -31,7 +31,7 @@
 #error "Only <gtk/gtk.h> can be included directly."
 #endif
 
-#include <gtk/gtkcontainer.h>
+#include <gtk/gtkwidget.h>
 
 
 G_BEGIN_DECLS


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