From 9b637ace2f430e954165f90ee6293e15eb00b79f Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sat, 22 Feb 2014 04:11:01 +0100 Subject: support non-continuous mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/blueshift-tray.py | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/src/blueshift-tray.py b/src/blueshift-tray.py index a16983e..0e14e43 100755 --- a/src/blueshift-tray.py +++ b/src/blueshift-tray.py @@ -33,7 +33,17 @@ gettext.bindtextdomain('blueshift', LOCALEDIR) gettext.textdomain('blueshift') +def process_quit(signum, frame): + global running + process.wait() + if running: + running = False + icon.set_visible(False) + gtk.main_quit() + +signal.signal(signal.SIGCHLD, process_quit) process = subprocess.Popen(['blueshift'] + sys.argv[1:]) +running = True def create_menu(menu, image, title, function): @@ -58,17 +68,23 @@ def f_reload(widget, data = None): process.send_signal(signal.SIGUSR1) def f_quit(widget, data = None): - icon.set_visible(False) - gtk.main_quit() - process.send_signal(signal.SIGTERM) + global running + if running: + running = False + icon.set_visible(False) + gtk.main_quit() + process.send_signal(signal.SIGTERM) def f_panic_quit(widget, data = None): - icon.set_visible(False) - gtk.main_quit() - process.send_signal(signal.SIGTERM) - import time - time.sleep(0.01) - process.send_signal(signal.SIGTERM) + global running + if running: + running = False + icon.set_visible(False) + gtk.main_quit() + process.send_signal(signal.SIGTERM) + import time + time.sleep(0.01) + process.send_signal(signal.SIGTERM) def f_popup(widget, button, time, data = None): @@ -95,6 +111,7 @@ try: gtk.main() except KeyboardInterrupt: + running = False icon.set_visible(False) process.send_signal(signal.SIGTERM) -- cgit v1.2.3-70-g09d2