[Knuckles] shown Gajim when we try to run it while it is already running. Fixes #7274

This commit is contained in:
Yann Leboulanger 2012-12-09 11:51:36 +01:00
parent c5e6c6a501
commit 97bd4d5152
2 changed files with 31 additions and 0 deletions

View File

@ -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')

View File

@ -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):
"""