[gegl] bin/gegl: store edits in text files



commit 6d3606f4cb55b95fc5c53f783f5e592824f4e9b5
Author: Øyvind Kolås <pippin gimp org>
Date:   Sat Feb 11 20:44:02 2017 +0100

    bin/gegl: store edits in text files
    
    We used to store full size exported png/jpg files, this makes changing to the
    next image while editing slow, stroing the edits as plain text, makes them more
    easily debuggable as well as improves interaction speed, edit list stored in
    meta data should return for explicitly exported images.

 bin/ui.c |   37 +++++++++++++------------------------
 1 files changed, 13 insertions(+), 24 deletions(-)
---
diff --git a/bin/ui.c b/bin/ui.c
index 55d5bca..6b895d5 100644
--- a/bin/ui.c
+++ b/bin/ui.c
@@ -44,7 +44,7 @@
 
 /* set this to 1 to print the active gegl chain
  */
-#define DEBUG_OP_LIST  0
+//#define DEBUG_OP_LIST  1
 
 
 static int audio_len   = 0;
@@ -1156,47 +1156,32 @@ static char *get_path_parent (const char *path)
 
 static char *suffix_path (const char *path)
 {
-  char *ret, *last_dot;
-
+  char *ret;
   if (!path)
     return NULL;
   ret  = malloc (strlen (path) + strlen (suffix) + 3);
   strcpy (ret, path);
-  last_dot = strrchr (ret, '.');
-  if (last_dot)
-  {
-    char *extension = strdup (last_dot + 1);
-    sprintf (last_dot, "%s.%s", suffix, extension);
-   free (extension);
-  }
-  else
-  {
-    sprintf (ret, "%s%s", path, suffix);
-  }
+  sprintf (ret, "%s%s", path, ".gegl");
   return ret;
 }
 
 static char *unsuffix_path (const char *path)
 {
-  char *ret = NULL, *last_dot, *extension;
-  char *suf;
+  char *ret = NULL, *last_dot;
 
   if (!path)
     return NULL;
   ret = malloc (strlen (path) + 4);
   strcpy (ret, path);
   last_dot = strrchr (ret, '.');
-  extension = strdup (last_dot + 1);
-
-  suf = strstr(ret, suffix);
-  sprintf (suf, ".%s", extension);
-  free (extension);
+  *last_dot = '\0';
   return ret;
 }
 
 static int is_gegl_path (const char *path)
 {
-  if (strstr (path, suffix)) return 1;
+  if (g_str_has_suffix (path, ".gegl"))
+    return 1;
   return 0;
 }
 
@@ -1343,7 +1328,10 @@ static void load_path (State *o)
   }
   else
   {
-    meta = gegl_meta_get (path);
+    meta = NULL;
+    if (is_gegl_path (path))
+      g_file_get_contents (path, &meta, NULL, NULL);
+    //meta = gegl_meta_get (path);
     if (meta)
     {
       GSList *nodes, *n;
@@ -1958,7 +1946,8 @@ static void save_cb (MrgEvent *event, void *data1, void *data2)
   }
   gegl_node_remove_child (o->gegl, load);
   gegl_node_link_many (o->load, o->source, NULL);
-  gegl_meta_set (path, serialized);
+
+  g_file_set_contents (path, serialized, -1, NULL);
   g_free (serialized);
   o->rev = 0;
 }


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