diff --git a/thunar/thunar-abstract-icon-view.c b/thunar/thunar-abstract-icon-view.c index f8c9c350..bb72f6b5 100644 --- a/thunar/thunar-abstract-icon-view.c +++ b/thunar/thunar-abstract-icon-view.c @@ -106,6 +106,8 @@ struct _ThunarAbstractIconViewPrivate gulong gesture_expose_id; gulong gesture_motion_id; gulong gesture_release_id; + + gboolean button_pressed; }; @@ -204,8 +206,7 @@ thunar_abstract_icon_view_init (ThunarAbstractIconView *abstract_icon_view) g_signal_connect (G_OBJECT (view), "button-press-event", G_CALLBACK (thunar_abstract_icon_view_button_press_event), abstract_icon_view); g_signal_connect (G_OBJECT (view), "key-press-event", G_CALLBACK (thunar_abstract_icon_view_key_press_event), abstract_icon_view); g_signal_connect (G_OBJECT (view), "item-activated", G_CALLBACK (thunar_abstract_icon_view_item_activated), abstract_icon_view); - g_signal_connect (G_OBJECT (view), "activate-cursor-item", G_CALLBACK (thunar_abstract_icon_view_activate_cursor_item), - abstract_icon_view); + g_signal_connect (G_OBJECT (view), "activate-cursor-item", G_CALLBACK (thunar_abstract_icon_view_activate_cursor_item), abstract_icon_view); g_signal_connect_swapped (G_OBJECT (view), "selection-changed", G_CALLBACK (thunar_standard_view_selection_changed), abstract_icon_view); gtk_container_add (GTK_CONTAINER (abstract_icon_view), view); gtk_widget_show (view); @@ -496,14 +497,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)) @@ -702,6 +698,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 "F10" is pressed */ if (event->keyval == GDK_KEY_Menu || ((event->state & GDK_SHIFT_MASK) != 0 && event->keyval == GDK_KEY_F10)) { @@ -761,6 +759,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"); @@ -780,10 +785,11 @@ thunar_abstract_icon_view_activate_cursor_item (ExoIconView *view, _thunar_return_val_if_fail (EXO_IS_ICON_VIEW (view), FALSE); _thunar_return_val_if_fail (THUNAR_IS_ABSTRACT_ICON_VIEW (abstract_icon_view), FALSE); - /* ensure that the cursor in the exo_icon_view so that any selected items do get activated */ + /* ensure that the cursor in the exo_icon_view is set so that any selected items do get activated */ + // TODO probably fixed by https://git.xfce.org/xfce/exo/commit/?id=dba8f14 selected_items = thunar_abstract_icon_view_get_selected_items (THUNAR_STANDARD_VIEW (abstract_icon_view)); - if(selected_items != NULL) - exo_icon_view_set_cursor (view,selected_items->data, NULL, FALSE); + if (selected_items != NULL) + exo_icon_view_set_cursor (view, selected_items->data, NULL, FALSE); return TRUE; }