[nautilus/wip/antoniof/gtk4-preparation-step-event-controllers: 3/22] list-view: Remove duplicate click selection code
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/antoniof/gtk4-preparation-step-event-controllers: 3/22] list-view: Remove duplicate click selection code
- Date: Wed, 22 Dec 2021 01:38:20 +0000 (UTC)
commit 3aa30d8bc82c02262b200eaa270df94f1673464f
Author: António Fernandes <antoniof gnome org>
Date: Wed Aug 11 23:25:01 2021 +0100
list-view: Remove duplicate click selection code
Primary and secondary click have similar code for handling selection
with modifiers, with some corner case inconsistencies.
Unifying the code path resolves the inconsistencies and simplifies the
code.
src/nautilus-list-view.c | 57 ++++++++++--------------------------------------
1 file changed, 11 insertions(+), 46 deletions(-)
---
diff --git a/src/nautilus-list-view.c b/src/nautilus-list-view.c
index 3ae90ef8d..7731f407c 100644
--- a/src/nautilus-list-view.c
+++ b/src/nautilus-list-view.c
@@ -625,9 +625,9 @@ on_tree_view_multi_press_gesture_pressed (GtkGestureMultiPress *gesture,
gdk_event_get_state (event, &state);
- if (button == GDK_BUTTON_SECONDARY)
+ if (path_selected)
{
- if (path_selected)
+ if ((state & GDK_SHIFT_MASK) == 0)
{
/* We're going to filter out some situations where
* we can't let the default code run because all
@@ -637,7 +637,10 @@ on_tree_view_multi_press_gesture_pressed (GtkGestureMultiPress *gesture,
*/
call_parent = FALSE;
}
- else if ((state & GDK_CONTROL_MASK) != 0)
+ }
+ else
+ {
+ if ((state & GDK_CONTROL_MASK) != 0)
{
/* If CTRL is pressed, we don't allow the parent
* class to handle it, since GtkTreeView doesn't
@@ -676,7 +679,10 @@ on_tree_view_multi_press_gesture_pressed (GtkGestureMultiPress *gesture,
}
g_list_free_full (selected_rows, (GDestroyNotify) gtk_tree_path_free);
}
- else if (on_expander)
+
+ if (button == GDK_BUTTON_SECONDARY &&
+ on_expander &&
+ !button_event_modifies_selection (event))
{
/* If the right click happened on an expander, we should
* fully change the selection on that row solely.
@@ -685,48 +691,6 @@ on_tree_view_multi_press_gesture_pressed (GtkGestureMultiPress *gesture,
}
}
- if ((button == GDK_BUTTON_PRIMARY || button == GDK_BUTTON_MIDDLE) &&
- ((state & GDK_CONTROL_MASK) != 0 || (state & GDK_SHIFT_MASK) == 0))
- {
- view->details->row_selected_on_button_down = path_selected;
-
- if (path_selected)
- {
- call_parent = on_expander;
- }
- else if ((state & GDK_CONTROL_MASK) != 0)
- {
- call_parent = FALSE;
- if ((state & GDK_SHIFT_MASK) != 0)
- {
- 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);
- }
- }
-
if (is_simple_click && on_expander)
{
/* Need to let the event propagate down, since propagating up
@@ -755,6 +719,7 @@ on_tree_view_multi_press_gesture_pressed (GtkGestureMultiPress *gesture,
view->details->drag_button = button;
view->details->drag_x = bin_x;
view->details->drag_y = bin_y;
+ view->details->row_selected_on_button_down = path_selected;
}
if (button == GDK_BUTTON_SECONDARY)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]