[gegl/mrg_ui] ui: store relative paths in xmp meta-data
- From: Øyvind Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl/mrg_ui] ui: store relative paths in xmp meta-data
- Date: Tue, 4 Aug 2015 19:10:00 +0000 (UTC)
commit 9825fa358dd4718ae2a17b9c0a3fcaee49f70f4c
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 e763539..2576c82 100644
--- a/bin/mrg-ui.c
+++ b/bin/mrg-ui.c
@@ -926,6 +926,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;
@@ -1101,7 +1115,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;
@@ -1672,7 +1688,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]