changeset 170:2ea8dab08160

Primitivus: XMLUI's show method now manage window and popup
author Goffi <goffi@goffi.org>
date Thu, 12 Aug 2010 12:31:45 +0800
parents 06985b6ad23a
children 96af1bec2e68
files frontends/primitivus/xmlui.py
diffstat 1 files changed, 19 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/frontends/primitivus/xmlui.py	Thu Aug 12 12:30:36 2010 +0800
+++ b/frontends/primitivus/xmlui.py	Thu Aug 12 12:31:45 2010 +0800
@@ -55,6 +55,7 @@
         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 @@
         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 @@
             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 @@
         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: