[nautilus/wip/antoniof/flow-box-preparation: 35/68] icon-controller: Simplify ::set_selection() implementation




commit 66a523b3d533b6dcec150ef281c7f172c196f492
Author: António Fernandes <antoniof gnome org>
Date:   Wed Aug 25 13:27:02 2021 +0100

    icon-controller: Simplify ::set_selection() implementation

 src/nautilus-view-icon-controller.c | 11 ++++++++++-
 src/nautilus-view-icon-ui.c         | 30 ------------------------------
 src/nautilus-view-icon-ui.h         |  6 +-----
 3 files changed, 11 insertions(+), 36 deletions(-)
---
diff --git a/src/nautilus-view-icon-controller.c b/src/nautilus-view-icon-controller.c
index 5c817589b..5d8b4c6ab 100644
--- a/src/nautilus-view-icon-controller.c
+++ b/src/nautilus-view-icon-controller.c
@@ -368,7 +368,16 @@ real_set_selection (NautilusFilesView *files_view,
 
     selection_files = convert_glist_to_queue (selection);
     selection_item_models = nautilus_view_model_get_items_from_files (self->model, selection_files);
-    nautilus_view_icon_ui_set_selection (self->view_ui, selection_item_models);
+
+    gtk_flow_box_unselect_all (GTK_FLOW_BOX (self->view_ui));
+    for (GList *l = g_queue_peek_head_link (selection_item_models); l != NULL ; l = l->next)
+    {
+        GtkWidget *item_ui;
+
+        item_ui = nautilus_view_item_model_get_item_ui (NAUTILUS_VIEW_ITEM_MODEL (l->data));
+        gtk_flow_box_select_child (GTK_FLOW_BOX (self->view_ui), GTK_FLOW_BOX_CHILD (item_ui));
+    }
+
     nautilus_files_view_notify_selection_changed (files_view);
 }
 
diff --git a/src/nautilus-view-icon-ui.c b/src/nautilus-view-icon-ui.c
index 05af3de77..299ca4a3d 100644
--- a/src/nautilus-view-icon-ui.c
+++ b/src/nautilus-view-icon-ui.c
@@ -98,36 +98,6 @@ set_property (GObject      *object,
     }
 }
 
-void
-nautilus_view_icon_ui_set_selection (NautilusViewIconUi *self,
-                                     GQueue             *selection)
-{
-    NautilusViewItemModel *item_model;
-    NautilusViewModel *model;
-    gint i = 0;
-
-    model = nautilus_view_icon_controller_get_model (self->controller);
-    while ((item_model = NAUTILUS_VIEW_ITEM_MODEL (g_list_model_get_item (G_LIST_MODEL (model), i))))
-    {
-        GtkWidget *item_ui;
-
-        item_ui = nautilus_view_item_model_get_item_ui (item_model);
-        if (g_queue_find (selection, item_model) != NULL)
-        {
-            gtk_flow_box_select_child (GTK_FLOW_BOX (self),
-                                       GTK_FLOW_BOX_CHILD (item_ui));
-        }
-        else
-        {
-            gtk_flow_box_unselect_child (GTK_FLOW_BOX (self),
-                                         GTK_FLOW_BOX_CHILD (item_ui));
-        }
-
-        i++;
-    }
-}
-
-
 static GtkWidget *
 create_widget_func (gpointer item,
                     gpointer user_data)
diff --git a/src/nautilus-view-icon-ui.h b/src/nautilus-view-icon-ui.h
index 4e1871d23..e8be3bfc0 100644
--- a/src/nautilus-view-icon-ui.h
+++ b/src/nautilus-view-icon-ui.h
@@ -30,9 +30,5 @@ G_BEGIN_DECLS
 G_DECLARE_FINAL_TYPE (NautilusViewIconUi, nautilus_view_icon_ui, NAUTILUS, VIEW_ICON_UI, GtkFlowBox)
 
 NautilusViewIconUi * nautilus_view_icon_ui_new (NautilusViewIconController *controller);
-/* TODO: this should become the "nautilus_view_set_selection" once we have a proper
- * MVC also in the nautilus-view level. */
-void nautilus_view_icon_ui_set_selection (NautilusViewIconUi *self,
-                                          GQueue             *selection);
 
-G_END_DECLS
\ No newline at end of file
+G_END_DECLS


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