From 6f82595c2b7391d3bcc5cfdab7cbc4b776005fc8 Mon Sep 17 00:00:00 2001 From: Evangelos Foutras Date: Tue, 10 May 2011 01:16:12 +0300 Subject: [PATCH] Only add tabs to the "Go" menu when num_tabs > 1 When there is only one tab in the current window, there is no point in adding an entry for it to the "Go" menu. Also, the 1 accelerator remains available for use in e.g. irssi (unless, of course, multiple tabs are open in the same window). Addresses https://bugzilla.xfce.org/show_bug.cgi?id=7595. --- terminal/terminal-window.c | 66 +++++++++++++++++++++++-------------------- 1 files changed, 35 insertions(+), 31 deletions(-) diff --git a/terminal/terminal-window.c b/terminal/terminal-window.c index f580a39..26e5b57 100644 --- a/terminal/terminal-window.c +++ b/terminal/terminal-window.c @@ -735,42 +735,46 @@ terminal_window_rebuild_gomenu (TerminalWindow *window) } } - /* create a new merge id */ - window->gomenu_merge_id = gtk_ui_manager_new_merge_id (window->ui_manager); - - /* walk the tabs */ + /* if we have more than one tab, add them to the "Go" menu */ npages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (window->notebook)); - for (n = 0; n < npages; n++) + if (npages > 1) { - page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (window->notebook), n); + /* create a new merge id */ + window->gomenu_merge_id = gtk_ui_manager_new_merge_id (window->ui_manager); - g_snprintf (name, sizeof (name), "accel-switch-to-tab%d", n + 1); + /* walk the tabs */ + for (n = 0; n < npages; n++) + { + page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (window->notebook), n); - /* create action */ - radio_action = gtk_radio_action_new (name, NULL, NULL, NULL, n); - exo_binding_new (G_OBJECT (page), "title", G_OBJECT (radio_action), "label"); - gtk_radio_action_set_group (radio_action, group); - group = gtk_radio_action_get_group (radio_action); - gtk_action_group_add_action (window->action_group, GTK_ACTION (radio_action)); - g_signal_connect (G_OBJECT (radio_action), "activate", - G_CALLBACK (terminal_window_action_goto_tab), window->notebook); + g_snprintf (name, sizeof (name), "accel-switch-to-tab%d", n + 1); - /* set an accelerator if the user definde one */ - if (g_object_class_find_property (G_OBJECT_GET_CLASS (window->preferences), name) != NULL) - { - path = g_strconcat ("/terminal-window/", name + 6, NULL); - gtk_action_set_accel_path (GTK_ACTION (radio_action), path); - g_free (path); - } + /* create action */ + radio_action = gtk_radio_action_new (name, NULL, NULL, NULL, n); + exo_binding_new (G_OBJECT (page), "title", G_OBJECT (radio_action), "label"); + gtk_radio_action_set_group (radio_action, group); + group = gtk_radio_action_get_group (radio_action); + gtk_action_group_add_action (window->action_group, GTK_ACTION (radio_action)); + g_signal_connect (G_OBJECT (radio_action), "activate", + G_CALLBACK (terminal_window_action_goto_tab), window->notebook); - /* connect action to the page so we can active it when a tab is switched */ - g_object_set_qdata_full (G_OBJECT (page), gomenu_action_quark, - radio_action, (GDestroyNotify) g_object_unref); + /* set an accelerator if the user defined one */ + if (g_object_class_find_property (G_OBJECT_GET_CLASS (window->preferences), name) != NULL) + { + path = g_strconcat ("/terminal-window/", name + 6, NULL); + gtk_action_set_accel_path (GTK_ACTION (radio_action), path); + g_free (path); + } - /* notify the ui about the new action */ - gtk_ui_manager_add_ui (window->ui_manager, window->gomenu_merge_id, - "/main-menu/go-menu/placeholder-tab-items", - name, name, GTK_UI_MANAGER_MENUITEM, FALSE); + /* connect action to the page so we can active it when a tab is switched */ + g_object_set_qdata_full (G_OBJECT (page), gomenu_action_quark, + radio_action, (GDestroyNotify) g_object_unref); + + /* notify the ui about the new action */ + gtk_ui_manager_add_ui (window->ui_manager, window->gomenu_merge_id, + "/main-menu/go-menu/placeholder-tab-items", + name, name, GTK_UI_MANAGER_MENUITEM, FALSE); + } } } -- 1.7.5.1