From 842ebdf242540467a797ad6c82d4ae4b7b27114f Mon Sep 17 00:00:00 2001 From: Harald Judt Date: Thu, 15 Jan 2015 12:11:47 +0100 Subject: Details view: Make single middle click open files and folders (bug #10587) On many mice, the middle mouse button is hard to press, and users likely won't hit it accidentally. So it is a bit cumbersome having to use a double middle-click. --- thunar/thunar-details-view.c | 68 ++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 37 deletions(-) diff --git a/thunar/thunar-details-view.c b/thunar/thunar-details-view.c index 05a539b..ce00c60 100644 --- a/thunar/thunar-details-view.c +++ b/thunar/thunar-details-view.c @@ -703,7 +703,7 @@ thunar_details_view_button_press_event (GtkTreeView *tree_view, return TRUE; } - else if ((event->type == GDK_BUTTON_PRESS || event->type == GDK_2BUTTON_PRESS) && event->button == 2) + else if (event->type == GDK_BUTTON_PRESS && event->button == 2) { /* determine the path to the item that was middle-clicked */ if (gtk_tree_view_get_path_at_pos (tree_view, event->x, event->y, &path, NULL, NULL, NULL)) @@ -713,45 +713,39 @@ thunar_details_view_button_press_event (GtkTreeView *tree_view, gtk_tree_selection_unselect_all (selection); gtk_tree_selection_select_path (selection, path); - /* if the event was a double-click or we are in single-click mode, then - * we'll open the file or folder (folder's are opened in new windows) - */ - if (G_LIKELY (event->type == GDK_2BUTTON_PRESS || exo_tree_view_get_single_click (EXO_TREE_VIEW (tree_view)))) + /* determine the file for the path */ + gtk_tree_model_get_iter (GTK_TREE_MODEL (THUNAR_STANDARD_VIEW (details_view)->model), &iter, path); + file = thunar_list_model_get_file (THUNAR_STANDARD_VIEW (details_view)->model, &iter); + if (G_LIKELY (file != NULL)) { - /* determine the file for the path */ - gtk_tree_model_get_iter (GTK_TREE_MODEL (THUNAR_STANDARD_VIEW (details_view)->model), &iter, path); - file = thunar_list_model_get_file (THUNAR_STANDARD_VIEW (details_view)->model, &iter); - if (G_LIKELY (file != NULL)) + /* determine the action to perform depending on the type of the file */ + if (thunar_file_is_directory (file)) { - /* determine the action to perform depending on the type of the file */ - 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)) - gtk_action_activate (action); - - /* release the file reference */ - g_object_unref (G_OBJECT (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)) + gtk_action_activate (action); + + /* release the file reference */ + g_object_unref (G_OBJECT (file)); + } /* cleanup */ gtk_tree_path_free (path); -- 2.2.1