Skip to content

Commit

Permalink
Resurrect --quit
Browse files Browse the repository at this point in the history
See also #24
  • Loading branch information
mgedmin committed Sep 8, 2014
1 parent 904ed75 commit 4805b03
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion NEWS.rst
Expand Up @@ -9,7 +9,7 @@ Changelog
* Drop support for Python 2.6 (PyGObject dropped support for it long ago).
* Drop EggTrayIcon support.
* Use GtkApplication instead of own DBus server for enforcing single-instance.
* Drop --prefer-pygtk, --replace, --quit, --ignore-dbus command-line
* Drop --prefer-pygtk, --replace, --ignore-dbus command-line
options because of the above changes.
* Use Tango colors in the main text buffer (GH: #13).
* Fix two Gtk-CRITICAL warnings on startup (GH: #14).
Expand Down
9 changes: 9 additions & 0 deletions src/gtimelog/main.py
Expand Up @@ -1001,6 +1001,7 @@ def __init__(self, *args, **kwargs):
make_option("--version", description="Show version number and exit"),
make_option("--tray", description="Start minimized"),
make_option("--toggle", description="Show/hide the GTimeLog window if already running"),
make_option("--quit", description="Tell an already-running GTimeLog instance to quit"),
make_option("--sample-config", description="Write a sample configuration file to 'gtimelogrc.sample'"),
make_option("--debug", description="Show debug information"),
])
Expand All @@ -1020,6 +1021,8 @@ def do_handle_local_options(self, options):
return 0
self.debug = options.contains('debug')
self.start_minimized = options.contains('tray')
if options.contains('quit'):
print('gtimelog: Telling the already-running instance to quit')
return -1 # send the args to the remote instance for processing

def do_command_line(self, command_line):
Expand All @@ -1029,6 +1032,12 @@ def do_command_line(self, command_line):
# hide the gtimelog window. Bug or feature?
self.main_window.toggle_visible()
return 0
if options.contains('quit'):
if self.main_window:
self.main_window.quit()
else:
print('gtimelog: not running')
return 0

self.do_activate()
return 0
Expand Down

0 comments on commit 4805b03

Please sign in to comment.