Cleanup the Activity API, code needs more love.

This commit is contained in:
Marco Pesenti Gritti
2007-02-22 00:57:49 +01:00
parent 0d7bdeb20a
commit 0b6b6cd6ac
4 changed files with 15 additions and 57 deletions
+8 -22
View File
@@ -26,16 +26,19 @@ from sugar import env
class Activity(gtk.Window):
"""Base Activity class that all other Activities derive from."""
def __init__(self, activity_handle):
def __init__(self, handle):
gtk.Window.__init__(self)
self.connect('destroy', self._destroy_cb)
self._shared = False
self._activity_id = None
self._service = None
self._activity_id = handle.activity_id
self._pservice = PresenceService.get_instance()
service = handle.get_presence_service()
if service:
self._join(service)
self.realize()
group = gtk.Window()
@@ -44,14 +47,6 @@ class Activity(gtk.Window):
self._bus = ActivityService(self)
def start(self, activity_id):
"""Start the activity."""
if self._activity_id != None:
logging.warning('The activity has been already started.')
return
self._activity_id = activity_id
self.present()
def get_type(self):
@@ -70,13 +65,8 @@ class Activity(gtk.Window):
"""Get the unique activity identifier."""
return self._activity_id
def join(self, activity_ps):
"""Join an activity shared on the network."""
if self._activity_id != None:
logging.warning('The activity has been already started.')
return
self._activity_id = activity_ps.get_id()
def _join(self, service):
self._service = service
self._shared = True
# Publish the default service, it's a copy of
@@ -103,10 +93,6 @@ class Activity(gtk.Window):
self._service = self._pservice.share_activity(self, default_type)
self._shared = True
def execute(self, command, args):
"""Execute the given command with args"""
return False
def _destroy_cb(self, window):
if self._bus:
del self._bus