Mercurial > libervia-backend
diff tools/xml_tools.py @ 183:9ee4a1d0d7fb
Added auto(dis)connect params + misc
- parameters,xmlui: "bool" type is now managed
- parameters,xmlui: categories now use label in addition of name
- QuickFrontend: auto(dis)connection management
- plugin XEP-0045: an error dialog is now show in frontend if room cannot be joined
- Wix: fixed unproper close event management
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 18 Aug 2010 15:57:26 +0800 |
parents | f494cba56a9e |
children | e178e8f6d13a |
line wrap: on
line diff
--- a/tools/xml_tools.py Wed Aug 18 12:45:48 2010 +0800 +++ b/tools/xml_tools.py Wed Aug 18 15:57:26 2010 +0800 @@ -81,12 +81,14 @@ param_ui = XMLUI("param", "tabs") for category in top.getElementsByTagName("category"): name = category.getAttribute('name') + label = category.getAttribute('label') if not name: error(_('INTERNAL ERROR: params categories must have a name')) assert(False) - param_ui.addCategory(name, 'pairs') + param_ui.addCategory(name, 'pairs', label=label) for param in category.getElementsByTagName("param"): name = param.getAttribute('name') + label = param.getAttribute('label') if not name: error(_('INTERNAL ERROR: params must have a name')) assert(False) @@ -96,7 +98,7 @@ if type == "button": param_ui.addEmpty() else: - param_ui.addLabel(name) + param_ui.addLabel(label or name) param_ui.addElement(name=name, type=type, value=value, callback_id=callback_id) return param_ui.toXml() @@ -209,6 +211,12 @@ if value: elem.setAttribute('value', value) + def addBool(self, name=None, value="true"): + """Add a string box""" + assert value in ["true","false"] + elem = self.__createElem('bool', name, self.currentLayout) + elem.setAttribute('value', value) + def addList(self, options, name=None, value=None, style=set()): """Add a list of choices""" styles = set(style) @@ -253,6 +261,10 @@ self.addPassword(name, value) elif type == 'textbox': self.addTextBox(name, value) + elif type == 'bool': + if not value: + value = "true" + self.addBool(name, value) elif type == 'list': self.addList(options, name, value) elif type == 'button': @@ -267,7 +279,7 @@ opt.setAttribute('value', option) parent.appendChild(opt) - def addCategory(self, name, layout): + def addCategory(self, name, layout, label=None): """Add a category to current layout (must be a tabs layout)""" assert(layout != 'tabs') if not self.parentTabsLayout: @@ -276,8 +288,12 @@ if self.parentTabsLayout.getAttribute('type') != 'tabs': error(_("parent layout of a category is not tabs")) assert(False) + + if not label: + label = name self.currentCategory = cat = self.doc.createElement('category') cat.setAttribute('name', name) + cat.setAttribute('label', label) self.changeLayout(layout) self.parentTabsLayout.appendChild(cat)