[nautilus/wip/antoniof/flow-box-preparation: 41/48] view-icon-controller: Implement .invert_selection()




commit 7d0927f67a9e5026688ad5f4b2160e25f05c4450
Author: António Fernandes <antoniof gnome org>
Date:   Wed Dec 8 00:52:30 2021 +0000

    view-icon-controller: Implement .invert_selection()

 src/nautilus-view-icon-controller.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
---
diff --git a/src/nautilus-view-icon-controller.c b/src/nautilus-view-icon-controller.c
index e9438c5eb..819b11e13 100644
--- a/src/nautilus-view-icon-controller.c
+++ b/src/nautilus-view-icon-controller.c
@@ -381,6 +381,22 @@ real_select_all (NautilusFilesView *files_view)
     gtk_flow_box_select_all (self->view_ui);
 }
 
+static void
+real_invert_selection (NautilusFilesView *files_view)
+{
+    NautilusViewIconController *self = NAUTILUS_VIEW_ICON_CONTROLLER (files_view);
+    g_autoptr (GList) selected_children = NULL;
+
+    selected_children = gtk_flow_box_get_selected_children (self->view_ui);
+
+    /* First select all, then unselect the previously selected children. */
+    gtk_flow_box_select_all (self->view_ui);
+    for (GList *l = selected_children; l != NULL; l = l->next)
+    {
+        gtk_flow_box_unselect_child (self->view_ui, GTK_FLOW_BOX_CHILD (l->data));
+    }
+}
+
 static GtkWidget *
 get_first_selected_item_ui (NautilusViewIconController *self)
 {
@@ -1187,6 +1203,7 @@ nautilus_view_icon_controller_class_init (NautilusViewIconControllerClass *klass
     files_view_class->update_actions_state = real_update_actions_state;
     files_view_class->reveal_selection = real_reveal_selection;
     files_view_class->select_all = real_select_all;
+    files_view_class->invert_selection = real_invert_selection;
     files_view_class->set_selection = real_set_selection;
     files_view_class->compare_files = real_compare_files;
     files_view_class->sort_directories_first_changed = real_sort_directories_first_changed;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]