[nautilus/wip/antoniof/gnome-42: 20/72] Revert "notebook: Dont override .insert-page()"




commit da37eeeff2d67fb825350b6ecc2a3dfee13a97af
Author: António Fernandes <antoniof gnome org>
Date:   Fri Feb 11 19:01:36 2022 +0000

    Revert "notebook: Dont override .insert-page()"
    
    This reverts commit 5d5b49a39ae5fff81924b01bc4f1b917a1785527.

 src/nautilus-notebook.c | 45 ++++++++++++++++++++++++++++++++-------------
 1 file changed, 32 insertions(+), 13 deletions(-)
---
diff --git a/src/nautilus-notebook.c b/src/nautilus-notebook.c
index ef75425f2..256c82a58 100644
--- a/src/nautilus-notebook.c
+++ b/src/nautilus-notebook.c
@@ -37,6 +37,12 @@
 
 #define AFTER_ALL_TABS -1
 
+static int  nautilus_notebook_insert_page (GtkNotebook *notebook,
+                                           GtkWidget   *child,
+                                           GtkWidget   *tab_label,
+                                           GtkWidget   *menu_label,
+                                           int          position);
+
 struct _NautilusNotebook
 {
     GtkNotebook parent_instance;
@@ -54,8 +60,11 @@ static void
 nautilus_notebook_class_init (NautilusNotebookClass *klass)
 {
     GObjectClass *object_class = G_OBJECT_CLASS (klass);
+    GtkNotebookClass *notebook_class = GTK_NOTEBOOK_CLASS (klass);
 
     object_class->dispose = nautilus_notebook_dispose;
+
+    notebook_class->insert_page = nautilus_notebook_insert_page;
 }
 
 static gint
@@ -107,18 +116,6 @@ on_page_removed (GtkNotebook *notebook,
                                 gtk_notebook_get_n_pages (notebook) > 1);
 }
 
-static void
-on_page_added (GtkNotebook *notebook,
-               GtkWidget   *child,
-               guint        page_num,
-               gpointer     user_data)
-{
-    gtk_notebook_set_show_tabs (notebook,
-                                gtk_notebook_get_n_pages (notebook) > 1);
-    gtk_notebook_set_tab_reorderable (notebook, child, TRUE);
-    gtk_notebook_set_tab_detachable (notebook, child, TRUE);
-}
-
 static void
 nautilus_notebook_init (NautilusNotebook *notebook)
 {
@@ -127,7 +124,6 @@ nautilus_notebook_init (NautilusNotebook *notebook)
     gtk_notebook_set_show_tabs (GTK_NOTEBOOK (notebook), FALSE);
 
     g_signal_connect (notebook, "page-removed", G_CALLBACK (on_page_removed), NULL);
-    g_signal_connect (notebook, "page-added", G_CALLBACK (on_page_added), NULL);
 }
 
 gboolean
@@ -316,6 +312,29 @@ build_tab_label (NautilusNotebook   *notebook,
     return box;
 }
 
+static int
+nautilus_notebook_insert_page (GtkNotebook *gnotebook,
+                               GtkWidget   *tab_widget,
+                               GtkWidget   *tab_label,
+                               GtkWidget   *menu_label,
+                               int          position)
+{
+    g_assert (GTK_IS_WIDGET (tab_widget));
+
+    position = GTK_NOTEBOOK_CLASS (nautilus_notebook_parent_class)->insert_page (gnotebook,
+                                                                                 tab_widget,
+                                                                                 tab_label,
+                                                                                 menu_label,
+                                                                                 position);
+
+    gtk_notebook_set_show_tabs (gnotebook,
+                                gtk_notebook_get_n_pages (gnotebook) > 1);
+    gtk_notebook_set_tab_reorderable (gnotebook, tab_widget, TRUE);
+    gtk_notebook_set_tab_detachable (gnotebook, tab_widget, TRUE);
+
+    return position;
+}
+
 int
 nautilus_notebook_add_tab (NautilusNotebook   *notebook,
                            NautilusWindowSlot *slot,


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