Mercurial > libervia-backend
comparison frontends/src/primitivus/xmlui.py @ 975:b37b1d183ac3
reverted changeset 5c7707c958d8 (revision 969)
author | souliane <souliane@mailoo.org> |
---|---|
date | Thu, 03 Apr 2014 14:38:48 +0200 |
parents | 5c7707c958d8 |
children | 68faf7d77a42 |
comparison
equal
deleted
inserted
replaced
974:54cd05f68c7c | 975:b37b1d183ac3 |
---|---|
17 # You should have received a copy of the GNU Affero General Public License | 17 # You should have received a copy of the GNU Affero General Public License |
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | 19 |
20 from sat.core.i18n import _ | 20 from sat.core.i18n import _ |
21 import urwid | 21 import urwid |
22 import copy | |
23 from urwid_satext import sat_widgets | 22 from urwid_satext import sat_widgets |
24 from logging import debug, info, warning, error | 23 from logging import debug, info, warning, error |
25 from xml.dom import minidom | 24 from xml.dom import minidom |
26 from sat_frontends.tools import xmlui | 25 from sat_frontends.tools import xmlui |
27 | 26 |
77 warning(_("Unknown div_char")) | 76 warning(_("Unknown div_char")) |
78 div_char = u'─' | 77 div_char = u'─' |
79 | 78 |
80 urwid.Divider.__init__(self, div_char) | 79 urwid.Divider.__init__(self, div_char) |
81 | 80 |
82 | |
83 class PrimitivusStringWidget(xmlui.StringWidget, sat_widgets.AdvancedEdit, PrimitivusEvents): | 81 class PrimitivusStringWidget(xmlui.StringWidget, sat_widgets.AdvancedEdit, PrimitivusEvents): |
84 | 82 |
85 def __init__(self, parent, value): | 83 def __init__(self, parent, value): |
86 sat_widgets.AdvancedEdit.__init__(self, edit_text=value) | 84 sat_widgets.AdvancedEdit.__init__(self, edit_text=value) |
87 | 85 |
88 def _xmluiSetValue(self, value): | |
89 self.set_edit_text(value) | |
90 | |
91 def _xmluiGetValue(self): | 86 def _xmluiGetValue(self): |
92 return self.get_edit_text() | 87 return self.get_edit_text() |
93 | 88 |
94 | 89 |
95 class PrimitivusPasswordWidget(xmlui.PasswordWidget, sat_widgets.Password, PrimitivusEvents): | 90 class PrimitivusPasswordWidget(xmlui.PasswordWidget, sat_widgets.Password, PrimitivusEvents): |
96 | 91 |
97 def __init__(self, parent, value): | 92 def __init__(self, parent, value): |
98 sat_widgets.Password.__init__(self, edit_text=value) | 93 sat_widgets.Password.__init__(self, edit_text=value) |
99 | 94 |
100 def _xmluiSetValue(self, value): | |
101 self.set_edit_text(value) | |
102 | |
103 def _xmluiGetValue(self): | 95 def _xmluiGetValue(self): |
104 return self.get_edit_text() | 96 return self.get_edit_text() |
105 | 97 |
106 | 98 |
107 class PrimitivusTextBoxWidget(xmlui.TextBoxWidget, sat_widgets.AdvancedEdit, PrimitivusEvents): | 99 class PrimitivusTextBoxWidget(xmlui.TextBoxWidget, sat_widgets.AdvancedEdit, PrimitivusEvents): |
108 | 100 |
109 def __init__(self, parent, value): | 101 def __init__(self, parent, value): |
110 sat_widgets.AdvancedEdit.__init__(self, edit_text=value, multiline=True) | 102 sat_widgets.AdvancedEdit.__init__(self, edit_text=value, multiline=True) |
111 | |
112 def _xmluiSetValue(self, value): | |
113 self.set_edit_text(value) | |
114 | 103 |
115 def _xmluiGetValue(self): | 104 def _xmluiGetValue(self): |
116 return self.get_edit_text() | 105 return self.get_edit_text() |
117 | 106 |
118 | 107 |
119 class PrimitivusBoolWidget(xmlui.BoolWidget, urwid.CheckBox, PrimitivusEvents): | 108 class PrimitivusBoolWidget(xmlui.BoolWidget, urwid.CheckBox, PrimitivusEvents): |
120 | 109 |
121 def __init__(self, parent, state): | 110 def __init__(self, parent, state): |
122 urwid.CheckBox.__init__(self, '', state=state) | 111 urwid.CheckBox.__init__(self, '', state=state) |
123 | |
124 def _xmluiSetValue(self, value): | |
125 self.set_state(value == "true") | |
126 | 112 |
127 def _xmluiGetValue(self): | 113 def _xmluiGetValue(self): |
128 return "true" if self.get_state() else "false" | 114 return "true" if self.get_state() else "false" |
129 | 115 |
130 | 116 |
146 def _xmluiSelectValues(self, values): | 132 def _xmluiSelectValues(self, values): |
147 return self.selectValues(values) | 133 return self.selectValues(values) |
148 | 134 |
149 def _xmluiGetSelectedValues(self): | 135 def _xmluiGetSelectedValues(self): |
150 return [option.value for option in self.getSelectedValues()] | 136 return [option.value for option in self.getSelectedValues()] |
151 | |
152 def _xmluiAddValues(self, values, select=True): | |
153 current_values = self.getAllValues() | |
154 new_values = copy.deepcopy(current_values) | |
155 for value in values: | |
156 if value not in current_values: | |
157 new_values.append(value) | |
158 if select: | |
159 selected = self._xmluiGetSelectedValues() | |
160 self.changeValues(new_values) | |
161 if select: | |
162 for value in values: | |
163 if value not in selected: | |
164 selected.append(value) | |
165 self._xmluiSelectValues(selected) | |
166 | 137 |
167 | 138 |
168 class PrimitivusAdvancedListContainer(xmlui.AdvancedListContainer, sat_widgets.TableContainer, PrimitivusEvents): | 139 class PrimitivusAdvancedListContainer(xmlui.AdvancedListContainer, sat_widgets.TableContainer, PrimitivusEvents): |
169 | 140 |
170 def __init__(self, parent, columns, selectable='no'): | 141 def __init__(self, parent, columns, selectable='no'): |