annotate src/browser/xmlui.py @ 451:1a0cec9b0f1e

better PEP-8 compliance
author souliane <souliane@mailoo.org>
date Tue, 20 May 2014 10:54:03 +0200
parents 981ed669d3b3
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/python
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
3
339
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 337
diff changeset
4 # Libervia: a Salut à Toi frontend
340
ce5b33f499c5 dates update
Goffi <goffi@goffi.org>
parents: 339
diff changeset
5 # Copyright (C) 2011, 2012, 2013, 2014 Jérôme Poisson <goffi@goffi.org>
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
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
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
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
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
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
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
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
981ed669d3b3 /!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents: 439
diff changeset
23
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
24 from pyjamas.ui.VerticalPanel import VerticalPanel
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
25 from pyjamas.ui.HorizontalPanel import HorizontalPanel
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
26 from pyjamas.ui.TabPanel import TabPanel
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
27 from pyjamas.ui.Grid import Grid
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
28 from pyjamas.ui.Label import Label
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
29 from pyjamas.ui.TextBox import TextBox
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
30 from pyjamas.ui.PasswordTextBox import PasswordTextBox
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
31 from pyjamas.ui.TextArea import TextArea
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
32 from pyjamas.ui.CheckBox import CheckBox
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
33 from pyjamas.ui.ListBox import ListBox
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
34 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
35 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
36
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
37 from nativedom 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
38
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
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
40 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
41
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 def __init__(self, parent):
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 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
44
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
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
46 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
47
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 def __init__(self, parent, 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
49 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
50
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
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
52 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
53
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 def __init__(self, parent, value):
451
1a0cec9b0f1e better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 449
diff changeset
55 TextWidget.__init__(self, 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
56
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
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
58 class JidWidget(xmlui.JidWidget, TextWidget):
337
ea1be522ba88 browser side: XMLUI fixes:
Goffi <goffi@goffi.org>
parents: 335
diff changeset
59
ea1be522ba88 browser side: XMLUI fixes:
Goffi <goffi@goffi.org>
parents: 335
diff changeset
60 def __init__(self, parent, value):
ea1be522ba88 browser side: XMLUI fixes:
Goffi <goffi@goffi.org>
parents: 335
diff changeset
61 TextWidget.__init__(self, 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
62
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
63
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
64 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
65
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 def __init__(self, parent, style='line'):
428
0c4547587637 browser_side (xmlui): implement the divider styles
souliane <souliane@mailoo.org>
parents: 392
diff changeset
67 """Add a divider
0c4547587637 browser_side (xmlui): implement the divider styles
souliane <souliane@mailoo.org>
parents: 392
diff changeset
68
0c4547587637 browser_side (xmlui): implement the divider styles
souliane <souliane@mailoo.org>
parents: 392
diff changeset
69 @param parent
0c4547587637 browser_side (xmlui): implement the divider styles
souliane <souliane@mailoo.org>
parents: 392
diff changeset
70 @param style (string): one of:
0c4547587637 browser_side (xmlui): implement the divider styles
souliane <souliane@mailoo.org>
parents: 392
diff changeset
71 - line: a simple line
0c4547587637 browser_side (xmlui): implement the divider styles
souliane <souliane@mailoo.org>
parents: 392
diff changeset
72 - dot: a line of dots
0c4547587637 browser_side (xmlui): implement the divider styles
souliane <souliane@mailoo.org>
parents: 392
diff changeset
73 - dash: a line of dashes
0c4547587637 browser_side (xmlui): implement the divider styles
souliane <souliane@mailoo.org>
parents: 392
diff changeset
74 - plain: a full thick line
0c4547587637 browser_side (xmlui): implement the divider styles
souliane <souliane@mailoo.org>
parents: 392
diff changeset
75 - blank: a blank line/space
0c4547587637 browser_side (xmlui): implement the divider styles
souliane <souliane@mailoo.org>
parents: 392
diff changeset
76 """
0c4547587637 browser_side (xmlui): implement the divider styles
souliane <souliane@mailoo.org>
parents: 392
diff changeset
77 HTML.__init__(self, "<hr/>")
0c4547587637 browser_side (xmlui): implement the divider styles
souliane <souliane@mailoo.org>
parents: 392
diff changeset
78 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
79
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
80
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
81 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
82
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 def __init__(self, parent, 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
84 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
85 self.setText(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
86
429
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
87 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
88 self.setText(value)
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
89
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
90 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
91 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
92
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
93 def _xmluiOnChange(self, callback):
378
3dd0b5334aef browser_side: fix typos
souliane <souliane@mailoo.org>
parents: 376
diff changeset
94 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
95
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
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 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
98
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
99 def __init__(self, parent, value):
390
76583fab7ea0 browser_side: fix XMLUI password box initialisation
souliane <souliane@mailoo.org>
parents: 378
diff changeset
100 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
101 self.setText(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
102
429
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
103 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
104 self.setText(value)
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
105
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 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
107 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
108
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
109 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
110 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
111
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
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 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
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 __init__(self, parent, 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
116 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
117 self.setText(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
118
429
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
119 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
120 self.setText(value)
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
121
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 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
123 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
124
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 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
126 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
127
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
128
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 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
130
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 def __init__(self, parent, state):
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 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
133 self.setChecked(state)
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
429
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
135 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
136 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
137
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
138 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
139 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
140
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
141 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
142 self.addClickListener(callback)
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
144
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
145 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
146
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 def __init__(self, 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
148 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
149
378
3dd0b5334aef browser_side: fix typos
souliane <souliane@mailoo.org>
parents: 376
diff changeset
150 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
151 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
152
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
153
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
154 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
155
429
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
156 def __init__(self, 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
157 ListBox.__init__(self)
430
a927a98b398d browser_side (xmlui): fix multi-selection
souliane <souliane@mailoo.org>
parents: 429
diff changeset
158 multi_selection = 'single' not in flags
a927a98b398d browser_side (xmlui): fix multi-selection
souliane <souliane@mailoo.org>
parents: 429
diff changeset
159 self.setMultipleSelect(multi_selection)
a927a98b398d browser_side (xmlui): fix multi-selection
souliane <souliane@mailoo.org>
parents: 429
diff changeset
160 if multi_selection:
a927a98b398d browser_side (xmlui): fix multi-selection
souliane <souliane@mailoo.org>
parents: 429
diff changeset
161 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
162 for option in options:
337
ea1be522ba88 browser side: XMLUI fixes:
Goffi <goffi@goffi.org>
parents: 335
diff changeset
163 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
164 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
165 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
166
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
167 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
168 """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
169 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
170 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
171 except IndexError:
439
d52f529a6d42 browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents: 430
diff changeset
172 log.warning("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
173 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
174 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
175
429
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
176 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
177 """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
178 self.setValueSelection(values)
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
179
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
180 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
181 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
182 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
183 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
184 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
185
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
186 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
187 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
188
429
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
189 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
190 selected = self._xmluiGetSelectedValues()
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
191 for value in values:
430
a927a98b398d browser_side (xmlui): fix multi-selection
souliane <souliane@mailoo.org>
parents: 429
diff changeset
192 if value not in self._xmlui_attr_map.values():
a927a98b398d browser_side (xmlui): fix multi-selection
souliane <souliane@mailoo.org>
parents: 429
diff changeset
193 self.addItem(value)
a927a98b398d browser_side (xmlui): fix multi-selection
souliane <souliane@mailoo.org>
parents: 429
diff changeset
194 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
195 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
196 selected.append(value)
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
197 self._xmluiSelectValues(selected)
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
198
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
199
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 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
201
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
202 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
203 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
204
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
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 class AdvancedListContainer(xmlui.AdvancedListContainer, Grid):
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
207
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
208 def __init__(self, parent, columns, selectable='no'):
337
ea1be522ba88 browser side: XMLUI fixes:
Goffi <goffi@goffi.org>
parents: 335
diff changeset
209 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
210 self.columns = columns
337
ea1be522ba88 browser side: XMLUI fixes:
Goffi <goffi@goffi.org>
parents: 335
diff changeset
211 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
212 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
213 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
214 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
215 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
216 self.addTableListener(self)
376
ab923b870fb0 browser side: XMLUI AdvancedListContainer: rows are highlighted when there are selectable
Goffi <goffi@goffi.org>
parents: 369
diff changeset
217 if self._xmlui_selectable:
ab923b870fb0 browser side: XMLUI AdvancedListContainer: rows are highlighted when there are selectable
Goffi <goffi@goffi.org>
parents: 369
diff changeset
218 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
219
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
220 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
221 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
222 return
376
ab923b870fb0 browser side: XMLUI AdvancedListContainer: rows are highlighted when there are selectable
Goffi <goffi@goffi.org>
parents: 369
diff changeset
223 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
224 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
225 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
226 except AttributeError:
439
d52f529a6d42 browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents: 430
diff changeset
227 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
228
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 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
230 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
231 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
232
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
233 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
234 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
235 self.col = 0
337
ea1be522ba88 browser side: XMLUI fixes:
Goffi <goffi@goffi.org>
parents: 335
diff changeset
236 self._xmlui_rows_idx.insert(self.row, idx)
451
1a0cec9b0f1e better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 449
diff changeset
237 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
238
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 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
240 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
241
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
242 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
243 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
244 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
245 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
246 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
247
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
248 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
249 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
250
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
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
252 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
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 __init__(self, parent):
247
fe83837d3491 browser_side: removed some trailing spaces
Goffi <goffi@goffi.org>
parents: 229
diff changeset
255 Grid.__init__(self, 0, 0)
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
256 self.row = 0
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
257 self.col = 0
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
258
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
259 def _xmluiAppend(self, widget):
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
260 if self.col == 0:
451
1a0cec9b0f1e better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 449
diff changeset
261 self.resize(self.row + 1, 2)
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
262 self.setWidget(self.row, self.col, widget)
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
263 self.col += 1
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
264 if self.col == 2:
451
1a0cec9b0f1e better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 449
diff changeset
265 self.row += 1
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
266 self.col = 0
247
fe83837d3491 browser_side: removed some trailing spaces
Goffi <goffi@goffi.org>
parents: 229
diff changeset
267
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
268
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 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
270
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 def __init__(self, parent):
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 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
273 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
274
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 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
276 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
277 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
278 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
279 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
280 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
281
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
282
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
283 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
284 __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
285
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
286 def __init__(self, parent):
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
287 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
288
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
289
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
290 class WidgetFactory(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
291 # XXX: __getattr__ doesn't work here for an unknown reason
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
292
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 def createVerticalContainer(self, *args, **kwargs):
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 instance = VerticalContainer(*args, **kwargs)
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 instance._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
296 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
297
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 def createPairsContainer(self, *args, **kwargs):
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 instance = PairsContainer(*args, **kwargs)
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 instance._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
301 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
302
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 def createTabsContainer(self, *args, **kwargs):
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 instance = TabsContainer(*args, **kwargs)
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 instance._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
306 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
307
337
ea1be522ba88 browser side: XMLUI fixes:
Goffi <goffi@goffi.org>
parents: 335
diff changeset
308 def createAdvancedListContainer(self, *args, **kwargs):
ea1be522ba88 browser side: XMLUI fixes:
Goffi <goffi@goffi.org>
parents: 335
diff changeset
309 instance = AdvancedListContainer(*args, **kwargs)
ea1be522ba88 browser side: XMLUI fixes:
Goffi <goffi@goffi.org>
parents: 335
diff changeset
310 instance._xmlui_main = self._xmlui_main
ea1be522ba88 browser side: XMLUI fixes:
Goffi <goffi@goffi.org>
parents: 335
diff changeset
311 return instance
ea1be522ba88 browser side: XMLUI fixes:
Goffi <goffi@goffi.org>
parents: 335
diff changeset
312
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
313 def createEmptyWidget(self, *args, **kwargs):
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 instance = EmptyWidget(*args, **kwargs)
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
315 instance._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
316 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
317
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
318 def createTextWidget(self, *args, **kwargs):
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 instance = TextWidget(*args, **kwargs)
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
320 instance._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
321 return instance
247
fe83837d3491 browser_side: removed some trailing spaces
Goffi <goffi@goffi.org>
parents: 229
diff changeset
322
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
323 def createLabelWidget(self, *args, **kwargs):
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
324 instance = LabelWidget(*args, **kwargs)
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
325 instance._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
326 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
327
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 def createJidWidget(self, *args, **kwargs):
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
329 instance = JidWidget(*args, **kwargs)
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
330 instance._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
331 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
332
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
333 def createDividerWidget(self, *args, **kwargs):
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
334 instance = DividerWidget(*args, **kwargs)
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
335 instance._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
336 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
337
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
338 def createStringWidget(self, *args, **kwargs):
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
339 instance = StringWidget(*args, **kwargs)
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
340 instance._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
341 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
342
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
343 def createPasswordWidget(self, *args, **kwargs):
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
344 instance = PasswordWidget(*args, **kwargs)
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
345 instance._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
346 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
347
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
348 def createTextBoxWidget(self, *args, **kwargs):
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
349 instance = TextBoxWidget(*args, **kwargs)
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
350 instance._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
351 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
352
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
353 def createBoolWidget(self, *args, **kwargs):
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
354 instance = BoolWidget(*args, **kwargs)
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 instance._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
356 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
357
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
358 def createButtonWidget(self, *args, **kwargs):
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
359 instance = ButtonWidget(*args, **kwargs)
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
360 instance._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
361 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
362
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
363 def createListWidget(self, *args, **kwargs):
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
364 instance = ListWidget(*args, **kwargs)
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 instance._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
366 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
367
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
368
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 # 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
370 # 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
371 # 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
372 # 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
373 # 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
374
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
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
376 class XMLUI(xmlui.XMLUI, 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
377 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
378
451
1a0cec9b0f1e better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 449
diff changeset
379 def __init__(self, host, xml_data, title=None, flags=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
380 self.widget_factory._xmlui_main = self
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
381 self.dom = 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
382 dom_parse = lambda xml_data: self.dom.parseString(xml_data)
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
383 VerticalPanel.__init__(self)
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
384 self.setSize('100%', '100%')
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 xmlui.XMLUI.__init__(self, host, xml_data, title, flags, dom_parse)
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
386
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
387 def setCloseCb(self, close_cb):
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
388 self.close_cb = close_cb
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
389
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
390 def _xmluiClose(self):
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
391 if self.close_cb:
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
392 self.close_cb()
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
393 else:
439
d52f529a6d42 browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents: 430
diff changeset
394 log.warning("no close method defined")
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
395
337
ea1be522ba88 browser side: XMLUI fixes:
Goffi <goffi@goffi.org>
parents: 335
diff changeset
396 def _xmluiLaunchAction(self, action_id, data):
ea1be522ba88 browser side: XMLUI fixes:
Goffi <goffi@goffi.org>
parents: 335
diff changeset
397 self.host.launchAction(action_id, data)
ea1be522ba88 browser side: XMLUI fixes:
Goffi <goffi@goffi.org>
parents: 335
diff changeset
398
ea1be522ba88 browser side: XMLUI fixes:
Goffi <goffi@goffi.org>
parents: 335
diff changeset
399 def _xmluiSetParam(self, name, value, category):
ea1be522ba88 browser side: XMLUI fixes:
Goffi <goffi@goffi.org>
parents: 335
diff changeset
400 self.host.bridge.call('setParam', None, name, value, category)
ea1be522ba88 browser side: XMLUI fixes:
Goffi <goffi@goffi.org>
parents: 335
diff changeset
401
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
402 def constructUI(self, xml_data):
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
403 super(XMLUI, self).constructUI(xml_data)
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
404 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
405 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
406 if self.type == 'form':
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
407 hpanel = HorizontalPanel()
392
f539f6f8ee9c browser_side: standardize the dialogs size and buttons display:
souliane <souliane@mailoo.org>
parents: 390
diff changeset
408 hpanel.setStyleName('marginAuto')
451
1a0cec9b0f1e better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 449
diff changeset
409 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
410 if not 'NO_CANCEL' in self.flags:
451
1a0cec9b0f1e better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 449
diff changeset
411 hpanel.add(Button('Cancel', self.onFormCancelled))
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
412 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
413 elif self.type == 'param':
451
1a0cec9b0f1e better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 449
diff changeset
414 assert(isinstance(self.children[0][0], TabPanel))
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
415 hpanel = HorizontalPanel()
392
f539f6f8ee9c browser_side: standardize the dialogs size and buttons display:
souliane <souliane@mailoo.org>
parents: 390
diff changeset
416 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
417 hpanel.add(Button('Cancel', lambda ignore: self._xmluiClose()))
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
418 self.add(hpanel)