[gnome-commander] tabs: close tab with mid-click



commit 9938bc8e9e445fc10e06e59c5fdd835e34dc494f
Author: Piotr Eljasiak <epiotr src gnome org>
Date:   Fri Jun 11 21:16:42 2010 +0200

    tabs: close tab with mid-click

 src/gnome-cmd-file-selector.cc |   75 +++++++++++++++++++++++-----------------
 1 files changed, 43 insertions(+), 32 deletions(-)
---
diff --git a/src/gnome-cmd-file-selector.cc b/src/gnome-cmd-file-selector.cc
index db4937d..1ef34de 100644
--- a/src/gnome-cmd-file-selector.cc
+++ b/src/gnome-cmd-file-selector.cc
@@ -601,51 +601,62 @@ static gboolean on_notebook_button_pressed (GtkWidget *widget, GdkEventButton *e
     switch (event->type)
     {
         case GDK_BUTTON_PRESS:
-            if (event->button!=3)
-                return FALSE;
+            switch (event->button)
+            {
+                case 2:
+                    tab_clicked = find_tab_num_at_pos (*notebook, event->x_root, event->y_root);
 
-            tab_clicked = find_tab_num_at_pos (*notebook, event->x_root, event->y_root);
+                    if (tab_clicked>=0)
+                        fs->close_tab(tab_clicked);
 
-            if (tab_clicked>=0)
-            {
-                // notebook->set_current_page(tab_clicked);    // switch to the page the mouse is over
+                    return tab_clicked>=0;
 
-                GtkWidget *menu = gtk_menu_new ();
-                GtkWidget *menuitem;
+                case 3:
+                    tab_clicked = find_tab_num_at_pos (*notebook, event->x_root, event->y_root);
 
-                menuitem = gtk_menu_item_new_with_mnemonic (_("Open in New _Tab"));
-                g_signal_connect (menuitem, "activate", G_CALLBACK (view_new_tab), fs->file_list(tab_clicked));
-                gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
+                    if (tab_clicked>=0)
+                    {
+                        // notebook->set_current_page(tab_clicked);    // switch to the page the mouse is over
 
-                gtk_menu_shell_append (GTK_MENU_SHELL (menu), gtk_separator_menu_item_new ());
+                        GtkWidget *menu = gtk_menu_new ();
+                        GtkWidget *menuitem;
 
-                menuitem = gtk_menu_item_new_with_mnemonic (_("_Refresh Tab"));
-                g_signal_connect (menuitem, "activate", G_CALLBACK (view_refresh), fs->file_list(tab_clicked));
-                gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
+                        menuitem = gtk_menu_item_new_with_mnemonic (_("Open in New _Tab"));
+                        g_signal_connect (menuitem, "activate", G_CALLBACK (view_new_tab), fs->file_list(tab_clicked));
+                        gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
 
-                menuitem = gtk_menu_item_new_with_mnemonic (_("Copy Tab to Other _Pane"));
-                g_signal_connect (menuitem, "activate", G_CALLBACK (view_in_inactive_tab), fs->file_list(tab_clicked));
-                gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
+                        gtk_menu_shell_append (GTK_MENU_SHELL (menu), gtk_separator_menu_item_new ());
 
-                gtk_menu_shell_append (GTK_MENU_SHELL (menu), gtk_separator_menu_item_new ());
+                        menuitem = gtk_menu_item_new_with_mnemonic (_("_Refresh Tab"));
+                        g_signal_connect (menuitem, "activate", G_CALLBACK (view_refresh), fs->file_list(tab_clicked));
+                        gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
 
-                menuitem = gtk_menu_item_new_with_mnemonic (_("_Close Tab"));
-                g_signal_connect (menuitem, "activate", G_CALLBACK (view_close_tab), GINT_TO_POINTER (tab_clicked));
-                gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
+                        menuitem = gtk_menu_item_new_with_mnemonic (_("Copy Tab to Other _Pane"));
+                        g_signal_connect (menuitem, "activate", G_CALLBACK (view_in_inactive_tab), fs->file_list(tab_clicked));
+                        gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
 
-                menuitem = gtk_menu_item_new_with_mnemonic (_("Close _All Tabs"));
-                g_signal_connect (menuitem, "activate", G_CALLBACK (view_close_all_tabs), NULL);
-                gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
+                        gtk_menu_shell_append (GTK_MENU_SHELL (menu), gtk_separator_menu_item_new ());
 
-                menuitem = gtk_menu_item_new_with_mnemonic (_("Close _Duplicate Tabs"));
-                g_signal_connect (menuitem, "activate", G_CALLBACK (view_close_duplicate_tabs), NULL);
-                gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
+                        menuitem = gtk_menu_item_new_with_mnemonic (_("_Close Tab"));
+                        g_signal_connect (menuitem, "activate", G_CALLBACK (view_close_tab), GINT_TO_POINTER (tab_clicked));
+                        gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
 
-                gtk_widget_show_all (menu);
-                gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, event->button, event->time);
-            }
+                        menuitem = gtk_menu_item_new_with_mnemonic (_("Close _All Tabs"));
+                        g_signal_connect (menuitem, "activate", G_CALLBACK (view_close_all_tabs), NULL);
+                        gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
 
-            return TRUE;
+                        menuitem = gtk_menu_item_new_with_mnemonic (_("Close _Duplicate Tabs"));
+                        g_signal_connect (menuitem, "activate", G_CALLBACK (view_close_duplicate_tabs), NULL);
+                        gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
+
+                        gtk_widget_show_all (menu);
+                        gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, event->button, event->time);
+                    }
+                    return TRUE;
+
+                default:
+                    return FALSE;
+            }
 
         case GDK_2BUTTON_PRESS:
             if (event->button!=1)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]