summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntónio Fernandes <antoniof@gnome.org>2021-12-19 16:59:54 +0000
committerAntónio Fernandes <antoniof@gnome.org>2022-01-05 11:41:46 +0000
commit5d5b49a39ae5fff81924b01bc4f1b917a1785527 (patch)
tree1924cc7ed5766d01f26ce13ec4f6546aeec3161c
parent663c5787cf0e4bbe80ceb48160406e0325127f00 (diff)
downloadnautilus-5d5b49a39ae5fff81924b01bc4f1b917a1785527.tar.gz
notebook: Dont override .insert-page()
In GTK 4 this vfunc won't be available for override. Instead, we can achieve the same result by connecting to ::page-added.
-rw-r--r--src/nautilus-notebook.c45
1 files changed, 13 insertions, 32 deletions
diff --git a/src/nautilus-notebook.c b/src/nautilus-notebook.c
index 256c82a58..ef75425f2 100644
--- a/src/nautilus-notebook.c
+++ b/src/nautilus-notebook.c
@@ -37,12 +37,6 @@
#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;
@@ -60,11 +54,8 @@ 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
@@ -117,6 +108,18 @@ on_page_removed (GtkNotebook *notebook,
}
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)
{
gtk_notebook_set_scrollable (GTK_NOTEBOOK (notebook), TRUE);
@@ -124,6 +127,7 @@ 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
@@ -312,29 +316,6 @@ 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,