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




commit fad1dd57f84f0f041b8f24d19b36dcc81fce8aba
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 93918b0a5..172291fad 100644
--- a/src/nautilus-view-icon-controller.c
+++ b/src/nautilus-view-icon-controller.c
@@ -383,6 +383,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)
 {
@@ -1258,6 +1274,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]