diff options
author | JCTutorius <charlie@tutorius-dev.(none)> | 2009-12-08 16:43:49 (GMT) |
---|---|---|
committer | JCTutorius <charlie@tutorius-dev.(none)> | 2009-12-08 16:43:49 (GMT) |
commit | 1f896f9f8892935c6eda88782f8cca08c0b0512d (patch) | |
tree | 63fd57f5870762e05b0169b6fcf7a199f5e768d3 | |
parent | 7797a2fbab53c833ed5a66328044426dbb39bdf3 (diff) | |
parent | 410da49824e3a310829a1d02e8f8b488b227d702 (diff) |
Merge branch 'master' of gitorious@git.sugarlabs.org:tutorius/mainline
-rwxr-xr-x | src/extensions/tutoriusremote.py | 2 | ||||
-rw-r--r-- | tutorius/actions.py | 48 | ||||
-rw-r--r-- | tutorius/creator.py | 32 | ||||
-rw-r--r-- | tutorius/overlayer.py | 9 | ||||
-rw-r--r-- | tutorius/tutorial.py | 2 |
5 files changed, 68 insertions, 25 deletions
diff --git a/src/extensions/tutoriusremote.py b/src/extensions/tutoriusremote.py index d795141..129b7b3 100755 --- a/src/extensions/tutoriusremote.py +++ b/src/extensions/tutoriusremote.py @@ -104,8 +104,8 @@ class TPalette(Palette): dlg.vbox.pack_start(gtk.Label(_('Which tutorial do you want to run?\n'))) activity = get_model().get_active_activity() + act_name = activity.get_type() - act_name = activity.get_activity_name() tutorial_dict = Vault.list_available_tutorials(act_name) # Build the combo box diff --git a/tutorius/actions.py b/tutorius/actions.py index fe64c95..ed348d9 100644 --- a/tutorius/actions.py +++ b/tutorius/actions.py @@ -17,6 +17,7 @@ This module defines Actions that can be done and undone on a state """ import gtk +import cairo import logging from gettext import gettext as _ @@ -70,22 +71,37 @@ class DragWrapper(object): y = self._widget.allocation.y depth = 24 # Should be set dynamically - pxbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8, width, height) - pxbuf.fill(0xFFFFFFFF) - - px = gtk.gdk.Pixmap(None, width, height, depth) # source, size, colors - px.set_colormap(gtk.gdk.colormap_get_system()) - ctxt = px.cairo_create() - ctxt.set_source_pixbuf(pxbuf,0,0) - ctxt.paint() - - # Compensate when drawing the icon for the context - # translation done to the position occupied by the widget - ctxt.translate(-x, -y) - self._widget.draw_with_context(ctxt) - - pxbuf.get_from_drawable(px,gtk.gdk.colormap_get_system(), 0, 0, 0, 0, -1, -1) - drag_context.set_icon_pixbuf(pxbuf,0,0) + if hasattr(self._widget, 'draw_with_context'): + # Use widget window to create drawable so we are sure to have + # the same colormap when it is drawn. + px = gtk.gdk.Pixmap(self._widget.window, width, height) + ctxt = px.cairo_create() + # Compensate when drawing the icon for the context + # translation done to the position occupied by the widget + ctxt.translate(-x, -y) + self._widget.draw_with_context(ctxt) + + # Do the same for the icon shape mask + mask = gtk.gdk.Pixmap(None, width, height, 1) + ctxt = mask.cairo_create() + ctxt.set_operator(cairo.OPERATOR_CLEAR) + ctxt.paint() + ctxt.set_operator(cairo.OPERATOR_SOURCE) + ctxt.translate(-x, -y) + self._widget.draw_with_context(ctxt) + + drag_context.set_icon_pixmap(gtk.gdk.colormap_get_system(), + px, mask, 0, 0) + else: + pxbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8, + width, height) + pxbuf.get_from_drawable(self._widget.window, + gtk.gdk.colormap_get_system(), + src_x=0, src_y=0, # has it's own window + dest_x=0, dest_y=0, + width=width, height=height) + drag_context.set_icon_pixbuf(pxbuf, 0, 0) + def _drag_fail(self, *args): """ diff --git a/tutorius/creator.py b/tutorius/creator.py index 2de21ac..6ba7011 100644 --- a/tutorius/creator.py +++ b/tutorius/creator.py @@ -44,6 +44,8 @@ from dbus import SessionBus from dbus.service import method, Object, BusName from .dbustools import ignore +from jarabe.model import bundleregistry + import logging LOGGER = logging.getLogger("creator") @@ -224,6 +226,10 @@ class Creator(Object): @param state_name: the name of the state to use as insertion point """ + # Check if already in state to avoid reinstalling actions needlessly + if self._state == state_name: + return + # 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. @@ -406,14 +412,24 @@ class Creator(Object): vault.INI_NAME_PROPERTY: tutorial_name, vault.INI_VERSION_PROPERTY: '1', } - # 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' + + related_activities_dict ={} + activity_set = set() + + for state_name in self._tutorial.get_state_dict().keys(): + for action in self._tutorial.get_action_dict(state_name).values(): + if action.source is not None: + activity_set.add(action.source) + + for event,next_state in self._tutorial.get_transition_dict(state_name).values(): + if event.source is not None: + activity_set.add(event.source) + + reg = bundleregistry.get_registry() + for activity_name in activity_set: + bundle = reg.get_bundle(activity_name) + if bundle is not None: + related_activities_dict[activity_name] = str(bundle.get_activity_version()) self._metadata['activities'] = dict(related_activities_dict) diff --git a/tutorius/overlayer.py b/tutorius/overlayer.py index 1072b47..ec611ab 100644 --- a/tutorius/overlayer.py +++ b/tutorius/overlayer.py @@ -256,6 +256,13 @@ class TextBubble(gtk.Widget): yradius = height/2 width -= self.line_width height -= self.line_width + + # translate by line width to because line is drawn both side of the + # coordinates. here what a line stroke looks like: + # / """""""""" }out of shape + # width | ---------- <-exact coord + # \ .......... }in shape + context.translate(self.line_width/2, self.line_width/2) # # TODO fetch speaker coordinates @@ -428,6 +435,8 @@ class TextBubbleWImg(gtk.Widget): yradius = height/2 width -= self.line_width height -= self.line_width + + context.translate(self.line_width/2, self.line_width/2) # # TODO fetch speaker coordinates diff --git a/tutorius/tutorial.py b/tutorius/tutorial.py index b45363f..efcc0dc 100644 --- a/tutorius/tutorial.py +++ b/tutorius/tutorial.py @@ -18,6 +18,7 @@ #TODO: For notification of modifications on the Tutorial check for GObject and PyDispatcher for inspiration from .constraints import ConstraintException +from . import properties from .properties import TPropContainer _NAME_SEPARATOR = "/" @@ -802,6 +803,7 @@ class State(object): #TODO: Define the automatic transition in the same way as # other events class AutomaticTransitionEvent(TPropContainer): + source = properties.TStringProperty(None, null=True) def __repr__(self): return str(self.__class__.__name__) |