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:
|
||||
def __init__(self, shell, window):
|
||||
self._shell = shell
|
||||
|
||||
xid = window.get_xid()
|
||||
self._window = window
|
||||
self._xid = window.get_xid()
|
||||
|
||||
bus = dbus.SessionBus()
|
||||
proxy_obj = bus.get_object(Activity.get_service_name(xid),
|
||||
Activity.get_object_path(xid))
|
||||
proxy_obj = bus.get_object(Activity.get_service_name(self._xid),
|
||||
Activity.get_object_path(self._xid))
|
||||
|
||||
self._activity = dbus.Interface(proxy_obj, Activity.ACTIVITY_INTERFACE)
|
||||
self._id = self._activity.get_id()
|
||||
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)
|
||||
|
||||
def get_id(self):
|
||||
@ -36,6 +36,9 @@ class ActivityHost:
|
||||
def show_people(self):
|
||||
self.show_dialog(self._people_window)
|
||||
|
||||
def present(self):
|
||||
self._window.activate(gtk.get_current_event_time())
|
||||
|
||||
def show_dialog(self, dialog):
|
||||
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]
|
||||
|
||||
def get_activity(self, activity_id):
|
||||
for host in self._hosts:
|
||||
for host in self._hosts.values():
|
||||
if host.get_id() == activity_id:
|
||||
return host
|
||||
return None
|
||||
@ -128,15 +128,20 @@ class Shell(gobject.GObject):
|
||||
info = self._registry.get_activity(service.get_type())
|
||||
|
||||
activity_id = service.get_activity_id()
|
||||
pservice = PresenceService()
|
||||
activity_ps = pservice.get_activity(activity_id)
|
||||
|
||||
if activity_ps:
|
||||
activity = ActivityFactory.create(info.get_id())
|
||||
activity.set_default_type(service.get_type())
|
||||
activity.join(activity_ps.object_path())
|
||||
activity = self.get_activity(activity_id)
|
||||
if activity:
|
||||
activity.present()
|
||||
else:
|
||||
logging.error('Cannot start activity.')
|
||||
pservice = PresenceService()
|
||||
activity_ps = pservice.get_activity(activity_id)
|
||||
|
||||
if activity_ps:
|
||||
activity = ActivityFactory.create(info.get_id())
|
||||
activity.set_default_type(service.get_type())
|
||||
activity.join(activity_ps.object_path())
|
||||
else:
|
||||
logging.error('Cannot start activity.')
|
||||
|
||||
def start_activity(self, activity_name):
|
||||
activity = ActivityFactory.create(activity_name)
|
||||
|
@ -14,7 +14,6 @@ def get_display_number():
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
try:
|
||||
s.connect(('127.0.0.1', 6000 + display_number))
|
||||
logging.info('Display %d is already in use. Trying next.' % (display_number))
|
||||
s.close()
|
||||
|
||||
display_number += 1
|
||||
|
Loading…
Reference in New Issue
Block a user