changeset 2739:e8dc00f612fb

jp (xmlui): JidWidget + small improvments: - JidWidget is now handled basically using TextWidget. - EmptyWidget display an empty line. - BoolWidget display current value with an asterisk when write is allowed. - fixed an bug in LabelContainer when for_name was not specified.
author Goffi <goffi@goffi.org>
date Wed, 02 Jan 2019 18:50:47 +0100
parents eb58f26ed236
children 8fd8ce5a5855
files sat_frontends/jp/xmlui_manager.py
diffstat 1 files changed, 19 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/sat_frontends/jp/xmlui_manager.py	Wed Jan 02 18:50:28 2019 +0100
+++ b/sat_frontends/jp/xmlui_manager.py	Wed Jan 02 18:50:47 2019 +0100
@@ -174,8 +174,12 @@
 
 
 class EmptyWidget(xmlui_base.EmptyWidget, Widget):
-    def __init__(self, _xmlui_parent):
-        Widget.__init__(self)
+
+    def __init__(self, xmlui_parent):
+        Widget.__init__(self, xmlui_parent)
+
+    def show(self):
+        self.host.disp(u'')
 
 
 class TextWidget(xmlui_base.TextWidget, ValueWidget):
@@ -204,6 +208,9 @@
         self.disp(A.color(ansi, self.value), no_lf=no_lf)
 
 
+class JidWidget(xmlui_base.JidWidget, TextWidget):
+    type = u"jid"
+
 class StringWidget(xmlui_base.StringWidget, InputWidget):
     type = u"string"
 
@@ -286,8 +293,12 @@
         if self.read_only:
             self.disp(disp_true if self.value else disp_false)
         else:
-            self.disp(A.color(C.A_HEADER, u"0: ", disp_false))
-            self.disp(A.color(C.A_HEADER, u"1: ", disp_true))
+            self.disp(A.color(C.A_HEADER, u"0: ",
+                              disp_false, A.RESET,
+                              u" *" if not self.value else u""))
+            self.disp(A.color(C.A_HEADER, u"1: ",
+                              disp_true, A.RESET,
+                              u" *" if self.value else u""))
             choice = None
             while choice not in ("0", "1"):
                 elems = [C.A_HEADER, _(u"your choice (0,1): ")]
@@ -342,7 +353,7 @@
             # to see if we want the label on the same line or not
             if child.type == u"label":
                 for_name = child.for_name
-                if for_name is not None:
+                if for_name:
                     for_widget = self.root.widgets[for_name]
                     wid_type = for_widget.type
                     if self.root.values_only or wid_type in (
@@ -382,9 +393,9 @@
         # TODO: handle title and level
         self.disp(self.message)
 
-    def __init__(self, _xmlui_parent, title, message, level):
-        Dialog.__init__(self, _xmlui_parent)
-        xmlui_base.NoteDialog.__init__(self, _xmlui_parent)
+    def __init__(self, xmlui_parent, title, message, level):
+        Dialog.__init__(self, xmlui_parent)
+        xmlui_base.NoteDialog.__init__(self, xmlui_parent)
         self.title, self.message, self.level = title, message, level