From 256b3510906a6b43107673ed56e403890ad55878 Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Wed, 2 Mar 2011 18:03:13 +0100 Subject: [PATCH] Provide tab overview menu on right-click of empty space --- midori/midori-browser.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/midori/midori-browser.c b/midori/midori-browser.c index e7e6f861..9d5e98f1 100644 --- a/midori/midori-browser.c +++ b/midori/midori-browser.c @@ -4755,6 +4755,14 @@ midori_browser_notebook_page_reordered_cb (GtkNotebook* notebook, g_object_thaw_notify (G_OBJECT (browser)); } +static void +midori_browser_switch_tab_cb (GtkWidget* menuitem, + MidoriBrowser* browser) +{ + gint index = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (menuitem), "index")); + midori_browser_set_current_page (browser, index); +} + static gboolean midori_browser_notebook_button_press_event_after_cb (GtkNotebook* notebook, GdkEventButton* event, @@ -4774,6 +4782,36 @@ midori_browser_notebook_button_press_event_after_cb (GtkNotebook* notebook, return TRUE; } + else if (event->type == GDK_BUTTON_PRESS && event->button == 3) + { + GtkWidget* menu = gtk_menu_new (); + GList* tabs = gtk_container_get_children (GTK_CONTAINER (notebook)); + GtkWidget* menuitem = sokoke_action_create_popup_menu_item ( + gtk_action_group_get_action (browser->action_group, "TabNew")); + gint i; + gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); + menuitem = sokoke_action_create_popup_menu_item ( + gtk_action_group_get_action (browser->action_group, "UndoTabClose")); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); + menuitem = gtk_separator_menu_item_new (); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); + for (; tabs != NULL; tabs = g_list_next (tabs)) + { + const gchar* title = midori_view_get_display_title (tabs->data); + menuitem = katze_image_menu_item_new_ellipsized (title); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), + gtk_image_new_from_pixbuf (midori_view_get_icon (tabs->data))); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); + g_object_set_data (G_OBJECT (menuitem), "index", GINT_TO_POINTER (i)); + g_signal_connect (menuitem, "activate", + G_CALLBACK (midori_browser_switch_tab_cb), browser); + i++; + } + g_list_free (tabs); + gtk_widget_show_all (menu); + katze_widget_popup (GTK_WIDGET (notebook), GTK_MENU (menu), NULL, + event->button == -1 ? KATZE_MENU_POSITION_LEFT : KATZE_MENU_POSITION_CURSOR); + } return FALSE; }