changeset 962da38dadfa in /home/hg/repos/gajim
details:http://hg.gajim.org/gajim?cmd=changeset;node=962da38dadfa description: [Knuckles] shown Gajim when we try to run it while it is already running. Fixes #7274
diffstat:
src/gajim.py | 18 ++++++++++++++++++ src/remote_control.py | 13 +++++++++++++ 2 files changed, 31 insertions(+), 0 deletions(-)
diffs (52 lines):
diff -r b67ec3e9a5b8 -r 962da38dadfa src/gajim.py --- a/src/gajim.py Fri Dec 07 17:05:20 2012 +0100 +++ b/src/gajim.py Sun Dec 09 11:51:36 2012 +0100 @@ -359,7 +359,25 @@ # Assume Gajim is running. return True
+def show_remote_gajim_roster(): + try: + import dbus + + OBJ_PATH = '/org/gajim/dbus/RemoteObject' + INTERFACE = 'org.gajim.dbus.RemoteInterface' + SERVICE = 'org.gajim.dbus' + + # Attempt to call show_roster + dbus.Interface(dbus.SessionBus().get_object(SERVICE, OBJ_PATH), INTERFACE).__getattr__("show_roster")() + + return True + except Exception: + return False + if pid_alive(): + if (show_remote_gajim_roster()): + print("Gajim is already running, bringing the roster to front...") + sys.exit(0) pix = gtkgui_helpers.get_icon_pixmap('gajim', 48) gtk.window_set_default_icon(pix) # set the icon to all newly opened wind pritext = _('Gajim is already running') diff -r b67ec3e9a5b8 -r 962da38dadfa src/remote_control.py --- a/src/remote_control.py Fri Dec 07 17:05:20 2012 +0100 +++ b/src/remote_control.py Sun Dec 09 11:51:36 2012 +0100 @@ -698,6 +698,19 @@ win.window.focus(long(time()))
@dbus.service.method(INTERFACE, in_signature='', out_signature='') + def show_roster(self): + """ + Show the roster window + """ + win = gajim.interface.roster.window + win.present() + # preserve the 'steal focus preservation' + if self._is_first(): + win.window.focus(gtk.get_current_event_time()) + else: + win.window.focus(long(time())) + + @dbus.service.method(INTERFACE, in_signature='', out_signature='') def toggle_ipython(self): """ Show/hide the ipython window