From 1b14209814e2319dd9fc74cb77576b352ed531a3 Mon Sep 17 00:00:00 2001 From: Goffi Date: Thu, 12 Aug 2010 12:31:45 +0800 Subject: [PATCH] Primitivus: XMLUI's show method now manage window and popup --- frontends/primitivus/xmlui.py | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/frontends/primitivus/xmlui.py b/frontends/primitivus/xmlui.py index c3838fff..6c217fff 100644 --- a/frontends/primitivus/xmlui.py +++ b/frontends/primitivus/xmlui.py @@ -55,6 +55,7 @@ class XMLUI(urwid.WidgetWrap): self.title = title self.options = options self.misc = misc + self.__dest = "window" self.ctrl_list = {} # usefull to access ctrl widget = self.constructUI(xml_data) urwid.WidgetWrap.__init__(self,widget) @@ -151,8 +152,7 @@ class XMLUI(urwid.WidgetWrap): cat_dom = minidom.parseString(xml_data.encode('utf-8')) top=cat_dom.documentElement self.type = top.getAttribute("type") - if not self.title: - self.title = top.getAttribute("title") #TODO: manage title + self.title = top.getAttribute("title") or self.title if top.nodeName != "sat_xmlui" or not self.type in ['form', 'param', 'window']: raise InvalidXMLUI @@ -185,10 +185,20 @@ class XMLUI(urwid.WidgetWrap): ret_wid.addFooter(grid_wid) return ret_wid - def show(self): - """Show the constructed UI""" + def show(self,show_type = 'popup'): + """Show the constructed UI + @param show_type: how to show the UI: + - popup + - window""" + self.__dest = "popup" decorated = custom_widgets.LabelLine(self, custom_widgets.SurroundedText(self.title or '')) - self.host.showPopUp(decorated) + if show_type == 'popup': + self.host.showPopUp(decorated) + elif show_type == 'window': + self.host.addWindow(decorated) + else: + error(_('INTERNAL ERROR: Unmanaged show_type (%s)') % show_type) + assert(False) self.host.redraw() @@ -230,7 +240,10 @@ class XMLUI(urwid.WidgetWrap): self.host.removePopUp() def onFormCancelled(self, button): - self.host.removePopUp() + if self.__dest == 'window': + self.host.removeWindow() + else: + self.host.removePopUp() def onSaveParams(self, button): for ctrl in self.param_changed: