Do not open multiple copies of the same activity
This commit is contained in:
parent
72bf637091
commit
c5fb39875c
@ -7,17 +7,17 @@ from PeopleWindow import PeopleWindow
|
|||||||
class ActivityHost:
|
class ActivityHost:
|
||||||
def __init__(self, shell, window):
|
def __init__(self, shell, window):
|
||||||
self._shell = shell
|
self._shell = shell
|
||||||
|
self._window = window
|
||||||
xid = window.get_xid()
|
self._xid = window.get_xid()
|
||||||
|
|
||||||
bus = dbus.SessionBus()
|
bus = dbus.SessionBus()
|
||||||
proxy_obj = bus.get_object(Activity.get_service_name(xid),
|
proxy_obj = bus.get_object(Activity.get_service_name(self._xid),
|
||||||
Activity.get_object_path(xid))
|
Activity.get_object_path(self._xid))
|
||||||
|
|
||||||
self._activity = dbus.Interface(proxy_obj, Activity.ACTIVITY_INTERFACE)
|
self._activity = dbus.Interface(proxy_obj, Activity.ACTIVITY_INTERFACE)
|
||||||
self._id = self._activity.get_id()
|
self._id = self._activity.get_id()
|
||||||
self._default_type = self._activity.get_default_type()
|
self._default_type = self._activity.get_default_type()
|
||||||
self._window = gtk.gdk.window_foreign_new(window.get_xid())
|
self._gdk_window = gtk.gdk.window_foreign_new(self._xid)
|
||||||
self._people_window = PeopleWindow(shell, self)
|
self._people_window = PeopleWindow(shell, self)
|
||||||
|
|
||||||
def get_id(self):
|
def get_id(self):
|
||||||
@ -36,6 +36,9 @@ class ActivityHost:
|
|||||||
def show_people(self):
|
def show_people(self):
|
||||||
self.show_dialog(self._people_window)
|
self.show_dialog(self._people_window)
|
||||||
|
|
||||||
|
def present(self):
|
||||||
|
self._window.activate(gtk.get_current_event_time())
|
||||||
|
|
||||||
def show_dialog(self, dialog):
|
def show_dialog(self, dialog):
|
||||||
dialog.show()
|
dialog.show()
|
||||||
dialog.window.set_transient_for(self._window)
|
dialog.window.set_transient_for(self._gdk_window)
|
||||||
|
@ -90,7 +90,7 @@ class Shell(gobject.GObject):
|
|||||||
del self._hosts[xid]
|
del self._hosts[xid]
|
||||||
|
|
||||||
def get_activity(self, activity_id):
|
def get_activity(self, activity_id):
|
||||||
for host in self._hosts:
|
for host in self._hosts.values():
|
||||||
if host.get_id() == activity_id:
|
if host.get_id() == activity_id:
|
||||||
return host
|
return host
|
||||||
return None
|
return None
|
||||||
@ -128,6 +128,11 @@ class Shell(gobject.GObject):
|
|||||||
info = self._registry.get_activity(service.get_type())
|
info = self._registry.get_activity(service.get_type())
|
||||||
|
|
||||||
activity_id = service.get_activity_id()
|
activity_id = service.get_activity_id()
|
||||||
|
|
||||||
|
activity = self.get_activity(activity_id)
|
||||||
|
if activity:
|
||||||
|
activity.present()
|
||||||
|
else:
|
||||||
pservice = PresenceService()
|
pservice = PresenceService()
|
||||||
activity_ps = pservice.get_activity(activity_id)
|
activity_ps = pservice.get_activity(activity_id)
|
||||||
|
|
||||||
|
@ -14,7 +14,6 @@ def get_display_number():
|
|||||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
try:
|
try:
|
||||||
s.connect(('127.0.0.1', 6000 + display_number))
|
s.connect(('127.0.0.1', 6000 + display_number))
|
||||||
logging.info('Display %d is already in use. Trying next.' % (display_number))
|
|
||||||
s.close()
|
s.close()
|
||||||
|
|
||||||
display_number += 1
|
display_number += 1
|
||||||
|
Loading…
Reference in New Issue
Block a user