# HG changeset patch # User Goffi # Date 1546451447 -3600 # Node ID e8dc00f612fbb773e07fefc2c8f179a60cfd6b8f # Parent eb58f26ed236e86ef6ff94abd7e7f2c9c924af33 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. diff -r eb58f26ed236 -r e8dc00f612fb sat_frontends/jp/xmlui_manager.py --- 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