From 97bd4d5152a4f843cf9da0ad4793ca9af3df734a Mon Sep 17 00:00:00 2001 From: Yann Leboulanger <asterix@lagaule.org> Date: Sun, 9 Dec 2012 11:51:36 +0100 Subject: [PATCH] [Knuckles] shown Gajim when we try to run it while it is already running. Fixes #7274 --- src/gajim.py | 18 ++++++++++++++++++ src/remote_control.py | 13 +++++++++++++ 2 files changed, 31 insertions(+) diff --git a/src/gajim.py b/src/gajim.py index 99d3c05096..f26480581a 100644 --- a/src/gajim.py +++ b/src/gajim.py @@ -359,7 +359,25 @@ def pid_alive(): # 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 --git a/src/remote_control.py b/src/remote_control.py index eada366683..ac34db3e5b 100644 --- a/src/remote_control.py +++ b/src/remote_control.py @@ -696,6 +696,19 @@ class SignalObject(dbus.service.Object): else: 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): """ -- GitLab