Allow swapping of the two open-directory actions. This patch adds an option which allows left-clicking to open a directory to do so in a new window. This is an option in ROX Filer and is the normal behaviour of the RISC OS filer. The changed behaviour does not apply to the shortcut or list panels. Signed-off-by: Darren Salt Index: thunar/thunar-preferences-dialog.c =================================================================== --- thunar/thunar-preferences-dialog.c (revision 22286) +++ thunar/thunar-preferences-dialog.c (working copy) @@ -544,6 +544,14 @@ gtk_table_attach (GTK_TABLE (table), button, 0, 1, 2, 3, GTK_EXPAND | GTK_FILL, 0, 0, 0); gtk_widget_show (button); + button = gtk_check_button_new_with_mnemonic (_("New _window on button 1")); + exo_mutual_binding_new (G_OBJECT (dialog->preferences), "misc-swapped-open", G_OBJECT (button), "active"); + g_signal_connect (G_OBJECT (button), "toggled", G_CALLBACK (g_object_notify), "active"); + gtk_tooltips_set_tip (dialog->tooltips, button, _("If enabled, left and middle click or double-click on a directory icon are swapped: " + "left will open a new window (like the RISC OS filer does).\n\n" + "Note that this does not affect side panels."), NULL); + gtk_table_attach (GTK_TABLE (table), button, 0, 1, 3, 4, GTK_EXPAND | GTK_FILL, 0, 0, 0); + gtk_widget_show (button); /* Advanced Index: thunar/thunar-preferences.c =================================================================== --- thunar/thunar-preferences.c (revision 22286) +++ thunar/thunar-preferences.c (working copy) @@ -76,6 +76,7 @@ PROP_MISC_SHOW_THUMBNAILS, PROP_MISC_SINGLE_CLICK, PROP_MISC_SINGLE_CLICK_TIMEOUT, + PROP_MISC_SWAPPED_OPEN, PROP_MISC_TEXT_BESIDE_ICONS, PROP_SHORTCUTS_ICON_EMBLEMS, PROP_SHORTCUTS_ICON_SIZE, @@ -577,6 +578,19 @@ EXO_PARAM_READWRITE)); /** + * ThunarPreferences:misc-mouse-gestures: + * + * Whether left or middle opens a new window (excluding side panels). + **/ + g_object_class_install_property (gobject_class, + PROP_MISC_SWAPPED_OPEN, + g_param_spec_boolean ("misc-swapped-open", + "misc-swapped-open", + "misc-swapped-open", + FALSE, + EXO_PARAM_READWRITE)); + + /** * ThunarPreferences:shortcuts-icon-emblems: * * Whether to display emblems for file icons (if defined) in the Index: thunar/thunar-details-view.c =================================================================== --- thunar/thunar-details-view.c (revision 22286) +++ thunar/thunar-details-view.c (working copy) @@ -696,9 +696,13 @@ if (G_LIKELY (file != NULL)) { /* determine the action to perform depending on the type of the file */ + gint swapped_open; + ThunarPreferences *preferences = thunar_preferences_get (); + g_object_get (G_OBJECT (preferences), "misc-swapped-open", &swapped_open, NULL); + g_object_unref (preferences); action = thunar_gtk_ui_manager_get_action_by_name (THUNAR_STANDARD_VIEW (details_view)->ui_manager, - thunar_file_is_directory (file) ? "open-in-new-window" : "open"); - + (thunar_file_is_directory (file) ^ swapped_open) ? "open-in-new-window" : "open"); + /* emit the action */ if (G_LIKELY (action != NULL)) gtk_action_activate (action); @@ -745,6 +749,7 @@ { GtkTreeSelection *selection; GtkAction *action; + gint swapped_open; g_return_if_fail (THUNAR_IS_DETAILS_VIEW (details_view)); @@ -754,7 +759,20 @@ gtk_tree_selection_select_path (selection, path); /* emit the "open" action */ - action = thunar_gtk_ui_manager_get_action_by_name (THUNAR_STANDARD_VIEW (details_view)->ui_manager, "open"); + ThunarPreferences *preferences = thunar_preferences_get (); + g_object_get (G_OBJECT (preferences), "misc-swapped-open", &swapped_open, NULL); + g_object_unref (preferences); + if (swapped_open) + { + GtkTreeIter iter; + gtk_tree_model_get_iter (GTK_TREE_MODEL (THUNAR_STANDARD_VIEW (details_view)->model), &iter, path); + ThunarFile *file = thunar_list_model_get_file (THUNAR_STANDARD_VIEW (details_view)->model, &iter); + action = thunar_gtk_ui_manager_get_action_by_name (THUNAR_STANDARD_VIEW (details_view)->ui_manager, + thunar_file_is_directory (file) ? "open-in-new-window" : "open"); + } + else + action = thunar_gtk_ui_manager_get_action_by_name (THUNAR_STANDARD_VIEW (details_view)->ui_manager, "open"); + if (G_LIKELY (action != NULL)) gtk_action_activate (action); } Index: thunar/thunar-abstract-icon-view.c =================================================================== --- thunar/thunar-abstract-icon-view.c (revision 22286) +++ thunar/thunar-abstract-icon-view.c (working copy) @@ -555,8 +555,12 @@ if (G_LIKELY (file != NULL)) { /* determine the action to perform depending on the type of the file */ + gint swapped_open; + ThunarPreferences *preferences = thunar_preferences_get (); + g_object_get (G_OBJECT (preferences), "misc-swapped-open", &swapped_open, NULL); + g_object_unref (preferences); action = thunar_gtk_ui_manager_get_action_by_name (THUNAR_STANDARD_VIEW (abstract_icon_view)->ui_manager, - thunar_file_is_directory (file) ? "open-in-new-window" : "open"); + (thunar_file_is_directory (file) ^ swapped_open) ? "open-in-new-window" : "open"); /* emit the action */ if (G_LIKELY (action != NULL)) @@ -764,6 +768,7 @@ ThunarAbstractIconView *abstract_icon_view) { GtkAction *action; + gint swapped_open; g_return_if_fail (THUNAR_IS_ABSTRACT_ICON_VIEW (abstract_icon_view)); @@ -772,7 +777,20 @@ exo_icon_view_select_path (view, path); /* emit the "open" action */ - action = thunar_gtk_ui_manager_get_action_by_name (THUNAR_STANDARD_VIEW (abstract_icon_view)->ui_manager, "open"); + ThunarPreferences *preferences = thunar_preferences_get (); + g_object_get (G_OBJECT (preferences), "misc-swapped-open", &swapped_open, NULL); + g_object_unref (preferences); + if (swapped_open) + { + GtkTreeIter iter; + gtk_tree_model_get_iter (GTK_TREE_MODEL (THUNAR_STANDARD_VIEW (abstract_icon_view)->model), &iter, path); + ThunarFile *file = thunar_list_model_get_file (THUNAR_STANDARD_VIEW (abstract_icon_view)->model, &iter); + action = thunar_gtk_ui_manager_get_action_by_name (THUNAR_STANDARD_VIEW (abstract_icon_view)->ui_manager, + thunar_file_is_directory (file) ? "open-in-new-window" : "open"); + } + else + action = thunar_gtk_ui_manager_get_action_by_name (THUNAR_STANDARD_VIEW (abstract_icon_view)->ui_manager, "open"); + if (G_LIKELY (action != NULL)) gtk_action_activate (action); }