diff frontends/src/tools/xmlui.py @ 1478:90130847a0a8

frontends, primitivus: JidsList XMLUI widget management /!\ urwid SàText must be updated
author Goffi <goffi@goffi.org>
date Thu, 20 Aug 2015 18:36:53 +0200
parents 675e0e9f1653
children a77217511afd
line wrap: on
line diff
--- a/frontends/src/tools/xmlui.py	Thu Aug 20 18:35:27 2015 +0200
+++ b/frontends/src/tools/xmlui.py	Thu Aug 20 18:36:53 2015 +0200
@@ -128,6 +128,11 @@
     pass
 
 
+class JidsListWidget(Widget):
+    """A widget able to show/choose one or several strings in a list"""
+    pass
+
+
 class Container(Widget):
     """Widget which can contain other ones with a specific layout"""
 
@@ -429,6 +434,11 @@
                     _selected = [option.getAttribute("value") for option in node.getElementsByTagName("option") if option.getAttribute('selected') == C.BOOL_TRUE]
                     ctrl = self.widget_factory.createListWidget(_xmlui_parent, _options, _selected, style)
                     self.ctrl_list[name] = ({'type': type_, 'control': ctrl})
+                elif type_ == "jids_list":
+                    style = []
+                    jids = [getText(jid_) for jid_ in node.getElementsByTagName("jid")]
+                    ctrl = self.widget_factory.createJidsListWidget(_xmlui_parent, jids, style)
+                    self.ctrl_list[name] = ({'type': type_, 'control': ctrl})
                 elif type_=="button":
                     callback_id = node.getAttribute("callback")
                     ctrl = self.widget_factory.createButtonWidget(_xmlui_parent, value, self.onButtonPress)
@@ -445,7 +455,7 @@
                         if not isinstance(ctrl, (EmptyWidget, TextWidget, LabelWidget, JidWidget)):
                             log.warning(_("No change listener on [%s]") % ctrl)
 
-                if type_ != 'text':
+                elif type_ != 'text':
                     callback = node.getAttribute("internal_callback") or None
                     if callback:
                         fields = [field.getAttribute('name') for field in node.getElementsByTagName("internal_field")]
@@ -499,7 +509,7 @@
 
         @param ctrl: widget modified
         """
-        assert(self.type == "param")
+        assert self.type == "param"
         self.param_changed.add(ctrl)
 
     def onAdvListSelect(self, ctrl):
@@ -574,8 +584,8 @@
 
         def groups_of_contact(source, target):
             """Select in target the groups of the contact which is selected in source."""
-            assert(isinstance(source, ListWidget))
-            assert(isinstance(target, ListWidget))
+            assert isinstance(source, ListWidget)
+            assert isinstance(target, ListWidget)
             try:
                 contact_jid_s = source._xmluiGetSelectedValues()[0]
             except IndexError:
@@ -649,7 +659,7 @@
 
         self.type must be param
         """
-        assert(self.type == 'param')
+        assert self.type == 'param'
         for ctrl in self.param_changed:
             if isinstance(ctrl, ListWidget):
                 value = u'\t'.join(ctrl._xmluiGetSelectedValues())