[Xfce4-commits] [xfce/thunar] 01/01: Allow opening of multiple file selections (bug #2487)
noreply at xfce.org
noreply at xfce.org
Thu Feb 20 00:07:50 CET 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 x f c e - 4 . 1 4
in repository xfce/thunar.
commit 5e58fd17f88476c9ad341e2236c5aead7e1444cd
Author: Reuben Green <reubengreen73 at gmail.com>
Date: Tue Feb 18 13:53:58 2020 +0000
Allow opening of multiple file selections (bug #2487)
Allow multiple file selections to be opened by pressing enter, space, or
Ctrl^O.
Fixes bug #2487
---
thunar/thunar-abstract-icon-view.c | 36 ++++++++++++++++++++++++++++++-----
thunar/thunar-details-view.c | 39 ++++++++++++++++++++++++++++++++++----
2 files changed, 66 insertions(+), 9 deletions(-)
diff --git a/thunar/thunar-abstract-icon-view.c b/thunar/thunar-abstract-icon-view.c
index 91ee300..f8c9c35 100644
--- a/thunar/thunar-abstract-icon-view.c
+++ b/thunar/thunar-abstract-icon-view.c
@@ -85,6 +85,8 @@ static gboolean thunar_abstract_icon_view_motion_notify_event (ExoIconView
static void thunar_abstract_icon_view_item_activated (ExoIconView *view,
GtkTreePath *path,
ThunarAbstractIconView *abstract_icon_view);
+static gboolean thunar_abstract_icon_view_activate_cursor_item (ExoIconView *view,
+ ThunarAbstractIconView *abstract_icon_view);
static void thunar_abstract_icon_view_sort_column_changed (GtkTreeSortable *sortable,
ThunarAbstractIconView *abstract_icon_view);
static void thunar_abstract_icon_view_zoom_level_changed (ThunarAbstractIconView *abstract_icon_view);
@@ -202,6 +204,8 @@ 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_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);
@@ -492,7 +496,14 @@ thunar_abstract_icon_view_button_press_event (ExoIconView *view,
gboolean in_tab;
const gchar *action_name;
- if (event->type == GDK_BUTTON_PRESS && event->button == 3)
+ 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)
{
/* open the context menu on right clicks */
if (exo_icon_view_get_item_at_pos (view, event->x, event->y, &path, NULL))
@@ -750,10 +761,6 @@ 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");
@@ -764,6 +771,25 @@ G_GNUC_END_IGNORE_DEPRECATIONS
+static gboolean
+thunar_abstract_icon_view_activate_cursor_item (ExoIconView *view,
+ ThunarAbstractIconView *abstract_icon_view)
+{
+ GList *selected_items;
+
+ _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);
+
+ return TRUE;
+}
+
+
+
static void
thunar_abstract_icon_view_sort_column_changed (GtkTreeSortable *sortable,
ThunarAbstractIconView *abstract_icon_view)
diff --git a/thunar/thunar-details-view.c b/thunar/thunar-details-view.c
index 9409663..7cf634a 100644
--- a/thunar/thunar-details-view.c
+++ b/thunar/thunar-details-view.c
@@ -93,6 +93,9 @@ static void thunar_details_view_row_activated (GtkTreeView
GtkTreePath *path,
GtkTreeViewColumn *column,
ThunarDetailsView *details_view);
+static gboolean thunar_details_view_select_cursor_row (GtkTreeView *tree_view,
+ gboolean editing,
+ ThunarDetailsView *details_view);
static void thunar_details_view_row_changed (GtkTreeView *tree_view,
GtkTreePath *path,
GtkTreeViewColumn *column,
@@ -221,6 +224,8 @@ G_GNUC_END_IGNORE_DEPRECATIONS
G_CALLBACK (thunar_details_view_key_press_event), details_view);
g_signal_connect (G_OBJECT (tree_view), "row-activated",
G_CALLBACK (thunar_details_view_row_activated), details_view);
+ g_signal_connect (G_OBJECT (tree_view), "select-cursor-row",
+ G_CALLBACK (thunar_details_view_select_cursor_row), details_view);
gtk_container_add (GTK_CONTAINER (details_view), tree_view);
gtk_widget_show (tree_view);
@@ -837,10 +842,34 @@ thunar_details_view_row_activated (GtkTreeView *tree_view,
_thunar_return_if_fail (THUNAR_IS_DETAILS_VIEW (details_view));
- /* be sure to have only the double clicked item selected */
- 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");
+ if (G_LIKELY (action != NULL))
+ gtk_action_activate (action);
+G_GNUC_END_IGNORE_DEPRECATIONS
+}
+
+
+
+static gboolean
+thunar_details_view_select_cursor_row (GtkTreeView *tree_view,
+ gboolean editing,
+ ThunarDetailsView *details_view)
+{
+ /* This function is a work-around to fix bug #2487. The default gtk handler for
+ * the "select-cursor-row" signal changes the selection to just the cursor row,
+ * which prevents multiple file selections being opened. Thus we bypass the gtk
+ * signal handler with g_signal_stop_emission_by_name, and emit the "open" action
+ * directly. A better long-term solution would be to fix exo to avoid using the
+ * default gtk signal handler there.
+ */
+
+ GtkAction *action;
+
+ _thunar_return_val_if_fail (THUNAR_IS_DETAILS_VIEW (details_view), FALSE);
+
+ g_signal_stop_emission_by_name(tree_view,"select-cursor-row");
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
/* emit the "open" action */
@@ -848,6 +877,8 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
if (G_LIKELY (action != NULL))
gtk_action_activate (action);
G_GNUC_END_IGNORE_DEPRECATIONS
+
+ return TRUE;
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list