Sophie

Sophie

distrib > Mandriva > 2009.0 > x86_64 > media > main-testing-src > by-pkgid > 31aa94742bb6cc6735ea4eaf2978fce1 > files > 6

system-config-printer-1.0.16-0.1mdv2009.0.src.rpm

diff -p -up system-config-printer-1.0.4/jobviewer.py.orig system-config-printer-1.0.4/jobviewer.py
--- system-config-printer-1.0.4/jobviewer.py.orig	2008-07-28 13:51:30.000000000 -0400
+++ system-config-printer-1.0.4/jobviewer.py	2008-07-28 13:51:39.000000000 -0400
@@ -630,6 +629,35 @@ class JobViewer (monitor.Watcher):
         self.num_jobs_when_hidden = len (self.jobs.keys ())
         self.set_statusicon_visibility ()
 
+    def on_icon_manage_activate(self, menuitem):
+        import os
+        pid = os.fork ()
+        if pid == 0:
+            # Child.
+            argv = ["/usr/bin/system-config-printer"]
+            os.execv (argv[0], argv)
+            sys.exit (1)
+        elif pid == -1:
+            print "Error forking process"
+        else:
+            gobject.timeout_add (60 * 1000, self.collect_exit_code, pid)
+
+    def collect_exit_code (self, pid):
+        # We do this with timers instead of signals because we already
+        # have gobject imported, but don't (yet) import signal;
+        # let's try not to inflate the process size.
+        import os
+        try:
+            print "Waiting for child %d" % pid
+            (pid, status) = os.waitpid (pid, os.WNOHANG)
+            if pid == 0:
+                # Run this timer again.
+                return True
+        except OSError:
+            pass
+
+        return False
+
     def on_icon_quit_activate (self, menuitem):
         if self.loop:
             self.loop.quit ()