diff options
Diffstat (limited to 'tutorius/creator.py')
-rw-r--r-- | tutorius/creator.py | 52 |
1 files changed, 42 insertions, 10 deletions
diff --git a/tutorius/creator.py b/tutorius/creator.py index 04c96fd..4ac2033 100644 --- a/tutorius/creator.py +++ b/tutorius/creator.py @@ -25,6 +25,8 @@ import gtk.glade import gobject from gettext import gettext as T +import pickle + import uuid import os from sugar.graphics import icon, style @@ -246,7 +248,8 @@ class Creator(Object): self._probe_mgr.install(action, action_installed_cb=return_cb, error_cb=self._dbus_exception, - is_editing=True) + is_editing=True, + editing_cb=self.update_addon_property) if state_actions: # I'm really lazy right now and to keep things simple I simply @@ -262,12 +265,14 @@ class Creator(Object): def _add_action_cb(self, widget, path): """Callback for the action creation toolbar tool""" action_type = self._propedit.actions_list[path][ToolBox.ICON_NAME] + LOGGER.debug("Creator :: Adding an action = %s"%(action_type)) action = addon.create(action_type) return_cb = partial(self._action_installed_cb, action) self._probe_mgr.install(action, action_installed_cb=return_cb, error_cb=self._dbus_exception, - is_editing=True) + is_editing=True, + editing_cb=self.update_addon_property) self._tutorial.add_action(self._state, action) self._propedit.action = action self._overview.win.queue_draw() @@ -324,8 +329,7 @@ class Creator(Object): address = action.address self._probe_mgr.update(address, action, - is_editing=True - ) + is_editing=True) def _update_error(self, exception): pass @@ -341,7 +345,8 @@ class Creator(Object): self._probe_mgr.install(action, action_installed_cb=return_cb, error_cb=self._dbus_exception, - is_editing=True) + is_editing=True, + editing_cb=self.update_addon_property) self._propedit.action = action self._overview.win.queue_draw() @@ -393,10 +398,17 @@ class Creator(Object): vault.INI_GUID_PROPERTY: self._guid, vault.INI_NAME_PROPERTY: tutorial_name, vault.INI_VERSION_PROPERTY: '1', - 'activities':{os.environ['SUGAR_BUNDLE_NAME']: - os.environ['SUGAR_BUNDLE_VERSION'] - }, } + # FIXME : The environment does not dispose of the appropriate + # variables to inform the creator at this point. We will + # need to iterate inside all the actions and remember + # their sources. + + # FIXME : I insist. This is a hack. + related_activities_dict = {} + related_activities_dict['calculate'] = '27' + + self._metadata['activities'] = dict(related_activities_dict) vault.Vault.saveTutorial(self._tutorial, self._metadata) @@ -413,13 +425,13 @@ class Creator(Object): action.address = address self._installed_actions.append(action) - def _dbus_exception(self, exception): + def _dbus_exception(self, event, exception): """ This is a callback intented to be use to receive exceptions on remote DBUS calls. @param exception: the exception thrown by the remote process """ - pass + LOGGER.debug("Creator :: Got exception -> %s"%(str(exception))) @method(BUS_NAME, in_signature='', @@ -430,6 +442,26 @@ class Creator(Object): """ return self.is_authoring + def update_addon_property(self, addon_address, diff_dict): + """ + Updates the properties on an addon. + + @param addon_address The address of the addon that has the property + @param diff_dict The updates to apply to the property dict. + This is treated as a partial update to the addon's + dictionary and contains at least one property value pair + @returns True if the property was updated, False otherwise + """ + # Look up the registered addresses inside the installed actions + for action in self._installed_actions: + # If this is the correct action + if action.address == addon_address: + # Update its property with the new value + action._props.update(diff_dict) + # Update the property edition dialog with it + self._propedit.action = action + return True + class ToolBox(object): """ Palette window for edition tools, including the actions, states and |