summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntónio Fernandes <antoniojpfernandes@gmail.com>2018-03-21 22:06:52 +0000
committerAntónio Fernandes <antoniojpfernandes@gmail.com>2018-03-21 22:06:52 +0000
commitb5eb9b14806bd2b4a5cd9dd57633b6d970fff059 (patch)
tree02ba812b1b7f46508052d8179a81125102bc89dd
parent9c9eba547b8a54eac606dadd2b4b8bf10581ac5e (diff)
parent315d14585bf40188780d9433887a7b3681d28eb4 (diff)
downloadnautilus-b5eb9b14806bd2b4a5cd9dd57633b6d970fff059.tar.gz
Merge AlexFazakas's list view selection fixes
list-view: Allow right clicking expanders list-view: Make list view selection consistent See merge request GNOME/nautilus!131
-rw-r--r--meson.build2
-rw-r--r--src/nautilus-list-view.c72
2 files changed, 61 insertions, 13 deletions
diff --git a/meson.build b/meson.build
index 99126aadb..cd3006932 100644
--- a/meson.build
+++ b/meson.build
@@ -79,7 +79,7 @@ glib = dependency('glib-2.0', version: glib_ver)
gmodule = dependency('gmodule-no-export-2.0', version: glib_ver)
gnome_autoar = dependency('gnome-autoar-0', version: '>= 0.2.1')
gnome_desktop = dependency('gnome-desktop-3.0', version: '>= 3.0.0')
-gtk = dependency('gtk+-3.0', version: '>= 3.22.26')
+gtk = dependency('gtk+-3.0', version: '>= 3.22.27')
selinux = []
if get_option('selinux')
selinux = dependency('libselinux', version: '>= 2.0')
diff --git a/src/nautilus-list-view.c b/src/nautilus-list-view.c
index c69f14394..d8a4e9104 100644
--- a/src/nautilus-list-view.c
+++ b/src/nautilus-list-view.c
@@ -678,15 +678,66 @@ button_press_callback (GtkWidget *widget,
}
else
{
- /* We're going to filter out some situations where
- * we can't let the default code run because all
- * but one row would be would be deselected. We don't
- * want that; we want the right click menu or single
- * click to apply to everything that's currently selected.
- */
- if (event->button == GDK_BUTTON_SECONDARY && path_selected)
+ g_autoptr (GtkTreePath) cursor = NULL;
+ GList *selected_rows = NULL;
+ if (event->button == GDK_BUTTON_SECONDARY)
{
- call_parent = FALSE;
+ if (path_selected)
+ {
+ /* We're going to filter out some situations where
+ * we can't let the default code run because all
+ * but one row would be would be deselected. We don't
+ * want that; we want the right click menu or single
+ * click to apply to everything that's currently selected.
+ */
+ call_parent = FALSE;
+ }
+ else if ((event->state & GDK_CONTROL_MASK) != 0)
+ {
+ /* If CTRL is pressed, we don't allow the parent
+ * class to handle it, since GtkTreeView doesn't
+ * do it as intended currently.
+ */
+ call_parent = FALSE;
+ if ((event->state & GDK_SHIFT_MASK) != 0)
+ {
+ /* This is the CTRL+SHIFT selection mode which
+ * we handleourselves, as the parent class would
+ * otherwise do an unexpected selection.
+ */
+ gtk_tree_view_get_cursor (tree_view, &cursor, NULL);
+ if (cursor != NULL)
+ {
+ gtk_tree_selection_select_range (selection, cursor, path);
+ }
+ else
+ {
+ gtk_tree_selection_select_path (selection, path);
+ }
+ }
+ else
+ {
+ gtk_tree_selection_select_path (selection, path);
+ }
+ selected_rows = gtk_tree_selection_get_selected_rows (selection, NULL);
+
+ /* This unselects everything */
+ gtk_tree_view_set_cursor (tree_view, path, NULL, FALSE);
+
+ /* So select it again */
+ for (GList *l = selected_rows; l != NULL; l = l->next)
+ {
+ gtk_tree_selection_select_path (selection, l->data);
+ }
+ g_list_free_full (selected_rows, (GDestroyNotify) gtk_tree_path_free);
+ }
+ else if (on_expander)
+ {
+ /* If the right click happened on an expander, we should
+ * fully change the selection on that row solely.
+ */
+ gtk_tree_view_set_cursor (tree_view, path, NULL, FALSE);
+ }
}
if ((event->button == GDK_BUTTON_PRIMARY || event->button == GDK_BUTTON_MIDDLE) &&
@@ -701,12 +752,9 @@ button_press_callback (GtkWidget *widget,
}
else if ((event->state & GDK_CONTROL_MASK) != 0)
{
- GList *selected_rows, *l;
-
call_parent = FALSE;
if ((event->state & GDK_SHIFT_MASK) != 0)
{
- GtkTreePath *cursor;
gtk_tree_view_get_cursor (tree_view, &cursor, NULL);
if (cursor != NULL)
{
@@ -727,7 +775,7 @@ button_press_callback (GtkWidget *widget,
gtk_tree_view_set_cursor (tree_view, path, NULL, FALSE);
/* So select it again */
- for (l = selected_rows; l != NULL; l = l->next)
+ for (GList *l = selected_rows; l != NULL; l = l->next)
{
gtk_tree_selection_select_path (selection, l->data);
}