From 6c7cab75774cf5591657c051397b665ec727aa0e Mon Sep 17 00:00:00 2001 From: Simon Poirier Date: Mon, 23 Nov 2009 02:52:54 +0000 Subject: bug fix: add last transition and fix non-linear edition --- (limited to 'tutorius') diff --git a/tutorius/creator.py b/tutorius/creator.py index baf7cb3..fd9f1e8 100644 --- a/tutorius/creator.py +++ b/tutorius/creator.py @@ -54,6 +54,14 @@ class Creator(object): self._tutorial.update_transition( transition_name=self._tutorial.INITIAL_TRANSITION_NAME, new_state=self._state) + final_event = addon.create( + name='MessageButtonNext', + message=T('This is the end of this tutorial.') + ) + self._tutorial.add_transition( + state_name=self._state, + transition=(final_event, self._tutorial.END), + ) else: self._tutorial = tutorial # TODO load existing tutorial; unused yet @@ -126,7 +134,9 @@ class Creator(object): @returns: True if successful, otherwise False. """ - if self._state in (self._tutorial.INIT, self._tutorial.END): + if self._state in (self._tutorial.INIT, self._tutorial.END) \ + or self._tutorial.END in \ + self._tutorial.get_following_states_dict(self._state): # last state cannot be removed return False @@ -137,9 +147,27 @@ class Creator(object): return bool(self._tutorial.delete_state(remove_state)) def get_insertion_point(self): + """ + @returns: the current tutorial insertion point. + """ return self._state def set_insertion_point(self, state_name): + """ + 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. + + @param state_name: the name of the state to use as insertion point + """ + # first is not modifiable, as the auto transition would make changes + # pointless. The end state is also pointless to modify, as the tutorial + # gets detached. + if state_name == self._tutorial.INIT \ + or state_name == self._tutorial.END: + return + for action in self._tutorial.get_action_dict(self._state).values(): action.exit_editmode() @@ -217,7 +245,26 @@ class Creator(object): self._overview.win.queue_draw() def _add_event_cb(self, widget, path): - """Callback for the event creation toolbar tool""" + """ + Callback for the event creation toolbar tool. + + The behaviour of event addition is to push the transition of the current + state to the next (newly created state). + + | + v + .--------. .-------. .--------. + | action |---->| event |---->| action | + '--------' '-------' '--------' + | + .--------. .-----------. v .-------. .--------. + | action |--->| new event |-->| event |---->| action | + '--------' '-----------' '-------' '--------' + The cursor always selects a state (between the action and transition) + The result is what the user expects: inserting before an action will + effectively shift the next transition to the next state. + + """ event_type = self._propedit.events_list[path][ToolBox.ICON_NAME] event = addon.create(event_type) addonname = type(event).__name__ @@ -230,10 +277,14 @@ class Creator(object): # if not at the end of tutorial if event_filters: - old_transition = event_filters.keys()[0] - new_state = self._tutorial.add_state(event_filters[old_transition]) - self._tutorial.update_transition(transition_name=old_transition, - new_state=new_state) + old_name = event_filters.keys()[0] + old_transition = self._tutorial.delete_transition(old_name) + new_state = self._tutorial.add_state( + transition_list=(old_transition,) + ) + self._tutorial.add_transition(state_name=self._state, + transition=(event, new_state), + ) else: # append empty state only if edit inserting at end of linearized -- cgit v0.9.1