Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tutorius
diff options
context:
space:
mode:
Diffstat (limited to 'tutorius')
-rw-r--r--tutorius/creator.py14
-rw-r--r--tutorius/propwidgets.py39
2 files changed, 40 insertions, 13 deletions
diff --git a/tutorius/creator.py b/tutorius/creator.py
index 9413186..f7f9752 100644
--- a/tutorius/creator.py
+++ b/tutorius/creator.py
@@ -264,6 +264,16 @@ class Creator(Object):
action_type = self._propedit.actions_list[path][ToolBox.ICON_NAME]
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,
@@ -327,6 +337,7 @@ class Creator(Object):
self._probe_mgr.update(address,
action,
is_editing=True)
+ self._propedit.action = action
def _action_refresh_cb(self, widget, evt, action):
"""
@@ -558,7 +569,8 @@ class ToolBox(object):
#Value field
prop = getattr(type(action), propname)
propedit = prop.widget_class(self.__parent, action, propname,
- self._refresh_action_cb)
+ self._refresh_action_cb,
+ probe_mgr=default_creator()._probe_mgr)
self._propedits.append(propedit)
row.pack_end(propedit.widget)
diff --git a/tutorius/propwidgets.py b/tutorius/propwidgets.py
index 7e78ba4..eb756fe 100644
--- a/tutorius/propwidgets.py
+++ b/tutorius/propwidgets.py
@@ -192,18 +192,22 @@ class PropWidget(object):
Base Class for property editing widgets.
Subclasses should implement create_widget, run_dialog and refresh_widget
"""
- def __init__(self, parent, edit_object, prop_name, changed_callback=None):
+ def __init__(self, parent, edit_object, prop_name, changed_callback=None,
+ probe_mgr=None):
"""Constructor
@param parent parent widget
@param edit_object TPropContainer being edited
@param prop_name name of property being edited
@param changed_callback optional callable to call on value changes
+ @type probe_mgr: ProbeMgr instance or None
+ @param probe_mgr: the probe manager to use to inspect activities
"""
self._parent = parent
self._edit_object = edit_object
self._propname = prop_name
self._widget = None
self._changed_cb = changed_callback
+ self._probe_mgr = probe_mgr
############################################################
# Begin Properties
@@ -254,13 +258,14 @@ class PropWidget(object):
return widget
@classmethod
- def run_dialog(cls, parent, obj_prop, propname):
+ def run_dialog(cls, parent, obj_prop, propname, probe_mgr=None):
"""
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()
@@ -318,13 +323,14 @@ class StringPropWidget(PropWidget):
self.widget.get_buffer().set_text(str(self.obj_prop)) #unicode() ?
@classmethod
- def run_dialog(cls, parent, obj_prop, propname):
+ def run_dialog(cls, parent, obj_prop, propname, probe_mgr=None):
"""
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",
@@ -380,8 +386,8 @@ class UAMPropWidget(PropWidget):
"""Allows editing an UAM property with a widget chooser"""
def _show_uam_chooser(self, widget):
"""show the UAM chooser"""
- selector = WidgetSelector(self.parent)
- self.obj_prop = selector.select()
+ evt = self._probe_mgr.create_event('FetchWidget')
+ self.obj_prop = evt.widaddr
self.notify()
def create_widget(self, init_value=None):
@@ -401,17 +407,24 @@ class UAMPropWidget(PropWidget):
self.widget.set_label(self.obj_prop)
@classmethod
- def run_dialog(cls, parent, obj_prop, propname):
+ def run_dialog(cls, parent, obj_prop, propname, probe_mgr=None):
"""
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
- """
- selector = WidgetSelector(parent)
- value = selector.select()
- setattr(obj_prop, propname, selector.select())
+ @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.')
class EventTypePropWidget(PropWidget):
"""Allows editing an EventType property"""
@@ -422,13 +435,14 @@ class EventTypePropWidget(PropWidget):
self.widget.set_text(str(self.obj_prop))
@classmethod
- def run_dialog(cls, parent, obj_prop, propname):
+ def run_dialog(cls, parent, obj_prop, propname, probe_mgr=None):
"""
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,
@@ -478,12 +492,13 @@ class IntArrayPropWidget(PropWidget):
children[i].set_text(str(value[i]))
@classmethod
- def run_dialog(cls, parent, obj_prop, propname):
+ def run_dialog(cls, parent, obj_prop, propname, probe_mgr=None):
"""
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