Add a start method to the activity. It's parallel/alternative to join.
This commit is contained in:
parent
ad31376488
commit
6b09475b99
@ -209,7 +209,7 @@ class Shell(gobject.GObject):
|
|||||||
def start_activity(self, activity_type):
|
def start_activity(self, activity_type):
|
||||||
logging.debug('Shell.start_activity')
|
logging.debug('Shell.start_activity')
|
||||||
activity = ActivityFactory.create(activity_type)
|
activity = ActivityFactory.create(activity_type)
|
||||||
activity.execute('test', [])
|
activity.start()
|
||||||
return activity
|
return activity
|
||||||
|
|
||||||
def set_zoom_level(self, level):
|
def set_zoom_level(self, level):
|
||||||
|
@ -23,7 +23,7 @@ import dbus.service
|
|||||||
import gtk
|
import gtk
|
||||||
import gobject
|
import gobject
|
||||||
|
|
||||||
from sugar.presence.PresenceService import PresenceService
|
from sugar.presence import PresenceService
|
||||||
from sugar import activity
|
from sugar import activity
|
||||||
from sugar import env
|
from sugar import env
|
||||||
import sugar.util
|
import sugar.util
|
||||||
@ -44,21 +44,31 @@ class ActivityDbusService(dbus.service.Object):
|
|||||||
The dbus service is separate from the actual Activity object so that we can
|
The dbus service is separate from the actual Activity object so that we can
|
||||||
tightly control what stuff passes through the dbus python bindings."""
|
tightly control what stuff passes through the dbus python bindings."""
|
||||||
|
|
||||||
def start(self, pservice, activity):
|
def __init__(self, activity):
|
||||||
|
xid = activity.window.xid
|
||||||
|
bus = dbus.SessionBus()
|
||||||
|
bus_name = dbus.service.BusName(get_service_name(xid), bus=bus)
|
||||||
|
dbus.service.Object.__init__(self, bus_name, get_object_path(xid))
|
||||||
|
|
||||||
self._activity = activity
|
self._activity = activity
|
||||||
self._pservice = pservice
|
self._pservice = PresenceService.get_instance()
|
||||||
|
|
||||||
|
@dbus.service.method(ACTIVITY_INTERFACE)
|
||||||
|
def start(self):
|
||||||
|
"""Start the activity."""
|
||||||
|
self._activity.start()
|
||||||
|
|
||||||
|
@dbus.service.method(ACTIVITY_INTERFACE)
|
||||||
|
def join(self, activity_ps_path):
|
||||||
|
"""Join the activity specified by its presence service path."""
|
||||||
|
activity_ps = self._pservice.get(activity_ps_path)
|
||||||
|
return self._activity.join(activity_ps)
|
||||||
|
|
||||||
@dbus.service.method(ACTIVITY_INTERFACE)
|
@dbus.service.method(ACTIVITY_INTERFACE)
|
||||||
def share(self):
|
def share(self):
|
||||||
"""Called by the shell to request the activity to share itself on the network."""
|
"""Called by the shell to request the activity to share itself on the network."""
|
||||||
self._activity.share()
|
self._activity.share()
|
||||||
|
|
||||||
@dbus.service.method(ACTIVITY_INTERFACE)
|
|
||||||
def join(self, activity_ps_path):
|
|
||||||
"""Join the activity specified by its presence service path"""
|
|
||||||
activity_ps = self._pservice.get(activity_ps_path)
|
|
||||||
return self._activity.join(activity_ps)
|
|
||||||
|
|
||||||
@dbus.service.method(ACTIVITY_INTERFACE)
|
@dbus.service.method(ACTIVITY_INTERFACE)
|
||||||
def get_id(self):
|
def get_id(self):
|
||||||
"""Get the activity identifier"""
|
"""Get the activity identifier"""
|
||||||
@ -90,7 +100,7 @@ class Activity(gtk.Window):
|
|||||||
self._shared = False
|
self._shared = False
|
||||||
self._activity_id = None
|
self._activity_id = None
|
||||||
self._service = None
|
self._service = None
|
||||||
self._pservice = PresenceService()
|
self._pservice = PresenceService.get_instance()
|
||||||
|
|
||||||
self.present()
|
self.present()
|
||||||
|
|
||||||
@ -98,12 +108,11 @@ class Activity(gtk.Window):
|
|||||||
group.realize()
|
group.realize()
|
||||||
self.window.set_group(group.window)
|
self.window.set_group(group.window)
|
||||||
|
|
||||||
bus = dbus.SessionBus()
|
self._bus = ActivityDbusService(self)
|
||||||
xid = self.window.xid
|
|
||||||
|
|
||||||
bus_name = dbus.service.BusName(get_service_name(xid), bus=bus)
|
def start(self):
|
||||||
self._bus = ActivityDbusService(bus_name, get_object_path(xid))
|
"""Start the activity."""
|
||||||
self._bus.start(self._pservice, self)
|
self._activity_id = sugar.util.unique_id()
|
||||||
|
|
||||||
def get_type(self):
|
def get_type(self):
|
||||||
"""Gets the activity type."""
|
"""Gets the activity type."""
|
||||||
@ -119,8 +128,6 @@ class Activity(gtk.Window):
|
|||||||
|
|
||||||
def get_id(self):
|
def get_id(self):
|
||||||
"""Get the unique activity identifier."""
|
"""Get the unique activity identifier."""
|
||||||
if self._activity_id == None:
|
|
||||||
self._activity_id = sugar.util.unique_id()
|
|
||||||
return self._activity_id
|
return self._activity_id
|
||||||
|
|
||||||
def join(self, activity_ps):
|
def join(self, activity_ps):
|
||||||
|
Loading…
Reference in New Issue
Block a user