Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--addons/changecolor.py4
-rw-r--r--tutorius/TProbe.py24
-rw-r--r--tutorius/actions.py6
-rw-r--r--tutorius/creator.py9
-rw-r--r--tutorius/propwidgets.py34
5 files changed, 40 insertions, 37 deletions
diff --git a/addons/changecolor.py b/addons/changecolor.py
index 53e6c53..2c47a9d 100644
--- a/addons/changecolor.py
+++ b/addons/changecolor.py
@@ -16,7 +16,7 @@
import gobject
-import gtk, gtk.gdk
+import gtk
from sugar.tutorius.actions import Action
from sugar.tutorius.properties import TUAMProperty
@@ -33,7 +33,7 @@ class ChangeColor(Action):
ChangeColorEvent
"""
# widget address property
- widaddr = TUAMProperty("0")
+ widaddr = TUAMProperty(None)
# set timeout
timeout = 500
diff --git a/tutorius/TProbe.py b/tutorius/TProbe.py
index 7f004ac..e3189fe 100644
--- a/tutorius/TProbe.py
+++ b/tutorius/TProbe.py
@@ -151,6 +151,7 @@ class TProbe(dbus.service.Object):
address = self._generate_action_reference(action)
self._installedActions[address] = action
+ updated_props = {}
if action._props:
action._props.update(loaded_action._props)
@@ -158,10 +159,23 @@ class TProbe(dbus.service.Object):
if not is_editing:
action.do(activity=self._activity, probe=self)
else:
+ # force mandatory props
+ addon_name = addon.get_name_from_type(type(action))
+ meta = addon.get_addon_meta(addon_name)
+ for propname in meta['mandatory_props']:
+ if getattr(action, propname) != None:
+ continue
+ prop = getattr(type(action), propname)
+ prop.widget_class.run_dialog(self._activity,
+ action,
+ propname)
+ updated_props[propname] = getattr(action, propname)
+
action.enter_editmode()
action.set_notification_cb(partial(self.update_action, address))
- return address
+ pickled_value = pickle.dumps((address, updated_props))
+ return pickled_value
@dbus.service.method("org.tutorius.ProbeInterface",
in_signature='ssb', out_signature='')
@@ -475,16 +489,18 @@ class ProbeProxy:
except:
return False
- def __update_action(self, action, callback, editing_cb, address):
+ def __update_action(self, action, callback, editing_cb, address_values):
+ address, values = pickle.loads(str(address_values))
LOGGER.debug("ProbeProxy :: Updating action %s with address %s", str(action), str(address))
address = str(address)
# Store the action
self._actions[address] = action
+ # Propagate the action installed callback upwards in the stack
+ callback(address)
# Store the edition callback
if editing_cb:
self._edition_callbacks[address] = editing_cb
- # Propagate the action installed callback upwards in the stack
- callback(address)
+ editing_cb(address, values)
def __clear_action(self, address):
# Remove the action installed at this address
diff --git a/tutorius/actions.py b/tutorius/actions.py
index 6d1f58e..40d9b03 100644
--- a/tutorius/actions.py
+++ b/tutorius/actions.py
@@ -225,7 +225,11 @@ class Action(TPropContainer):
self.__edit_img = gtk.EventBox()
self.__edit_img.set_visible_window(True)
self.__edit_img.add(actionicon)
-
+
+ # FIXME remove position when it's not required.
+ # Changes will also be required in the overview and DragWrapper.
+ if not hasattr(self, 'position'):
+ self.position = 0, 0
x, y = self.position
ObjectStore().activity._overlayer.put(self.__edit_img, x, y)
diff --git a/tutorius/creator.py b/tutorius/creator.py
index 3873298..ca68ca6 100644
--- a/tutorius/creator.py
+++ b/tutorius/creator.py
@@ -265,15 +265,6 @@ class Creator(Object):
LOGGER.debug("Creator :: Adding an action = %s"%(action_type))
action = addon.create(action_type)
- # force mandatory props
- meta = addon.get_addon_meta(action_type)
- for propname in meta['mandatory_props']:
- prop = getattr(type(action), propname)
- prop.widget_class.run_dialog(self._overview.win,
- action,
- propname,
- probe_mgr=self._probe_mgr)
-
return_cb = partial(self._action_installed_cb, action)
self._probe_mgr.install(action,
action_installed_cb=return_cb,
diff --git a/tutorius/propwidgets.py b/tutorius/propwidgets.py
index eb756fe..dfc6ac0 100644
--- a/tutorius/propwidgets.py
+++ b/tutorius/propwidgets.py
@@ -258,14 +258,13 @@ class PropWidget(object):
return widget
@classmethod
- def run_dialog(cls, parent, obj_prop, propname, probe_mgr=None):
+ def run_dialog(cls, parent, obj_prop, propname):
"""
Class Method.
Prompts the user for changing an object's property
@param parent widget
@param obj_prop TPropContainer to edit
@param propname name of property to edit
- @param probe_mgr a ProbeMgr instance for activity inspection
"""
raise NotImplementedError()
@@ -323,14 +322,13 @@ class StringPropWidget(PropWidget):
self.widget.get_buffer().set_text(str(self.obj_prop)) #unicode() ?
@classmethod
- def run_dialog(cls, parent, obj_prop, propname, probe_mgr=None):
+ def run_dialog(cls, parent, obj_prop, propname):
"""
Class Method.
Prompts the user for changing an object's property
@param parent widget
@param obj_prop TPropContainer to edit
@param propname name of property to edit
- @param probe_mgr a ProbeMgr instance for activity inspection
"""
dlg = TextInputDialog(parent,
text="Mandatory property",
@@ -404,27 +402,23 @@ class UAMPropWidget(PropWidget):
"""
Force the widget to update it's value in case the property has changed
"""
- self.widget.set_label(self.obj_prop)
+ if self.obj_prop:
+ self.widget.set_label(self.obj_prop)
+ else:
+ self.widget.set_label("")
@classmethod
- def run_dialog(cls, parent, obj_prop, propname, probe_mgr=None):
+ def run_dialog(cls, parent, obj_prop, propname):
"""
Class Method.
Prompts the user for changing an object's property
@param parent widget
@param obj_prop TPropContainer to edit
@param propname name of property to edit
- @param probe_mgr a ProbeMgr instance for activity inspection
- """
- if probe_mgr:
- evt = probe_mgr.create_event('FetchWidget')
- setattr(obj_prop, propname, evt.widaddr)
- elif parent:
- selector = WidgetSelector(parent)
- value = selector.select()
- setattr(obj_prop, propname, selector.select())
- else:
- raise RuntimeError('No parent or probe_mgr passed for inspection.')
+ """
+ selector = WidgetSelector(parent)
+ value = selector.select()
+ setattr(obj_prop, propname, selector.select())
class EventTypePropWidget(PropWidget):
"""Allows editing an EventType property"""
@@ -435,14 +429,13 @@ class EventTypePropWidget(PropWidget):
self.widget.set_text(str(self.obj_prop))
@classmethod
- def run_dialog(cls, parent, obj_prop, propname, probe_mgr=None):
+ def run_dialog(cls, parent, obj_prop, propname):
"""
Class Method.
Prompts the user for changing an object's property
@param parent widget
@param obj_prop TPropContainer to edit
@param propname name of property to edit
- @param probe_mgr a ProbeMgr instance for activity inspection
"""
try:
dlg = SignalInputDialog(parent,
@@ -492,13 +485,12 @@ class IntArrayPropWidget(PropWidget):
children[i].set_text(str(value[i]))
@classmethod
- def run_dialog(cls, parent, obj_prop, propname, probe_mgr=None):
+ def run_dialog(cls, parent, obj_prop, propname):
"""
Class Method.
Prompts the user for changing an object's property
@param parent widget
@param obj_prop TPropContainer to edit
@param propname name of property to edit
- @param probe_mgr a ProbeMgr instance for activity inspection
"""
pass