[nautilus/wip/antoniof/new-list-view-without-expanders: 3/13] view-icon-item-ui: Rename to NautilusGridCell




commit 9b71b6ef88200acccbd2939132a5da3f9fdd81bf
Author: António Fernandes <antoniof gnome org>
Date:   Wed Jun 8 10:46:35 2022 +0100

    view-icon-item-ui: Rename to NautilusGridCell
    
    Following the view rename, also rename the item widget.
    
    Upcoming NautilusViewClass subclasses are going to follow the same
    Nautilus*Class naming pattern.
    
    Also add missing copyright notice with SPDX licence id.

 po/POTFILES.in                                     |  2 +-
 src/meson.build                                    |  4 +-
 ...us-view-icon-item-ui.c => nautilus-grid-cell.c} | 58 ++++++++++++----------
 src/nautilus-grid-cell.h                           | 29 +++++++++++
 src/nautilus-grid-view.c                           | 50 +++++++++----------
 src/nautilus-view-icon-item-ui.h                   | 26 ----------
 src/resources/nautilus.gresource.xml               |  2 +-
 ...-view-icon-item-ui.ui => nautilus-grid-cell.ui} |  2 +-
 8 files changed, 91 insertions(+), 82 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index cea948da6..878a9022a 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -91,7 +91,7 @@ src/resources/ui/nautilus-starred-is-empty.ui
 src/resources/ui/nautilus-toolbar.ui
 src/resources/ui/nautilus-toolbar-view-menu.ui
 src/resources/ui/nautilus-trash-is-empty.ui
-src/resources/ui/nautilus-view-icon-item-ui.ui
+src/resources/ui/nautilus-grid-cell.ui
 src/resources/ui/nautilus-window.ui
 src/gtk/nautilusgtkplacesview.c
 src/gtk/nautilusgtkplacesviewrow.c
diff --git a/src/meson.build b/src/meson.build
index 7a1cd8b30..7cb59efc4 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-cell.c',
+  'nautilus-grid-cell.h',
   'nautilus-grid-view.c',
   'nautilus-grid-view.h',
   'nautilus-list-base.c',
@@ -128,8 +130,6 @@ libnautilus_sources = [
   'nautilus-view.h',
   'nautilus-view-cell.c',
   'nautilus-view-cell.h',
-  'nautilus-view-icon-item-ui.c',
-  'nautilus-view-icon-item-ui.h',
   'nautilus-view-item-model.c',
   'nautilus-view-item-model.h',
   'nautilus-view-model.c',
diff --git a/src/nautilus-view-icon-item-ui.c b/src/nautilus-grid-cell.c
similarity index 81%
rename from src/nautilus-view-icon-item-ui.c
rename to src/nautilus-grid-cell.c
index 4c5897a89..b1afcb504 100644
--- a/src/nautilus-view-icon-item-ui.c
+++ b/src/nautilus-grid-cell.c
@@ -1,6 +1,12 @@
-#include "nautilus-view-icon-item-ui.h"
+/*
+ * Copyright (C) 2022 The GNOME project contributors
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
 
-struct _NautilusViewIconItemUi
+#include "nautilus-grid-cell.h"
+
+struct _NautilusGridCell
 {
     NautilusViewCell parent_instance;
 
@@ -16,12 +22,12 @@ struct _NautilusViewIconItemUi
     GtkWidget *third_caption;
 };
 
-G_DEFINE_TYPE (NautilusViewIconItemUi, nautilus_view_icon_item_ui, NAUTILUS_TYPE_VIEW_CELL)
+G_DEFINE_TYPE (NautilusGridCell, nautilus_grid_cell, NAUTILUS_TYPE_VIEW_CELL)
 
 #define EXTRA_WIDTH_FOR_TEXT 36
 
 static void
-update_icon (NautilusViewIconItemUi *self)
+update_icon (NautilusGridCell *self)
 {
     NautilusViewItemModel *item;
     NautilusFileIconFlags flags;
@@ -66,7 +72,7 @@ update_icon (NautilusViewIconItemUi *self)
 }
 
 static void
-update_captions (NautilusViewIconItemUi *self)
+update_captions (NautilusGridCell *self)
 {
     NautilusViewItemModel *item;
     NautilusFile *file;
@@ -76,12 +82,12 @@ update_captions (NautilusViewIconItemUi *self)
         self->second_caption,
         self->third_caption
     };
-    G_STATIC_ASSERT (G_N_ELEMENTS (caption_labels) == NAUTILUS_VIEW_ICON_N_CAPTIONS);
+    G_STATIC_ASSERT (G_N_ELEMENTS (caption_labels) == NAUTILUS_GRID_CELL_N_CAPTIONS);
 
     item = nautilus_view_cell_get_item (NAUTILUS_VIEW_CELL (self));
     g_return_if_fail (item != NULL);
     file = nautilus_view_item_model_get_file (item);
-    for (guint i = 0; i < NAUTILUS_VIEW_ICON_N_CAPTIONS; i++)
+    for (guint i = 0; i < NAUTILUS_GRID_CELL_N_CAPTIONS; i++)
     {
         GQuark attribute_q = self->caption_attributes[i];
         gboolean show_caption;
@@ -98,7 +104,7 @@ update_captions (NautilusViewIconItemUi *self)
 }
 
 static void
-on_file_changed (NautilusViewIconItemUi *self)
+on_file_changed (NautilusGridCell *self)
 {
     NautilusViewItemModel *item;
     NautilusFile *file;
@@ -115,14 +121,14 @@ on_file_changed (NautilusViewIconItemUi *self)
 }
 
 static void
-on_item_size_changed (NautilusViewIconItemUi *self)
+on_item_size_changed (NautilusGridCell *self)
 {
     update_icon (self);
     update_captions (self);
 }
 
 static void
-on_item_is_cut_changed (NautilusViewIconItemUi *self)
+on_item_is_cut_changed (NautilusGridCell *self)
 {
     gboolean is_cut;
 
@@ -140,32 +146,32 @@ on_item_is_cut_changed (NautilusViewIconItemUi *self)
 static void
 finalize (GObject *object)
 {
-    NautilusViewIconItemUi *self = (NautilusViewIconItemUi *) object;
+    NautilusGridCell *self = (NautilusGridCell *) object;
 
     g_object_unref (self->item_signal_group);
-    G_OBJECT_CLASS (nautilus_view_icon_item_ui_parent_class)->finalize (object);
+    G_OBJECT_CLASS (nautilus_grid_cell_parent_class)->finalize (object);
 }
 
 static void
-nautilus_view_icon_item_ui_class_init (NautilusViewIconItemUiClass *klass)
+nautilus_grid_cell_class_init (NautilusGridCellClass *klass)
 {
     GObjectClass *object_class = G_OBJECT_CLASS (klass);
     GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
 
     object_class->finalize = finalize;
 
-    gtk_widget_class_set_template_from_resource (widget_class, 
"/org/gnome/nautilus/ui/nautilus-view-icon-item-ui.ui");
+    gtk_widget_class_set_template_from_resource (widget_class, 
"/org/gnome/nautilus/ui/nautilus-grid-cell.ui");
 
-    gtk_widget_class_bind_template_child (widget_class, NautilusViewIconItemUi, fixed_height_box);
-    gtk_widget_class_bind_template_child (widget_class, NautilusViewIconItemUi, icon);
-    gtk_widget_class_bind_template_child (widget_class, NautilusViewIconItemUi, label);
-    gtk_widget_class_bind_template_child (widget_class, NautilusViewIconItemUi, first_caption);
-    gtk_widget_class_bind_template_child (widget_class, NautilusViewIconItemUi, second_caption);
-    gtk_widget_class_bind_template_child (widget_class, NautilusViewIconItemUi, third_caption);
+    gtk_widget_class_bind_template_child (widget_class, NautilusGridCell, fixed_height_box);
+    gtk_widget_class_bind_template_child (widget_class, NautilusGridCell, icon);
+    gtk_widget_class_bind_template_child (widget_class, NautilusGridCell, label);
+    gtk_widget_class_bind_template_child (widget_class, NautilusGridCell, first_caption);
+    gtk_widget_class_bind_template_child (widget_class, NautilusGridCell, second_caption);
+    gtk_widget_class_bind_template_child (widget_class, NautilusGridCell, third_caption);
 }
 
 static void
-nautilus_view_icon_item_ui_init (NautilusViewIconItemUi *self)
+nautilus_grid_cell_init (NautilusGridCell *self)
 {
     gtk_widget_init_template (GTK_WIDGET (self));
 
@@ -199,17 +205,17 @@ nautilus_view_icon_item_ui_init (NautilusViewIconItemUi *self)
 #endif
 }
 
-NautilusViewIconItemUi *
-nautilus_view_icon_item_ui_new (NautilusListBase *view)
+NautilusGridCell *
+nautilus_grid_cell_new (NautilusListBase *view)
 {
-    return g_object_new (NAUTILUS_TYPE_VIEW_ICON_ITEM_UI,
+    return g_object_new (NAUTILUS_TYPE_GRID_CELL,
                          "view", view,
                          NULL);
 }
 
 void
-nautilus_view_item_ui_set_caption_attributes (NautilusViewIconItemUi *self,
-                                              GQuark                 *attrs)
+nautilus_grid_cell_set_caption_attributes (NautilusGridCell *self,
+                                           GQuark           *attrs)
 {
     self->caption_attributes = attrs;
 }
diff --git a/src/nautilus-grid-cell.h b/src/nautilus-grid-cell.h
new file mode 100644
index 000000000..52da1f81c
--- /dev/null
+++ b/src/nautilus-grid-cell.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2022 The GNOME project contributors
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#pragma once
+
+#include "nautilus-view-cell.h"
+
+G_BEGIN_DECLS
+
+enum
+{
+    NAUTILUS_GRID_CELL_FIRST_CAPTION,
+    NAUTILUS_GRID_CELL_SECOND_CAPTION,
+    NAUTILUS_GRID_CELL_THIRD_CAPTION,
+    NAUTILUS_GRID_CELL_N_CAPTIONS
+};
+
+#define NAUTILUS_TYPE_GRID_CELL (nautilus_grid_cell_get_type())
+
+G_DECLARE_FINAL_TYPE (NautilusGridCell, nautilus_grid_cell, NAUTILUS, GRID_CELL, NautilusViewCell)
+
+NautilusGridCell * nautilus_grid_cell_new (NautilusListBase *view);
+void nautilus_grid_cell_set_caption_attributes (NautilusGridCell *self,
+                                                GQuark           *attrs);
+
+G_END_DECLS
diff --git a/src/nautilus-grid-view.c b/src/nautilus-grid-view.c
index 2410bc657..d4ab61d6a 100644
--- a/src/nautilus-grid-view.c
+++ b/src/nautilus-grid-view.c
@@ -7,7 +7,7 @@
 #include "nautilus-list-base-private.h"
 #include "nautilus-grid-view.h"
 
-#include "nautilus-view-icon-item-ui.h"
+#include "nautilus-grid-cell.h"
 #include "nautilus-global-preferences.h"
 
 struct _NautilusGridView
@@ -21,7 +21,7 @@ struct _NautilusGridView
 
     gboolean directories_first;
 
-    GQuark caption_attributes[NAUTILUS_VIEW_ICON_N_CAPTIONS];
+    GQuark caption_attributes[NAUTILUS_GRID_CELL_N_CAPTIONS];
 
     NautilusFileSortType sort_type;
     gboolean reversed;
@@ -154,7 +154,7 @@ set_zoom_level (NautilusGridView *self,
     self->zoom_level = new_level;
 
     /* The zoom level may change how many captions are allowed. Update it before
-     * setting the icon size, under the assumption that NautilusViewIconItemUi
+     * setting the icon size, under the assumption that NautilusGridCell
      * updates captions whenever the icon size is set*/
     set_captions_from_preferences (self);
 
@@ -325,7 +325,7 @@ on_captions_preferences_changed (NautilusGridView *self)
 {
     set_captions_from_preferences (self);
 
-    /* Hack: this relies on the assumption that NautilusViewIconItemUi updates
+    /* Hack: this relies on the assumption that NautilusGridCell updates
      * captions whenever the icon size is set (even if it's the same value). */
     nautilus_list_base_set_icon_size (NAUTILUS_LIST_BASE (self),
                                       get_icon_size_for_zoom_level (self->zoom_level));
@@ -344,26 +344,26 @@ finalize (GObject *object)
 }
 
 static void
-bind_item_ui (GtkSignalListItemFactory *factory,
-              GtkListItem              *listitem,
-              gpointer                  user_data)
+bind_cell (GtkSignalListItemFactory *factory,
+           GtkListItem              *listitem,
+           gpointer                  user_data)
 {
-    GtkWidget *item_ui;
+    GtkWidget *cell;
     NautilusViewItemModel *item_model;
 
-    item_ui = gtk_list_item_get_child (listitem);
+    cell = gtk_list_item_get_child (listitem);
     item_model = NAUTILUS_VIEW_ITEM_MODEL (gtk_list_item_get_item (listitem));
 
-    nautilus_view_item_model_set_item_ui (item_model, item_ui);
+    nautilus_view_item_model_set_item_ui (item_model, cell);
 
-    if (nautilus_view_cell_once (NAUTILUS_VIEW_CELL (item_ui)))
+    if (nautilus_view_cell_once (NAUTILUS_VIEW_CELL (cell)))
     {
         GtkWidget *parent;
 
         /* At the time of ::setup emission, the item ui has got no parent yet,
          * that's why we need to complete the widget setup process here, on the
          * first time ::bind is emitted. */
-        parent = gtk_widget_get_parent (item_ui);
+        parent = gtk_widget_get_parent (cell);
         gtk_widget_set_halign (parent, GTK_ALIGN_CENTER);
         gtk_widget_set_valign (parent, GTK_ALIGN_START);
         gtk_widget_set_margin_top (parent, 3);
@@ -374,9 +374,9 @@ bind_item_ui (GtkSignalListItemFactory *factory,
 }
 
 static void
-unbind_item_ui (GtkSignalListItemFactory *factory,
-                GtkListItem              *listitem,
-                gpointer                  user_data)
+unbind_cell (GtkSignalListItemFactory *factory,
+             GtkListItem              *listitem,
+             gpointer                  user_data)
 {
     NautilusViewItemModel *item_model;
 
@@ -386,17 +386,17 @@ unbind_item_ui (GtkSignalListItemFactory *factory,
 }
 
 static void
-setup_item_ui (GtkSignalListItemFactory *factory,
-               GtkListItem              *listitem,
-               gpointer                  user_data)
+setup_cell (GtkSignalListItemFactory *factory,
+            GtkListItem              *listitem,
+            gpointer                  user_data)
 {
     NautilusGridView *self = NAUTILUS_GRID_VIEW (user_data);
-    NautilusViewIconItemUi *item_ui;
+    NautilusGridCell *cell;
 
-    item_ui = nautilus_view_icon_item_ui_new (NAUTILUS_LIST_BASE (self));
-    setup_cell_common (listitem, NAUTILUS_VIEW_CELL (item_ui));
+    cell = nautilus_grid_cell_new (NAUTILUS_LIST_BASE (self));
+    setup_cell_common (listitem, NAUTILUS_VIEW_CELL (cell));
 
-    nautilus_view_item_ui_set_caption_attributes (item_ui, self->caption_attributes);
+    nautilus_grid_cell_set_caption_attributes (cell, self->caption_attributes);
 }
 
 static GtkGridView *
@@ -409,9 +409,9 @@ create_view_ui (NautilusGridView *self)
     model = nautilus_list_base_get_model (NAUTILUS_LIST_BASE (self));
 
     factory = gtk_signal_list_item_factory_new ();
-    g_signal_connect (factory, "setup", G_CALLBACK (setup_item_ui), self);
-    g_signal_connect (factory, "bind", G_CALLBACK (bind_item_ui), self);
-    g_signal_connect (factory, "unbind", G_CALLBACK (unbind_item_ui), self);
+    g_signal_connect (factory, "setup", G_CALLBACK (setup_cell), self);
+    g_signal_connect (factory, "bind", G_CALLBACK (bind_cell), self);
+    g_signal_connect (factory, "unbind", G_CALLBACK (unbind_cell), self);
 
     widget = gtk_grid_view_new (GTK_SELECTION_MODEL (model), factory);
     gtk_widget_set_focusable (widget, TRUE);
diff --git a/src/resources/nautilus.gresource.xml b/src/resources/nautilus.gresource.xml
index 304814f75..8d5db0e18 100644
--- a/src/resources/nautilus.gresource.xml
+++ b/src/resources/nautilus.gresource.xml
@@ -25,7 +25,7 @@
     <file>ui/nautilus-file-conflict-dialog.ui</file>
     <file>ui/nautilus-files-view-select-items.ui</file>
     <file>ui/nautilus-operations-ui-manager-request-passphrase.ui</file>
-    <file>ui/nautilus-view-icon-item-ui.ui</file>
+    <file>ui/nautilus-grid-cell.ui</file>
     <file alias="gtk/ui/nautilusgtksidebarrow.ui">../gtk/nautilusgtksidebarrow.ui</file>
     <file alias="gtk/ui/nautilusgtkplacesview.ui">../gtk/nautilusgtkplacesview.ui</file>
     <file alias="gtk/ui/nautilusgtkplacesviewrow.ui">../gtk/nautilusgtkplacesviewrow.ui</file>
diff --git a/src/resources/ui/nautilus-view-icon-item-ui.ui b/src/resources/ui/nautilus-grid-cell.ui
similarity index 98%
rename from src/resources/ui/nautilus-view-icon-item-ui.ui
rename to src/resources/ui/nautilus-grid-cell.ui
index e614c538f..2a9417aa8 100644
--- a/src/resources/ui/nautilus-view-icon-item-ui.ui
+++ b/src/resources/ui/nautilus-grid-cell.ui
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <requires lib="gtk" version="4.0"/>
-  <template class="NautilusViewIconItemUi" parent="NautilusViewCell">
+  <template class="NautilusGridCell" parent="NautilusViewCell">
     <child>
       <object class="AdwClamp">
         <property name="maximum-size">0</property>


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