annotate src/browser/sat_browser/xmlui.py @ 546:ff03fdb5215d SàT v0.5.0

SàT 0.5.0 released
author Goffi <goffi@goffi.org>
date Tue, 09 Sep 2014 08:28:13 +0200
parents f030491cff75
children fed185c95f1c
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
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
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
28 from pyjamas.ui.VerticalPanel import VerticalPanel
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
29 from pyjamas.ui.HorizontalPanel import HorizontalPanel
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
30 from pyjamas.ui.TabPanel import TabPanel
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
31 from pyjamas.ui.Grid import Grid
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
32 from pyjamas.ui.Label import Label
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
33 from pyjamas.ui.TextBox import TextBox
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
34 from pyjamas.ui.PasswordTextBox import PasswordTextBox
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
35 from pyjamas.ui.TextArea import TextArea
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
36 from pyjamas.ui.CheckBox import CheckBox
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
37 from pyjamas.ui.ListBox import ListBox
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
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
97c72fe4a5f2 browser_side: import fixes:
Goffi <goffi@goffi.org>
parents: 451
diff changeset
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
ea1be522ba88 browser side: XMLUI fixes:
Goffi <goffi@goffi.org>
parents: 335
diff changeset
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
428
0c4547587637 browser_side (xmlui): implement the divider styles
souliane <souliane@mailoo.org>
parents: 392
diff changeset
74 @param style (string): 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
3dd0b5334aef browser_side: fix typos
souliane <souliane@mailoo.org>
parents: 376
diff changeset
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
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
151
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
152
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
153 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
154
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
155 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
156 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
157
378
3dd0b5334aef browser_side: fix typos
souliane <souliane@mailoo.org>
parents: 376
diff changeset
158 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
159 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
160
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
161
e8c26e24a6c7 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 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
163
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
164 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
165 ListBox.__init__(self)
430
a927a98b398d browser_side (xmlui): fix multi-selection
souliane <souliane@mailoo.org>
parents: 429
diff changeset
166 multi_selection = 'single' not in flags
a927a98b398d browser_side (xmlui): fix multi-selection
souliane <souliane@mailoo.org>
parents: 429
diff changeset
167 self.setMultipleSelect(multi_selection)
a927a98b398d browser_side (xmlui): fix multi-selection
souliane <souliane@mailoo.org>
parents: 429
diff changeset
168 if multi_selection:
a927a98b398d browser_side (xmlui): fix multi-selection
souliane <souliane@mailoo.org>
parents: 429
diff changeset
169 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
170 for option in options:
337
ea1be522ba88 browser side: XMLUI fixes:
Goffi <goffi@goffi.org>
parents: 335
diff changeset
171 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
172 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
173 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
174
e8c26e24a6c7 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 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
176 """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
177 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
178 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
179 except IndexError:
439
d52f529a6d42 browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents: 430
diff changeset
180 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
181 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
182 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
183
429
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
184 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
185 """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
186 self.setValueSelection(values)
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
187
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
188 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
189 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
190 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
191 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
192 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
193
e8c26e24a6c7 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 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
195 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
196
429
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
197 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
198 selected = self._xmluiGetSelectedValues()
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
199 for value in values:
430
a927a98b398d browser_side (xmlui): fix multi-selection
souliane <souliane@mailoo.org>
parents: 429
diff changeset
200 if value not in self._xmlui_attr_map.values():
a927a98b398d browser_side (xmlui): fix multi-selection
souliane <souliane@mailoo.org>
parents: 429
diff changeset
201 self.addItem(value)
a927a98b398d browser_side (xmlui): fix multi-selection
souliane <souliane@mailoo.org>
parents: 429
diff changeset
202 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
203 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
204 selected.append(value)
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
205 self._xmluiSelectValues(selected)
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
206
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
207
e8c26e24a6c7 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 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
209
e8c26e24a6c7 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 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
211 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
212
e8c26e24a6c7 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
e8c26e24a6c7 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 class AdvancedListContainer(xmlui.AdvancedListContainer, Grid):
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
215
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
216 def __init__(self, _xmlui_parent, columns, selectable='no'):
337
ea1be522ba88 browser side: XMLUI fixes:
Goffi <goffi@goffi.org>
parents: 335
diff changeset
217 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
218 self.columns = columns
337
ea1be522ba88 browser side: XMLUI fixes:
Goffi <goffi@goffi.org>
parents: 335
diff changeset
219 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
220 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
221 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
222 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
223 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
224 self.addTableListener(self)
376
ab923b870fb0 browser side: XMLUI AdvancedListContainer: rows are highlighted when there are selectable
Goffi <goffi@goffi.org>
parents: 369
diff changeset
225 if self._xmlui_selectable:
ab923b870fb0 browser side: XMLUI AdvancedListContainer: rows are highlighted when there are selectable
Goffi <goffi@goffi.org>
parents: 369
diff changeset
226 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
227
e8c26e24a6c7 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 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
229 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
230 return
376
ab923b870fb0 browser side: XMLUI AdvancedListContainer: rows are highlighted when there are selectable
Goffi <goffi@goffi.org>
parents: 369
diff changeset
231 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
232 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
233 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
234 except AttributeError:
439
d52f529a6d42 browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents: 430
diff changeset
235 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
236
e8c26e24a6c7 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 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
238 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
239 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
240
e8c26e24a6c7 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 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
242 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
243 self.col = 0
337
ea1be522ba88 browser side: XMLUI fixes:
Goffi <goffi@goffi.org>
parents: 335
diff changeset
244 self._xmlui_rows_idx.insert(self.row, idx)
451
1a0cec9b0f1e better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 449
diff changeset
245 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
246
e8c26e24a6c7 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 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
248 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
249
e8c26e24a6c7 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 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
251 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
252 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
253 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
254 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
255
e8c26e24a6c7 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 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
257 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
258
e8c26e24a6c7 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
e8c26e24a6c7 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 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
261
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
262 def __init__(self, _xmlui_parent):
247
fe83837d3491 browser_side: removed some trailing spaces
Goffi <goffi@goffi.org>
parents: 229
diff changeset
263 Grid.__init__(self, 0, 0)
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
264 self.row = 0
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
265 self.col = 0
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
266
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
267 def _xmluiAppend(self, widget):
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
268 if self.col == 0:
451
1a0cec9b0f1e better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 449
diff changeset
269 self.resize(self.row + 1, 2)
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
270 self.setWidget(self.row, self.col, widget)
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
271 self.col += 1
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
272 if self.col == 2:
451
1a0cec9b0f1e better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 449
diff changeset
273 self.row += 1
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
274 self.col = 0
247
fe83837d3491 browser_side: removed some trailing spaces
Goffi <goffi@goffi.org>
parents: 229
diff changeset
275
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
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 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
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):
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
280 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
281 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
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 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
284 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
285 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
286 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
287 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
288 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
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
e8c26e24a6c7 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 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
292 __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
293
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
294 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
295 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
296
e8c26e24a6c7 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
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
298 ## 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
299
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
300
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
301 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
302
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
303 def _xmluiShow(self):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
304 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
305
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
306 def _xmluiClose(self):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
307 pass
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
308
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
309
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
310 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
311
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
312 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
313 #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
314 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
315 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
316 Dlg.__init__(self)
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
317 xmlui.MessageDialog.__init__(self, _xmlui_parent)
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
318 dialog.InfoDialog.__init__(self, title, message, self._xmluiValidated())
337
ea1be522ba88 browser side: XMLUI fixes:
Goffi <goffi@goffi.org>
parents: 335
diff changeset
319
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
320
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
321 class NoteDialog(xmlui.NoteDialog, MessageDialog):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
322 # TODO: separate NoteDialog
247
fe83837d3491 browser_side: removed some trailing spaces
Goffi <goffi@goffi.org>
parents: 229
diff changeset
323
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
324 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
325 xmlui.NoteDialog.__init__(self, _xmlui_parent)
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
326 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
327
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
328
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
329 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
330
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
331 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
332 #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
333 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
334 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
335 xmlui.ConfirmDialog.__init__(self, _xmlui_parent)
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
336 Dlg.__init__(self)
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
337 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
338
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
339 def answered(self, validated):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
340 if validated:
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
341 self._xmluiValidated()
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
342 else:
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
343 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
344
500
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 FileDialog(xmlui.FileDialog, Dlg):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
347 #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
348
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
349 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
350 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
351
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
352
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
353 class GenericFactory(object):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
354 # 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
355 # so an introspection workaround is used
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
356
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
357 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
358
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
359 for name, cls in globals().items():
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
360 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
361 log.info("registering: %s" % name)
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
362 def createCreater(cls):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
363 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
364 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
365
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
366 def _genericCreate(self, cls, *args, **kwargs):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
367 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
368 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
369
e8c26e24a6c7 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 # 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
371 # 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
372 # 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
373 # 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
374 # 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
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
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
377 class WidgetFactory(GenericFactory):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
378
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
379 def _genericCreate(self, cls, *args, **kwargs):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
380 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
381 instance._xmlui_main = self._xmlui_main
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
382 return instance
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
383
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
384 class LiberviaXMLUIBase(object):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
385
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
386 def _xmluiLaunchAction(self, action_id, data):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
387 self.host.launchAction(action_id, data)
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
388
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
389
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
390 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
391 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
392
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
393 def __init__(self, host, parsed_xml, 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
394 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
395 VerticalPanel.__init__(self)
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
396 self.setSize('100%', '100%')
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
397 xmlui.XMLUIPanel.__init__(self, host, parsed_xml, title, flags)
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
398
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
399 def setCloseCb(self, close_cb):
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
400 self.close_cb = close_cb
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
401
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
402 def _xmluiClose(self):
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
403 if self.close_cb:
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
404 self.close_cb()
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
405 else:
439
d52f529a6d42 browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents: 430
diff changeset
406 log.warning("no close method defined")
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
407
337
ea1be522ba88 browser side: XMLUI fixes:
Goffi <goffi@goffi.org>
parents: 335
diff changeset
408 def _xmluiSetParam(self, name, value, category):
ea1be522ba88 browser side: XMLUI fixes:
Goffi <goffi@goffi.org>
parents: 335
diff changeset
409 self.host.bridge.call('setParam', None, name, value, category)
ea1be522ba88 browser side: XMLUI fixes:
Goffi <goffi@goffi.org>
parents: 335
diff changeset
410
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
411 def constructUI(self, parsed_dom):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
412 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
413 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
414 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
415 if self.type == 'form':
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
416 hpanel = HorizontalPanel()
392
f539f6f8ee9c browser_side: standardize the dialogs size and buttons display:
souliane <souliane@mailoo.org>
parents: 390
diff changeset
417 hpanel.setStyleName('marginAuto')
451
1a0cec9b0f1e better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 449
diff changeset
418 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
419 if not 'NO_CANCEL' in self.flags:
451
1a0cec9b0f1e better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 449
diff changeset
420 hpanel.add(Button('Cancel', self.onFormCancelled))
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
421 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
422 elif self.type == 'param':
451
1a0cec9b0f1e better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 449
diff changeset
423 assert(isinstance(self.children[0][0], TabPanel))
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
424 hpanel = HorizontalPanel()
392
f539f6f8ee9c browser_side: standardize the dialogs size and buttons display:
souliane <souliane@mailoo.org>
parents: 390
diff changeset
425 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
426 hpanel.add(Button('Cancel', lambda ignore: self._xmluiClose()))
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
427 self.add(hpanel)
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
428
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
429 def show(self):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
430 options = ['NO_CLOSE'] if self.type == C.XMLUI_FORM else []
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
431 _dialog = dialog.GenericDialog(self.title, self, options=options)
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
432 self.setCloseCb(_dialog.close)
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
433 _dialog.show()
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
434
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
435
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
436 class XMLUIDialog(LiberviaXMLUIBase, xmlui.XMLUIDialog):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
437 dialog_factory = GenericFactory()
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
438
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
439 def __init__(self, host, parsed_dom, title = None, flags = None):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
440 xmlui.XMLUIDialog.__init__(self, host, parsed_dom, title, flags)
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
441
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
442 xmlui.registerClass(xmlui.CLASS_PANEL, XMLUIPanel)
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
443 xmlui.registerClass(xmlui.CLASS_DIALOG, XMLUIDialog)
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
444
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
445 def create(*args, **kwargs):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
446 dom = nativedom.NativeDOM()
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
447 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
448 return xmlui.create(*args, **kwargs)