[nautilus/wip/antoniof/new-list-view-without-expanders: 6/13] view-item: Refine property definitions




commit c7bab4c314ce55a4ff603521de9341bf25a20e8c
Author: António Fernandes <antoniof gnome org>
Date:   Tue Jun 14 17:51:04 2022 +0100

    view-item: Refine property definitions
    
    Optimize code readability using a static param spec array.
    
    Replace useless "nick" and "description" with empty strings and
    pass G_PARAM_STATIC_STRINGS flag.
    
    Lower the minimum icon size to support upcoming list view.

 src/nautilus-view-item.c | 51 ++++++++++++++++++++----------------------------
 1 file changed, 21 insertions(+), 30 deletions(-)
---
diff --git a/src/nautilus-view-item.c b/src/nautilus-view-item.c
index daf186399..141046963 100644
--- a/src/nautilus-view-item.c
+++ b/src/nautilus-view-item.c
@@ -27,6 +27,8 @@ enum
     N_PROPS
 };
 
+static GParamSpec *properties[N_PROPS] = { NULL, };
+
 enum
 {
     FILE_CHANGED,
@@ -152,36 +154,25 @@ nautilus_view_item_class_init (NautilusViewItemClass *klass)
     object_class->get_property = nautilus_view_item_get_property;
     object_class->set_property = nautilus_view_item_set_property;
 
-    g_object_class_install_property (object_class,
-                                     PROP_ICON_SIZE,
-                                     g_param_spec_int ("icon-size",
-                                                       "Icon size",
-                                                       "The size in pixels of the icon",
-                                                       NAUTILUS_GRID_ICON_SIZE_SMALL,
-                                                       NAUTILUS_GRID_ICON_SIZE_LARGEST,
-                                                       NAUTILUS_GRID_ICON_SIZE_LARGE,
-                                                       G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-    g_object_class_install_property (object_class,
-                                     PROP_IS_CUT,
-                                     g_param_spec_boolean ("is-cut",
-                                                           "", "",
-                                                           FALSE,
-                                                           G_PARAM_READWRITE));
-    g_object_class_install_property (object_class,
-                                     PROP_FILE,
-                                     g_param_spec_object ("file",
-                                                          "File",
-                                                          "The file the icon item represents",
-                                                          NAUTILUS_TYPE_FILE,
-                                                          G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
-
-    g_object_class_install_property (object_class,
-                                     PROP_ITEM_UI,
-                                     g_param_spec_object ("item-ui",
-                                                          "Item ui",
-                                                          "The UI that reprensents the item model",
-                                                          GTK_TYPE_WIDGET,
-                                                          G_PARAM_READWRITE));
+    properties[PROP_ICON_SIZE] = g_param_spec_int ("icon-size",
+                                                   "", "",
+                                                   NAUTILUS_LIST_ICON_SIZE_SMALL,
+                                                   NAUTILUS_GRID_ICON_SIZE_LARGEST,
+                                                   NAUTILUS_GRID_ICON_SIZE_LARGE,
+                                                   G_PARAM_READWRITE | G_PARAM_CONSTRUCT | 
G_PARAM_STATIC_STRINGS);
+    properties[PROP_IS_CUT] = g_param_spec_boolean ("is-cut",
+                                                    "", "",
+                                                    FALSE,
+                                                    G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+    properties[PROP_FILE] = g_param_spec_object ("file",
+                                                 "", "",
+                                                 NAUTILUS_TYPE_FILE,
+                                                 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | 
G_PARAM_STATIC_STRINGS);
+    properties[PROP_ITEM_UI] = g_param_spec_object ("item-ui",
+                                                    "", "",
+                                                    GTK_TYPE_WIDGET,
+                                                    G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+    g_object_class_install_properties (object_class, N_PROPS, properties);
 
     signals[FILE_CHANGED] = g_signal_new ("file-changed",
                                           G_TYPE_FROM_CLASS (klass),


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