From 3396e5a2815ed72ae97c90d3b2a6d2028855a060 Mon Sep 17 00:00:00 2001 From: Reuben Green Date: Sun, 29 Mar 2020 12:36:05 +0100 Subject: [PATCH] Allow drag-and-drop of multiple files in icon view Fixes a bug introduced by commit 9801a67b3a165fc1be81b520ec28b5529a9ab822 which broke multiple file drag-and-drop in icon and compact view. Bug 2487 --- thunar/thunar-abstract-icon-view.c | 34 ++++++++++++++++++------------ 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/thunar/thunar-abstract-icon-view.c b/thunar/thunar-abstract-icon-view.c index f8c9c350..f5f9b3fb 100644 --- a/thunar/thunar-abstract-icon-view.c +++ b/thunar/thunar-abstract-icon-view.c @@ -496,14 +496,7 @@ 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) + 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)) @@ -761,6 +754,10 @@ 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 double clicked item selected */ + 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"); @@ -775,15 +772,26 @@ static gboolean thunar_abstract_icon_view_activate_cursor_item (ExoIconView *view, ThunarAbstractIconView *abstract_icon_view) { - GList *selected_items; + /* The user has used the keyboard to activate the selected item(s). We do not want + * thunar_abstract_icon_view_item_activated to be run in response to this, since that + * will reduce the selection to just the "cursor item", preventing the opening of + * multiple files at the same time. We therefore stop the signal emission and emit the + * "open" action here. + */ + + GtkAction *action; _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 */ - 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); + g_signal_stop_emission_by_name (view, "activate-cursor-item"); + +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"); + if (G_LIKELY (action != NULL)) + gtk_action_activate (action); +G_GNUC_END_IGNORE_DEPRECATIONS return TRUE; } -- 2.25.1