diff options
author | Marco Pesenti Gritti <marco@localhost.localdomain> | 2007-06-01 19:21:30 (GMT) |
---|---|---|
committer | Marco Pesenti Gritti <marco@localhost.localdomain> | 2007-06-01 19:21:30 (GMT) |
commit | 2b7ffe41d9e8160c7bda506efe9ad35971d599df (patch) | |
tree | 3b35d81db14c94327c30a32abbe8a614a56f8c17 /sugar/activity/activity.py | |
parent | 5cc9a8c42437376ccef2fbe578a637f8ab3396b5 (diff) |
Make bundle_id and activity_id window properties to
avoid races.
Diffstat (limited to 'sugar/activity/activity.py')
-rw-r--r-- | sugar/activity/activity.py | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/sugar/activity/activity.py b/sugar/activity/activity.py index f1bda6c..143fa94 100644 --- a/sugar/activity/activity.py +++ b/sugar/activity/activity.py @@ -32,6 +32,7 @@ from sugar.graphics.window import Window from sugar.graphics.toolbox import Toolbox from sugar.graphics.toolbutton import ToolButton from sugar.datastore import datastore +from sugar import wm from sugar import profile class ActivityToolbar(gtk.Toolbar): @@ -178,6 +179,7 @@ class Activity(Window, gtk.Container): Window.__init__(self) self.connect('destroy', self._destroy_cb) + self.connect('realize', self._realize_cb) self._active = False self._activity_id = handle.activity_id @@ -207,7 +209,7 @@ class Activity(Window, gtk.Container): logging.debug('Creating a jobject.') self._jobject = datastore.create() self._jobject.metadata['title'] = '%s %s' % (get_bundle_name(), 'Activity') - self._jobject.metadata['activity'] = self.get_service_name() + self._jobject.metadata['activity'] = self._get_service_name() self._jobject.metadata['keep'] = '0' self._jobject.metadata['buddies'] = '' self._jobject.metadata['preview'] = '' @@ -286,20 +288,12 @@ class Activity(Window, gtk.Container): self.present() self.emit('joined') - def get_service_name(self): - """Gets the activity service name.""" - return os.environ['SUGAR_BUNDLE_SERVICE_NAME'] - def get_shared(self): """Returns TRUE if the activity is shared on the mesh.""" if not self._shared_activity: return False return self._shared_activity.props.joined - def get_id(self): - """Get the unique activity identifier.""" - return self._activity_id - def _internal_share_cb(self, ps, success, activity, err): self._pservice.disconnect(self._share_id) self._share_id = None @@ -322,6 +316,13 @@ class Activity(Window, gtk.Container): """Execute the given command with args""" return False + def _get_service_name(self): + return os.environ['SUGAR_BUNDLE_SERVICE_NAME'] + + def _realize_cb(self, window): + wm.set_bundle_id(window.window, self._get_service_name()) + wm.set_activity_id(window.window, self._activity_id) + def _destroy_cb(self, window): """Destroys our ActivityService and sharing service""" if self._bus: |