[gimp-perl] Add Gimp::on_quit. Bug 728539



commit 9c4512eb7c1a1193c70e101e6135af2b16c81139
Author: Ed J <m8r-35s8eo mailinator com>
Date:   Sat Apr 19 03:00:45 2014 +0100

    Add Gimp::on_quit. Bug 728539

 Gimp.pm              |   26 +++++---------------------
 Net/Net.pm           |   11 +++--------
 examples/Perl-Server |    1 +
 t/supplied.t         |    2 +-
 4 files changed, 10 insertions(+), 30 deletions(-)
---
diff --git a/Gimp.pm b/Gimp.pm
index e1abd90..3c76624 100644
--- a/Gimp.pm
+++ b/Gimp.pm
@@ -113,8 +113,6 @@ sub import($;@) {
 # the monadic identity function
 sub N_($) { shift }
 
-my @init_functions;
-
 my $gtk_init = 1;
 
 sub gtk_init() {
@@ -124,14 +122,6 @@ sub gtk_init() {
       Gtk2::Rc->parse (Gimp->gtkrc);
       $gtk_init = 0;
    }
-   &{shift @init_functions} while @init_functions;
-}
-
-sub gtk_init_hook(&) {
-   push @init_functions, @_;
-   unless ($gtk_init) {
-      &{shift @init_functions} while @init_functions;
-   }
 }
 
 # internal utility function for Gimp::Fu and others
@@ -255,6 +245,7 @@ sub on_query(&) { register_callback "query", $_[0] }
 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 main {
    &{"$interface_pkg\::gimp_main"};
@@ -625,6 +616,10 @@ Run only when called from within Gimp.
 
 Run when anything calls it (network or lib).
 
+=item Gimp::on_quit
+
+Run when plugin terminates.
+
 =back
 
 =head1 OUTLINE OF A GIMP EXTENSION
@@ -720,17 +715,6 @@ Initialize Gtk in a similar way GIMP itself did it. This automatically
 parses gimp's gtkrc and sets a variety of default settings (visual,
 colormap, gamma, shared memory...).
 
-=item Gimp::gtk_init_add { init statements ... };
-
-Add a callback function that should be called when gtk is being
-initialized (i.e. when Gimp::gtk_init is called, which should therefore be
-done even in Gnome applications).
-
-This is different to Gtk->init_add, which only gets called in Gtk->main,
-which is too late for registering types.
-
-This function has not been well tested.
-
 =item use Gimp qw(net_init=...);
 
 This is how to use Gimp-Perl in "net mode". Previous versions of this
diff --git a/Net/Net.pm b/Net/Net.pm
index e376ba9..b20ba1d 100644
--- a/Net/Net.pm
+++ b/Net/Net.pm
@@ -484,16 +484,11 @@ sub perl_server_run {
       }
     }
   }
+}
 
+sub perl_server_quit {
   slog __"server going down...";
-  if ($use_tcp) {
-    undef $tcp;
-  }
-  if ($use_unix) {
-    undef $unix;
-    unlink $unix_path;
-    rmdir $DEFAULT_UNIX_DIR;
-  }
+  unlink $unix_path or die "failed to unlink '$unix_path': $!\n" if $unix_path;
 }
 
 1;
diff --git a/examples/Perl-Server b/examples/Perl-Server
index 00b895e..0cbee36 100755
--- a/examples/Perl-Server
+++ b/examples/Perl-Server
@@ -11,6 +11,7 @@ Gimp::set_trace(\$Gimp::Net::trace_res);
 Gimp::ignore_functions(qw(gimp_progress_init gimp_progress_update));
 
 Gimp::on_run \&Gimp::Net::perl_server_run;
+Gimp::on_quit \&Gimp::Net::perl_server_quit;
 
 Gimp::on_query {
    Gimp->install_procedure(
diff --git a/t/supplied.t b/t/supplied.t
index 90eba92..807afbf 100644
--- a/t/supplied.t
+++ b/t/supplied.t
@@ -22,7 +22,7 @@ BEGIN {
       bump-map checkerboard edge file-gif-save file-png unsharp-mask crop-auto
     );
 }
-use Gimp qw(:auto), "net_init=spawn/";
+use Gimp qw(:consts), "net_init=spawn/";
 #Gimp::set_trace(TRACE_ALL);
 
 sub newimage {


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