From 44a0e296d1df2c94b01ecd782f415ed1f9cd280b Mon Sep 17 00:00:00 2001 From: Harald Judt Date: Thu, 15 Jan 2015 11:11:39 +0100 Subject: 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-abstract-icon-view.c | 67 +++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 37 deletions(-) diff --git a/thunar/thunar-abstract-icon-view.c b/thunar/thunar-abstract-icon-view.c index c79b747..d67fedf 100644 --- a/thunar/thunar-abstract-icon-view.c +++ b/thunar/thunar-abstract-icon-view.c @@ -515,7 +515,7 @@ thunar_abstract_icon_view_button_press_event (ExoIconView *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) { /* unselect all currently selected items */ exo_icon_view_unselect_all (view); @@ -526,45 +526,38 @@ thunar_abstract_icon_view_button_press_event (ExoIconView *view, /* select only the path to the item on which the user clicked */ exo_icon_view_select_path (view, 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_icon_view_get_single_click (view))) + /* determine the file for the path */ + gtk_tree_model_get_iter (GTK_TREE_MODEL (THUNAR_STANDARD_VIEW (abstract_icon_view)->model), &iter, path); + file = thunar_list_model_get_file (THUNAR_STANDARD_VIEW (abstract_icon_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 (abstract_icon_view)->model), &iter, path); - file = thunar_list_model_get_file (THUNAR_STANDARD_VIEW (abstract_icon_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)) - { - /* 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"; - } - - /* emit the action */ - action = thunar_gtk_ui_manager_get_action_by_name (THUNAR_STANDARD_VIEW (abstract_icon_view)->ui_manager, action_name); - if (G_LIKELY (action != NULL)) - gtk_action_activate (action); - - /* release the file reference */ - g_object_unref (G_OBJECT (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"; + + /* emit the action */ + action = thunar_gtk_ui_manager_get_action_by_name (THUNAR_STANDARD_VIEW (abstract_icon_view)->ui_manager, action_name); + 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