[gegl/mrg_ui] ui: also remove suffixed file when discarding



commit f33a3b166eb5d43ac705e2520203c456ccb861ca
Author: Oyvind Kolas <pippin gimp org>
Date:   Mon Aug 3 16:16:30 2015 +0200

    ui: also remove suffixed file when discarding

 bin/gegl.c   |    2 --
 bin/mrg-ui.c |   28 ++++++++++++++++++++++++----
 2 files changed, 24 insertions(+), 6 deletions(-)
---
diff --git a/bin/gegl.c b/bin/gegl.c
index c86cb4e..d92d946 100644
--- a/bin/gegl.c
+++ b/bin/gegl.c
@@ -87,8 +87,6 @@ main (gint    argc,
   gchar       *script    = NULL;
   GError      *err       = NULL;
   gchar       *path_root = NULL;
-      mrg_ui_main (argc, argv);
-      return 0;
 
   g_object_set (gegl_config (),
                 "application-license", "GPL3",
diff --git a/bin/mrg-ui.c b/bin/mrg-ui.c
index 8e9fa05..f002eaa 100644
--- a/bin/mrg-ui.c
+++ b/bin/mrg-ui.c
@@ -1070,7 +1070,12 @@ static void load_path (State *o)
     gegl_node_link_many (o->load, o->source, o->sink, NULL);
     gegl_node_set (o->load, "buffer", o->buffer, NULL);
   }
-  zoom_to_fit (o);
+  {
+    struct stat stat_buf;
+    lstat (o->path, &stat_buf);
+    if (S_ISREG (stat_buf.st_mode))
+      zoom_to_fit (o);
+  }
 
   mrg_queue_draw (o->mrg, NULL);
 }
@@ -1243,6 +1248,7 @@ static void drag_preview (MrgEvent *e)
 static void load_into_buffer (State *o, const char *path)
 {
   GeglNode *gegl, *load, *sink;
+  struct stat stat_buf;
 
   if (o->buffer)
   {
@@ -1250,6 +1256,11 @@ static void load_into_buffer (State *o, const char *path)
     o->buffer = NULL;
   }
 
+  lstat (path, &stat_buf);
+  if (S_ISREG (stat_buf.st_mode))
+  {
+
+
   gegl = gegl_node_new ();
   load = gegl_node_new_child (gegl, "operation", "gegl:load",
                                     "path", path,
@@ -1272,6 +1283,12 @@ static void load_into_buffer (State *o, const char *path)
   o->buffer = tempbuf;
   }
 #endif
+    }
+  else
+    {
+      GeglRectangle extent = {0,0,1,1}; /* segfaults with NULL / 0,0,0,0*/
+      o->buffer = gegl_buffer_new (&extent, babl_format("R'G'B' u8"));
+    }
 }
 
 static GeglNode *locate_node (State *o, const char *op_name)
@@ -1550,6 +1567,7 @@ static void discard_cb (MrgEvent *event, void *data1, void *data2)
   if (lastslash)
   {
     char command[2048];
+    char *suffixed = suffix_path (old_path);
     if (lastslash == tmp)
       lastslash[1] = '\0';
     else
@@ -1558,7 +1576,9 @@ static void discard_cb (MrgEvent *event, void *data1, void *data2)
     sprintf (command, "mkdir %s/.discard > /dev/null 2>&1", tmp);
     system (command);
     sprintf (command, "mv %s %s/.discard", old_path, tmp);
+    sprintf (command, "mv %s %s/.discard", suffixed, tmp);
     system (command);
+    free (suffixed);
   }
   free (tmp);
   free (old_path);
@@ -1656,10 +1676,10 @@ gegl_meta_get (const char *path)
   GError *error = NULL;
   GExiv2Metadata *e2m = gexiv2_metadata_new ();
   gexiv2_metadata_open_path (e2m, path, &error);
-  if (error)
-    g_warning ("%s", error->message);
-  else
+  if (!error)
     ret = gexiv2_metadata_get_tag_string (e2m, "Xmp.xmp.GEGL");
+  /*else
+    g_warning ("%s", error->message);*/
   gexiv2_metadata_free (e2m);
   return ret;
 }



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