annotate sat_frontends/jp/xmlui_manager.py @ 3632:7acf19bdca2f

doc: minor typo
author Goffi <goffi@goffi.org>
date Fri, 27 Aug 2021 14:59:47 +0200
parents 04283582966f
children 53a8b50d69ca
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3137
559a625a236b fixed shebangs
Goffi <goffi@goffi.org>
parents: 3136
diff changeset
1 #!/usr/bin/env python3
559a625a236b fixed shebangs
Goffi <goffi@goffi.org>
parents: 3136
diff changeset
2
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
3
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
4 # JP: a SàT frontend
3479
be6d91572633 date update
Goffi <goffi@goffi.org>
parents: 3407
diff changeset
5 # Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
6
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
7 # This program is free software: you can redistribute it and/or modify
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
8 # it under the terms of the GNU Affero General Public License as published by
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
9 # the Free Software Foundation, either version 3 of the License, or
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
10 # (at your option) any later version.
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
11
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
12 # This program is distributed in the hope that it will be useful,
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
15 # GNU Affero General Public License for more details.
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
16
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
17 # You should have received a copy of the GNU Affero General Public License
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
19
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
20 from functools import partial
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
21 from sat.core.log import getLogger
2669
bdb8276fd2da frontends (xmlui): class_map is now an arg of create function:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
22 from sat_frontends.tools import xmlui as xmlui_base
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
23 from sat_frontends.jp.constants import Const as C
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
24 from sat.tools.common.ansi import ANSI as A
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
25 from sat.core.i18n import _
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
26
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
27 log = getLogger(__name__)
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
28
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
29 # workflow constants
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
30
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
31 SUBMIT = "SUBMIT" # submit form
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
32
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
33
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
34 ## Widgets ##
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
35
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
36
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
37 class Base(object):
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
38 """Base for Widget and Container"""
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
39
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
40 type = None
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
41 _root = None
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
42
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
43 def __init__(self, xmlui_parent):
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
44 self.xmlui_parent = xmlui_parent
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
45 self.host = self.xmlui_parent.host
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
46
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
47 @property
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
48 def root(self):
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
49 """retrieve main XMLUI parent class"""
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
50 if self._root is not None:
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
51 return self._root
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
52 root = self
2669
bdb8276fd2da frontends (xmlui): class_map is now an arg of create function:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
53 while not isinstance(root, xmlui_base.XMLUIBase):
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
54 root = root.xmlui_parent
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
55 self._root = root
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
56 return root
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
57
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
58 def disp(self, *args, **kwargs):
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
59 self.host.disp(*args, **kwargs)
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
60
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
61
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
62 class Widget(Base):
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2961
diff changeset
63 category = "widget"
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
64 enabled = True
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
65
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
66 @property
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
67 def name(self):
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
68 return self._xmlui_name
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
69
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
70 async def show(self):
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
71 """display current widget
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
72
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
73 must be overriden by subclasses
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
74 """
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
75 raise NotImplementedError(self.__class__)
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
76
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
77 def verboseName(self, elems=None, value=None):
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
78 """add name in color to the elements
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
79
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
80 helper method to display name which can then be used to automate commands
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
81 elems is only modified if verbosity is > 0
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
82 @param elems(list[unicode], None): elements to display
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
83 None to display name directly
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
84 @param value(unicode, None): value to show
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
85 use self.name if None
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
86 """
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
87 if value is None:
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
88 value = self.name
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
89 if self.host.verbosity:
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
90 to_disp = [
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
91 A.FG_MAGENTA,
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2961
diff changeset
92 " " if elems else "",
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2961
diff changeset
93 "({})".format(value),
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
94 A.RESET,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
95 ]
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
96 if elems is None:
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
97 self.host.disp(A.color(*to_disp))
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
98 else:
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
99 elems.extend(to_disp)
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
100
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
101
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
102 class ValueWidget(Widget):
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
103 def __init__(self, xmlui_parent, value):
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
104 super(ValueWidget, self).__init__(xmlui_parent)
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
105 self.value = value
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
106
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
107 @property
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
108 def values(self):
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
109 return [self.value]
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
110
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
111
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
112 class InputWidget(ValueWidget):
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
113 def __init__(self, xmlui_parent, value, read_only=False):
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
114 super(InputWidget, self).__init__(xmlui_parent, value)
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
115 self.read_only = read_only
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
116
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
117 def _xmluiGetValue(self):
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
118 return self.value
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
119
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
120
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
121 class OptionsWidget(Widget):
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
122 def __init__(self, xmlui_parent, options, selected, style):
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
123 super(OptionsWidget, self).__init__(xmlui_parent)
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
124 self.options = options
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
125 self.selected = selected
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
126 self.style = style
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
127
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
128 @property
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
129 def values(self):
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
130 return self.selected
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
131
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
132 @values.setter
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
133 def values(self, values):
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
134 self.selected = values
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
135
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
136 @property
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
137 def value(self):
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
138 return self.selected[0]
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
139
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
140 @value.setter
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
141 def value(self, value):
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
142 self.selected = [value]
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
143
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
144 def _xmluiSelectValue(self, value):
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
145 self.value = value
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
146
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
147 def _xmluiSelectValues(self, values):
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
148 self.values = values
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
149
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
150 def _xmluiGetSelectedValues(self):
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
151 return self.values
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
152
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
153 @property
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
154 def labels(self):
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
155 """return only labels from self.items"""
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
156 for value, label in self.items:
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
157 yield label
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
158
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
159 @property
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
160 def items(self):
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
161 """return suitable items, according to style"""
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
162 no_select = self.no_select
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
163 for value, label in self.options:
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
164 if no_select or value in self.selected:
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
165 yield value, label
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
166
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
167 @property
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
168 def inline(self):
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2961
diff changeset
169 return "inline" in self.style
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
170
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
171 @property
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
172 def no_select(self):
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2961
diff changeset
173 return "noselect" in self.style
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
174
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
175
2669
bdb8276fd2da frontends (xmlui): class_map is now an arg of create function:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
176 class EmptyWidget(xmlui_base.EmptyWidget, Widget):
2739
e8dc00f612fb jp (xmlui): JidWidget + small improvments:
Goffi <goffi@goffi.org>
parents: 2669
diff changeset
177 def __init__(self, xmlui_parent):
e8dc00f612fb jp (xmlui): JidWidget + small improvments:
Goffi <goffi@goffi.org>
parents: 2669
diff changeset
178 Widget.__init__(self, xmlui_parent)
e8dc00f612fb jp (xmlui): JidWidget + small improvments:
Goffi <goffi@goffi.org>
parents: 2669
diff changeset
179
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
180 async def show(self):
3568
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
181 self.host.disp("")
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
182
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
183
2669
bdb8276fd2da frontends (xmlui): class_map is now an arg of create function:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
184 class TextWidget(xmlui_base.TextWidget, ValueWidget):
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2961
diff changeset
185 type = "text"
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
186
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
187 async def show(self):
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
188 self.host.disp(self.value)
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
189
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
190
2669
bdb8276fd2da frontends (xmlui): class_map is now an arg of create function:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
191 class LabelWidget(xmlui_base.LabelWidget, ValueWidget):
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2961
diff changeset
192 type = "label"
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
193
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
194 @property
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
195 def for_name(self):
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
196 try:
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
197 return self._xmlui_for_name
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
198 except AttributeError:
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
199 return None
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
200
3568
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
201 async def show(self, end="\n", ansi=""):
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
202 """show label
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
203
3407
2f0be2b7de68 jp: replace `no_lf` argument by `end` in `disp` (same as in `print`)
Goffi <goffi@goffi.org>
parents: 3212
diff changeset
204 @param end(str): same as for [JP.disp]
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
205 @param ansi(unicode): ansi escape code to print before label
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
206 """
3407
2f0be2b7de68 jp: replace `no_lf` argument by `end` in `disp` (same as in `print`)
Goffi <goffi@goffi.org>
parents: 3212
diff changeset
207 self.disp(A.color(ansi, self.value), end=end)
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
208
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
209
2739
e8dc00f612fb jp (xmlui): JidWidget + small improvments:
Goffi <goffi@goffi.org>
parents: 2669
diff changeset
210 class JidWidget(xmlui_base.JidWidget, TextWidget):
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2961
diff changeset
211 type = "jid"
2739
e8dc00f612fb jp (xmlui): JidWidget + small improvments:
Goffi <goffi@goffi.org>
parents: 2669
diff changeset
212
3568
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
213
2669
bdb8276fd2da frontends (xmlui): class_map is now an arg of create function:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
214 class StringWidget(xmlui_base.StringWidget, InputWidget):
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2961
diff changeset
215 type = "string"
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
216
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
217 async def show(self):
2961
620bbcec884c jp (xmlui): check root read_only status in addition to widget one
Goffi <goffi@goffi.org>
parents: 2960
diff changeset
218 if self.read_only or self.root.read_only:
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
219 self.disp(self.value)
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
220 else:
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
221 elems = []
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
222 self.verboseName(elems)
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
223 if self.value:
3568
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
224 elems.append(_("(enter: {value})").format(value=self.value))
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2961
diff changeset
225 elems.extend([C.A_HEADER, "> "])
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
226 value = await self.host.ainput(A.color(*elems))
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
227 if value:
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
228 #  TODO: empty value should be possible
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
229 # an escape key should be used for default instead of enter with empty value
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
230 self.value = value
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
231
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
232
2669
bdb8276fd2da frontends (xmlui): class_map is now an arg of create function:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
233 class JidInputWidget(xmlui_base.JidInputWidget, StringWidget):
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2961
diff changeset
234 type = "jid_input"
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
235
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
236
2669
bdb8276fd2da frontends (xmlui): class_map is now an arg of create function:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
237 class TextBoxWidget(xmlui_base.TextWidget, StringWidget):
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2961
diff changeset
238 type = "textbox"
2939
18a98a541f7a jp (xmlui manager): basic handling of multi-lines text in TextBoxWidget
Goffi <goffi@goffi.org>
parents: 2783
diff changeset
239 # TODO: use a more advanced input method
18a98a541f7a jp (xmlui manager): basic handling of multi-lines text in TextBoxWidget
Goffi <goffi@goffi.org>
parents: 2783
diff changeset
240
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
241 async def show(self):
2939
18a98a541f7a jp (xmlui manager): basic handling of multi-lines text in TextBoxWidget
Goffi <goffi@goffi.org>
parents: 2783
diff changeset
242 self.verboseName()
2961
620bbcec884c jp (xmlui): check root read_only status in addition to widget one
Goffi <goffi@goffi.org>
parents: 2960
diff changeset
243 if self.read_only or self.root.read_only:
2939
18a98a541f7a jp (xmlui manager): basic handling of multi-lines text in TextBoxWidget
Goffi <goffi@goffi.org>
parents: 2783
diff changeset
244 self.disp(self.value)
18a98a541f7a jp (xmlui manager): basic handling of multi-lines text in TextBoxWidget
Goffi <goffi@goffi.org>
parents: 2783
diff changeset
245 else:
18a98a541f7a jp (xmlui manager): basic handling of multi-lines text in TextBoxWidget
Goffi <goffi@goffi.org>
parents: 2783
diff changeset
246 if self.value:
3568
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
247 self.disp(
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
248 A.color(C.A_HEADER, "↓ current value ↓\n", A.FG_CYAN, self.value, "")
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
249 )
2939
18a98a541f7a jp (xmlui manager): basic handling of multi-lines text in TextBoxWidget
Goffi <goffi@goffi.org>
parents: 2783
diff changeset
250
18a98a541f7a jp (xmlui manager): basic handling of multi-lines text in TextBoxWidget
Goffi <goffi@goffi.org>
parents: 2783
diff changeset
251 values = []
18a98a541f7a jp (xmlui manager): basic handling of multi-lines text in TextBoxWidget
Goffi <goffi@goffi.org>
parents: 2783
diff changeset
252 while True:
18a98a541f7a jp (xmlui manager): basic handling of multi-lines text in TextBoxWidget
Goffi <goffi@goffi.org>
parents: 2783
diff changeset
253 try:
18a98a541f7a jp (xmlui manager): basic handling of multi-lines text in TextBoxWidget
Goffi <goffi@goffi.org>
parents: 2783
diff changeset
254 if not values:
3568
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
255 line = await self.host.ainput(
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
256 A.color(C.A_HEADER, "[Ctrl-D to finish]> ")
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
257 )
2939
18a98a541f7a jp (xmlui manager): basic handling of multi-lines text in TextBoxWidget
Goffi <goffi@goffi.org>
parents: 2783
diff changeset
258 else:
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
259 line = await self.host.ainput()
2939
18a98a541f7a jp (xmlui manager): basic handling of multi-lines text in TextBoxWidget
Goffi <goffi@goffi.org>
parents: 2783
diff changeset
260 values.append(line)
18a98a541f7a jp (xmlui manager): basic handling of multi-lines text in TextBoxWidget
Goffi <goffi@goffi.org>
parents: 2783
diff changeset
261 except EOFError:
3568
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
262 break
2939
18a98a541f7a jp (xmlui manager): basic handling of multi-lines text in TextBoxWidget
Goffi <goffi@goffi.org>
parents: 2783
diff changeset
263
3568
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
264 self.value = "\n".join(values).rstrip()
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
265
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
266
2783
442ab697f831 frontends, jp, templates: added XHTMLBox widget:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
267 class XHTMLBoxWidget(xmlui_base.XHTMLBoxWidget, StringWidget):
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2961
diff changeset
268 type = "xhtmlbox"
2783
442ab697f831 frontends, jp, templates: added XHTMLBox widget:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
269
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
270 async def show(self):
2783
442ab697f831 frontends, jp, templates: added XHTMLBox widget:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
271 # FIXME: we use bridge in a blocking way as permitted by python-dbus
442ab697f831 frontends, jp, templates: added XHTMLBox widget:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
272 # this only for now to make it simpler, it must be refactored
442ab697f831 frontends, jp, templates: added XHTMLBox widget:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
273 # to use async when jp will be fully async (expected for 0.8)
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
274 self.value = await self.host.bridge.syntaxConvert(
3568
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
275 self.value, C.SYNTAX_XHTML, "markdown", False, self.host.profile
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
276 )
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
277 await super(XHTMLBoxWidget, self).show()
2783
442ab697f831 frontends, jp, templates: added XHTMLBox widget:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
278
442ab697f831 frontends, jp, templates: added XHTMLBox widget:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
279
2669
bdb8276fd2da frontends (xmlui): class_map is now an arg of create function:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
280 class ListWidget(xmlui_base.ListWidget, OptionsWidget):
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2961
diff changeset
281 type = "list"
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
282 # TODO: handle flags, notably multi
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
283
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
284 async def show(self):
2541
65695b9343d3 jp (xmlui): added whitelist, read_only and values_only options:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
285 if self.root.values_only:
65695b9343d3 jp (xmlui): added whitelist, read_only and values_only options:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
286 for value in self.values:
65695b9343d3 jp (xmlui): added whitelist, read_only and values_only options:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
287 self.disp(self.value)
65695b9343d3 jp (xmlui): added whitelist, read_only and values_only options:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
288 return
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
289 if not self.options:
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
290 return
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
291
3568
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
292 # list display
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
293 self.verboseName()
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
294
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
295 for idx, (value, label) in enumerate(self.options):
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
296 elems = []
2541
65695b9343d3 jp (xmlui): added whitelist, read_only and values_only options:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
297 if not self.root.read_only:
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2961
diff changeset
298 elems.extend([C.A_SUBHEADER, str(idx), A.RESET, ": "])
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
299 elems.append(label)
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
300 self.verboseName(elems, value)
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
301 self.disp(A.color(*elems))
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
302
2541
65695b9343d3 jp (xmlui): added whitelist, read_only and values_only options:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
303 if self.root.read_only:
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
304 return
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
305
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
306 if len(self.options) == 1:
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
307 # we have only one option, no need to ask
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
308 self.value = self.options[0][0]
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
309 return
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
310
3568
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
311 #  we ask use to choose an option
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
312 choice = None
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
313 limit_max = len(self.options) - 1
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
314 while choice is None or choice < 0 or choice > limit_max:
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
315 choice = await self.host.ainput(
3568
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
316 A.color(
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
317 C.A_HEADER,
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
318 _("your choice (0-{limit_max}): ").format(limit_max=limit_max),
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
319 )
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
320 )
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
321 try:
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
322 choice = int(choice)
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
323 except ValueError:
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
324 choice = None
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
325 self.value = self.options[choice][0]
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
326 self.disp("")
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
327
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
328
2669
bdb8276fd2da frontends (xmlui): class_map is now an arg of create function:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
329 class BoolWidget(xmlui_base.BoolWidget, InputWidget):
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2961
diff changeset
330 type = "bool"
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
331
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
332 async def show(self):
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2961
diff changeset
333 disp_true = A.color(A.FG_GREEN, "TRUE")
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2961
diff changeset
334 disp_false = A.color(A.FG_RED, "FALSE")
2961
620bbcec884c jp (xmlui): check root read_only status in addition to widget one
Goffi <goffi@goffi.org>
parents: 2960
diff changeset
335 if self.read_only or self.root.read_only:
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
336 self.disp(disp_true if self.value else disp_false)
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
337 else:
3568
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
338 self.disp(
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
339 A.color(
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
340 C.A_HEADER, "0: ", disp_false, A.RESET, " *" if not self.value else ""
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
341 )
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
342 )
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
343 self.disp(
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
344 A.color(C.A_HEADER, "1: ", disp_true, A.RESET, " *" if self.value else "")
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
345 )
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
346 choice = None
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
347 while choice not in ("0", "1"):
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2961
diff changeset
348 elems = [C.A_HEADER, _("your choice (0,1): ")]
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
349 self.verboseName(elems)
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
350 choice = await self.host.ainput(A.color(*elems))
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
351 self.value = bool(int(choice))
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
352 self.disp("")
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
353
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
354 def _xmluiGetValue(self):
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
355 return C.boolConst(self.value)
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
356
3568
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
357 ## Containers ##
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
358
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
359
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
360 class Container(Base):
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2961
diff changeset
361 category = "container"
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
362
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
363 def __init__(self, xmlui_parent):
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
364 super(Container, self).__init__(xmlui_parent)
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
365 self.children = []
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
366
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
367 def __iter__(self):
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
368 return iter(self.children)
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
369
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
370 def _xmluiAppend(self, widget):
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
371 self.children.append(widget)
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
372
2541
65695b9343d3 jp (xmlui): added whitelist, read_only and values_only options:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
373 def _xmluiRemove(self, widget):
65695b9343d3 jp (xmlui): added whitelist, read_only and values_only options:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
374 self.children.remove(widget)
65695b9343d3 jp (xmlui): added whitelist, read_only and values_only options:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
375
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
376 async def show(self):
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
377 for child in self.children:
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
378 await child.show()
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
379
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
380
2669
bdb8276fd2da frontends (xmlui): class_map is now an arg of create function:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
381 class VerticalContainer(xmlui_base.VerticalContainer, Container):
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2961
diff changeset
382 type = "vertical"
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
383
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
384
2669
bdb8276fd2da frontends (xmlui): class_map is now an arg of create function:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
385 class PairsContainer(xmlui_base.PairsContainer, Container):
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2961
diff changeset
386 type = "pairs"
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
387
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
388
2669
bdb8276fd2da frontends (xmlui): class_map is now an arg of create function:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
389 class LabelContainer(xmlui_base.PairsContainer, Container):
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2961
diff changeset
390 type = "label"
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
391
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
392 async def show(self):
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
393 for child in self.children:
3568
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
394 end = "\n"
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
395 # we check linked widget type
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
396 # to see if we want the label on the same line or not
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2961
diff changeset
397 if child.type == "label":
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
398 for_name = child.for_name
2739
e8dc00f612fb jp (xmlui): JidWidget + small improvments:
Goffi <goffi@goffi.org>
parents: 2669
diff changeset
399 if for_name:
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
400 for_widget = self.root.widgets[for_name]
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
401 wid_type = for_widget.type
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
402 if self.root.values_only or wid_type in (
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
403 "text",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
404 "string",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
405 "jid_input",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
406 ):
3568
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
407 end = " "
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
408 elif wid_type == "bool" and for_widget.read_only:
3568
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
409 end = " "
3407
2f0be2b7de68 jp: replace `no_lf` argument by `end` in `disp` (same as in `print`)
Goffi <goffi@goffi.org>
parents: 3212
diff changeset
410 await child.show(end=end, ansi=A.FG_CYAN)
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
411 else:
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
412 await child.show()
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
413
3568
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
414 ## Dialogs ##
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
415
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
416
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
417 class Dialog(object):
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
418 def __init__(self, xmlui_parent):
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
419 self.xmlui_parent = xmlui_parent
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
420 self.host = self.xmlui_parent.host
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
421
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
422 def disp(self, *args, **kwargs):
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
423 self.host.disp(*args, **kwargs)
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
424
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
425 async def show(self):
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
426 """display current dialog
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
427
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
428 must be overriden by subclasses
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
429 """
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
430 raise NotImplementedError(self.__class__)
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
431
3568
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
432
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
433 class MessageDialog(xmlui_base.MessageDialog, Dialog):
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
434 def __init__(self, xmlui_parent, title, message, level):
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
435 Dialog.__init__(self, xmlui_parent)
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
436 xmlui_base.MessageDialog.__init__(self, xmlui_parent)
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
437 self.title, self.message, self.level = title, message, level
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
438
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
439 async def show(self):
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
440 # TODO: handle level
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
441 if self.title:
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
442 self.disp(A.color(C.A_HEADER, self.title))
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
443 self.disp(self.message)
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
444
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
445
2669
bdb8276fd2da frontends (xmlui): class_map is now an arg of create function:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
446 class NoteDialog(xmlui_base.NoteDialog, Dialog):
2739
e8dc00f612fb jp (xmlui): JidWidget + small improvments:
Goffi <goffi@goffi.org>
parents: 2669
diff changeset
447 def __init__(self, xmlui_parent, title, message, level):
e8dc00f612fb jp (xmlui): JidWidget + small improvments:
Goffi <goffi@goffi.org>
parents: 2669
diff changeset
448 Dialog.__init__(self, xmlui_parent)
e8dc00f612fb jp (xmlui): JidWidget + small improvments:
Goffi <goffi@goffi.org>
parents: 2669
diff changeset
449 xmlui_base.NoteDialog.__init__(self, xmlui_parent)
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
450 self.title, self.message, self.level = title, message, level
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
451
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
452 async def show(self):
3093
d909473a76cc jp (xmlui_manager): use level for notes:
Goffi <goffi@goffi.org>
parents: 3040
diff changeset
453 # TODO: handle title
d909473a76cc jp (xmlui_manager): use level for notes:
Goffi <goffi@goffi.org>
parents: 3040
diff changeset
454 error = self.level in (C.XMLUI_DATA_LVL_WARNING, C.XMLUI_DATA_LVL_ERROR)
d909473a76cc jp (xmlui_manager): use level for notes:
Goffi <goffi@goffi.org>
parents: 3040
diff changeset
455 if self.level == C.XMLUI_DATA_LVL_WARNING:
d909473a76cc jp (xmlui_manager): use level for notes:
Goffi <goffi@goffi.org>
parents: 3040
diff changeset
456 msg = A.color(C.A_WARNING, self.message)
d909473a76cc jp (xmlui_manager): use level for notes:
Goffi <goffi@goffi.org>
parents: 3040
diff changeset
457 elif self.level == C.XMLUI_DATA_LVL_ERROR:
d909473a76cc jp (xmlui_manager): use level for notes:
Goffi <goffi@goffi.org>
parents: 3040
diff changeset
458 msg = A.color(C.A_FAILURE, self.message)
d909473a76cc jp (xmlui_manager): use level for notes:
Goffi <goffi@goffi.org>
parents: 3040
diff changeset
459 else:
d909473a76cc jp (xmlui_manager): use level for notes:
Goffi <goffi@goffi.org>
parents: 3040
diff changeset
460 msg = self.message
d909473a76cc jp (xmlui_manager): use level for notes:
Goffi <goffi@goffi.org>
parents: 3040
diff changeset
461 self.disp(msg, error=error)
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
462
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
463
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
464 class ConfirmDialog(xmlui_base.ConfirmDialog, Dialog):
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
465 def __init__(self, xmlui_parent, title, message, level, buttons_set):
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
466 Dialog.__init__(self, xmlui_parent)
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
467 xmlui_base.ConfirmDialog.__init__(self, xmlui_parent)
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
468 self.title, self.message, self.level, self.buttons_set = (
3568
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
469 title,
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
470 message,
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
471 level,
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
472 buttons_set,
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
473 )
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
474
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
475 async def show(self):
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
476 # TODO: handle buttons_set and level
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
477 self.disp(self.message)
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
478 if self.title:
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
479 self.disp(A.color(C.A_HEADER, self.title))
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
480 input_ = None
3568
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
481 while input_ not in ("y", "n"):
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
482 input_ = await self.host.ainput(f"{self.message} (y/n)? ")
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
483 input_ = input_.lower()
3568
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
484 if input_ == "y":
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
485 self._xmluiValidated()
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
486 else:
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
487 self._xmluiCancelled()
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
488
3568
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
489 ## Factory ##
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
490
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
491
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
492 class WidgetFactory(object):
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
493 def __getattr__(self, attr):
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
494 if attr.startswith("create"):
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
495 cls = globals()[attr[6:]]
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
496 return cls
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
497
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
498
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
499 class XMLUIPanel(xmlui_base.AIOXMLUIPanel):
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
500 widget_factory = WidgetFactory()
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
501 _actions = 0 # use to keep track of bridge's launchAction calls
2541
65695b9343d3 jp (xmlui): added whitelist, read_only and values_only options:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
502 read_only = False
65695b9343d3 jp (xmlui): added whitelist, read_only and values_only options:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
503 values_only = False
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
504 workflow = None
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
505 _submit_cb = None
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
506
3568
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
507 def __init__(
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
508 self,
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
509 host,
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
510 parsed_dom,
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
511 title=None,
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
512 flags=None,
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
513 callback=None,
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
514 ignore=None,
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
515 whitelist=None,
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
516 profile=None,
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
517 ):
2669
bdb8276fd2da frontends (xmlui): class_map is now an arg of create function:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
518 xmlui_base.XMLUIPanel.__init__(
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
519 self,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
520 host,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
521 parsed_dom,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
522 title=title,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
523 flags=flags,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
524 ignore=ignore,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
525 whitelist=whitelist,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
526 profile=host.profile,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
527 )
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
528 self.submitted = False
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
529
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
530 @property
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
531 def command(self):
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
532 return self.host.command
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
533
3212
89d97776fd34 jp (xmlui): added missing `disp` method in XMLUIPanel
Goffi <goffi@goffi.org>
parents: 3137
diff changeset
534 def disp(self, *args, **kwargs):
89d97776fd34 jp (xmlui): added missing `disp` method in XMLUIPanel
Goffi <goffi@goffi.org>
parents: 3137
diff changeset
535 self.host.disp(*args, **kwargs)
89d97776fd34 jp (xmlui): added missing `disp` method in XMLUIPanel
Goffi <goffi@goffi.org>
parents: 3137
diff changeset
536
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
537 async def show(self, workflow=None, read_only=False, values_only=False):
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
538 """display the panel
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
539
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
540 @param workflow(list, None): command to execute if not None
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
541 put here for convenience, the main workflow is the class attribute
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
542 (because workflow can continue in subclasses)
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
543 command are a list of consts or lists:
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
544 - SUBMIT is the only constant so far, it submits the XMLUI
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
545 - list must contain widget name/widget value to fill
2541
65695b9343d3 jp (xmlui): added whitelist, read_only and values_only options:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
546 @param read_only(bool): if True, don't request values
65695b9343d3 jp (xmlui): added whitelist, read_only and values_only options:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
547 @param values_only(bool): if True, only show select values (imply read_only)
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
548 """
2541
65695b9343d3 jp (xmlui): added whitelist, read_only and values_only options:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
549 self.read_only = read_only
65695b9343d3 jp (xmlui): added whitelist, read_only and values_only options:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
550 self.values_only = values_only
65695b9343d3 jp (xmlui): added whitelist, read_only and values_only options:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
551 if self.values_only:
65695b9343d3 jp (xmlui): added whitelist, read_only and values_only options:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
552 self.read_only = True
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
553 if workflow:
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
554 XMLUIPanel.workflow = workflow
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
555 if XMLUIPanel.workflow:
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
556 await self.runWorkflow()
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
557 else:
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
558 await self.main_cont.show()
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
559
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
560 async def runWorkflow(self):
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
561 """loop into workflow commands and execute commands
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
562
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
563 SUBMIT will interrupt workflow (which will be continue on callback)
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
564 @param workflow(list): same as [show]
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
565 """
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
566 workflow = XMLUIPanel.workflow
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
567 while True:
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
568 try:
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
569 cmd = workflow.pop(0)
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
570 except IndexError:
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
571 break
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
572 if cmd == SUBMIT:
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
573 await self.onFormSubmitted()
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
574 self.submit_id = None # avoid double submit
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
575 return
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
576 elif isinstance(cmd, list):
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
577 name, value = cmd
2412
7641bef56dcd jp (xmlui): fixed workflow when value is for a BoolWidget
Goffi <goffi@goffi.org>
parents: 2410
diff changeset
578 widget = self.widgets[name]
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
579 if widget.type == "bool":
2412
7641bef56dcd jp (xmlui): fixed workflow when value is for a BoolWidget
Goffi <goffi@goffi.org>
parents: 2410
diff changeset
580 value = C.bool(value)
7641bef56dcd jp (xmlui): fixed workflow when value is for a BoolWidget
Goffi <goffi@goffi.org>
parents: 2410
diff changeset
581 widget.value = value
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
582 await self.show()
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
583
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
584 async def submitForm(self, callback=None):
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
585 XMLUIPanel._submit_cb = callback
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
586 await self.onFormSubmitted()
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
587
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
588 async def onFormSubmitted(self, ignore=None):
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
589 # self.submitted is a Q&D workaround to avoid
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
590 # double submit when a workflow is set
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
591 if self.submitted:
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
592 return
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
593 self.submitted = True
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
594 await super(XMLUIPanel, self).onFormSubmitted(ignore)
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
595
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
596 def _xmluiClose(self):
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
597 pass
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
598
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
599 async def _launchActionCb(self, data):
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
600 XMLUIPanel._actions -= 1
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
601 assert XMLUIPanel._actions >= 0
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2961
diff changeset
602 if "xmlui" in data:
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
603 xmlui_raw = data["xmlui"]
2669
bdb8276fd2da frontends (xmlui): class_map is now an arg of create function:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
604 xmlui = create(self.host, xmlui_raw)
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
605 await xmlui.show()
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
606 if xmlui.submit_id:
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
607 await xmlui.onFormSubmitted()
3568
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
608 # TODO: handle data other than XMLUI
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
609 if not XMLUIPanel._actions:
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
610 if self._submit_cb is None:
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
611 self.host.quit()
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
612 else:
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
613 self._submit_cb()
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
614
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
615 async def _xmluiLaunchAction(self, action_id, data):
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
616 XMLUIPanel._actions += 1
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
617 try:
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
618 data = await self.host.bridge.launchAction(
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
619 action_id,
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
620 data,
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
621 self.profile,
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
622 )
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
623 except Exception as e:
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
624 self.disp(f"can't launch XMLUI action: {e}", error=True)
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
625 self.host.quit(C.EXIT_BRIDGE_ERRBACK)
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
626 else:
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
627 await self._launchActionCb(data)
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
628
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
629
2669
bdb8276fd2da frontends (xmlui): class_map is now an arg of create function:
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
630 class XMLUIDialog(xmlui_base.XMLUIDialog):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
631 type = "dialog"
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
632 dialog_factory = WidgetFactory()
2541
65695b9343d3 jp (xmlui): added whitelist, read_only and values_only options:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
633 read_only = False
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
634
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
635 async def show(self, __=None):
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
636 await self.dlg.show()
2408
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
637
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
638 def _xmluiClose(self):
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
639 pass
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
640
a870daeab15e jp: XMLUI implementation first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
641
3568
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
642 create = partial(
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
643 xmlui_base.create,
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
644 class_map={xmlui_base.CLASS_PANEL: XMLUIPanel, xmlui_base.CLASS_DIALOG: XMLUIDialog},
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
645 )