frontends (XMLUI): TabsContainer can now be the main container (Primitivus keep the old behaviour and always use VerticalContainer as main container)

This commit is contained in:
Goffi 2019-01-02 18:32:16 +01:00
commit 24c4cc0487
3 changed files with 17 additions and 1 deletions

View file

@ -693,10 +693,12 @@ class HorizontalContainer(Container):
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"

View file

@ -432,6 +432,20 @@ class XMLUIPanel(xmlui.XMLUIPanel, PrimitivusWidget):
)
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

View file

@ -439,7 +439,7 @@ class XMLUIPanel(XMLUIBase):
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)