From 342f15e9e9170af02ed332cefd095b51fa0ed759 Mon Sep 17 00:00:00 2001 From: Simon Poirier Date: Mon, 07 Dec 2009 05:56:49 +0000 Subject: run_dialog in activity context to permit full activity introspection and benefit from nonblocking mandatory property selection --- (limited to 'tutorius') 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 -- cgit v0.9.1