[gimp] libgimpconfig: (de)serialize GFile properties as config paths



commit bafe4419c6199af94001a925ce83585118f49652
Author: Michael Natterer <mitch gimp org>
Date:   Mon Oct 17 18:55:50 2016 +0200

    libgimpconfig: (de)serialize GFile properties as config paths
    
    so they are found in relocated prefixes / user configs.

 libgimpconfig/gimpconfig-deserialize.c |   15 +++++++++++++--
 libgimpconfig/gimpconfig-serialize.c   |   27 +++++++++++++++++++++------
 2 files changed, 34 insertions(+), 8 deletions(-)
---
diff --git a/libgimpconfig/gimpconfig-deserialize.c b/libgimpconfig/gimpconfig-deserialize.c
index 141147b..c1a8b1e 100644
--- a/libgimpconfig/gimpconfig-deserialize.c
+++ b/libgimpconfig/gimpconfig-deserialize.c
@@ -872,9 +872,20 @@ gimp_config_deserialize_file_value (GValue     *value,
     }
   else
     {
-      GFile *file = g_file_parse_name (scanner->value.v_string);
+      gchar *path = gimp_config_path_expand (scanner->value.v_string, TRUE,
+                                             NULL);
 
-      g_value_take_object (value, file);
+      if (path)
+        {
+          GFile *file = g_file_new_for_path (path);
+
+          g_value_take_object (value, file);
+          g_free (path);
+        }
+      else
+        {
+          g_value_set_object (value, NULL);
+        }
     }
 
   return G_TOKEN_RIGHT_PAREN;
diff --git a/libgimpconfig/gimpconfig-serialize.c b/libgimpconfig/gimpconfig-serialize.c
index 06efc3b..0c4fefe 100644
--- a/libgimpconfig/gimpconfig-serialize.c
+++ b/libgimpconfig/gimpconfig-serialize.c
@@ -34,6 +34,7 @@
 #include "gimpconfigwriter.h"
 #include "gimpconfig-iface.h"
 #include "gimpconfig-params.h"
+#include "gimpconfig-path.h"
 #include "gimpconfig-serialize.h"
 #include "gimpconfig-utils.h"
 
@@ -491,14 +492,28 @@ gimp_config_serialize_value (const GValue *value,
 
       if (file)
         {
-          gchar *parse_name = g_file_get_parse_name (file);
+          gchar *path     = g_file_get_path (file);
+          gchar *unexpand = NULL;
 
-          if (escaped)
-            gimp_config_string_append_escaped (str, parse_name);
-          else
-            g_string_append (str, parse_name);
+          if (path)
+            {
+              unexpand = gimp_config_path_unexpand (path, TRUE, NULL);
+              g_free (path);
+            }
+
+          if (unexpand)
+            {
+              if (escaped)
+                gimp_config_string_append_escaped (str, unexpand);
+              else
+                g_string_append (str, unexpand);
 
-          g_free (parse_name);
+              g_free (unexpand);
+            }
+          else
+            {
+              g_string_append (str, "NULL");
+            }
         }
       else
         {


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