XMLUI (core, frontends): added JidWidget and DividerWidget + popup type + some bugfixes:
- JidWidget is a text container a Jabber ID, this can be used by frontends for special treatment (e.g.: possibility to click on it)
- DividerWidget is a separator, like a blank or dashed line
- popup type is similar to normal window, but designed for a smaller popping window
This commit is contained in:
parent
9661c1c2c5
commit
edf3e1bc87
1 changed files with 122 additions and 14 deletions
|
|
@ -424,6 +424,7 @@ class AdvancedListContainer(Container):
|
|||
self.addHeader(header)
|
||||
|
||||
def addHeader(self, header):
|
||||
|
||||
pass # TODO
|
||||
|
||||
def addItems(self, items):
|
||||
|
|
@ -443,7 +444,7 @@ class AdvancedListContainer(Container):
|
|||
change current container to first container parent
|
||||
|
||||
"""
|
||||
if self._current_colum % self._columns != 0:
|
||||
if self._item_idx % self._columns != 0:
|
||||
raise exceptions.DataError(_("Incorrect number of items in list"))
|
||||
parent_container = self.getParentContainer()
|
||||
self.xmlui.changeContainer(parent_container)
|
||||
|
|
@ -490,6 +491,37 @@ class LabelWidget(Widget):
|
|||
self.elem.setAttribute('value', label)
|
||||
|
||||
|
||||
class JidWidget(Widget):
|
||||
type='jid'
|
||||
|
||||
def __init__(self, xmlui, jid, name=None, parent=None):
|
||||
super(JidWidget, self).__init__(xmlui, name, parent)
|
||||
try:
|
||||
self.elem.setAttribute('value', jid.full())
|
||||
except AttributeError:
|
||||
self.elem.setAttribute('value', unicode(jid))
|
||||
|
||||
|
||||
class DividerWidget(Widget):
|
||||
type = 'divider'
|
||||
|
||||
def __init__(self, xmlui, style='line', name=None, parent=None):
|
||||
""" Create a divider
|
||||
@param xmlui: XMLUI instance
|
||||
@param style: one of:
|
||||
- line: a simple line
|
||||
- dot: a line of dots
|
||||
- dash: a line of dashes
|
||||
- plain: a full thick line
|
||||
- blank: a blank line/space
|
||||
@param name: name of the widget
|
||||
@param parent: parent container
|
||||
|
||||
"""
|
||||
super(DividerWidget, self).__init__(xmlui, name, parent)
|
||||
self.elem.setAttribute('style', style)
|
||||
|
||||
|
||||
class StringWidget(InputWidget):
|
||||
type = 'string'
|
||||
|
||||
|
|
@ -521,7 +553,7 @@ class BoolWidget(InputWidget):
|
|||
self.elem.setAttribute('value', value)
|
||||
|
||||
|
||||
class ButtonWidget(InputWidget):
|
||||
class ButtonWidget(Widget):
|
||||
type = 'button'
|
||||
|
||||
def __init__(self, xmlui, callback_id, value=None, fields_back=None, name=None, parent=None):
|
||||
|
|
@ -571,10 +603,11 @@ class ListWidget(InputWidget):
|
|||
class XMLUI(object):
|
||||
"""This class is used to create a user interface (form/window/parameters/etc) using SàT XML"""
|
||||
|
||||
def __init__(self, panel_type, container="vertical", title=None, submit_id=None, session_id=None):
|
||||
def __init__(self, panel_type="window", container="vertical", title=None, submit_id=None, session_id=None):
|
||||
"""Init SàT XML Panel
|
||||
@param panel_type: one of
|
||||
- window (new window)
|
||||
- popup
|
||||
- form (formulaire, depend of the frontend, usually a panel with cancel/submit buttons)
|
||||
- param (parameters, presentation depend of the frontend)
|
||||
@param container: disposition of elements, one of:
|
||||
|
|
@ -587,7 +620,7 @@ class XMLUI(object):
|
|||
@param submit_id: callback id to call for panel_type we can submit (form, param)
|
||||
"""
|
||||
self._introspect()
|
||||
if panel_type not in ['window', 'form', 'param']:
|
||||
if panel_type not in ['window', 'form', 'param', 'popup']:
|
||||
raise exceptions.DataError(_("Unknown panel type [%s]") % panel_type)
|
||||
if panel_type == 'form' and submit_id is None:
|
||||
raise exceptions.DataError(_("form XMLUI need a submit_id"))
|
||||
|
|
@ -686,7 +719,7 @@ class XMLUI(object):
|
|||
if container not in self._containers:
|
||||
raise exceptions.DataError(_("Unknown container type [%s]") % container)
|
||||
cls = self._containers[container]
|
||||
new_container = cls(self, parent, **kwargs)
|
||||
new_container = cls(self, parent=parent, **kwargs)
|
||||
return new_container
|
||||
|
||||
def changeContainer(self, container, **kwargs):
|
||||
|
|
|
|||
Loading…
Reference in a new issue