[gegl] ui: store relative paths in xmp meta-data
- From: Øyvind Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] ui: store relative paths in xmp meta-data
- Date: Tue, 13 Oct 2015 13:09:52 +0000 (UTC)
commit 11f3cdafeb7df136952993fd25cf17891335b5aa
Author: Oyvind Kolas <pippin gimp org>
Date: Tue Aug 4 21:02:16 2015 +0200
ui: store relative paths in xmp meta-data
This should make opening a file work if it is mounted at a different path or
if files including source material is copied between folders/computers.
bin/mrg-ui.c | 24 ++++++++++++++++++++++--
1 files changed, 22 insertions(+), 2 deletions(-)
---
diff --git a/bin/mrg-ui.c b/bin/mrg-ui.c
index cb1ebb2..4d4233f 100644
--- a/bin/mrg-ui.c
+++ b/bin/mrg-ui.c
@@ -925,6 +925,20 @@ static void gegl_ui (Mrg *mrg, void *data)
/***********************************************/
+static char *get_path_parent (const char *path)
+{
+ char *ret = strdup (path);
+ char *lastslash = strrchr (ret, '/');
+ if (lastslash)
+ {
+ if (lastslash == ret)
+ lastslash[1] = '\0';
+ else
+ lastslash[0] = '\0';
+ }
+ return ret;
+}
+
static char *suffix_path (const char *path)
{
char *ret, *last_dot;
@@ -1100,7 +1114,9 @@ static void load_path (State *o)
if (meta)
{
GSList *nodes, *n;
- o->gegl = gegl_node_new_from_xml (meta, NULL);
+ char *containing_path = get_path_parent (o->path);
+ o->gegl = gegl_node_new_from_xml (meta, containing_path);
+ free (containing_path);
o->sink = gegl_node_new_child (o->gegl,
"operation", "gegl:nop", NULL);
o->source = NULL;
@@ -1671,7 +1687,11 @@ static void save_cb (MrgEvent *event, void *data1, void *data2)
"path", o->path,
NULL);
gegl_node_link_many (load, o->source, NULL);
- xml = gegl_node_to_xml (o->sink, NULL);
+ {
+ char *containing_path = get_path_parent (o->path);
+ xml = gegl_node_to_xml (o->sink, containing_path);
+ free (containing_path);
+ }
gegl_node_remove_child (o->gegl, load);
gegl_node_link_many (o->load, o->source, NULL);
gegl_meta_set (path, xml);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]