diff --git a/thunar/thunar-abstract-icon-view.c b/thunar/thunar-abstract-icon-view.c index 92e213d53e7865791a7e1fee23ce08a7c3d05cde..de37c39b61907763c054f655d1b55226ca1e3bf2 100644 --- a/thunar/thunar-abstract-icon-view.c +++ b/thunar/thunar-abstract-icon-view.c @@ -104,6 +104,8 @@ struct _ThunarAbstractIconViewPrivate gulong gesture_expose_id; gulong gesture_motion_id; gulong gesture_release_id; + + gboolean button_pressed; }; @@ -492,14 +494,9 @@ thunar_abstract_icon_view_button_press_event (ExoIconView *view, gboolean in_tab; const gchar *action_name; - if (event->type == GDK_BUTTON_PRESS && event->button == 1) - { - /* we don't unselect all other items if Control or Shift is active */ - if ((event->state & GDK_CONTROL_MASK) == 0 && (event->state & GDK_SHIFT_MASK) == 0) - exo_icon_view_unselect_all (view); - return FALSE; - } - else if (event->type == GDK_BUTTON_PRESS && event->button == 3) + abstract_icon_view->priv->button_pressed = TRUE; + + if (event->type == GDK_BUTTON_PRESS && event->button == 3) { /* open the context menu on right clicks */ if (exo_icon_view_get_item_at_pos (view, event->x, event->y, &path, NULL)) @@ -698,6 +695,8 @@ thunar_abstract_icon_view_key_press_event (ExoIconView *view, GdkEventKey *event, ThunarAbstractIconView *abstract_icon_view) { + abstract_icon_view->priv->button_pressed = FALSE; + /* popup context menu if "Menu" or "<Shift>F10" is pressed */ if (event->keyval == GDK_KEY_Menu || ((event->state & GDK_SHIFT_MASK) != 0 && event->keyval == GDK_KEY_F10)) { @@ -757,6 +756,13 @@ thunar_abstract_icon_view_item_activated (ExoIconView *view, _thunar_return_if_fail (THUNAR_IS_ABSTRACT_ICON_VIEW (abstract_icon_view)); + /* be sure to have only the clicked item selected */ + if (abstract_icon_view->priv->button_pressed) + { + exo_icon_view_unselect_all (view); + exo_icon_view_select_path (view, path); + } + G_GNUC_BEGIN_IGNORE_DEPRECATIONS /* emit the "open" action */ action = thunar_gtk_ui_manager_get_action_by_name (THUNAR_STANDARD_VIEW (abstract_icon_view)->ui_manager, "open"); diff --git a/thunar/thunar-details-view.c b/thunar/thunar-details-view.c index 9967b0905011babda794bd209f156fd2420a23d8..68729828115009dba291f38f72a160122f26cc0c 100644 --- a/thunar/thunar-details-view.c +++ b/thunar/thunar-details-view.c @@ -131,6 +131,9 @@ struct _ThunarDetailsView /* the UI manager merge id for the details view */ guint ui_merge_id; + + /* whether the most recent item activation used a mouse button press */ + gboolean button_pressed; }; @@ -700,6 +703,8 @@ thunar_details_view_button_press_event (GtkTreeView *tree_view, { GtkTreePath *cursor_path; + details_view->button_pressed = TRUE; + /* grab the tree view */ gtk_widget_grab_focus (GTK_WIDGET (tree_view)); @@ -819,6 +824,8 @@ thunar_details_view_key_press_event (GtkTreeView *tree_view, GdkEventKey *event, ThunarDetailsView *details_view) { + details_view->button_pressed = FALSE; + /* popup context menu if "Menu" or "<Shift>F10" is pressed */ if (event->keyval == GDK_KEY_Menu || ((event->state & GDK_SHIFT_MASK) != 0 && event->keyval == GDK_KEY_F10)) { @@ -837,10 +844,19 @@ thunar_details_view_row_activated (GtkTreeView *tree_view, GtkTreeViewColumn *column, ThunarDetailsView *details_view) { + GtkTreeSelection *selection; GtkAction *action; _thunar_return_if_fail (THUNAR_IS_DETAILS_VIEW (details_view)); + /* be sure to have only the clicked item selected */ + if (details_view->button_pressed) + { + selection = gtk_tree_view_get_selection (tree_view); + gtk_tree_selection_unselect_all (selection); + gtk_tree_selection_select_path (selection, path); + } + G_GNUC_BEGIN_IGNORE_DEPRECATIONS /* emit the "open" action */ action = thunar_gtk_ui_manager_get_action_by_name (THUNAR_STANDARD_VIEW (details_view)->ui_manager, "open");