diff options
Diffstat (limited to 'tutorius/creator.py')
-rw-r--r-- | tutorius/creator.py | 47 |
1 files changed, 20 insertions, 27 deletions
diff --git a/tutorius/creator.py b/tutorius/creator.py index 0d3ac3c..50017dc 100644 --- a/tutorius/creator.py +++ b/tutorius/creator.py @@ -58,7 +58,6 @@ def default_creator(): at a time. This method returns a new instance only if none already exists. Else, the existing instance is returned. """ - Creator._instance = Creator._instance or Creator() return Creator._instance def get_creator_proxy(): @@ -76,14 +75,22 @@ class Creator(Object): _instance = None - def __init__(self): + def __init__(self, probe_manager): + """ + Creates the instance of the creator. It is assumed this will be called + only once, by the Service. + + @param probe_manager The Probe Manager + """ bus_name = BusName(BUS_NAME, bus=SessionBus()) Object.__init__(self, bus_name, BUS_PATH) self.tuto = None self.is_authoring = False + if Creator._instance: + raise RuntimeError("Creator was already instanciated") Creator._instance = self - self._probe_mgr = TProbe.ProbeManager.default_instance + self._probe_mgr = probe_manager self._installed_actions = list() def start_authoring(self, tutorial=None): @@ -129,7 +136,7 @@ class Creator(Object): self._propedit = ToolBox(None) self._propedit.tree.signal_autoconnect({ - 'on_quit_clicked': self._cleanup_cb, + 'on_quit_clicked': self.cleanup_cb, 'on_save_clicked': self.save, 'on_action_activate': self._add_action_cb, 'on_event_activate': self._add_event_cb, @@ -156,18 +163,6 @@ class Creator(Object): self._transitions = dict() - # FIXME : remove when probemgr completed - #self._probe_mgr.attach('org.laptop.Calculate') - self._probe_mgr._current_activity = 'org.laptop.Calculate' - - def _tool_enter_notify_cb(self, window, event): - frame = jarabe.frame.get_view() - frame._bottom_panel.hover = True - - def _tool_leave_notify_cb(self, window, event): - frame = jarabe.frame.get_view() - frame._bottom_panel.hover = False - def _update_next_state(self, state, event, next_state): self._transitions[event] = next_state @@ -223,8 +218,8 @@ class Creator(Object): """ Set the tutorial modification point to the specified state. Actions of the state will enter the edit mode. - New actions will be inserted to that state and new transisions will - shift the current transision to the next state. + New actions will be inserted to that state and new transitions will + shift the current transition to the next state. @param state_name: the name of the state to use as insertion point """ @@ -324,21 +319,19 @@ class Creator(Object): self.set_insertion_point(new_state) - def properties_changed(self, action, properties): - LOGGER.debug("Creator :: properties_changed for action at address %s to %s"%(action.address, str(properties))) + def properties_changed(self, action): + LOGGER.debug("Creator :: properties_changed for action at address %s to %s"%(action.address)) address = action.address self._probe_mgr.update(address, action, is_editing=True) - def _update_error(self, exception): - pass - def _action_refresh_cb(self, widget, evt, action): """ Callback for refreshing properties values and notifying the property dialog of the new values. """ + # TODO : replace with update self._probe_mgr.uninstall(action.address, is_editing=True) return_cb = partial(self._action_installed_cb, action) @@ -351,7 +344,7 @@ class Creator(Object): self._overview.win.queue_draw() - def _cleanup_cb(self, *args, **kwargs): + def cleanup_cb(self, *args, **kwargs): """ Quit editing and cleanup interface artifacts. @@ -364,7 +357,8 @@ class Creator(Object): # TODO : Support quit cancellation - right now,every time we execute this, # we will forcibly end edition afterwards. It would be nice to keep creating - if kwargs.get('force', False): + if not kwargs.get('force', False): + # TODO : Move the dialog in the middle of the screen dialog = gtk.MessageDialog( parent=self._overview.win, flags=gtk.DIALOG_MODAL, @@ -579,8 +573,7 @@ class ToolBox(object): def _refresh_action_cb(self): if self._action is not None: - default_creator().properties_changed(self._action, self._action._props) - #self.__parent._creator._action_refresh_cb(None, None, self._action) + default_creator().properties_changed(self._action) # The purpose of this function is to reformat text, as current IconView # implentation does not insert carriage returns on long lines. |