changeset 2737:5c2ed8a5ae22

frontends (XMLUI): TabsContainer can now be the main container (Primitivus keep the old behaviour and always use VerticalContainer as main container)
author Goffi <goffi@goffi.org>
date Wed, 02 Jan 2019 18:32:16 +0100
parents df2bc2e704bc
children eb58f26ed236
files sat/tools/xml_tools.py sat_frontends/primitivus/xmlui.py sat_frontends/tools/xmlui.py
diffstat 3 files changed, 17 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/sat/tools/xml_tools.py	Wed Jan 02 18:28:30 2019 +0100
+++ b/sat/tools/xml_tools.py	Wed Jan 02 18:32:16 2019 +0100
@@ -693,10 +693,12 @@
 
 
 class PairsContainer(Container):
+    """Container with series of 2 elements"""
     type = "pairs"
 
 
 class LabelContainer(Container):
+    """Like PairsContainer, but first element can only be a label"""
     type = "label"
 
 
--- a/sat_frontends/primitivus/xmlui.py	Wed Jan 02 18:28:30 2019 +0100
+++ b/sat_frontends/primitivus/xmlui.py	Wed Jan 02 18:32:16 2019 +0100
@@ -432,6 +432,20 @@
         )
         PrimitivusWidget.__init__(self, self.main_cont, self.xmlui_title)
 
+
+    def _parseChilds(self, _xmlui_parent, current_node, wanted=("container",), data=None):
+        # Small hack to always have a VerticalContainer as main container in Primitivus.
+        # this used to be the default behaviour for all frontends, but now
+        # TabsContainer can also be the main container.
+        if _xmlui_parent is self:
+            node = current_node.childNodes[0]
+            if node.nodeName == "container" and node.getAttribute("type") == "tabs":
+                _xmlui_parent = self.widget_factory.createVerticalContainer(self)
+                self.main_cont = _xmlui_parent
+        return super(XMLUIPanel, self)._parseChilds(_xmlui_parent, current_node, wanted,
+                                                    data)
+
+
     def constructUI(self, parsed_dom):
         def postTreat():
             assert self.main_cont.body
--- a/sat_frontends/tools/xmlui.py	Wed Jan 02 18:28:30 2019 +0100
+++ b/sat_frontends/tools/xmlui.py	Wed Jan 02 18:32:16 2019 +0100
@@ -439,7 +439,7 @@
 
             if node.nodeName == "container":
                 type_ = node.getAttribute("type")
-                if _xmlui_parent is self and type_ != "vertical":
+                if _xmlui_parent is self and type_ not in ("vertical", "tabs"):
                     # main container is not a VerticalContainer and we want one,
                     # so we create one to wrap it
                     _xmlui_parent = self.widget_factory.createVerticalContainer(self)