[nautilus/wip/antoniof/gtk4-preparation-step-event-controllers: 9/28] 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: 9/28] list-view: Remove duplicate click selection code
- Date: Tue, 21 Dec 2021 15:52:48 +0000 (UTC)
commit f83ef2f942c5d977fd3f824e3c727a7a5aa8da98
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 2e26247dc..fd77e2702 100644
--- a/src/nautilus-list-view.c
+++ b/src/nautilus-list-view.c
@@ -688,9 +688,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
@@ -700,7 +700,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
@@ -739,7 +742,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.
@@ -748,48 +754,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
@@ -818,6 +782,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]