[gtk/wip/otte/listview: 2097/2170] listview: Implement (un)select all
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/otte/listview: 2097/2170] listview: Implement (un)select all
- Date: Sun, 24 May 2020 17:15:34 +0000 (UTC)
commit 0362a42b6ac8439052b26119c6b9f834d58c17fb
Author: Benjamin Otte <otte redhat com>
Date: Wed Oct 16 01:59:01 2019 +0200
listview: Implement (un)select all
Adds listitem.select-all and listitem.unselect-all actions and installs
the same keybindings as the treeview for those actions.
gtk/gtklistview.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 54 insertions(+)
---
diff --git a/gtk/gtklistview.c b/gtk/gtklistview.c
index 7650918db3..6eb896e79c 100644
--- a/gtk/gtklistview.c
+++ b/gtk/gtklistview.c
@@ -905,6 +905,32 @@ gtk_list_view_select_item_action (GtkWidget *widget,
gtk_list_view_select_item (self, pos, modify, extend);
}
+static void
+gtk_list_view_select_all (GtkWidget *widget,
+ const char *action_name,
+ GVariant *parameter)
+{
+ GtkListView *self = GTK_LIST_VIEW (widget);
+ GtkSelectionModel *selection_model;
+
+ selection_model = gtk_list_item_manager_get_model (self->item_manager);
+
+ gtk_selection_model_select_all (selection_model);
+}
+
+static void
+gtk_list_view_unselect_all (GtkWidget *widget,
+ const char *action_name,
+ GVariant *parameter)
+{
+ GtkListView *self = GTK_LIST_VIEW (widget);
+ GtkSelectionModel *selection_model;
+
+ selection_model = gtk_list_item_manager_get_model (self->item_manager);
+
+ gtk_selection_model_unselect_all (selection_model);
+}
+
static void
gtk_list_view_scroll_to_item (GtkWidget *widget,
const char *action_name,
@@ -1111,6 +1137,28 @@ gtk_list_view_class_init (GtkListViewClass *klass)
"(ubb)",
gtk_list_view_select_item_action);
+ /**
+ * GtkListView|list.select-all:
+ *
+ * If the selection model supports it, select all items in the model.
+ * If not, do nothing.
+ */
+ gtk_widget_class_install_action (widget_class,
+ "list.select-all",
+ NULL,
+ gtk_list_view_select_all);
+
+ /**
+ * GtkListView|list.unselect-all:
+ *
+ * If the selection model supports it, unselect all items in the model.
+ * If not, do nothing.
+ */
+ gtk_widget_class_install_action (widget_class,
+ "list.unselect-all",
+ NULL,
+ gtk_list_view_unselect_all);
+
/**
* GtkListView|list.scroll-to-item:
* @position: position of item to scroll to
@@ -1123,6 +1171,12 @@ gtk_list_view_class_init (GtkListViewClass *klass)
"u",
gtk_list_view_scroll_to_item);
+ 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);
+
gtk_widget_class_set_css_name (widget_class, I_("list"));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]