From bd7ca398c98ec50a9b49178b06e0de8ebd19973a Mon Sep 17 00:00:00 2001 From: Nick Schermer <nick@xfce.org> Date: Mon, 29 Oct 2012 20:19:02 +0100 Subject: [PATCH] Open in tabs in the details view too. --- thunar/thunar-details-view.c | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/thunar/thunar-details-view.c b/thunar/thunar-details-view.c index 1c258849b..b6a5f3d8e 100644 --- a/thunar/thunar-details-view.c +++ b/thunar/thunar-details-view.c @@ -29,6 +29,7 @@ #include <thunar/thunar-gtk-extensions.h> #include <thunar/thunar-private.h> #include <thunar/thunar-text-renderer.h> +#include <thunar/thunar-preferences.h> @@ -651,11 +652,14 @@ thunar_details_view_button_press_event (GtkTreeView *tree_view, GdkEventButton *event, ThunarDetailsView *details_view) { - GtkTreeSelection *selection; - GtkTreePath *path; - GtkTreeIter iter; - ThunarFile *file; - GtkAction *action; + GtkTreeSelection *selection; + GtkTreePath *path; + GtkTreeIter iter; + ThunarFile *file; + GtkAction *action; + ThunarPreferences *preferences; + gboolean in_tab; + const gchar *action_name; /* check if the event is for the bin window */ if (G_UNLIKELY (event->window != gtk_tree_view_get_bin_window (tree_view))) @@ -714,8 +718,25 @@ thunar_details_view_button_press_event (GtkTreeView *tree_view, if (G_LIKELY (file != NULL)) { /* determine the action to perform depending on the type of the file */ - 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"); + if (thunar_file_is_directory (file)) + { + /* lookup setting if we should open in a tab or a window */ + preferences = thunar_preferences_get (); + g_object_get (preferences, "misc-middle-click-in-tab", &in_tab, NULL); + g_object_unref (preferences); + + /* holding ctrl inverts the action */ + if ((event->state & GDK_CONTROL_MASK) != 0) + in_tab = !in_tab; + + action_name = in_tab ? "open-in-new-tab" : "open-in-new-window"; + } + else + { + action_name = "open"; + } + + action = thunar_gtk_ui_manager_get_action_by_name (THUNAR_STANDARD_VIEW (details_view)->ui_manager, action_name); /* emit the action */ if (G_LIKELY (action != NULL)) -- GitLab