Mercurial > libervia-web
annotate src/browser/sat_browser/xmlui.py @ 712:bf562fb9c273
server_side: use Jinja2 template engine for static blog
author | souliane <souliane@mailoo.org> |
---|---|
date | Mon, 13 Jul 2015 18:11:38 +0200 |
parents | 82123705474b |
children | 9a9e2fcc6347 |
rev | line source |
---|---|
143 | 1 #!/usr/bin/python |
2 # -*- coding: utf-8 -*- | |
3 | |
339
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
337
diff
changeset
|
4 # Libervia: a Salut à Toi frontend |
685 | 5 # Copyright (C) 2011, 2012, 2013, 2014, 2015 Jérôme Poisson <goffi@goffi.org> |
143 | 6 |
339
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
337
diff
changeset
|
7 # This program is free software: you can redistribute it and/or modify |
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
337
diff
changeset
|
8 # it under the terms of the GNU Affero General Public License as published by |
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
337
diff
changeset
|
9 # the Free Software Foundation, either version 3 of the License, or |
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
337
diff
changeset
|
10 # (at your option) any later version. |
143 | 11 |
339
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
337
diff
changeset
|
12 # This program is distributed in the hope that it will be useful, |
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
337
diff
changeset
|
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
337
diff
changeset
|
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
337
diff
changeset
|
15 # GNU Affero General Public License for more details. |
143 | 16 |
339
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
337
diff
changeset
|
17 # You should have received a copy of the GNU Affero General Public License |
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
337
diff
changeset
|
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
143 | 19 |
439
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
430
diff
changeset
|
20 from sat.core.log import getLogger |
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
430
diff
changeset
|
21 log = getLogger(__name__) |
449
981ed669d3b3
/!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
22 from sat_frontends.tools import xmlui |
504
f030491cff75
browser side (XMLUI): fixed bad use of text instead of XHTML in dialogs
Goffi <goffi@goffi.org>
parents:
500
diff
changeset
|
23 from sat_frontends.tools import strings |
500
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
24 from sat_browser.constants import Const as C |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
25 from sat_browser import dialog |
504
f030491cff75
browser side (XMLUI): fixed bad use of text instead of XHTML in dialogs
Goffi <goffi@goffi.org>
parents:
500
diff
changeset
|
26 from sat_browser import html_tools |
449
981ed669d3b3
/!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
27 |
143 | 28 from pyjamas.ui.VerticalPanel import VerticalPanel |
29 from pyjamas.ui.HorizontalPanel import HorizontalPanel | |
30 from pyjamas.ui.TabPanel import TabPanel | |
31 from pyjamas.ui.Grid import Grid | |
32 from pyjamas.ui.Label import Label | |
33 from pyjamas.ui.TextBox import TextBox | |
34 from pyjamas.ui.PasswordTextBox import PasswordTextBox | |
35 from pyjamas.ui.TextArea import TextArea | |
36 from pyjamas.ui.CheckBox import CheckBox | |
37 from pyjamas.ui.ListBox import ListBox | |
38 from pyjamas.ui.Button import Button | |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
39 from pyjamas.ui.HTML import HTML |
449
981ed669d3b3
/!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
40 |
467 | 41 import nativedom |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
42 |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
43 |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
44 class EmptyWidget(xmlui.EmptyWidget, Label): |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
45 |
500
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
46 def __init__(self, _xmlui_parent): |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
47 Label.__init__(self, '') |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
48 |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
49 |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
50 class TextWidget(xmlui.TextWidget, Label): |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
51 |
500
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
52 def __init__(self, _xmlui_parent, value): |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
53 Label.__init__(self, value) |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
54 |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
55 |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
56 class LabelWidget(xmlui.LabelWidget, TextWidget): |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
57 |
500
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
58 def __init__(self, _xmlui_parent, value): |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
59 TextWidget.__init__(self, _xmlui_parent, value + ": ") |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
60 |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
61 |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
62 class JidWidget(xmlui.JidWidget, TextWidget): |
337 | 63 |
500
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
64 def __init__(self, _xmlui_parent, value): |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
65 TextWidget.__init__(self, _xmlui_parent, value) |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
66 |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
67 |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
68 class DividerWidget(xmlui.DividerWidget, HTML): |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
69 |
500
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
70 def __init__(self, _xmlui_parent, style='line'): |
428
0c4547587637
browser_side (xmlui): implement the divider styles
souliane <souliane@mailoo.org>
parents:
392
diff
changeset
|
71 """Add a divider |
0c4547587637
browser_side (xmlui): implement the divider styles
souliane <souliane@mailoo.org>
parents:
392
diff
changeset
|
72 |
500
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
73 @param _xmlui_parent |
662
ebb602d8b3f2
browser_side: replace all instances of 'str' with 'unicode'
souliane <souliane@mailoo.org>
parents:
589
diff
changeset
|
74 @param style (unicode): one of: |
489
1ce6133993e4
browser side (XMLUI): implementation of read_only attribute
Goffi <goffi@goffi.org>
parents:
467
diff
changeset
|
75 - line: a simple line |
1ce6133993e4
browser side (XMLUI): implementation of read_only attribute
Goffi <goffi@goffi.org>
parents:
467
diff
changeset
|
76 - dot: a line of dots |
1ce6133993e4
browser side (XMLUI): implementation of read_only attribute
Goffi <goffi@goffi.org>
parents:
467
diff
changeset
|
77 - dash: a line of dashes |
1ce6133993e4
browser side (XMLUI): implementation of read_only attribute
Goffi <goffi@goffi.org>
parents:
467
diff
changeset
|
78 - plain: a full thick line |
1ce6133993e4
browser side (XMLUI): implementation of read_only attribute
Goffi <goffi@goffi.org>
parents:
467
diff
changeset
|
79 - blank: a blank line/space |
428
0c4547587637
browser_side (xmlui): implement the divider styles
souliane <souliane@mailoo.org>
parents:
392
diff
changeset
|
80 """ |
0c4547587637
browser_side (xmlui): implement the divider styles
souliane <souliane@mailoo.org>
parents:
392
diff
changeset
|
81 HTML.__init__(self, "<hr/>") |
0c4547587637
browser_side (xmlui): implement the divider styles
souliane <souliane@mailoo.org>
parents:
392
diff
changeset
|
82 self.addStyleName(style) |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
83 |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
84 |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
85 class StringWidget(xmlui.StringWidget, TextBox): |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
86 |
500
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
87 def __init__(self, _xmlui_parent, value, read_only=False): |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
88 TextBox.__init__(self) |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
89 self.setText(value) |
489
1ce6133993e4
browser side (XMLUI): implementation of read_only attribute
Goffi <goffi@goffi.org>
parents:
467
diff
changeset
|
90 self.setReadonly(read_only) |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
91 |
429
9283f9e5e5dd
browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents:
428
diff
changeset
|
92 def _xmluiSetValue(self, value): |
9283f9e5e5dd
browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents:
428
diff
changeset
|
93 self.setText(value) |
9283f9e5e5dd
browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents:
428
diff
changeset
|
94 |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
95 def _xmluiGetValue(self): |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
96 return self.getText() |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
97 |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
98 def _xmluiOnChange(self, callback): |
378 | 99 self.addChangeListener(callback) |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
100 |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
101 |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
102 class PasswordWidget(xmlui.PasswordWidget, PasswordTextBox): |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
103 |
500
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
104 def __init__(self, _xmlui_parent, value, read_only=False): |
390
76583fab7ea0
browser_side: fix XMLUI password box initialisation
souliane <souliane@mailoo.org>
parents:
378
diff
changeset
|
105 PasswordTextBox.__init__(self) |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
106 self.setText(value) |
489
1ce6133993e4
browser side (XMLUI): implementation of read_only attribute
Goffi <goffi@goffi.org>
parents:
467
diff
changeset
|
107 self.setReadonly(read_only) |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
108 |
429
9283f9e5e5dd
browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents:
428
diff
changeset
|
109 def _xmluiSetValue(self, value): |
9283f9e5e5dd
browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents:
428
diff
changeset
|
110 self.setText(value) |
9283f9e5e5dd
browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents:
428
diff
changeset
|
111 |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
112 def _xmluiGetValue(self): |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
113 return self.getText() |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
114 |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
115 def _xmluiOnChange(self, callback): |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
116 self.addChangeListener(callback) |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
117 |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
118 |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
119 class TextBoxWidget(xmlui.TextBoxWidget, TextArea): |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
120 |
500
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
121 def __init__(self, _xmlui_parent, value, read_only=False): |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
122 TextArea.__init__(self) |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
123 self.setText(value) |
489
1ce6133993e4
browser side (XMLUI): implementation of read_only attribute
Goffi <goffi@goffi.org>
parents:
467
diff
changeset
|
124 self.setReadonly(read_only) |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
125 |
429
9283f9e5e5dd
browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents:
428
diff
changeset
|
126 def _xmluiSetValue(self, value): |
9283f9e5e5dd
browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents:
428
diff
changeset
|
127 self.setText(value) |
9283f9e5e5dd
browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents:
428
diff
changeset
|
128 |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
129 def _xmluiGetValue(self): |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
130 return self.getText() |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
131 |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
132 def _xmluiOnChange(self, callback): |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
133 self.addChangeListener(callback) |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
134 |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
135 |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
136 class BoolWidget(xmlui.BoolWidget, CheckBox): |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
137 |
500
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
138 def __init__(self, _xmlui_parent, state, read_only=False): |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
139 CheckBox.__init__(self) |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
140 self.setChecked(state) |
489
1ce6133993e4
browser side (XMLUI): implementation of read_only attribute
Goffi <goffi@goffi.org>
parents:
467
diff
changeset
|
141 self.setReadonly(read_only) |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
142 |
429
9283f9e5e5dd
browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents:
428
diff
changeset
|
143 def _xmluiSetValue(self, value): |
9283f9e5e5dd
browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents:
428
diff
changeset
|
144 self.setChecked(value == "true") |
9283f9e5e5dd
browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents:
428
diff
changeset
|
145 |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
146 def _xmluiGetValue(self): |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
147 return "true" if self.isChecked() else "false" |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
148 |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
149 def _xmluiOnChange(self, callback): |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
150 self.addClickListener(callback) |
143 | 151 |
152 | |
564
fed185c95f1c
browser_side: add XMLUI "int" widget type + historyPrint uses the new param "Chat history limit"
souliane <souliane@mailoo.org>
parents:
504
diff
changeset
|
153 class IntWidget(xmlui.IntWidget, TextBox): |
fed185c95f1c
browser_side: add XMLUI "int" widget type + historyPrint uses the new param "Chat history limit"
souliane <souliane@mailoo.org>
parents:
504
diff
changeset
|
154 |
fed185c95f1c
browser_side: add XMLUI "int" widget type + historyPrint uses the new param "Chat history limit"
souliane <souliane@mailoo.org>
parents:
504
diff
changeset
|
155 def __init__(self, _xmlui_parent, value, read_only=False): |
fed185c95f1c
browser_side: add XMLUI "int" widget type + historyPrint uses the new param "Chat history limit"
souliane <souliane@mailoo.org>
parents:
504
diff
changeset
|
156 TextBox.__init__(self) |
fed185c95f1c
browser_side: add XMLUI "int" widget type + historyPrint uses the new param "Chat history limit"
souliane <souliane@mailoo.org>
parents:
504
diff
changeset
|
157 self.setText(value) |
fed185c95f1c
browser_side: add XMLUI "int" widget type + historyPrint uses the new param "Chat history limit"
souliane <souliane@mailoo.org>
parents:
504
diff
changeset
|
158 self.setReadonly(read_only) |
fed185c95f1c
browser_side: add XMLUI "int" widget type + historyPrint uses the new param "Chat history limit"
souliane <souliane@mailoo.org>
parents:
504
diff
changeset
|
159 |
fed185c95f1c
browser_side: add XMLUI "int" widget type + historyPrint uses the new param "Chat history limit"
souliane <souliane@mailoo.org>
parents:
504
diff
changeset
|
160 def _xmluiSetValue(self, value): |
fed185c95f1c
browser_side: add XMLUI "int" widget type + historyPrint uses the new param "Chat history limit"
souliane <souliane@mailoo.org>
parents:
504
diff
changeset
|
161 self.setText(value) |
fed185c95f1c
browser_side: add XMLUI "int" widget type + historyPrint uses the new param "Chat history limit"
souliane <souliane@mailoo.org>
parents:
504
diff
changeset
|
162 |
fed185c95f1c
browser_side: add XMLUI "int" widget type + historyPrint uses the new param "Chat history limit"
souliane <souliane@mailoo.org>
parents:
504
diff
changeset
|
163 def _xmluiGetValue(self): |
fed185c95f1c
browser_side: add XMLUI "int" widget type + historyPrint uses the new param "Chat history limit"
souliane <souliane@mailoo.org>
parents:
504
diff
changeset
|
164 return self.getText() |
fed185c95f1c
browser_side: add XMLUI "int" widget type + historyPrint uses the new param "Chat history limit"
souliane <souliane@mailoo.org>
parents:
504
diff
changeset
|
165 |
fed185c95f1c
browser_side: add XMLUI "int" widget type + historyPrint uses the new param "Chat history limit"
souliane <souliane@mailoo.org>
parents:
504
diff
changeset
|
166 def _xmluiOnChange(self, callback): |
fed185c95f1c
browser_side: add XMLUI "int" widget type + historyPrint uses the new param "Chat history limit"
souliane <souliane@mailoo.org>
parents:
504
diff
changeset
|
167 self.addChangeListener(callback) |
fed185c95f1c
browser_side: add XMLUI "int" widget type + historyPrint uses the new param "Chat history limit"
souliane <souliane@mailoo.org>
parents:
504
diff
changeset
|
168 |
fed185c95f1c
browser_side: add XMLUI "int" widget type + historyPrint uses the new param "Chat history limit"
souliane <souliane@mailoo.org>
parents:
504
diff
changeset
|
169 |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
170 class ButtonWidget(xmlui.ButtonWidget, Button): |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
171 |
500
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
172 def __init__(self, _xmlui_parent, value, click_callback): |
429
9283f9e5e5dd
browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents:
428
diff
changeset
|
173 Button.__init__(self, value, click_callback) |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
174 |
378 | 175 def _xmluiOnClick(self, callback): |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
176 self.addClickListener(callback) |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
177 |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
178 |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
179 class ListWidget(xmlui.ListWidget, ListBox): |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
180 |
500
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
181 def __init__(self, _xmlui_parent, options, selected, flags): |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
182 ListBox.__init__(self) |
430
a927a98b398d
browser_side (xmlui): fix multi-selection
souliane <souliane@mailoo.org>
parents:
429
diff
changeset
|
183 multi_selection = 'single' not in flags |
a927a98b398d
browser_side (xmlui): fix multi-selection
souliane <souliane@mailoo.org>
parents:
429
diff
changeset
|
184 self.setMultipleSelect(multi_selection) |
a927a98b398d
browser_side (xmlui): fix multi-selection
souliane <souliane@mailoo.org>
parents:
429
diff
changeset
|
185 if multi_selection: |
a927a98b398d
browser_side (xmlui): fix multi-selection
souliane <souliane@mailoo.org>
parents:
429
diff
changeset
|
186 self.setVisibleItemCount(5) |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
187 for option in options: |
337 | 188 self.addItem(option[1]) |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
189 self._xmlui_attr_map = {label: value for value, label in options} |
429
9283f9e5e5dd
browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents:
428
diff
changeset
|
190 self._xmluiSelectValues(selected) |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
191 |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
192 def _xmluiSelectValue(self, value): |
429
9283f9e5e5dd
browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents:
428
diff
changeset
|
193 """Select a value checking its item""" |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
194 try: |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
195 label = [label for label, _value in self._xmlui_attr_map.items() if _value == value][0] |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
196 except IndexError: |
694
82123705474b
massive (preventive) addition of 'u' (unicode) before the strings passed to logging functions
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
197 log.warning(u"Can't find value [%s] to select" % value) |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
198 return |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
199 self.selectItem(label) |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
200 |
429
9283f9e5e5dd
browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents:
428
diff
changeset
|
201 def _xmluiSelectValues(self, values): |
9283f9e5e5dd
browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents:
428
diff
changeset
|
202 """Select multiple values, ignore the items""" |
9283f9e5e5dd
browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents:
428
diff
changeset
|
203 self.setValueSelection(values) |
9283f9e5e5dd
browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents:
428
diff
changeset
|
204 |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
205 def _xmluiGetSelectedValues(self): |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
206 ret = [] |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
207 for label in self.getSelectedItemText(): |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
208 ret.append(self._xmlui_attr_map[label]) |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
209 return ret |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
210 |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
211 def _xmluiOnChange(self, callback): |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
212 self.addChangeListener(callback) |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
213 |
429
9283f9e5e5dd
browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents:
428
diff
changeset
|
214 def _xmluiAddValues(self, values, select=True): |
9283f9e5e5dd
browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents:
428
diff
changeset
|
215 selected = self._xmluiGetSelectedValues() |
9283f9e5e5dd
browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents:
428
diff
changeset
|
216 for value in values: |
430
a927a98b398d
browser_side (xmlui): fix multi-selection
souliane <souliane@mailoo.org>
parents:
429
diff
changeset
|
217 if value not in self._xmlui_attr_map.values(): |
a927a98b398d
browser_side (xmlui): fix multi-selection
souliane <souliane@mailoo.org>
parents:
429
diff
changeset
|
218 self.addItem(value) |
a927a98b398d
browser_side (xmlui): fix multi-selection
souliane <souliane@mailoo.org>
parents:
429
diff
changeset
|
219 self._xmlui_attr_map[value] = value |
429
9283f9e5e5dd
browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents:
428
diff
changeset
|
220 if value not in selected: |
9283f9e5e5dd
browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents:
428
diff
changeset
|
221 selected.append(value) |
9283f9e5e5dd
browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents:
428
diff
changeset
|
222 self._xmluiSelectValues(selected) |
9283f9e5e5dd
browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents:
428
diff
changeset
|
223 |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
224 |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
225 class LiberviaContainer(object): |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
226 |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
227 def _xmluiAppend(self, widget): |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
228 self.append(widget) |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
229 |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
230 |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
231 class AdvancedListContainer(xmlui.AdvancedListContainer, Grid): |
143 | 232 |
500
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
233 def __init__(self, _xmlui_parent, columns, selectable='no'): |
337 | 234 Grid.__init__(self, 0, columns) |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
235 self.columns = columns |
337 | 236 self.row = -1 |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
237 self.col = 0 |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
238 self._xmlui_rows_idx = [] |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
239 self._xmlui_selectable = selectable != 'no' |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
240 self._xmlui_selected_row = None |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
241 self.addTableListener(self) |
376
ab923b870fb0
browser side: XMLUI AdvancedListContainer: rows are highlighted when there are selectable
Goffi <goffi@goffi.org>
parents:
369
diff
changeset
|
242 if self._xmlui_selectable: |
ab923b870fb0
browser side: XMLUI AdvancedListContainer: rows are highlighted when there are selectable
Goffi <goffi@goffi.org>
parents:
369
diff
changeset
|
243 self.addStyleName('AdvancedListSelectable') |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
244 |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
245 def onCellClicked(self, grid, row, col): |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
246 if not self._xmlui_selectable: |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
247 return |
376
ab923b870fb0
browser side: XMLUI AdvancedListContainer: rows are highlighted when there are selectable
Goffi <goffi@goffi.org>
parents:
369
diff
changeset
|
248 self._xmlui_selected_row = row |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
249 try: |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
250 self._xmlui_select_cb(self) |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
251 except AttributeError: |
439
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
430
diff
changeset
|
252 log.warning("no select callback set") |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
253 |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
254 def _xmluiAppend(self, widget): |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
255 self.setWidget(self.row, self.col, widget) |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
256 self.col += 1 |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
257 |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
258 def _xmluiAddRow(self, idx): |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
259 self.row += 1 |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
260 self.col = 0 |
337 | 261 self._xmlui_rows_idx.insert(self.row, idx) |
451 | 262 self.resizeRows(self.row + 1) |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
263 |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
264 def _xmluiGetSelectedWidgets(self): |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
265 return [self.getWidget(self._xmlui_selected_row, col) for col in range(self.columns)] |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
266 |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
267 def _xmluiGetSelectedIndex(self): |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
268 try: |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
269 return self._xmlui_rows_idx[self._xmlui_selected_row] |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
270 except TypeError: |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
271 return None |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
272 |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
273 def _xmluiOnSelect(self, callback): |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
274 self._xmlui_select_cb = callback |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
275 |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
276 |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
277 class PairsContainer(xmlui.PairsContainer, Grid): |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
278 |
500
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
279 def __init__(self, _xmlui_parent): |
247
fe83837d3491
browser_side: removed some trailing spaces
Goffi <goffi@goffi.org>
parents:
229
diff
changeset
|
280 Grid.__init__(self, 0, 0) |
143 | 281 self.row = 0 |
282 self.col = 0 | |
283 | |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
284 def _xmluiAppend(self, widget): |
143 | 285 if self.col == 0: |
451 | 286 self.resize(self.row + 1, 2) |
143 | 287 self.setWidget(self.row, self.col, widget) |
288 self.col += 1 | |
289 if self.col == 2: | |
451 | 290 self.row += 1 |
143 | 291 self.col = 0 |
247
fe83837d3491
browser_side: removed some trailing spaces
Goffi <goffi@goffi.org>
parents:
229
diff
changeset
|
292 |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
293 |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
294 class TabsContainer(LiberviaContainer, xmlui.TabsContainer, TabPanel): |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
295 |
500
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
296 def __init__(self, _xmlui_parent): |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
297 TabPanel.__init__(self) |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
298 self.setStyleName('liberviaTabPanel') |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
299 |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
300 def _xmluiAddTab(self, label): |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
301 tab_panel = VerticalContainer(self) |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
302 self.add(tab_panel, label) |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
303 if len(self.getChildren()) == 1: |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
304 self.selectTab(0) |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
305 return tab_panel |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
306 |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
307 |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
308 class VerticalContainer(LiberviaContainer, xmlui.VerticalContainer, VerticalPanel): |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
309 __bases__ = (LiberviaContainer, xmlui.VerticalContainer, VerticalPanel) |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
310 |
500
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
311 def __init__(self, _xmlui_parent): |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
312 VerticalPanel.__init__(self) |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
313 |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
314 |
500
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
315 ## Dialogs ## |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
316 |
500
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
317 |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
318 class Dlg(object): |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
319 |
500
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
320 def _xmluiShow(self): |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
321 self.show() |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
322 |
500
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
323 def _xmluiClose(self): |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
324 pass |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
325 |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
326 |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
327 class MessageDialog(Dlg, xmlui.MessageDialog, dialog.InfoDialog): |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
328 |
500
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
329 def __init__(self, _xmlui_parent, title, message, level): |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
330 #TODO: level is not managed |
504
f030491cff75
browser side (XMLUI): fixed bad use of text instead of XHTML in dialogs
Goffi <goffi@goffi.org>
parents:
500
diff
changeset
|
331 title = html_tools.html_sanitize(title) |
f030491cff75
browser side (XMLUI): fixed bad use of text instead of XHTML in dialogs
Goffi <goffi@goffi.org>
parents:
500
diff
changeset
|
332 message = strings.addURLToText(html_tools.XHTML2Text(message)) |
500
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
333 Dlg.__init__(self) |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
334 xmlui.MessageDialog.__init__(self, _xmlui_parent) |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
335 dialog.InfoDialog.__init__(self, title, message, self._xmluiValidated()) |
337 | 336 |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
337 |
500
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
338 class NoteDialog(xmlui.NoteDialog, MessageDialog): |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
339 # TODO: separate NoteDialog |
247
fe83837d3491
browser_side: removed some trailing spaces
Goffi <goffi@goffi.org>
parents:
229
diff
changeset
|
340 |
500
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
341 def __init__(self, _xmlui_parent, title, message, level): |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
342 xmlui.NoteDialog.__init__(self, _xmlui_parent) |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
343 MessageDialog.__init__(self, _xmlui_parent, title, message, level) |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
344 |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
345 |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
346 class ConfirmDialog(xmlui.ConfirmDialog, Dlg, dialog.ConfirmDialog): |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
347 |
500
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
348 def __init__(self, _xmlui_parent, title, message, level): |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
349 #TODO: level is not managed |
504
f030491cff75
browser side (XMLUI): fixed bad use of text instead of XHTML in dialogs
Goffi <goffi@goffi.org>
parents:
500
diff
changeset
|
350 title = html_tools.html_sanitize(title) |
f030491cff75
browser side (XMLUI): fixed bad use of text instead of XHTML in dialogs
Goffi <goffi@goffi.org>
parents:
500
diff
changeset
|
351 message = strings.addURLToText(html_tools.XHTML2Text(message)) |
500
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
352 xmlui.ConfirmDialog.__init__(self, _xmlui_parent) |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
353 Dlg.__init__(self) |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
354 dialog.ConfirmDialog.__init__(self, self.answered, message, title) |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
355 |
500
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
356 def answered(self, validated): |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
357 if validated: |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
358 self._xmluiValidated() |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
359 else: |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
360 self._xmluiCancelled() |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
361 |
500
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
362 |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
363 class FileDialog(xmlui.FileDialog, Dlg): |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
364 #TODO: |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
365 |
500
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
366 def __init__(self, _xmlui_parent, title, message, level, filetype): |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
367 raise NotImplementedError("FileDialog is not implemented in Libervia yet") |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
368 |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
369 |
500
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
370 class GenericFactory(object): |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
371 # XXX: __getattr__ doens't work here with pyjamas for an unknown reason |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
372 # so an introspection workaround is used |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
373 |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
374 def __init__(self): |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
375 |
500
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
376 for name, cls in globals().items(): |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
377 if name.endswith("Widget") or name.endswith("Container") or name.endswith("Dialog"): |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
378 log.info("registering: %s" % name) |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
379 def createCreater(cls): |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
380 return lambda *args, **kwargs: self._genericCreate(cls, *args, **kwargs) |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
381 setattr(self, "create%s" % name, createCreater(cls)) |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
382 |
500
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
383 def _genericCreate(self, cls, *args, **kwargs): |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
384 instance = cls(*args, **kwargs) |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
385 return instance |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
386 |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
387 # def __getattr__(self, attr): |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
388 # if attr.startswith("create"): |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
389 # cls = globals()[attr[6:]] |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
390 # cls._xmlui_main = self._xmlui_main |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
391 # return cls |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
392 |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
393 |
500
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
394 class WidgetFactory(GenericFactory): |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
395 |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
396 def _genericCreate(self, cls, *args, **kwargs): |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
397 instance = GenericFactory._genericCreate(self, cls, *args, **kwargs) |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
398 instance._xmlui_main = self._xmlui_main |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
399 return instance |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
400 |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
401 class LiberviaXMLUIBase(object): |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
402 |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
403 def _xmluiLaunchAction(self, action_id, data): |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
404 self.host.launchAction(action_id, data) |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
405 |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
406 |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
407 class XMLUIPanel(LiberviaXMLUIBase, xmlui.XMLUIPanel, VerticalPanel): |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
408 widget_factory = WidgetFactory() |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
409 |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
564
diff
changeset
|
410 def __init__(self, host, parsed_xml, title=None, flags=None, callback=None, profile=C.PROF_KEY_NONE): |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
411 self.widget_factory._xmlui_main = self |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
412 VerticalPanel.__init__(self) |
143 | 413 self.setSize('100%', '100%') |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
564
diff
changeset
|
414 xmlui.XMLUIPanel.__init__(self, host, parsed_xml, title, flags, callback, profile) |
143 | 415 |
416 def setCloseCb(self, close_cb): | |
417 self.close_cb = close_cb | |
418 | |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
419 def _xmluiClose(self): |
143 | 420 if self.close_cb: |
421 self.close_cb() | |
422 else: | |
439
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
430
diff
changeset
|
423 log.warning("no close method defined") |
143 | 424 |
337 | 425 def _xmluiSetParam(self, name, value, category): |
426 self.host.bridge.call('setParam', None, name, value, category) | |
427 | |
500
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
428 def constructUI(self, parsed_dom): |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
429 super(XMLUIPanel, self).constructUI(parsed_dom) |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
430 self.add(self.main_cont) |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
431 self.setCellHeight(self.main_cont, '100%') |
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
432 if self.type == 'form': |
143 | 433 hpanel = HorizontalPanel() |
392
f539f6f8ee9c
browser_side: standardize the dialogs size and buttons display:
souliane <souliane@mailoo.org>
parents:
390
diff
changeset
|
434 hpanel.setStyleName('marginAuto') |
451 | 435 hpanel.add(Button('Submit', self.onFormSubmitted)) |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
436 if not 'NO_CANCEL' in self.flags: |
451 | 437 hpanel.add(Button('Cancel', self.onFormCancelled)) |
143 | 438 self.add(hpanel) |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
439 elif self.type == 'param': |
451 | 440 assert(isinstance(self.children[0][0], TabPanel)) |
143 | 441 hpanel = HorizontalPanel() |
392
f539f6f8ee9c
browser_side: standardize the dialogs size and buttons display:
souliane <souliane@mailoo.org>
parents:
390
diff
changeset
|
442 hpanel.add(Button('Save', self.onSaveParams)) |
335
e8c26e24a6c7
browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents:
325
diff
changeset
|
443 hpanel.add(Button('Cancel', lambda ignore: self._xmluiClose())) |
143 | 444 self.add(hpanel) |
500
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
445 |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
446 def show(self): |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
447 options = ['NO_CLOSE'] if self.type == C.XMLUI_FORM else [] |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
564
diff
changeset
|
448 _dialog = dialog.GenericDialog(self.xmlui_title, self, options=options) |
500
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
449 self.setCloseCb(_dialog.close) |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
450 _dialog.show() |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
451 |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
452 |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
453 class XMLUIDialog(LiberviaXMLUIBase, xmlui.XMLUIDialog): |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
454 dialog_factory = GenericFactory() |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
455 |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
564
diff
changeset
|
456 def __init__(self, host, parsed_dom, title = None, flags = None, callback=None, profile=C.PROF_KEY_NONE): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
564
diff
changeset
|
457 xmlui.XMLUIDialog.__init__(self, host, parsed_dom, title, flags, callback, profile) |
500
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
458 |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
459 xmlui.registerClass(xmlui.CLASS_PANEL, XMLUIPanel) |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
460 xmlui.registerClass(xmlui.CLASS_DIALOG, XMLUIDialog) |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
461 |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
462 def create(*args, **kwargs): |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
463 dom = nativedom.NativeDOM() |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
464 kwargs['dom_parse'] = lambda xml_data: dom.parseString(xml_data) |
67a4e8383b70
browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents:
489
diff
changeset
|
465 return xmlui.create(*args, **kwargs) |