[gegl] ui: add ops after -- to processing chain for images



commit b0f7f9c5de15e9b65098a16e530ea298376faab0
Author: Oyvind Kolas <pippin gimp org>
Date:   Mon Aug 3 20:57:38 2015 +0200

    ui: add ops after -- to processing chain for images
    
    This permits easy testing of a new gegl:op on a multiple files. A further
    improvement would be to extend the handling of arguments so that argumnents
    containing a ':' are ops and subsequent ones containing a '=' are property
    assignments.

 bin/gegl-options.c |    4 ++--
 bin/gegl.c         |    6 +++---
 bin/mrg-ui.c       |   41 +++++++++++++++++++++++++++++++++++++++--
 3 files changed, 44 insertions(+), 7 deletions(-)
---
diff --git a/bin/gegl-options.c b/bin/gegl-options.c
index 6558746..d6db180 100644
--- a/bin/gegl-options.c
+++ b/bin/gegl-options.c
@@ -325,12 +325,12 @@ parse_args (int    argc,
         }
 
         else if (match ("--")) {
-            o->rest = curr+1;
+            o->rest = curr;
             break;
         }
 
         else if (*curr[0]=='-') {
-            fprintf (stderr, _("\n\nunknown parameter '%s' giving you help instead\n\n\n"), *curr);
+            fprintf (stderr, _("\n\nunknown argument '%s' giving you help instead\n\n\n"), *curr);
             usage (argv[0]);
         }
 
diff --git a/bin/gegl.c b/bin/gegl.c
index d92d946..1448879 100644
--- a/bin/gegl.c
+++ b/bin/gegl.c
@@ -76,7 +76,7 @@ static gboolean file_is_gegl_xml (const gchar *path)
   return FALSE;
 }
 
-int mrg_ui_main (int argc, char **argv);
+int mrg_ui_main (int argc, char **argv, char **ops);
 
 gint
 main (gint    argc,
@@ -92,13 +92,13 @@ main (gint    argc,
                 "application-license", "GPL3",
                 NULL);
 
+  o = gegl_options_parse (argc, argv);
   gegl_init (&argc, &argv);
 #ifdef HAVE_SPIRO
   gegl_path_spiro_init ();
 #endif
   gegl_path_smooth_init ();
 
-  o = gegl_options_parse (argc, argv);
 
   if (o->fatal_warnings)
     {
@@ -177,7 +177,7 @@ main (gint    argc,
   if (o->mode == GEGL_RUN_MODE_DISPLAY)
     {
 #if HAVE_MRG
-      mrg_ui_main (argc, argv);
+      mrg_ui_main (argc, argv, o->rest);
       return 0;
 #endif
     }
diff --git a/bin/mrg-ui.c b/bin/mrg-ui.c
index 3133eb7..891b276 100644
--- a/bin/mrg-ui.c
+++ b/bin/mrg-ui.c
@@ -82,6 +82,9 @@ struct _State {
   float       preview_quality;
 
   int         controls_timeout;
+
+
+  char      **ops; // the operations part of the commandline, if any
 };
 
 
@@ -181,7 +184,7 @@ static void save_cb                 (MrgEvent *event, void *data1, void *data2);
 static void toggle_show_controls_cb (MrgEvent *event, void *data1, void *data2);
 
 static void gegl_ui       (Mrg *mrg, void *data);
-int         mrg_ui_main   (int argc, char **argv);
+int         mrg_ui_main   (int argc, char **argv, char **ops);
 void        gegl_meta_set (const char *path, const char *meta_data);
 char *      gegl_meta_get (const char *path); 
 
@@ -256,7 +259,10 @@ static void populate_paths (State *o)
 }
 
 static State *hack_state = NULL;  // XXX: this shoudl be factored away
-int mrg_ui_main (int argc, char **argv)
+
+char **ops = NULL;
+
+int mrg_ui_main (int argc, char **argv, char **ops)
 {
   Mrg *mrg = mrg_new (1024, 768, NULL);
   State o = {NULL,};
@@ -270,6 +276,21 @@ int mrg_ui_main (int argc, char **argv)
 
 /* we want to see the speed gotten if the fastest babl conversions we have were more accurate */
   g_setenv ("BABL_TOLERANCE", "0.1", TRUE);
+  
+  if(ops)
+    o.ops = ops;
+  else
+  {
+    int i;
+    for (i = 0; argv[i]; i++)
+    {
+      if (!strcmp (argv[i], "--"))
+      {
+        o.ops = &argv[i];
+        break;
+      }
+    }
+  }
 
   gegl_init (&argc, &argv);
   o.gegl            = gegl_node_new ();
@@ -286,6 +307,7 @@ int mrg_ui_main (int argc, char **argv)
       return -1;
     }
 
+
   load_path (&o);
   mrg_set_ui (mrg, gegl_ui, &o);
   hack_state = &o;  
@@ -1133,6 +1155,21 @@ static void load_path (State *o)
       zoom_to_fit (o);
   }
 
+  if (o->ops)
+  {
+    int i;
+    for (i = 0; o->ops[i]; i++)
+    {
+      o->active = gegl_node_new_child (o->gegl,
+       "operation", o->ops[i], NULL);
+
+      gegl_node_link_many (gegl_node_get_producer (o->sink, "input", NULL),
+                                 o->active,
+                                 o->sink,
+                                 NULL);
+    }
+  }
+
   mrg_queue_draw (o->mrg, NULL);
 }
 


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