[nautilus/wip/antoniof/new-list-view-without-expanders: 13/23] view-icon-controller: Rename to NautilusGridView




commit 02696936e6d475a45dfad1e122be5e1b53e88e7e
Author: António Fernandes <antoniof gnome org>
Date:   Sat Apr 9 00:21:20 2022 +0100

    view-icon-controller: Rename to NautilusGridView
    
    This is a clearer and shorter name.
    
    Also add missing copyright notice with SPDX licence id.

 src/meson.build                                    |  4 +-
 src/nautilus-files-view.c                          |  6 +-
 ...view-icon-controller.c => nautilus-grid-view.c} | 83 ++++++++++++----------
 src/nautilus-grid-view.h                           | 20 ++++++
 src/nautilus-view-icon-controller.h                | 17 -----
 5 files changed, 69 insertions(+), 61 deletions(-)
---
diff --git a/src/meson.build b/src/meson.build
index 3525c2f7c..7a1cd8b30 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -83,6 +83,8 @@ libnautilus_sources = [
   'nautilus-floating-bar.h',
   'nautilus-freedesktop-dbus.c',
   'nautilus-freedesktop-dbus.h',
+  'nautilus-grid-view.c',
+  'nautilus-grid-view.h',
   'nautilus-list-base.c',
   'nautilus-list-base.h',
   'nautilus-list-model.c',
@@ -126,8 +128,6 @@ libnautilus_sources = [
   'nautilus-view.h',
   'nautilus-view-cell.c',
   'nautilus-view-cell.h',
-  'nautilus-view-icon-controller.c',
-  'nautilus-view-icon-controller.h',
   'nautilus-view-icon-item-ui.c',
   'nautilus-view-icon-item-ui.h',
   'nautilus-view-item-model.c',
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index 12c08dd3b..7b59199cc 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -86,7 +86,7 @@
 #include "nautilus-trash-monitor.h"
 #include "nautilus-ui-utilities.h"
 #include "nautilus-view.h"
-#include "nautilus-view-icon-controller.h"
+#include "nautilus-grid-view.h"
 #include "nautilus-window.h"
 #include "nautilus-tracker-utilities.h"
 
@@ -3718,7 +3718,7 @@ done_loading (NautilusFilesView *view,
 
         if (do_reveal)
         {
-            if (NAUTILUS_IS_LIST_VIEW (view) || NAUTILUS_IS_VIEW_ICON_CONTROLLER (view))
+            if (NAUTILUS_IS_LIST_VIEW (view) || NAUTILUS_IS_GRID_VIEW (view))
             {
                 /* HACK: We should be able to directly call reveal_selection here,
                  * but at this point the GtkTreeView hasn't allocated the new nodes
@@ -9605,7 +9605,7 @@ nautilus_files_view_new (guint               id,
     {
         case NAUTILUS_VIEW_GRID_ID:
         {
-            view = NAUTILUS_FILES_VIEW (nautilus_view_icon_controller_new (slot));
+            view = NAUTILUS_FILES_VIEW (nautilus_grid_view_new (slot));
         }
         break;
 
diff --git a/src/nautilus-view-icon-controller.c b/src/nautilus-grid-view.c
similarity index 85%
rename from src/nautilus-view-icon-controller.c
rename to src/nautilus-grid-view.c
index 78652a019..ed4782111 100644
--- a/src/nautilus-view-icon-controller.c
+++ b/src/nautilus-grid-view.c
@@ -1,11 +1,16 @@
+/*
+ * Copyright (C) 2022 The GNOME project contributors
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
 #include "nautilus-list-base-private.h"
-#include "nautilus-view-icon-controller.h"
-#include "nautilus-view-item-model.h"
+#include "nautilus-grid-view.h"
+
 #include "nautilus-view-icon-item-ui.h"
-#include "nautilus-file.h"
 #include "nautilus-global-preferences.h"
 
-struct _NautilusViewIconController
+struct _NautilusGridView
 {
     NautilusListBase parent_instance;
 
@@ -22,16 +27,16 @@ struct _NautilusViewIconController
     gboolean reversed;
 };
 
-G_DEFINE_TYPE (NautilusViewIconController, nautilus_view_icon_controller, NAUTILUS_TYPE_LIST_BASE)
+G_DEFINE_TYPE (NautilusGridView, nautilus_grid_view, NAUTILUS_TYPE_LIST_BASE)
 
 static guint get_icon_size_for_zoom_level (NautilusGridZoomLevel zoom_level);
 
 static gint
-nautilus_view_icon_controller_sort (gconstpointer a,
-                                    gconstpointer b,
-                                    gpointer      user_data)
+nautilus_grid_view_sort (gconstpointer a,
+                         gconstpointer b,
+                         gpointer      user_data)
 {
-    NautilusViewIconController *self = user_data;
+    NautilusGridView *self = user_data;
     NautilusFile *file_a;
     NautilusFile *file_b;
 
@@ -48,7 +53,7 @@ static void
 real_bump_zoom_level (NautilusFilesView *files_view,
                       int                zoom_increment)
 {
-    NautilusViewIconController *self = NAUTILUS_VIEW_ICON_CONTROLLER (files_view);
+    NautilusGridView *self = NAUTILUS_GRID_VIEW (files_view);
     NautilusGridZoomLevel new_level;
 
     new_level = self->zoom_level + zoom_increment;
@@ -112,7 +117,7 @@ get_default_zoom_level (void)
 }
 
 static void
-set_captions_from_preferences (NautilusViewIconController *self)
+set_captions_from_preferences (NautilusGridView *self)
 {
     g_auto (GStrv) value = NULL;
     gint n_captions_for_zoom_level;
@@ -143,8 +148,8 @@ set_captions_from_preferences (NautilusViewIconController *self)
 }
 
 static void
-set_zoom_level (NautilusViewIconController *self,
-                guint                       new_level)
+set_zoom_level (NautilusGridView *self,
+                guint             new_level)
 {
     self->zoom_level = new_level;
 
@@ -162,9 +167,9 @@ set_zoom_level (NautilusViewIconController *self,
 static void
 real_restore_standard_zoom_level (NautilusFilesView *files_view)
 {
-    NautilusViewIconController *self;
+    NautilusGridView *self;
 
-    self = NAUTILUS_VIEW_ICON_CONTROLLER (files_view);
+    self = NAUTILUS_GRID_VIEW (files_view);
     g_action_group_change_action_state (self->action_group,
                                         "zoom-to-level",
                                         g_variant_new_int32 (NAUTILUS_GRID_ZOOM_LEVEL_LARGE));
@@ -173,10 +178,10 @@ real_restore_standard_zoom_level (NautilusFilesView *files_view)
 static gboolean
 real_is_zoom_level_default (NautilusFilesView *files_view)
 {
-    NautilusViewIconController *self;
+    NautilusGridView *self;
     guint icon_size;
 
-    self = NAUTILUS_VIEW_ICON_CONTROLLER (files_view);
+    self = NAUTILUS_GRID_VIEW (files_view);
     icon_size = get_icon_size_for_zoom_level (self->zoom_level);
 
     return icon_size == NAUTILUS_GRID_ICON_SIZE_LARGE;
@@ -185,7 +190,7 @@ real_is_zoom_level_default (NautilusFilesView *files_view)
 static gboolean
 real_can_zoom_in (NautilusFilesView *files_view)
 {
-    NautilusViewIconController *self = NAUTILUS_VIEW_ICON_CONTROLLER (files_view);
+    NautilusGridView *self = NAUTILUS_GRID_VIEW (files_view);
 
     return self->zoom_level < NAUTILUS_GRID_ZOOM_LEVEL_LARGEST;
 }
@@ -193,7 +198,7 @@ real_can_zoom_in (NautilusFilesView *files_view)
 static gboolean
 real_can_zoom_out (NautilusFilesView *files_view)
 {
-    NautilusViewIconController *self = NAUTILUS_VIEW_ICON_CONTROLLER (files_view);
+    NautilusGridView *self = NAUTILUS_GRID_VIEW (files_view);
 
     return self->zoom_level > NAUTILUS_GRID_ZOOM_LEVEL_SMALL;
 }
@@ -211,7 +216,7 @@ on_grid_view_item_activated (GtkGridView *grid_view,
                              guint        position,
                              gpointer     user_data)
 {
-    NautilusViewIconController *self = NAUTILUS_VIEW_ICON_CONTROLLER (user_data);
+    NautilusGridView *self = NAUTILUS_GRID_VIEW (user_data);
 
     nautilus_files_view_activate_selection (NAUTILUS_FILES_VIEW (self));
 }
@@ -219,7 +224,7 @@ on_grid_view_item_activated (GtkGridView *grid_view,
 static guint
 real_get_icon_size (NautilusListBase *files_model_view)
 {
-    NautilusViewIconController *self = NAUTILUS_VIEW_ICON_CONTROLLER (files_model_view);
+    NautilusGridView *self = NAUTILUS_GRID_VIEW (files_model_view);
 
     return get_icon_size_for_zoom_level (self->zoom_level);
 }
@@ -227,7 +232,7 @@ real_get_icon_size (NautilusListBase *files_model_view)
 static GtkWidget *
 real_get_view_ui (NautilusListBase *files_model_view)
 {
-    NautilusViewIconController *self = NAUTILUS_VIEW_ICON_CONTROLLER (files_model_view);
+    NautilusGridView *self = NAUTILUS_GRID_VIEW (files_model_view);
 
     return GTK_WIDGET (self->view_ui);
 }
@@ -236,7 +241,7 @@ static void
 real_scroll_to_item (NautilusListBase *files_model_view,
                      guint             position)
 {
-    NautilusViewIconController *self = NAUTILUS_VIEW_ICON_CONTROLLER (files_model_view);
+    NautilusGridView *self = NAUTILUS_GRID_VIEW (files_model_view);
 
     gtk_widget_activate_action (GTK_WIDGET (self->view_ui),
                                 "list.scroll-to-item",
@@ -247,15 +252,15 @@ real_scroll_to_item (NautilusListBase *files_model_view,
 static void
 real_sort_directories_first_changed (NautilusFilesView *files_view)
 {
-    NautilusViewIconController *self;
+    NautilusGridView *self;
     NautilusViewModel *model;
     g_autoptr (GtkCustomSorter) sorter = NULL;
 
-    self = NAUTILUS_VIEW_ICON_CONTROLLER (files_view);
+    self = NAUTILUS_GRID_VIEW (files_view);
     self->directories_first = nautilus_files_view_should_sort_directories_first (NAUTILUS_FILES_VIEW (self));
 
     model = nautilus_list_base_get_model (NAUTILUS_LIST_BASE (self));
-    sorter = gtk_custom_sorter_new (nautilus_view_icon_controller_sort, self, NULL);
+    sorter = gtk_custom_sorter_new (nautilus_grid_view_sort, self, NULL);
     nautilus_view_model_set_sorter (model, GTK_SORTER (sorter));
 }
 
@@ -265,7 +270,7 @@ action_sort_order_changed (GSimpleAction *action,
                            gpointer       user_data)
 {
     const gchar *target_name;
-    NautilusViewIconController *self = NAUTILUS_VIEW_ICON_CONTROLLER (user_data);
+    NautilusGridView *self = NAUTILUS_GRID_VIEW (user_data);
     NautilusViewModel *model;
     g_autoptr (GtkCustomSorter) sorter = NULL;
 
@@ -278,7 +283,7 @@ action_sort_order_changed (GSimpleAction *action,
     g_variant_get (value, "(&sb)", &target_name, &self->reversed);
     self->sort_type = get_sorts_type_from_metadata_text (target_name);
 
-    sorter = gtk_custom_sorter_new (nautilus_view_icon_controller_sort, self, NULL);
+    sorter = gtk_custom_sorter_new (nautilus_grid_view_sort, self, NULL);
     model = nautilus_list_base_get_model (NAUTILUS_LIST_BASE (self));
     nautilus_view_model_set_sorter (model, GTK_SORTER (sorter));
     set_directory_sort_metadata (nautilus_files_view_get_directory_as_file (NAUTILUS_FILES_VIEW (self)),
@@ -299,7 +304,7 @@ action_zoom_to_level (GSimpleAction *action,
                       GVariant      *state,
                       gpointer       user_data)
 {
-    NautilusViewIconController *self = NAUTILUS_VIEW_ICON_CONTROLLER (user_data);
+    NautilusGridView *self = NAUTILUS_GRID_VIEW (user_data);
     int zoom_level;
 
     zoom_level = g_variant_get_int32 (state);
@@ -316,7 +321,7 @@ action_zoom_to_level (GSimpleAction *action,
 }
 
 static void
-on_captions_preferences_changed (NautilusViewIconController *self)
+on_captions_preferences_changed (NautilusGridView *self)
 {
     set_captions_from_preferences (self);
 
@@ -329,13 +334,13 @@ on_captions_preferences_changed (NautilusViewIconController *self)
 static void
 dispose (GObject *object)
 {
-    G_OBJECT_CLASS (nautilus_view_icon_controller_parent_class)->dispose (object);
+    G_OBJECT_CLASS (nautilus_grid_view_parent_class)->dispose (object);
 }
 
 static void
 finalize (GObject *object)
 {
-    G_OBJECT_CLASS (nautilus_view_icon_controller_parent_class)->finalize (object);
+    G_OBJECT_CLASS (nautilus_grid_view_parent_class)->finalize (object);
 }
 
 static void
@@ -385,7 +390,7 @@ setup_item_ui (GtkSignalListItemFactory *factory,
                GtkListItem              *listitem,
                gpointer                  user_data)
 {
-    NautilusViewIconController *self = NAUTILUS_VIEW_ICON_CONTROLLER (user_data);
+    NautilusGridView *self = NAUTILUS_GRID_VIEW (user_data);
     NautilusViewIconItemUi *item_ui;
 
     item_ui = nautilus_view_icon_item_ui_new (NAUTILUS_LIST_BASE (self));
@@ -395,7 +400,7 @@ setup_item_ui (GtkSignalListItemFactory *factory,
 }
 
 static GtkGridView *
-create_view_ui (NautilusViewIconController *self)
+create_view_ui (NautilusGridView *self)
 {
     NautilusViewModel *model;
     GtkListItemFactory *factory;
@@ -437,7 +442,7 @@ const GActionEntry view_icon_actions[] =
 };
 
 static void
-nautilus_view_icon_controller_class_init (NautilusViewIconControllerClass *klass)
+nautilus_grid_view_class_init (NautilusGridViewClass *klass)
 {
     GObjectClass *object_class = G_OBJECT_CLASS (klass);
     NautilusFilesViewClass *files_view_class = NAUTILUS_FILES_VIEW_CLASS (klass);
@@ -460,7 +465,7 @@ nautilus_view_icon_controller_class_init (NautilusViewIconControllerClass *klass
 }
 
 static void
-nautilus_view_icon_controller_init (NautilusViewIconController *self)
+nautilus_grid_view_init (NautilusGridView *self)
 {
     GtkWidget *content_widget;
 
@@ -494,10 +499,10 @@ nautilus_view_icon_controller_init (NautilusViewIconController *self)
                                         "zoom-to-level", g_variant_new_int32 (self->zoom_level));
 }
 
-NautilusViewIconController *
-nautilus_view_icon_controller_new (NautilusWindowSlot *slot)
+NautilusGridView *
+nautilus_grid_view_new (NautilusWindowSlot *slot)
 {
-    return g_object_new (NAUTILUS_TYPE_VIEW_ICON_CONTROLLER,
+    return g_object_new (NAUTILUS_TYPE_GRID_VIEW,
                          "window-slot", slot,
                          NULL);
 }
diff --git a/src/nautilus-grid-view.h b/src/nautilus-grid-view.h
new file mode 100644
index 000000000..4c8835fcb
--- /dev/null
+++ b/src/nautilus-grid-view.h
@@ -0,0 +1,20 @@
+/*
+ * Copyright (C) 2022 The GNOME project contributors
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#pragma once
+
+#include "nautilus-list-base.h"
+#include "nautilus-window-slot.h"
+
+G_BEGIN_DECLS
+
+#define NAUTILUS_TYPE_GRID_VIEW (nautilus_grid_view_get_type())
+
+G_DECLARE_FINAL_TYPE (NautilusGridView, nautilus_grid_view, NAUTILUS, GRID_VIEW, NautilusListBase)
+
+NautilusGridView *nautilus_grid_view_new (NautilusWindowSlot *slot);
+
+G_END_DECLS


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