[gegl] bin: repair discard command for new folder structure



commit 2f03a5537ef4f9a969e02de973d45fb62911dca3
Author: Øyvind Kolås <pippin gimp org>
Date:   Sat Apr 27 18:03:14 2019 +0200

    bin: repair discard command for new folder structure

 bin/lua/viewer.lua | 37 ++++++++++++++++++++++++++++++++++++-
 bin/ui-core.c      | 21 +++++++++++++++------
 2 files changed, 51 insertions(+), 7 deletions(-)
---
diff --git a/bin/lua/viewer.lua b/bin/lua/viewer.lua
index 039df15d2..63d5a57d5 100644
--- a/bin/lua/viewer.lua
+++ b/bin/lua/viewer.lua
@@ -314,6 +314,41 @@ if o.is_video ~= 0 then
 end
 
 
+if 0 ~= 0 then -- hack for testing animation scrubbing
+
+  local frame = o.pos;
+  local frames = o.duration;
+
+  local source = GObject.Object(STATE).sink
+
+  if o.show_controls ~= 0 then
+    cr:set_line_width(2)
+    cr:new_path()
+    cr:move_to(height * .15, height * .95);
+    cr:line_to(width - height * .15, height * .95);
+    cr:set_source_rgba(1,1,1,1)
+
+    cr:stroke()
+    cr:move_to(height * .15 + frame * (width - height * .3)  / frames, height * 0.975)
+    cr:rel_line_to(0, -0.05 * height)
+    cr:stroke()
+
+    cr:set_source_rgba(1,1,1,.5)
+    cr:fill()
+
+
+  end
+
+  cr:rectangle(height * .1 , height * .9, width - height * .2, height *.1)
+  mrg:listen(Mrg.DRAG, function(event)
+      o.pos = (event.x - height *.15) / (width - height * .3) * frames
+      sink:set_time(o.pos)
+      event:stop_propagate()
+  end)
+  cr:new_path()
+end
+
+
 function pdf_next_page()
   local pages = source:get_property('pages').value
   local page = source:get_property('page').value
@@ -331,7 +366,7 @@ function draw_thumb_bar()
   cr:set_source_rgba(1,1,1,.1)
   cr:rectangle(0, mrg:height()*0.8, mrg:width(), mrg:height()*0.2)
   mrg:listen(Mrg.MOTION, function(e)
-    print('a') end)
+    end)
   cr:fill()
   mrg:print("thumbbar")
 end
diff --git a/bin/ui-core.c b/bin/ui-core.c
index b8d651ffb..1ff047eba 100644
--- a/bin/ui-core.c
+++ b/bin/ui-core.c
@@ -730,7 +730,7 @@ void populate_path_list (GeState *o)
 
   for (int i = 0; i < n;i++)
     free(namelist[i]);
-  free (namelist);
+//  free (namelist);
 }
 
 char **ops = NULL;  /* initialized by the non-ui main() before ours get called */
@@ -6751,13 +6751,13 @@ int cmd_discard (COMMAND_ARGS) /* "discard", 0, "", "moves the current image to
 {
   GeState *o = global_state;
   char *old_path;
+  char *basename;
   char *tmp;
   char *lastslash;
   if (o->is_dir)
   {
     char *basedir = o->path;
     char *basename = meta_get_child (o, basedir, o->entry_no);
-    g_free (o->path);
     old_path = g_strdup_printf ("%s/%s", basedir, basename);
     g_free (basename);
   }
@@ -6779,22 +6779,31 @@ int cmd_discard (COMMAND_ARGS) /* "discard", 0, "", "moves the current image to
   lastslash  = strrchr (tmp, '/');
   if (lastslash)
   {
-    char command[2048];
+    char command[4096];
     char *suffixed = ui_suffix_path (old_path);
+    basename = g_path_get_basename (old_path);
     if (lastslash == tmp)
       lastslash[1] = '\0';
     else
       lastslash[0] = '\0';
 
-    // XXX : replace with proper code, also discard thumb?
-
+    /* XXX : todo this should be real code and not pseudo-shell code */
     sprintf (command, "mkdir %s/.discard > /dev/null 2>&1", tmp);
     system (command);
     sprintf (command, "mv %s %s/.discard > /dev/null 2>&1", old_path, tmp);
     system (command);
-    sprintf (command, "mv %s %s/.discard > /dev/null 2>&1", suffixed, tmp);
+    sprintf (command, "rm %s/.gegl/%s/thumb.jpg > /dev/null 2>&1", tmp, basename);
+    system (command);
+    sprintf (command, "mv %s/.gegl/%s/chain.gegl %s/.discard/%s.gegl > /dev/null 2>&1", tmp, basename, tmp, 
basename);
     system (command);
+
+    sprintf (command, "mv %s/.gegl/%s/metadata %s/.discard/%s.meta > /dev/null 2>&1", tmp, basename, tmp, 
basename);
+    system (command);
+    sprintf (command, "rmdir %s/.gegl/%s", tmp, basename);
+    system (command);
+
     g_free (suffixed);
+    g_free (basename);
     populate_path_list (o);
   }
   g_free (tmp);


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