davemds pushed a commit to branch master. http://git.enlightenment.org/apps/espionage.git/commit/?id=49faa4d42352f2d58673a6ff6ff8a7c719be7936
commit 49faa4d42352f2d58673a6ff6ff8a7c719be7936 Author: davemds <[email protected]> Date: Wed Dec 11 21:11:45 2013 +0100 Open the Method Runner in a separate window. Instead of using Popup now the method runner open a new window for each method to run. You can now keep multiple runners opened at the same time and the window is resizable too. a full win. credits to k-s for the suggestion --- espionage/espionage.py | 134 ++++++++++++++++++++++++++++--------------------- 1 file changed, 78 insertions(+), 56 deletions(-) diff --git a/espionage/espionage.py b/espionage/espionage.py index e9b162e..0f663d9 100644 --- a/espionage/espionage.py +++ b/espionage/espionage.py @@ -69,6 +69,14 @@ def prettify_if_needed(data): else: return utf8_to_markup(str(data)) +def colored_params(plist, omit_braces=False): + p = ', '.join(["<font %s>%s</> <font %s>%s</>" % \ + (options.stl_ptype, ty, options.stl_pname, name) + for name, ty in plist]) + if omit_braces: + return p + return '<font %s>(</>%s<font %s>)</>' % \ + (options.stl_brackets, p, options.stl_brackets) ### connect to session and system buses, and set session as the current one session_bus = dbus.SessionBus(mainloop=DBusEcoreMainLoop()) @@ -407,13 +415,6 @@ class NodeItemClass(GenlistItemClass): def __init__(self): GenlistItemClass.__init__(self, item_style="default_style") - def _colored_params(self, plist): - p = ["<font %s>%s</> <font %s>%s</>" % (options.stl_ptype, ty, - options.stl_pname, name) - for name, ty in plist] - return '<font %s>(</>%s<font %s>)</>' % \ - (options.stl_brackets, ', '.join(p), options.stl_brackets) - def text_get(self, gl, part, obj): if isinstance(obj, DBusInterface): return '<font %s>[IFACE] %s</>' % (options.stl_iface, obj.name) @@ -428,15 +429,15 @@ class NodeItemClass(GenlistItemClass): (options.stl_name, obj.name, options.stl_ptype, obj.type, obj.access, options.stl_arrow) if isinstance(obj, DBusMethod): - params = self._colored_params(obj.params) + params = colored_params(obj.params) if obj.returns: - rets = self._colored_params(obj.returns) + rets = colored_params(obj.returns) return '<font %s>[METH] %s</> %s <font %s>→</> %s' % \ (options.stl_name, obj.name, params, options.stl_arrow, rets) else: return '<font %s>[METH] %s</> %s' % (options.stl_name, obj.name, params) if isinstance(obj, DBusSignal): - params = self._colored_params(obj.params) + params = colored_params(obj.params) return '<font %s>[SIGN] %s</> %s' % (options.stl_name, obj.name, params) class DetailList(Genlist): @@ -506,68 +507,72 @@ class DetailList(Genlist): ### Methods runner -class MethodRunner(Popup): +class MethodRunner(StandardWindow): def __init__(self, parent, method): - Popup.__init__(self, parent) + StandardWindow.__init__(self, "espionage", "Method", autodel = True) self._method = method self._param_entry = None self._return_entry = None - # title - self.part_text_set('title,text', 'Method: %s()' % method.name) - self.show() - - # content is vbox - vbox = Box(parent) + # content is vbox (with surrounding pad frame) + pad = Frame(self, style='pad_medium') + pad.size_hint_weight = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND + pad.size_hint_align = EVAS_HINT_FILL, EVAS_HINT_FILL + self.resize_object_add(pad) + pad.show() + + vbox = Box(self) + vbox.size_hint_weight = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND + vbox.size_hint_align = EVAS_HINT_FILL, EVAS_HINT_FILL + pad.content = vbox vbox.show() - self.content = vbox + + # title + f = "font_size=16 align=0.5 font_weight=Bold" + en = Entry(self, text='<font %s>%s()</>' % (f, method.name)) + en.size_hint_weight = EVAS_HINT_EXPAND, 0.0 + en.size_hint_align = EVAS_HINT_FILL, 0.0 + en.editable = False + vbox.pack_end(en) + en.show() # params label + entry if len(method.params) > 0: - label = Label(parent) - label.size_hint_align = 0.0, 0.5 - label.text = 'Params: ' + method.params_str - label.show() + label = Entry(self, editable=False) + label.size_hint_weight = EVAS_HINT_EXPAND, 0.0 + label.size_hint_align = EVAS_HINT_FILL, 0.0 + pars = colored_params(method.params, omit_braces=True) + label.text = 'Params: %s' % (pars if method.params else 'None') vbox.pack_end(label) + label.show() - en = Entry(parent) + en = Entry(self, editable=True, scrollable=True, single_line=True) + en.size_hint_weight = EVAS_HINT_EXPAND, 0.0 + en.size_hint_align = EVAS_HINT_FILL, 0.0 self._param_entry = en - en.editable = True - en.scrollable = True - en.single_line = True - en.entry = '' - en.size_hint_weight = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND - en.size_hint_align = EVAS_HINT_FILL, EVAS_HINT_FILL - en.show() vbox.pack_end(en) - - sp = Separator(parent) - sp.horizontal = True - sp.show() - vbox.pack_end(sp) + en.show() # returns label + entry - label = Label(parent) - label.size_hint_align = 0.0, 0.5 - label.text = 'Returns: ' - label.text += method.returns_str if method.returns_str else 'None' - label.show() + label = Entry(self, editable=False) + label.size_hint_weight = EVAS_HINT_EXPAND, 0.0 + label.size_hint_align = EVAS_HINT_FILL, 0.0 + rets = colored_params(method.returns, omit_braces=True) + label.text = 'Returns: %s' % (rets if method.returns else 'None') vbox.pack_end(label) + label.show() - en = Entry(parent) - self._return_entry = en + en = Entry(self, editable=False, scrollable=True) en.size_hint_weight = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND en.size_hint_align = EVAS_HINT_FILL, EVAS_HINT_FILL - en.size_hint_min = 800, 800 # TODO: this should be respected :/ - en.editable = False - en.scrollable = True - en.show() + self._return_entry = en vbox.pack_end(en) + en.show() # pretty print check button def pretty_output_clicked_cb(chk): options.pretty_output = chk.state - ch = Check(parent) + ch = Check(self) ch.size_hint_align = 0.0, 0.5 ch.text = "Prettify output (loosing type infos)" ch.state = options.pretty_output @@ -575,21 +580,38 @@ class MethodRunner(Popup): ch.show() vbox.pack_end(ch) - # popup buttons - btn = Button(parent) + sep = Separator(self, horizontal=True) + vbox.pack_end(sep) + sep.show() + + # buttons + hbox = Box(self, horizontal=True) + hbox.size_hint_weight = EVAS_HINT_EXPAND, 0.0 + hbox.size_hint_align = EVAS_HINT_FILL, 0.5 + vbox.pack_end(hbox) + hbox.show() + + btn = Button(self) btn.text = 'Close' btn.callback_clicked_add(lambda b: self.delete()) - self.part_content_set('button1', btn) + hbox.pack_end(btn) + btn.show() - btn = Button(parent) + btn = Button(self) btn.text = 'Clear output' btn.callback_clicked_add(lambda b: self._return_entry.entry_set('')) - self.part_content_set('button2', btn) + hbox.pack_end(btn) + btn.show() - btn = Button(parent) + btn = Button(self) btn.text = 'Run method' btn.callback_clicked_add(self.run_clicked_cb) - self.part_content_set('button3', btn) + hbox.pack_end(btn) + btn.show() + + # show the window + self.resize(300, 300) + self.show() def run_clicked_cb(self, btn): # collect method infos @@ -607,7 +629,7 @@ class MethodRunner(Popup): iface = dbus.Interface(obj, iface_name) meth = iface.get_dbus_method(method_name) - # async method call # TODO make another example for this + # async method call try: if user_params: meth(eval(user_params), --
