[gimp-perl] Add on_proc hook called in lib mode only



commit 457abc378d6a5d926c3e711761cb46ea70189007
Author: Ed J <edj src gnome org>
Date:   Thu Nov 20 04:32:11 2014 +0000

    Add on_proc hook called in lib mode only

 Gimp.pm     |   12 ++++++++++++
 Gimp/Lib.xs |    2 ++
 TODO        |    4 ----
 3 files changed, 14 insertions(+), 4 deletions(-)
---
diff --git a/Gimp.pm b/Gimp.pm
index 46261dc..a34dab0 100644
--- a/Gimp.pm
+++ b/Gimp.pm
@@ -195,6 +195,9 @@ sub callback {
   } elsif ($type eq "-quit") {
     @cb = cbchain(qw(quit));
     for (@cb) { &$_ }
+  } elsif ($type eq "-proc") {
+    @cb = cbchain(qw(proc));
+    for (@cb) { &$_ }
   }
 }
 
@@ -208,6 +211,7 @@ sub on_net  (&) { register_callback "net"  , $_[0] }
 sub on_lib  (&) { register_callback "lib"  , $_[0] }
 sub on_run  (&) { register_callback "run"  , $_[0] }
 sub on_quit  (&) { register_callback "quit"  , $_[0] }
+sub on_proc  (&) { register_callback "proc"  , $_[0] }
 
 sub main {
    no strict 'refs';
@@ -681,6 +685,10 @@ plug-in writer.  This does not apply if using C<Gimp::Fu>, as these are
 done automatically. These are specifically how your program can fit into
 the model of query, run and quit hooks.
 
+The additional C<on_proc> is how to supply code that will be run every
+time a GIMP PDB call is made. This is mainly useful for updating the
+progress bar on a plugin.
+
 =head3 Gimp::on_query
 
 Do any activities that must be performed at GIMP startup, when the
@@ -705,6 +713,10 @@ Run when anything calls it (network or lib).
 Run when plugin terminates - allows a plugin (or extension, see below)
 to clean up after itself before it actually exits.
 
+=head3 Gimp::on_proc
+
+Run each time a PDB call is made. Currently only operates in "lib mode".
+
 =head1 OUTLINE OF A GIMP EXTENSION
 
 A GIMP extension is a special type of plugin. Once started, it stays
diff --git a/Gimp/Lib.xs b/Gimp/Lib.xs
index 537f7fc..31435dc 100644
--- a/Gimp/Lib.xs
+++ b/Gimp/Lib.xs
@@ -1488,6 +1488,8 @@ PPCODE:
   )
     croak (__("gimp procedure '%s' not found"), proc_name);
 
+  try_call ("-proc");
+
   int runmode_firstparam = nparams
                && params[0].type == GIMP_PDB_INT32
                && (!strcmp (params[0].name, "run_mode") || !strcmp (params[0].name, "run-mode"));
diff --git a/TODO b/TODO
index 218a5d8..63be640 100644
--- a/TODO
+++ b/TODO
@@ -6,10 +6,6 @@ Items as of 2014-06-30 (by Ed J)
   PDB call added in tools/pdbgen/pdb/gimp.pdb
 * Progress bar in UI:
   - adding a Gimp::UI::ProgressBar;
-  - allowing the UI to keep updating itself while the code runs - probably
-    with a Gimp::proc_hook, registered when interact starts and $code is
-    defined, called every time a PDB call is made, to process all pending
-    UI events.
 * e/fade-alpha should generate buttons, not hardcode
 * Gimp/Lib.xs is huge, and not very XS-y - lots of it is manually
   pushing GIMP data structures onto perl stack and vice versa. Figure


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