Mercurial > libervia-desktop-kivy
annotate cagou/core/xmlui.py @ 280:b0461363bc65
core: certificate validation can be disabled:
By using "no_certificate_validation=true" in sat.conf in [cagou] section, certificate validation can be disabled.
This is mainly useful for developping on local machines with self-signed certificates.
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 20 Mar 2019 09:29:44 +0100 |
parents | 1f579baf787a |
children | 1b835bcfa663 |
rev | line source |
---|---|
0 | 1 #!/usr/bin/python |
2 # -*- coding: utf-8 -*- | |
3 | |
4 # Cagou: a SàT frontend | |
126 | 5 # Copyright (C) 2016-2018 Jérôme Poisson (goffi@goffi.org) |
0 | 6 |
7 # This program is free software: you can redistribute it and/or modify | |
8 # it under the terms of the GNU Affero General Public License as published by | |
9 # the Free Software Foundation, either version 3 of the License, or | |
10 # (at your option) any later version. | |
11 | |
12 # This program is distributed in the hope that it will be useful, | |
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 # GNU Affero General Public License for more details. | |
16 | |
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/>. | |
19 | |
20 from sat.core.i18n import _ | |
55 | 21 from .constants import Const as C |
0 | 22 from sat.core.log import getLogger |
23 log = getLogger(__name__) | |
24 from sat_frontends.tools import xmlui | |
241 | 25 from kivy.uix.scrollview import ScrollView |
99 | 26 from kivy.uix.boxlayout import BoxLayout |
53
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
27 from kivy.uix.gridlayout import GridLayout |
69
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
28 from kivy.uix.tabbedpanel import TabbedPanel, TabbedPanelItem |
0 | 29 from kivy.uix.textinput import TextInput |
30 from kivy.uix.label import Label | |
31 from kivy.uix.button import Button | |
53
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
32 from kivy.uix.togglebutton import ToggleButton |
0 | 33 from kivy.uix.widget import Widget |
53
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
34 from kivy.uix.switch import Switch |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
35 from kivy import properties |
29 | 36 from cagou import G |
204
37638765c97b
xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
37 from cagou.core import dialog |
235
525527a01439
xmlui: use create with partial and class_map, following change in base class
Goffi <goffi@goffi.org>
parents:
227
diff
changeset
|
38 from functools import partial |
29 | 39 |
40 | |
41 ## Widgets ## | |
0 | 42 |
43 | |
69
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
44 class TextInputOnChange(object): |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
45 |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
46 def __init__(self): |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
47 self._xmlui_onchange_cb = None |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
48 self._got_focus = False |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
49 |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
50 def _xmluiOnChange(self, callback): |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
51 self._xmlui_onchange_cb = callback |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
52 |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
53 def on_focus(self, instance, focus): |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
54 # we need to wait for first focus, else initial value |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
55 # will trigger a on_text |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
56 if not self._got_focus and focus: |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
57 self._got_focus = True |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
58 |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
59 def on_text(self, instance, new_text): |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
60 if self._xmlui_onchange_cb is not None and self._got_focus: |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
61 self._xmlui_onchange_cb(self) |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
62 |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
63 |
53
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
64 class EmptyWidget(xmlui.EmptyWidget, Widget): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
65 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
66 def __init__(self, _xmlui_parent): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
67 Widget.__init__(self) |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
68 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
69 |
0 | 70 class TextWidget(xmlui.TextWidget, Label): |
71 | |
72 def __init__(self, xmlui_parent, value): | |
73 Label.__init__(self, text=value) | |
74 | |
75 | |
53
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
76 class LabelWidget(xmlui.LabelWidget, TextWidget): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
77 pass |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
78 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
79 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
80 class JidWidget(xmlui.JidWidget, TextWidget): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
81 pass |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
82 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
83 |
69
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
84 class StringWidget(xmlui.StringWidget, TextInput, TextInputOnChange): |
53
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
85 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
86 def __init__(self, xmlui_parent, value, read_only=False): |
236
ca86954b3788
xmlui: implemented TextBoxWidget + set height for XMLUIPanel
Goffi <goffi@goffi.org>
parents:
235
diff
changeset
|
87 TextInput.__init__(self, text=value) |
69
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
88 TextInputOnChange.__init__(self) |
53
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
89 self.readonly = read_only |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
90 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
91 def _xmluiSetValue(self, value): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
92 self.text = value |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
93 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
94 def _xmluiGetValue(self): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
95 return self.text |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
96 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
97 |
236
ca86954b3788
xmlui: implemented TextBoxWidget + set height for XMLUIPanel
Goffi <goffi@goffi.org>
parents:
235
diff
changeset
|
98 class TextBoxWidget(xmlui.TextBoxWidget, StringWidget): |
ca86954b3788
xmlui: implemented TextBoxWidget + set height for XMLUIPanel
Goffi <goffi@goffi.org>
parents:
235
diff
changeset
|
99 pass |
ca86954b3788
xmlui: implemented TextBoxWidget + set height for XMLUIPanel
Goffi <goffi@goffi.org>
parents:
235
diff
changeset
|
100 |
ca86954b3788
xmlui: implemented TextBoxWidget + set height for XMLUIPanel
Goffi <goffi@goffi.org>
parents:
235
diff
changeset
|
101 |
53
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
102 class JidInputWidget(xmlui.JidInputWidget, StringWidget): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
103 pass |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
104 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
105 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
106 class ButtonWidget(xmlui.ButtonWidget, Button): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
107 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
108 def __init__(self, _xmlui_parent, value, click_callback): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
109 Button.__init__(self) |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
110 self.text = value |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
111 self.callback = click_callback |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
112 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
113 def _xmluiOnClick(self, callback): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
114 self.callback = callback |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
115 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
116 def on_release(self): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
117 self.callback(self) |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
118 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
119 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
120 class DividerWidget(xmlui.DividerWidget, Widget): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
121 # FIXME: not working properly + only 'line' is handled |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
122 style = properties.OptionProperty('line', |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
123 options=['line', 'dot', 'dash', 'plain', 'blank']) |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
124 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
125 def __init__(self, _xmlui_parent, style="line"): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
126 Widget.__init__(self, style=style) |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
127 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
128 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
129 class ListWidgetItem(ToggleButton): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
130 value = properties.StringProperty() |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
131 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
132 def on_release(self): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
133 parent = self.parent |
251
1f579baf787a
xmlui: some design improvments + use ScrollView + BoxLayout instead of DropDown for ListWidget:
Goffi <goffi@goffi.org>
parents:
243
diff
changeset
|
134 while parent is not None and not isinstance(parent, ListWidget): |
53
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
135 parent = parent.parent |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
136 |
251
1f579baf787a
xmlui: some design improvments + use ScrollView + BoxLayout instead of DropDown for ListWidget:
Goffi <goffi@goffi.org>
parents:
243
diff
changeset
|
137 if parent is not None: |
53
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
138 parent.select(self) |
251
1f579baf787a
xmlui: some design improvments + use ScrollView + BoxLayout instead of DropDown for ListWidget:
Goffi <goffi@goffi.org>
parents:
243
diff
changeset
|
139 return super(ListWidgetItem, self).on_release() |
53
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
140 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
141 @property |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
142 def selected(self): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
143 return self.state == 'down' |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
144 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
145 @selected.setter |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
146 def selected(self, value): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
147 self.state = 'down' if value else 'normal' |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
148 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
149 |
251
1f579baf787a
xmlui: some design improvments + use ScrollView + BoxLayout instead of DropDown for ListWidget:
Goffi <goffi@goffi.org>
parents:
243
diff
changeset
|
150 class ListWidget(xmlui.ListWidget, ScrollView): |
1f579baf787a
xmlui: some design improvments + use ScrollView + BoxLayout instead of DropDown for ListWidget:
Goffi <goffi@goffi.org>
parents:
243
diff
changeset
|
151 layout = properties.ObjectProperty() |
53
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
152 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
153 def __init__(self, _xmlui_parent, options, selected, flags): |
251
1f579baf787a
xmlui: some design improvments + use ScrollView + BoxLayout instead of DropDown for ListWidget:
Goffi <goffi@goffi.org>
parents:
243
diff
changeset
|
154 ScrollView.__init__(self) |
53
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
155 self.multi = 'single' not in flags |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
156 self._values = [] |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
157 for option in options: |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
158 self.addValue(option) |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
159 self._xmluiSelectValues(selected) |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
160 self._on_change = None |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
161 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
162 @property |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
163 def items(self): |
251
1f579baf787a
xmlui: some design improvments + use ScrollView + BoxLayout instead of DropDown for ListWidget:
Goffi <goffi@goffi.org>
parents:
243
diff
changeset
|
164 return self.layout.children |
53
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
165 |
251
1f579baf787a
xmlui: some design improvments + use ScrollView + BoxLayout instead of DropDown for ListWidget:
Goffi <goffi@goffi.org>
parents:
243
diff
changeset
|
166 def select(self, item): |
53
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
167 if not self.multi: |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
168 self._xmluiSelectValues([item.value]) |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
169 if self._on_change is not None: |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
170 self._on_change(self) |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
171 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
172 def addValue(self, option, selected=False): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
173 """add a value in the list |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
174 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
175 @param option(tuple): value, label in a tuple |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
176 """ |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
177 self._values.append(option) |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
178 item = ListWidgetItem() |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
179 item.value, item.text = option |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
180 item.selected = selected |
251
1f579baf787a
xmlui: some design improvments + use ScrollView + BoxLayout instead of DropDown for ListWidget:
Goffi <goffi@goffi.org>
parents:
243
diff
changeset
|
181 self.layout.add_widget(item) |
53
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
182 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
183 def _xmluiSelectValue(self, value): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
184 self._xmluiSelectValues([value]) |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
185 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
186 def _xmluiSelectValues(self, values): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
187 for item in self.items: |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
188 item.selected = item.value in values |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
189 if item.selected and not self.multi: |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
190 self.text = item.text |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
191 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
192 def _xmluiGetSelectedValues(self): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
193 return [item.value for item in self.items if item.selected] |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
194 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
195 def _xmluiAddValues(self, values, select=True): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
196 values = set(values).difference([c.value for c in self.items]) |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
197 for v in values: |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
198 self.addValue(v, select) |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
199 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
200 def _xmluiOnChange(self, callback): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
201 self._on_change = callback |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
202 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
203 |
69
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
204 class JidsListWidget(ListWidget): |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
205 # TODO: real list dedicated to jids |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
206 |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
207 def __init__(self, _xmlui_parent, jids, flags): |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
208 ListWidget.__init__(self, _xmlui_parent, [(j,j) for j in jids], [], flags) |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
209 |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
210 |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
211 class PasswordWidget(xmlui.PasswordWidget, TextInput, TextInputOnChange): |
0 | 212 |
213 def __init__(self, _xmlui_parent, value, read_only=False): | |
214 TextInput.__init__(self, password=True, multiline=False, | |
215 text=value, readonly=read_only, size=(100,25), size_hint=(1,None)) | |
69
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
216 TextInputOnChange.__init__(self) |
0 | 217 |
218 def _xmluiSetValue(self, value): | |
219 self.text = value | |
220 | |
221 def _xmluiGetValue(self): | |
222 return self.text | |
223 | |
224 | |
53
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
225 class BoolWidget(xmlui.BoolWidget, Switch): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
226 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
227 def __init__(self, _xmlui_parent, state, read_only=False): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
228 Switch.__init__(self, active=state) |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
229 if read_only: |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
230 self.disabled = True |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
231 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
232 def _xmluiSetValue(self, value): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
233 self.active = value |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
234 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
235 def _xmluiGetValue(self): |
76
a766c278b640
xmlui: fixed BoolWidget _xmluiGetValue:
Goffi <goffi@goffi.org>
parents:
71
diff
changeset
|
236 return C.BOOL_TRUE if self.active else C.BOOL_FALSE |
53
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
237 |
69
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
238 def _xmluiOnChange(self, callback): |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
239 self.bind(active=lambda instance, value: callback(instance)) |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
240 |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
241 |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
242 class IntWidget(xmlui.IntWidget, TextInput, TextInputOnChange): |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
243 |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
244 def __init__(self, _xmlui_parent, value, read_only=False): |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
245 TextInput.__init__(self, text=value, input_filter='int', multiline=False) |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
246 TextInputOnChange.__init__(self) |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
247 if read_only: |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
248 self.disabled = True |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
249 |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
250 def _xmluiSetValue(self, value): |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
251 self.text = value |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
252 |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
253 def _xmluiGetValue(self): |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
254 return self.text |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
255 |
53
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
256 |
29 | 257 ## Containers ## |
258 | |
259 | |
241 | 260 class VerticalContainer(xmlui.VerticalContainer, ScrollView): |
261 layout = properties.ObjectProperty(None) | |
0 | 262 |
263 def __init__(self, xmlui_parent): | |
69
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
264 self.xmlui_parent = xmlui_parent |
241 | 265 ScrollView.__init__(self) |
53
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
266 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
267 def _xmluiAppend(self, widget): |
241 | 268 self.layout.add_widget(widget) |
53
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
269 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
270 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
271 class PairsContainer(xmlui.PairsContainer, GridLayout): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
272 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
273 def __init__(self, xmlui_parent): |
69
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
274 self.xmlui_parent = xmlui_parent |
53
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
275 GridLayout.__init__(self) |
0 | 276 |
277 def _xmluiAppend(self, widget): | |
278 self.add_widget(widget) | |
279 | |
280 | |
125
b6e6afb0dc46
xmlui: added LabelContainer and updated XMLUIPanel following changes in main class
Goffi <goffi@goffi.org>
parents:
99
diff
changeset
|
281 class LabelContainer(PairsContainer, xmlui.LabelContainer): |
b6e6afb0dc46
xmlui: added LabelContainer and updated XMLUIPanel following changes in main class
Goffi <goffi@goffi.org>
parents:
99
diff
changeset
|
282 pass |
b6e6afb0dc46
xmlui: added LabelContainer and updated XMLUIPanel following changes in main class
Goffi <goffi@goffi.org>
parents:
99
diff
changeset
|
283 |
b6e6afb0dc46
xmlui: added LabelContainer and updated XMLUIPanel following changes in main class
Goffi <goffi@goffi.org>
parents:
99
diff
changeset
|
284 |
69
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
285 class TabsPanelContainer(TabbedPanelItem): |
241 | 286 layout = properties.ObjectProperty(None) |
69
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
287 |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
288 def _xmluiAppend(self, widget): |
241 | 289 self.layout.add_widget(widget) |
69
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
290 |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
291 |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
292 class TabsContainer(xmlui.TabsContainer, TabbedPanel): |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
293 |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
294 def __init__(self, xmlui_parent): |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
295 self.xmlui_parent = xmlui_parent |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
296 TabbedPanel.__init__(self, do_default_tab=False) |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
297 |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
298 def _xmluiAddTab(self, label, selected): |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
299 tab = TabsPanelContainer(text=label) |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
300 self.add_widget(tab) |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
301 return tab |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
302 |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
303 |
53
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
304 class AdvancedListRow(GridLayout): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
305 global_index = 0 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
306 index = properties.ObjectProperty() |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
307 selected = properties.BooleanProperty(False) |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
308 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
309 def __init__(self, **kwargs): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
310 self.global_index = AdvancedListRow.global_index |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
311 AdvancedListRow.global_index += 1 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
312 super(AdvancedListRow, self).__init__(**kwargs) |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
313 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
314 def on_touch_down(self, touch): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
315 if self.collide_point(*touch.pos): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
316 parent = self.parent |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
317 while parent is not None and not isinstance(parent, AdvancedListContainer): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
318 parent = parent.parent |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
319 if parent is None: |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
320 log.error(u"Can't find parent AdvancedListContainer") |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
321 else: |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
322 if parent.selectable: |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
323 self.selected = parent._xmluiToggleSelected(self) |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
324 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
325 return super(AdvancedListRow, self).on_touch_down(touch) |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
326 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
327 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
328 class AdvancedListContainer(xmlui.AdvancedListContainer, GridLayout): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
329 |
69
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
330 def __init__(self, xmlui_parent, columns, selectable='no'): |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
331 self.xmlui_parent = xmlui_parent |
53
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
332 GridLayout.__init__(self) |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
333 self._columns = columns |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
334 self.selectable = selectable != 'no' |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
335 self._current_row = None |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
336 self._selected = [] |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
337 self._xmlui_select_cb = None |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
338 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
339 def _xmluiToggleSelected(self, row): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
340 """inverse selection status of an AdvancedListRow |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
341 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
342 @param row(AdvancedListRow): row to (un)select |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
343 @return (bool): True if row is selected |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
344 """ |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
345 try: |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
346 self._selected.remove(row) |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
347 except ValueError: |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
348 self._selected.append(row) |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
349 if self._xmlui_select_cb is not None: |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
350 self._xmlui_select_cb(self) |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
351 return True |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
352 else: |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
353 return False |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
354 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
355 def _xmluiAppend(self, widget): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
356 if self._current_row is None: |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
357 log.error(u"No row set, ignoring append") |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
358 return |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
359 self._current_row.add_widget(widget) |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
360 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
361 def _xmluiAddRow(self, idx): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
362 self._current_row = AdvancedListRow() |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
363 self._current_row.cols = self._columns |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
364 self._current_row.index = idx |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
365 self.add_widget(self._current_row) |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
366 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
367 def _xmluiGetSelectedWidgets(self): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
368 return self._selected |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
369 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
370 def _xmluiGetSelectedIndex(self): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
371 if not self._selected: |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
372 return None |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
373 return self._selected[0].index |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
374 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
375 def _xmluiOnSelect(self, callback): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
376 """ Call callback with widget as only argument """ |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
377 self._xmlui_select_cb = callback |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
378 |
29 | 379 ## Dialogs ## |
380 | |
381 | |
382 class NoteDialog(xmlui.NoteDialog): | |
383 | |
384 def __init__(self, _xmlui_parent, title, message, level): | |
385 xmlui.NoteDialog.__init__(self, _xmlui_parent) | |
386 self.title, self.message, self.level = title, message, level | |
387 | |
388 def _xmluiShow(self): | |
389 G.host.addNote(self.title, self.message, self.level) | |
390 | |
391 | |
243 | 392 class MessageDialog(xmlui.MessageDialog, dialog.MessageDialog): |
393 | |
394 def __init__(self, _xmlui_parent, title, message, level): | |
395 dialog.MessageDialog.__init__(self, | |
396 title=title, | |
397 message=message, | |
398 level=level, | |
399 close_cb = self.close_cb) | |
400 xmlui.MessageDialog.__init__(self, _xmlui_parent) | |
401 | |
402 def close_cb(self): | |
403 self._xmluiClose() | |
404 | |
405 def _xmluiShow(self): | |
406 G.host.addNotifUI(self) | |
407 | |
408 def _xmluiClose(self): | |
409 G.host.closeUI() | |
410 | |
411 def show(self, *args, **kwargs): | |
412 G.host.showUI(self) | |
413 | |
414 | |
204
37638765c97b
xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
415 class ConfirmDialog(xmlui.ConfirmDialog, dialog.ConfirmDialog): |
37638765c97b
xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
416 |
37638765c97b
xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
417 def __init__(self, _xmlui_parent, title, message, level, buttons_set): |
37638765c97b
xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
418 dialog.ConfirmDialog.__init__(self, |
37638765c97b
xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
419 title=title, |
37638765c97b
xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
420 message=message, |
37638765c97b
xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
421 no_cb = self.no_cb, |
37638765c97b
xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
422 yes_cb = self.yes_cb) |
37638765c97b
xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
423 xmlui.ConfirmDialog.__init__(self, _xmlui_parent) |
37638765c97b
xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
424 |
37638765c97b
xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
425 def no_cb(self): |
37638765c97b
xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
426 G.host.closeUI() |
37638765c97b
xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
427 self._xmluiCancelled() |
37638765c97b
xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
428 |
37638765c97b
xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
429 def yes_cb(self): |
37638765c97b
xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
430 G.host.closeUI() |
37638765c97b
xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
431 self._xmluiValidated() |
37638765c97b
xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
432 |
37638765c97b
xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
433 def _xmluiShow(self): |
37638765c97b
xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
434 G.host.addNotifUI(self) |
37638765c97b
xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
435 |
37638765c97b
xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
436 def _xmluiClose(self): |
37638765c97b
xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
437 G.host.closeUI() |
37638765c97b
xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
438 |
37638765c97b
xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
439 def show(self, *args, **kwargs): |
37638765c97b
xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
440 assert kwargs["force"] |
37638765c97b
xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
441 G.host.showUI(self) |
37638765c97b
xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
442 |
37638765c97b
xmlui: implemented ConfirmDialog using new dialog.ConfirmDialog
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
443 |
99 | 444 class FileDialog(xmlui.FileDialog, BoxLayout): |
445 message = properties.ObjectProperty() | |
446 | |
447 def __init__(self, _xmlui_parent, title, message, level, filetype): | |
448 xmlui.FileDialog.__init__(self, _xmlui_parent) | |
449 BoxLayout.__init__(self) | |
450 self.message.text = message | |
451 if filetype == C.XMLUI_DATA_FILETYPE_DIR: | |
452 self.file_chooser.dirselect = True | |
453 | |
454 def _xmluiShow(self): | |
455 G.host.addNotifUI(self) | |
456 | |
457 def _xmluiClose(self): | |
458 # FIXME: notif UI is not removed if dialog is not shown yet | |
459 G.host.closeUI() | |
460 | |
461 def onSelect(self, path): | |
462 try: | |
463 path = path[0] | |
464 except IndexError: | |
465 path = None | |
466 if not path: | |
467 self._xmluiCancelled() | |
468 else: | |
469 self._xmluiValidated({'path': path}) | |
470 | |
471 def show(self, *args, **kwargs): | |
472 assert kwargs["force"] | |
473 G.host.showUI(self) | |
474 | |
475 | |
29 | 476 ## Factory ## |
477 | |
478 | |
0 | 479 class WidgetFactory(object): |
480 | |
481 def __getattr__(self, attr): | |
482 if attr.startswith("create"): | |
483 cls = globals()[attr[6:]] | |
484 return cls | |
485 | |
486 | |
29 | 487 ## Core ## |
488 | |
489 | |
0 | 490 class Title(Label): |
491 | |
492 def __init__(self, *args, **kwargs): | |
493 kwargs['size'] = (100, 25) | |
494 kwargs['size_hint'] = (1,None) | |
495 super(Title, self).__init__(*args, **kwargs) | |
496 | |
497 | |
53
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
498 class FormButton(Button): |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
499 pass |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
500 |
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
501 |
159 | 502 class XMLUIPanel(xmlui.XMLUIPanel, BoxLayout): |
0 | 503 widget_factory = WidgetFactory() |
504 | |
243 | 505 def __init__(self, host, parsed_xml, title=None, flags=None, callback=None, |
506 ignore=None, whitelist=None, profile=C.PROF_KEY_NONE): | |
241 | 507 BoxLayout.__init__(self) |
0 | 508 self.close_cb = None |
69
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
509 self._post_treats = [] # list of callback to call after UI is constructed |
125
b6e6afb0dc46
xmlui: added LabelContainer and updated XMLUIPanel following changes in main class
Goffi <goffi@goffi.org>
parents:
99
diff
changeset
|
510 xmlui.XMLUIPanel.__init__(self, |
b6e6afb0dc46
xmlui: added LabelContainer and updated XMLUIPanel following changes in main class
Goffi <goffi@goffi.org>
parents:
99
diff
changeset
|
511 host, |
b6e6afb0dc46
xmlui: added LabelContainer and updated XMLUIPanel following changes in main class
Goffi <goffi@goffi.org>
parents:
99
diff
changeset
|
512 parsed_xml, |
b6e6afb0dc46
xmlui: added LabelContainer and updated XMLUIPanel following changes in main class
Goffi <goffi@goffi.org>
parents:
99
diff
changeset
|
513 title=title, |
b6e6afb0dc46
xmlui: added LabelContainer and updated XMLUIPanel following changes in main class
Goffi <goffi@goffi.org>
parents:
99
diff
changeset
|
514 flags=flags, |
b6e6afb0dc46
xmlui: added LabelContainer and updated XMLUIPanel following changes in main class
Goffi <goffi@goffi.org>
parents:
99
diff
changeset
|
515 callback=callback, |
b6e6afb0dc46
xmlui: added LabelContainer and updated XMLUIPanel following changes in main class
Goffi <goffi@goffi.org>
parents:
99
diff
changeset
|
516 ignore=ignore, |
129
0704f3be65cb
xmlui: fixed missing whitelist argument
Goffi <goffi@goffi.org>
parents:
126
diff
changeset
|
517 whitelist=whitelist, |
125
b6e6afb0dc46
xmlui: added LabelContainer and updated XMLUIPanel following changes in main class
Goffi <goffi@goffi.org>
parents:
99
diff
changeset
|
518 profile=profile) |
0 | 519 |
520 def setCloseCb(self, close_cb): | |
521 self.close_cb = close_cb | |
522 | |
523 def _xmluiClose(self): | |
524 if self.close_cb is not None: | |
525 self.close_cb(self) | |
526 else: | |
33
c21d1be2e54c
core: XMLUI notifications coming from backend are handled:
Goffi <goffi@goffi.org>
parents:
29
diff
changeset
|
527 G.host.closeUI() |
0 | 528 |
71
8c9fe2c5aacc
settings: save button is now disabled when there is nothing to save
Goffi <goffi@goffi.org>
parents:
69
diff
changeset
|
529 def onParamChange(self, ctrl): |
8c9fe2c5aacc
settings: save button is now disabled when there is nothing to save
Goffi <goffi@goffi.org>
parents:
69
diff
changeset
|
530 super(XMLUIPanel, self).onParamChange(ctrl) |
8c9fe2c5aacc
settings: save button is now disabled when there is nothing to save
Goffi <goffi@goffi.org>
parents:
69
diff
changeset
|
531 self.save_btn.disabled = False |
8c9fe2c5aacc
settings: save button is now disabled when there is nothing to save
Goffi <goffi@goffi.org>
parents:
69
diff
changeset
|
532 |
69
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
533 def addPostTreat(self, callback): |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
534 self._post_treats.append(callback) |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
535 |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
536 def _postTreatCb(self): |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
537 for cb in self._post_treats: |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
538 cb() |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
539 del self._post_treats |
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
540 |
71
8c9fe2c5aacc
settings: save button is now disabled when there is nothing to save
Goffi <goffi@goffi.org>
parents:
69
diff
changeset
|
541 def _saveButtonCb(self, button): |
8c9fe2c5aacc
settings: save button is now disabled when there is nothing to save
Goffi <goffi@goffi.org>
parents:
69
diff
changeset
|
542 button.disabled = True |
8c9fe2c5aacc
settings: save button is now disabled when there is nothing to save
Goffi <goffi@goffi.org>
parents:
69
diff
changeset
|
543 self.onSaveParams(button) |
8c9fe2c5aacc
settings: save button is now disabled when there is nothing to save
Goffi <goffi@goffi.org>
parents:
69
diff
changeset
|
544 |
0 | 545 def constructUI(self, parsed_dom): |
69
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
546 xmlui.XMLUIPanel.constructUI(self, parsed_dom, self._postTreatCb) |
0 | 547 if self.xmlui_title: |
548 self.add_widget(Title(text=self.xmlui_title)) | |
549 self.add_widget(self.main_cont) | |
550 if self.type == 'form': | |
53
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
551 submit_btn = FormButton(text=_(u"Submit")) |
0 | 552 submit_btn.bind(on_press=self.onFormSubmitted) |
553 self.add_widget(submit_btn) | |
554 if not 'NO_CANCEL' in self.flags: | |
53
65775152aac1
xmlui: implemented most of XMLUI, not finished yet
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
555 cancel_btn = FormButton(text=_(u"Cancel")) |
0 | 556 cancel_btn.bind(on_press=self.onFormCancelled) |
557 self.add_widget(cancel_btn) | |
69
a9c6b089070d
xmlui: improvments to prepare parameters:
Goffi <goffi@goffi.org>
parents:
55
diff
changeset
|
558 elif self.type == 'param': |
71
8c9fe2c5aacc
settings: save button is now disabled when there is nothing to save
Goffi <goffi@goffi.org>
parents:
69
diff
changeset
|
559 self.save_btn = FormButton(text=_(u"Save"), disabled=True) |
8c9fe2c5aacc
settings: save button is now disabled when there is nothing to save
Goffi <goffi@goffi.org>
parents:
69
diff
changeset
|
560 self.save_btn.bind(on_press=self._saveButtonCb) |
8c9fe2c5aacc
settings: save button is now disabled when there is nothing to save
Goffi <goffi@goffi.org>
parents:
69
diff
changeset
|
561 self.add_widget(self.save_btn) |
0 | 562 |
33
c21d1be2e54c
core: XMLUI notifications coming from backend are handled:
Goffi <goffi@goffi.org>
parents:
29
diff
changeset
|
563 def show(self, *args, **kwargs): |
c21d1be2e54c
core: XMLUI notifications coming from backend are handled:
Goffi <goffi@goffi.org>
parents:
29
diff
changeset
|
564 if not self.user_action and not kwargs.get("force", False): |
c21d1be2e54c
core: XMLUI notifications coming from backend are handled:
Goffi <goffi@goffi.org>
parents:
29
diff
changeset
|
565 G.host.addNotifUI(self) |
c21d1be2e54c
core: XMLUI notifications coming from backend are handled:
Goffi <goffi@goffi.org>
parents:
29
diff
changeset
|
566 else: |
c21d1be2e54c
core: XMLUI notifications coming from backend are handled:
Goffi <goffi@goffi.org>
parents:
29
diff
changeset
|
567 G.host.showUI(self) |
c21d1be2e54c
core: XMLUI notifications coming from backend are handled:
Goffi <goffi@goffi.org>
parents:
29
diff
changeset
|
568 |
0 | 569 |
29 | 570 class XMLUIDialog(xmlui.XMLUIDialog): |
571 dialog_factory = WidgetFactory() | |
572 | |
573 | |
235
525527a01439
xmlui: use create with partial and class_map, following change in base class
Goffi <goffi@goffi.org>
parents:
227
diff
changeset
|
574 create = partial(xmlui.create, class_map={ |
525527a01439
xmlui: use create with partial and class_map, following change in base class
Goffi <goffi@goffi.org>
parents:
227
diff
changeset
|
575 xmlui.CLASS_PANEL: XMLUIPanel, |
525527a01439
xmlui: use create with partial and class_map, following change in base class
Goffi <goffi@goffi.org>
parents:
227
diff
changeset
|
576 xmlui.CLASS_DIALOG: XMLUIDialog}) |