Make GTimeLog a single instance application

Bug #356495 reported by Bruce van der Kooij
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
GTimeLog
Fix Released
Medium
Unassigned

Bug Description

Currently it is possible to start multiple instances of GTimeLog, to me personally this doesn't seem very useful.

The attached patch turns GTimeLog into a single-instance application for all platforms with DBus (python-dbus) and degrade gracefully for those without. When another instance is started the application checks whether or not the DBus service is running, if so (meaning that another instance of GTimeLog is still running) it calls a ToggleFocus function which shows the main GTimeLog window if it wasn't visible (active) or hides it if it was (meaning you were most likely looking at it).

This behavior is also handy when you consider you can already easily assign global keybindings when running Metacity (gconf /apps/metacity/global_keybindings) to start a program (in this case gtimelog) so this patch also allows the requested behavior from Bug #209762 (Global keyboard shortcut to access GTimeLog). I personally am currently using <Control><Alt>G (though Metacity seems to have seem focus stealing prevention rules which prevent the instance from being focused).

Though not exactly related, this patch also introduces a new configuration key (boolean) start_in_tray which when enabled will make sure that GTimeLog always starts hidden.

Tags: patch
Revision history for this message
Bruce van der Kooij (brucevdk) wrote :

Uhm, not sure what I was smoking but the comment in main() made no sense.

Changed in gtimelog:
status: New → Confirmed
Changed in gtimelog:
importance: Undecided → Medium
tags: added: patch
Revision history for this message
Marius Gedminas (mgedmin) wrote :

I'm sorry for ignoring your patch for so long.

I like the idea. I like that you handle the case when dbus is not available (some people use GTimeLog on Windows).

Note that currently gtimelog can work without a tray icon; I think it would be best to ignore the start_in_tray option in that case.

I dislike the ToggleFocus idea: if gtimelog is running and has a window open (on a different workspace), launching it again should bring that window to front, not hide it. Do you know of any other application that would hide an open window if you tried to launch it twice?

Revision history for this message
Marius Gedminas (mgedmin) wrote :

It took way too long, but this was finally committed, with some tweaks.

There's now gtimelog --tray, useful for adding to your GNOME session. One difference from the normal start_in_tray option:

   gtimelog -> starts in tray, starts dbus service
   gtimelog -> shows gtimelog window

while

   gtimelog --tray -> starts in tray, starts dbus service
   gtimelog --tray -> does nothing, since it's already running in the tray

Also, I made the default DBus activation always present the gtimelog window. If you want toggling, bind the key to gtimelog --toggle.

Changed in gtimelog:
status: Confirmed → Fix Committed
Changed in gtimelog:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.