[Xfce4-commits] [xfce/thunar] 01/01: Allow drag-and-drop of multiple files in icon view (Bug #2487)

noreply at xfce.org noreply at xfce.org
Tue Apr 14 11:17:52 CEST 2020


This is an automated email from the git hooks/post-receive script.

a   l   e   x       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository xfce/thunar.

commit 99ba79edf3ee3f05360ea2604efdb5f0af47848d
Author: Theo Linkspfeifer <lastonestanding at tutanota.com>
Date:   Mon Apr 13 23:44:03 2020 +0100

    Allow drag-and-drop of multiple files in icon view (Bug #2487)
    
    Fixes a bug introduced by commit
    9801a67b3a165fc1be81b520ec28b5529a9ab822
    which broke multiple file drag-and-drop in icon and compact view and
    single-click mode in details-view
    
    Co-authored-by: Reuben Green <reubengreen73 at gmail.com>
---
 thunar/thunar-abstract-icon-view.c | 22 ++++++++++++++--------
 thunar/thunar-details-view.c       | 16 ++++++++++++++++
 2 files changed, 30 insertions(+), 8 deletions(-)

diff --git a/thunar/thunar-abstract-icon-view.c b/thunar/thunar-abstract-icon-view.c
index 92e213d..de37c39 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 9967b09..6872982 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");

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list