[Knuckles] shown Gajim when we try to run it while it is already running. Fixes #7274
This commit is contained in:
parent
c5e6c6a501
commit
97bd4d5152
18
src/gajim.py
18
src/gajim.py
|
@ -359,7 +359,25 @@ def pid_alive():
|
||||||
# Assume Gajim is running.
|
# Assume Gajim is running.
|
||||||
return True
|
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 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)
|
pix = gtkgui_helpers.get_icon_pixmap('gajim', 48)
|
||||||
gtk.window_set_default_icon(pix) # set the icon to all newly opened wind
|
gtk.window_set_default_icon(pix) # set the icon to all newly opened wind
|
||||||
pritext = _('Gajim is already running')
|
pritext = _('Gajim is already running')
|
||||||
|
|
|
@ -696,6 +696,19 @@ class SignalObject(dbus.service.Object):
|
||||||
else:
|
else:
|
||||||
win.window.focus(long(time()))
|
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='')
|
@dbus.service.method(INTERFACE, in_signature='', out_signature='')
|
||||||
def toggle_ipython(self):
|
def toggle_ipython(self):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue