[Xfce4-commits] <xfce4-settings:bluesabre/display-settings> Show Strv arrays in the renderer.

Nick Schermer noreply at xfce.org
Mon Dec 9 12:56:05 CET 2013


Updating branch refs/heads/bluesabre/display-settings
         to afa79de4dfda99e58bb55efb07c021e6c71e9a6c (commit)
       from eb85045030f7adc2bada1e989ece718a3a883533 (commit)

commit afa79de4dfda99e58bb55efb07c021e6c71e9a6c
Author: Nick Schermer <nick at xfce.org>
Date:   Tue Oct 9 19:25:19 2012 +0200

    Show Strv arrays in the renderer.

 .../xfce-settings-cell-renderer.c                  |   37 ++++++++++++++++++--
 1 file changed, 35 insertions(+), 2 deletions(-)

diff --git a/xfce4-settings-editor/xfce-settings-cell-renderer.c b/xfce4-settings-editor/xfce-settings-cell-renderer.c
index fd684a1..31e964e 100644
--- a/xfce4-settings-editor/xfce-settings-cell-renderer.c
+++ b/xfce4-settings-editor/xfce-settings-cell-renderer.c
@@ -108,7 +108,8 @@ static GtkCellEditable *xfce_settings_cell_renderer_start_editing (GtkCellRender
                                                                    GdkRectangle         *background_area,
                                                                    GdkRectangle         *cell_area,
                                                                    GtkCellRendererState  flags);
-
+static void             xfce_settings_strv_to_string              (const GValue         *src_value,
+                                                                   GValue               *dest_value);
 
 
 G_DEFINE_TYPE (XfceSettingsCellRenderer, xfce_settings_cell_renderer, GTK_TYPE_CELL_RENDERER)
@@ -158,6 +159,9 @@ xfce_settings_cell_renderer_class_init (XfceSettingsCellRendererClass *klass)
                                                     G_TYPE_VALUE);
 
     edit_data_quark = g_quark_from_static_string ("path");
+
+    g_value_register_transform_func (G_TYPE_STRV, G_TYPE_STRING,
+                                     xfce_settings_strv_to_string);
 }
 
 
@@ -282,7 +286,8 @@ xfce_settings_cell_renderer_prepare (XfceSettingsCellRenderer *renderer)
     const GValue *value = &renderer->cell_value;
     GValue        str_value = { 0, };
 
-    if (G_VALUE_TYPE (value) == xfce_settings_array_type ())
+    if (G_VALUE_TYPE (value) == xfce_settings_array_type ()
+        || G_VALUE_TYPE (value) == G_TYPE_STRV)
         goto transform_value;
 
     switch (G_VALUE_TYPE (value))
@@ -613,6 +618,34 @@ xfce_settings_array_to_string (const GValue *src_value,
 
 
 
+static void
+xfce_settings_strv_to_string (const GValue *src_value,
+                              GValue       *dest_value)
+{
+    gchar   **array = g_value_get_boxed (src_value);
+    GString  *str;
+    guint     i;
+
+    g_return_if_fail (G_VALUE_HOLDS_STRING (dest_value));
+    g_return_if_fail (array != NULL);
+
+    str = g_string_new ("[ ");
+
+    for (i = 0; array[i] != NULL; i++)
+    {
+        if (i > 0)
+          g_string_append (str, ", ");
+        g_string_append_printf (str, "\"%s\"", array[i]);
+    }
+
+    g_string_append (str, " ]");
+
+    g_value_take_string (dest_value, g_string_free (str, FALSE));
+}
+
+
+
+
 GtkCellRenderer *
 xfce_settings_cell_renderer_new (void)
 {


More information about the Xfce4-commits mailing list