summaryrefslogtreecommitdiff
path: root/frontends/gtk
diff options
context:
space:
mode:
Diffstat (limited to 'frontends/gtk')
-rw-r--r--frontends/gtk/menu.c2
-rw-r--r--frontends/gtk/menu.h4
-rw-r--r--frontends/gtk/scaffolding.c13
-rw-r--r--frontends/gtk/tabs.c21
4 files changed, 22 insertions, 18 deletions
diff --git a/frontends/gtk/menu.c b/frontends/gtk/menu.c
index d0a984a99..03056d2a8 100644
--- a/frontends/gtk/menu.c
+++ b/frontends/gtk/menu.c
@@ -611,7 +611,6 @@ nserror nsgtk_menu_bar_destroy(struct nsgtk_bar_submenu *menu)
free(menu->view_submenu->scaleview_submenu);
free(menu->view_submenu);
free(menu->nav_submenu);
- free(menu->tabs_submenu);
free(menu->tools_submenu->developer_submenu);
free(menu->tools_submenu);
free(menu->help_submenu);
@@ -633,7 +632,6 @@ nserror nsgtk_burger_menu_destroy(struct nsgtk_burger_menu *menu)
free(menu->view_submenu->scaleview_submenu);
free(menu->view_submenu);
free(menu->nav_submenu);
- free(menu->tabs_submenu);
free(menu->tools_submenu->developer_submenu);
free(menu->tools_submenu);
free(menu->help_submenu);
diff --git a/frontends/gtk/menu.h b/frontends/gtk/menu.h
index a6f9ea456..cf63b334a 100644
--- a/frontends/gtk/menu.h
+++ b/frontends/gtk/menu.h
@@ -145,7 +145,6 @@ struct nsgtk_bar_submenu {
struct nsgtk_edit_menu *edit_submenu;
struct nsgtk_view_menu *view_submenu;
struct nsgtk_nav_menu *nav_submenu;
- struct nsgtk_tabs_submenu *tabs_submenu;
struct nsgtk_tools_menu *tools_submenu;
struct nsgtk_help_menu *help_submenu;
};
@@ -165,9 +164,6 @@ struct nsgtk_burger_menu {
GtkWidget *nav_menuitem;
struct nsgtk_nav_menu *nav_submenu;
- GtkWidget *tabs_menuitem;
- struct nsgtk_tabs_submenu *tabs_submenu;
-
GtkWidget *tools_menuitem;
struct nsgtk_tools_menu *tools_submenu;
diff --git a/frontends/gtk/scaffolding.c b/frontends/gtk/scaffolding.c
index 001cb91fc..ccf3fcb45 100644
--- a/frontends/gtk/scaffolding.c
+++ b/frontends/gtk/scaffolding.c
@@ -75,6 +75,9 @@ struct nsgtk_scaffolding {
/** tab widget holding displayed pages */
GtkNotebook *notebook;
+ /** handler id for tabs remove callback */
+ gulong tabs_remove_handler_id;
+
/** menu bar hierarchy */
struct nsgtk_bar_submenu *menu_bar;
@@ -171,8 +174,6 @@ popup_menu_show(struct nsgtk_popup_menu *menu, bool nav, bool cnp)
}
-/* event handlers and support functions for them */
-
/**
* resource cleanup function for window destruction.
*
@@ -207,6 +208,8 @@ static void scaffolding_window_destroy(GtkWidget *widget, gpointer data)
nsgtk_popup_menu_destroy(gs->popup_menu);
nsgtk_link_menu_destroy(gs->link_menu);
+ g_signal_handler_disconnect(gs->notebook, gs->tabs_remove_handler_id);
+
free(gs);
if (scaf_list == NULL) {
@@ -425,6 +428,8 @@ nsgtk_window_tabs_remove(GtkNotebook *notebook,
guint page_num,
struct nsgtk_scaffolding *gs)
{
+ gboolean visible;
+
/* if the scaffold is being destroyed it is not useful to
* update the state, further many of the widgets may have
* already been destroyed.
@@ -439,7 +444,7 @@ nsgtk_window_tabs_remove(GtkNotebook *notebook,
return;
}
- gboolean visible = gtk_notebook_get_show_tabs(gs->notebook);
+ visible = gtk_notebook_get_show_tabs(gs->notebook);
g_object_set(gs->menu_bar->view_submenu->tabs_menuitem,
"visible", visible, NULL);
g_object_set(gs->burger_menu->view_submenu->tabs_menuitem,
@@ -1548,7 +1553,7 @@ struct nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *toplevel)
"page-added",
G_CALLBACK(nsgtk_window_tabs_add),
gs);
- g_signal_connect_after(gs->notebook,
+ gs->tabs_remove_handler_id = g_signal_connect_after(gs->notebook,
"page-removed",
G_CALLBACK(nsgtk_window_tabs_remove),
gs);
diff --git a/frontends/gtk/tabs.c b/frontends/gtk/tabs.c
index 54aa5faf4..76fd02f89 100644
--- a/frontends/gtk/tabs.c
+++ b/frontends/gtk/tabs.c
@@ -312,14 +312,19 @@ nsgtk_tab_add_newtab(GtkNotebook *notebook)
static void
nsgtk_tab_visibility_update(GtkNotebook *notebook, GtkWidget *child, guint page)
{
- gint pagec = gtk_notebook_get_n_pages(notebook);
- GtkWidget *addpage = g_object_get_data(G_OBJECT(notebook), "addtab");
-
- if (addpage != NULL) {
- pagec--; /* skip the add tab */
- if ((gint)page == pagec) {
- /* ensure the add new tab cannot be current */
- gtk_notebook_set_current_page(notebook, page - 1);
+ gint pagec;
+ GtkWidget *addpage;
+
+ pagec = gtk_notebook_get_n_pages(notebook);
+ if (pagec > 1) {
+ addpage = g_object_get_data(G_OBJECT(notebook), "addtab");
+ if (addpage != NULL) {
+ pagec--; /* skip the add tab */
+ if ((gint)page == pagec) {
+ /* ensure the add new tab cannot be current */
+ gtk_notebook_set_current_page(notebook,
+ page - 1);
+ }
}
}