[nautilus/wip/antoniof/flow-box-preparation] WIP view-icon-controller: Implement captions



commit 93fcf006db2c5f9bcccc1cfeb93ff24402c6f8c5
Author: António Fernandes <antoniof gnome org>
Date:   Fri Dec 10 20:30:39 2021 +0000

    WIP view-icon-controller: Implement captions

 src/nautilus-view-icon-controller.c | 42 +++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
---
diff --git a/src/nautilus-view-icon-controller.c b/src/nautilus-view-icon-controller.c
index 80653439b..17c908c5f 100644
--- a/src/nautilus-view-icon-controller.c
+++ b/src/nautilus-view-icon-controller.c
@@ -19,6 +19,9 @@ struct _NautilusViewIconController
     GIcon *view_icon;
     GActionGroup *action_group;
     gint zoom_level;
+    GQuark first_caption_attribute_q;
+    GQuark second_caption_attribute_q;
+    GQuark third_caption_attribute_q;
 
     gboolean single_click_mode;
     gboolean activate_on_release;
@@ -1134,6 +1137,39 @@ action_zoom_to_level (GSimpleAction *action,
     }
 }
 
+static void
+set_captions_from_preferences (NautilusViewIconController *self)
+{
+    g_auto (GStrv) value = NULL;
+    GQuark quark_array[3] = {0, 0, 0};
+
+    value = g_settings_get_strv (nautilus_icon_view_preferences,
+                                 NAUTILUS_PREFERENCES_ICON_VIEW_CAPTIONS);
+
+    /* Convert to quarks in advance. If we didn't, each NautilusFile attribute
+     * getter would have to call g_quark_from_string() once for each file. */
+    for (gint i = 0, quark_i = 0; value[i] != NULL && quark_i < 3; i++)
+    {
+        if (g_strcmp0 (value[i], "none") == 0)
+        {
+            continue;
+        }
+
+        quark_array[quark_i] = g_quark_from_string (value[i]);
+        quark_i++;
+    }
+
+    self->first_caption_attribute_q = quark_array[0];
+    self->second_caption_attribute_q = quark_array[1];
+    self->third_caption_attribute_q = quark_array[2];
+}
+
+static void
+on_captions_preferences_changed (NautilusViewIconController *self)
+{
+    set_captions_from_preferences (self);
+}
+
 static void
 on_default_sort_order_changed (NautilusViewIconController *self)
 {
@@ -1399,6 +1435,12 @@ nautilus_view_icon_controller_init (NautilusViewIconController *self)
                               "changed::" NAUTILUS_PREFERENCES_DEFAULT_SORT_IN_REVERSE_ORDER,
                               G_CALLBACK (on_default_sort_order_changed),
                               self);
+
+    set_captions_from_preferences (self);
+    g_signal_connect_swapped (nautilus_icon_view_preferences,
+                              "changed::" NAUTILUS_PREFERENCES_ICON_VIEW_CAPTIONS,
+                              G_CALLBACK (on_captions_preferences_changed),
+                              self);
 }
 
 NautilusViewIconController *


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