macos: shortcuts for GtkListBase and GtkListBox

Select all and multi-select and toggle selection.
This commit is contained in:
Arjan Molenaar 2024-05-21 22:35:04 +02:00
parent 6fa23794fc
commit 613a004d18
3 changed files with 27 additions and 0 deletions

View File

@ -1327,10 +1327,15 @@ gtk_list_base_class_init (GtkListBaseClass *klass)
gtk_list_base_add_custom_move_binding (widget_class, GDK_KEY_Page_Down, gtk_list_base_move_cursor_page_down);
gtk_list_base_add_custom_move_binding (widget_class, GDK_KEY_KP_Page_Down, gtk_list_base_move_cursor_page_down);
#ifdef __APPLE__
gtk_widget_class_add_binding_action (widget_class, GDK_KEY_a, GDK_META_MASK, "list.select-all", NULL);
gtk_widget_class_add_binding_action (widget_class, GDK_KEY_A, GDK_META_MASK | GDK_SHIFT_MASK, "list.unselect-all", NULL);
#else
gtk_widget_class_add_binding_action (widget_class, GDK_KEY_a, GDK_CONTROL_MASK, "list.select-all", NULL);
gtk_widget_class_add_binding_action (widget_class, GDK_KEY_slash, GDK_CONTROL_MASK, "list.select-all", NULL);
gtk_widget_class_add_binding_action (widget_class, GDK_KEY_A, GDK_CONTROL_MASK | GDK_SHIFT_MASK, "list.unselect-all", NULL);
gtk_widget_class_add_binding_action (widget_class, GDK_KEY_backslash, GDK_CONTROL_MASK, "list.unselect-all", NULL);
#endif
}
static gboolean
@ -1858,6 +1863,11 @@ get_selection_modifiers (GtkGesture *gesture,
*modify = TRUE;
if ((state & GDK_SHIFT_MASK) == GDK_SHIFT_MASK)
*extend = TRUE;
#ifdef __APPLE__
if ((state & GDK_META_MASK) == GDK_META_MASK)
*modify = TRUE;
#endif
}
static void

View File

@ -741,6 +741,16 @@ gtk_list_box_class_init (GtkListBoxClass *klass)
"toggle-cursor-row",
NULL);
#ifdef __APPLE__
gtk_widget_class_add_binding_signal (widget_class,
GDK_KEY_a, GDK_META_MASK,
"select-all",
NULL);
gtk_widget_class_add_binding_signal (widget_class,
GDK_KEY_a, GDK_META_MASK | GDK_SHIFT_MASK,
"unselect-all",
NULL);
#else
gtk_widget_class_add_binding_signal (widget_class,
GDK_KEY_a, GDK_CONTROL_MASK,
"select-all",
@ -749,6 +759,7 @@ gtk_list_box_class_init (GtkListBoxClass *klass)
GDK_KEY_a, GDK_CONTROL_MASK | GDK_SHIFT_MASK,
"unselect-all",
NULL);
#endif
gtk_widget_class_set_css_name (widget_class, I_("list"));
gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_LIST);
@ -1950,6 +1961,9 @@ gtk_list_box_click_gesture_released (GtkGestureClick *gesture,
state = gdk_event_get_modifier_state (event);
extend = (state & GDK_SHIFT_MASK) != 0;
modify = (state & GDK_CONTROL_MASK) != 0;
#ifdef __APPLE__
modify = modify | ((state & GDK_META_MASK) != 0);
#endif
source = gdk_device_get_source (gdk_event_get_device (event));
if (source == GDK_SOURCE_TOUCHSCREEN)

View File

@ -465,6 +465,9 @@ gtk_list_factory_widget_click_gesture_released (GtkGestureClick *gesture,
state = gdk_event_get_modifier_state (event);
extend = (state & GDK_SHIFT_MASK) != 0;
modify = (state & GDK_CONTROL_MASK) != 0;
#ifdef __APPLE__
modify = modify | ((state & GDK_META_MASK) != 0);
#endif
gtk_widget_activate_action (GTK_WIDGET (self),
"list.select-item",