[gnome-commander] tabs: added option for opening a subpath folder in new tab with middle click



commit d4e06159b3b8cebd2df9fca65187b394aca04a80
Author: Piotr Eljasiak <epiotr src gnome org>
Date:   Sat Nov 20 23:18:05 2010 +0100

    tabs: added option for opening a subpath folder in new tab with middle click

 src/gnome-cmd-data.cc           |    3 +++
 src/gnome-cmd-data.h            |    7 +++++++
 src/gnome-cmd-file-selector.cc  |   10 +++++++++-
 src/gnome-cmd-options-dialog.cc |   19 +++++++++++++++++++
 4 files changed, 38 insertions(+), 1 deletions(-)
---
diff --git a/src/gnome-cmd-data.cc b/src/gnome-cmd-data.cc
index fbf4365..6b07fbe 100644
--- a/src/gnome-cmd-data.cc
+++ b/src/gnome-cmd-data.cc
@@ -903,6 +903,7 @@ GnomeCmdData::GnomeCmdData()
     confirm_move_overwrite = GNOME_CMD_CONFIRM_OVERWRITE_QUERY;
     left_mouse_button_mode = LEFT_BUTTON_OPENS_WITH_DOUBLE_CLICK;
     left_mouse_button_unselects = TRUE;
+    middle_mouse_button_mode = MIDDLE_BUTTON_GOES_UP_DIR;
     right_mouse_button_mode = RIGHT_BUTTON_POPUPS_MENU;
     color_mode = GNOME_CMD_COLOR_DEEP_BLUE;
     size_disp_mode = GNOME_CMD_SIZE_DISP_MODE_POWERED;
@@ -1154,6 +1155,7 @@ void GnomeCmdData::load()
     ext_disp_mode = (GnomeCmdExtDispMode) gnome_cmd_data_get_int ("/options/ext_disp_mode", GNOME_CMD_EXT_DISP_BOTH);
     left_mouse_button_mode = (LeftMouseButtonMode) gnome_cmd_data_get_int ("/options/left_mouse_button_mode", LEFT_BUTTON_OPENS_WITH_DOUBLE_CLICK);
     left_mouse_button_unselects = gnome_cmd_data_get_bool ("/options/left_mouse_button_unselects", TRUE);
+    middle_mouse_button_mode = (MiddleMouseButtonMode) gnome_cmd_data_get_int ("/options/middle_mouse_button_mode", MIDDLE_BUTTON_GOES_UP_DIR);
     right_mouse_button_mode = (RightMouseButtonMode) gnome_cmd_data_get_int ("/options/right_mouse_button_mode", RIGHT_BUTTON_POPUPS_MENU);
     icon_size = gnome_cmd_data_get_int ("/options/icon_size", 16);
     dev_icon_size = gnome_cmd_data_get_int ("/options/dev_icon_size", 16);
@@ -1574,6 +1576,7 @@ void GnomeCmdData::save()
     gnome_cmd_data_set_int    ("/options/ext_disp_mode", ext_disp_mode);
     gnome_cmd_data_set_int    ("/options/left_mouse_button_mode", left_mouse_button_mode);
     gnome_cmd_data_set_bool   ("/options/left_mouse_button_unselects", left_mouse_button_unselects);
+    gnome_cmd_data_set_int    ("/options/middle_mouse_button_mode", middle_mouse_button_mode);
     gnome_cmd_data_set_int    ("/options/right_mouse_button_mode", right_mouse_button_mode);
     gnome_cmd_data_set_int    ("/options/icon_size", icon_size);
     gnome_cmd_data_set_int    ("/options/dev_icon_size", dev_icon_size);
diff --git a/src/gnome-cmd-data.h b/src/gnome-cmd-data.h
index 96030fd..8a0bd5e 100644
--- a/src/gnome-cmd-data.h
+++ b/src/gnome-cmd-data.h
@@ -44,6 +44,12 @@ struct GnomeCmdData
         LEFT_BUTTON_OPENS_WITH_DOUBLE_CLICK
     };
 
+    enum MiddleMouseButtonMode
+    {
+        MIDDLE_BUTTON_GOES_UP_DIR,
+        MIDDLE_BUTTON_OPENS_NEW_TAB
+    };
+
     enum RightMouseButtonMode
     {
         RIGHT_BUTTON_POPUPS_MENU,
@@ -189,6 +195,7 @@ struct GnomeCmdData
     GnomeCmdConfirmOverwriteMode confirm_move_overwrite;
     LeftMouseButtonMode          left_mouse_button_mode;
     gboolean                     left_mouse_button_unselects;
+    MiddleMouseButtonMode        middle_mouse_button_mode;
     RightMouseButtonMode         right_mouse_button_mode;
     GnomeCmdColorMode            color_mode;
     GnomeCmdSizeDispMode         size_disp_mode;
diff --git a/src/gnome-cmd-file-selector.cc b/src/gnome-cmd-file-selector.cc
index 0bf23d3..f91c17f 100644
--- a/src/gnome-cmd-file-selector.cc
+++ b/src/gnome-cmd-file-selector.cc
@@ -465,7 +465,15 @@ static void on_list_list_clicked (GnomeCmdFileList *fl, GnomeCmdFile *f, GdkEven
                 break;
 
             case 2:
-                fs->goto_directory("..");
+                if (gnome_cmd_data.middle_mouse_button_mode==GnomeCmdData::MIDDLE_BUTTON_GOES_UP_DIR)
+                    fs->goto_directory("..");
+                else
+                {
+                    if (f && f->is_dotdot)
+                        fs->new_tab(gnome_cmd_dir_get_parent (fl->cwd), TRUE);
+                    else
+                        fs->new_tab(f && f->info->type==GNOME_VFS_FILE_TYPE_DIRECTORY ? GNOME_CMD_DIR (f) : fl->cwd, TRUE);
+                }
                 break;
         }
 }
diff --git a/src/gnome-cmd-options-dialog.cc b/src/gnome-cmd-options-dialog.cc
index 351fbee..9b1aa82 100644
--- a/src/gnome-cmd-options-dialog.cc
+++ b/src/gnome-cmd-options-dialog.cc
@@ -99,6 +99,21 @@ static GtkWidget *create_general_tab (GtkWidget *parent)
     gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), gnome_cmd_data.left_mouse_button_unselects);
 
 
+    // Middle mouse button settings
+    cat_box = create_vbox (parent, FALSE, 0);
+    cat = create_category (parent, cat_box, _("Middle mouse button"));
+    gtk_box_pack_start (GTK_BOX (vbox), cat, FALSE, TRUE, 0);
+
+    radio = create_radio (parent, NULL, _("Up one directory"), "mmb_cd_up_radio");
+    gtk_box_pack_start (GTK_BOX (cat_box), radio, FALSE, TRUE, 0);
+    if (gnome_cmd_data.middle_mouse_button_mode == GnomeCmdData::MIDDLE_BUTTON_GOES_UP_DIR)
+        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE);
+    radio = create_radio (parent, get_radio_group (radio), _("Opens new tab"), "mmb_new_tab_radio");
+    gtk_container_add (GTK_CONTAINER (cat_box), radio);
+    if (gnome_cmd_data.middle_mouse_button_mode == GnomeCmdData::MIDDLE_BUTTON_OPENS_NEW_TAB)
+        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE);
+
+
     // Right mouse button settings
     cat_box = create_vbox (parent, FALSE, 0);
     cat = create_category (parent, cat_box, _("Right mouse button"));
@@ -193,6 +208,7 @@ inline void store_general_options (GnomeCmdOptionsDialog *dialog)
 {
     GtkWidget *lmb_singleclick_radio = lookup_widget (GTK_WIDGET (dialog), "lmb_singleclick_radio");
     GtkWidget *lmb_unselects_check = lookup_widget (GTK_WIDGET (dialog), "lmb_unselects_check");
+    GtkWidget *mmb_cd_up_radio = lookup_widget (GTK_WIDGET (dialog), "mmb_cd_up_radio");
     GtkWidget *rmb_popup_radio = lookup_widget (GTK_WIDGET (dialog), "rmb_popup_radio");
     GtkWidget *ft_regex_radio = lookup_widget (GTK_WIDGET (dialog), "ft_regex_radio");
     GtkWidget *case_sens_check = lookup_widget (GTK_WIDGET (dialog), "case_sens_check");
@@ -207,6 +223,9 @@ inline void store_general_options (GnomeCmdOptionsDialog *dialog)
 
     gnome_cmd_data.left_mouse_button_unselects = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (lmb_unselects_check));
 
+    gnome_cmd_data.middle_mouse_button_mode = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (mmb_cd_up_radio)) ? GnomeCmdData::MIDDLE_BUTTON_GOES_UP_DIR
+                                                                                                                 : GnomeCmdData::MIDDLE_BUTTON_OPENS_NEW_TAB;
+
     gnome_cmd_data.right_mouse_button_mode = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (rmb_popup_radio)) ? GnomeCmdData::RIGHT_BUTTON_POPUPS_MENU
                                                                                                                 : GnomeCmdData::RIGHT_BUTTON_SELECTS;
 



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