From 2c8fe66c0f7490c8aaaae27b4977b987001c6b71 Mon Sep 17 00:00:00 2001 From: mike Date: Tue, 01 Dec 2009 20:11:43 +0000 Subject: Merge branch 'master' of git://git.sugarlabs.org/tutorius/simpoirs-clone Conflicts: src/extensions/tutoriusremote.py tutorius/TProbe.py tutorius/creator.py --- (limited to 'tutorius/creator.py') diff --git a/tutorius/creator.py b/tutorius/creator.py index e8182b0..54e2912 100644 --- a/tutorius/creator.py +++ b/tutorius/creator.py @@ -37,6 +37,8 @@ from . import viewer from .propwidgets import TextInputDialog from . import TProbe +from functools import partial + from dbus import SessionBus from dbus.service import method, Object, BusName @@ -75,6 +77,7 @@ class Creator(Object): self.is_authoring = False Creator._instance = self self._probe_mgr = TProbe.ProbeManager.default_instance + self._installed_actions = list() def start_authoring(self, tutorial=None): """ @@ -177,8 +180,8 @@ class Creator(Object): .get(action, None) if not action_obj: return False - #action_obj.exit_editmode() - self._probe_mgr.uninstall(action_obj, is_editing=True) + + self._probe_mgr.uninstall(action_obj.address) self._tutorial.delete_action(action) self._overview.win.queue_draw() return True @@ -225,47 +228,43 @@ class Creator(Object): or state_name == self._tutorial.END: return - for action in self._tutorial.get_action_dict(self._state).values(): - #action.exit_editmode() - self._probe_mgr.uninstall(action, is_editing=True) + for action in self._installed_actions: + self._probe_mgr.uninstall(action.address, + is_editing=True) + self._installed_actions = [] self._state = state_name state_actions = self._tutorial.get_action_dict(self._state).values() + for action in state_actions: - action.enter_editmode() - action._drag._eventbox.connect_after( - "button-release-event", self._action_refresh_cb, action) + 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) if state_actions: + # I'm really lazy right now and to keep things simple I simply + # always select the first action when + # we change state. we should really select the clicked block + # in the overview instead. FIXME self._propedit.action = state_actions[0] else: self._propedit.action = None self._overview.win.queue_draw() - - def _evfilt_cb(self, menuitem, event): - """ - This will get called once the user has selected a menu item from the - event filter popup menu. This should add the correct event filter - to the FSM and increment states. - """ - # undo actions so they don't persist through step editing - for action in self._state.get_action_list(): - self._probe_mgr.uninstall(action, is_editing=True) - #action.exit_editmode() - self._propedit.action = None - #self._activity.queue_draw() - def _add_action_cb(self, widget, path): """Callback for the action creation toolbar tool""" action_type = self._propedit.actions_list[path][ToolBox.ICON_NAME] action = addon.create(action_type) - self._probe_mgr.install(action, is_editing=True) + 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) self._tutorial.add_action(self._state, action) - # FIXME: replace following with event catching - #action._drag._eventbox.connect_after( - # "button-release-event", self._action_refresh_cb, action) + self._propedit.action = action self._overview.win.queue_draw() def _add_event_cb(self, widget, path): @@ -290,12 +289,7 @@ class Creator(Object): """ event_type = self._propedit.events_list[path][ToolBox.ICON_NAME] - event = addon.create(event_type) - addonname = type(event).__name__ - meta = addon.get_addon_meta(addonname) - for propname in meta['mandatory_props']: - prop = getattr(type(event), propname) - prop.widget_class.run_dialog(None, event, propname) + event = self._probe_mgr.create_event(event_type) event_filters = self._tutorial.get_transition_dict(self._state) @@ -328,14 +322,13 @@ class Creator(Object): Callback for refreshing properties values and notifying the property dialog of the new values. """ - self._probe_mgr.uninstall(action, is_editing=True) - #action.exit_editmode() - self._probe_mgr.install(action, is_editing=True) - #action.enter_editmode() - #self._activity.queue_draw() - # TODO: replace following with event catching - #action._drag._eventbox.connect_after( - # "button-release-event", self._action_refresh_cb, action) + self._probe_mgr.uninstall(action.address, + is_editing=True) + 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) self._propedit.action = action self._overview.win.queue_draw() @@ -348,12 +341,12 @@ class Creator(Object): """ # undo actions so they don't persist through step editing for action in self._tutorial.get_action_dict(self._state).values(): - #action.exit_editmode() - self._probe_mgr.uninstall(action, is_editing=True) + self._probe_mgr.uninstall(action.address, + is_editing=True) if kwargs.get('force', False): dialog = gtk.MessageDialog( - parent=None, + parent=self._overview.win, flags=gtk.DIALOG_MODAL, type=gtk.MESSAGE_QUESTION, buttons=gtk.BUTTONS_YES_NO, @@ -398,6 +391,23 @@ class Creator(Object): assert False, "REMOVE THIS CALL!!!" launch = staticmethod(launch) + def _action_installed_cb(self, action, address): + """ + This is a callback intented to be use to receive actions addresses + after they are installed. + @param address: the address of the newly installed action + """ + action.address = address + self._installed_actions.append(action) + + def _dbus_exception(self, 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 + class ToolBox(object): """ -- cgit v0.9.1