[nautilus/wip/antoniof/gtk4-preparation-popovers: 19/21] notebook: Dont override .insert-page()
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/antoniof/gtk4-preparation-popovers: 19/21] notebook: Dont override .insert-page()
- Date: Wed, 5 Jan 2022 11:31:40 +0000 (UTC)
commit b7a24466ce941d84be29b7cd11d5ef7784ea0bf0
Author: António Fernandes <antoniof gnome org>
Date: Sun Dec 19 16:59:54 2021 +0000
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.
src/nautilus-notebook.c | 45 +++++++++++++--------------------------------
1 file changed, 13 insertions(+), 32 deletions(-)
---
diff --git a/src/nautilus-notebook.c b/src/nautilus-notebook.c
index 69190e52f..ce3202495 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
@@ -116,6 +107,18 @@ 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)
{
@@ -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,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]