annotate src/browser/sat_browser/xmlui.py @ 720:bf0a7da558e8

browser side (xmlui): factory is instantiated on Panel init + main panel is passed as first argument to widgets
author Goffi <goffi@goffi.org>
date Fri, 21 Aug 2015 15:37:21 +0200
parents 9a9e2fcc6347
children 102bab805ec1
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
685
9877607c719a 2015 copyright dates update
Goffi <goffi@goffi.org>
parents: 662
diff changeset
5 # Copyright (C) 2011, 2012, 2013, 2014, 2015 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
720
bf0a7da558e8 browser side (xmlui): factory is instantiated on Panel init + main panel is passed as first argument to widgets
Goffi <goffi@goffi.org>
parents: 719
diff changeset
46 def __init__(self, xmlui_main, 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
720
bf0a7da558e8 browser side (xmlui): factory is instantiated on Panel init + main panel is passed as first argument to widgets
Goffi <goffi@goffi.org>
parents: 719
diff changeset
52 def __init__(self, xmlui_main, 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
720
bf0a7da558e8 browser side (xmlui): factory is instantiated on Panel init + main panel is passed as first argument to widgets
Goffi <goffi@goffi.org>
parents: 719
diff changeset
58 def __init__(self, xmlui_main, xmlui_parent, value):
bf0a7da558e8 browser side (xmlui): factory is instantiated on Panel init + main panel is passed as first argument to widgets
Goffi <goffi@goffi.org>
parents: 719
diff changeset
59 TextWidget.__init__(self, xmlui_main, 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
720
bf0a7da558e8 browser side (xmlui): factory is instantiated on Panel init + main panel is passed as first argument to widgets
Goffi <goffi@goffi.org>
parents: 719
diff changeset
64 def __init__(self, xmlui_main, xmlui_parent, value):
bf0a7da558e8 browser side (xmlui): factory is instantiated on Panel init + main panel is passed as first argument to widgets
Goffi <goffi@goffi.org>
parents: 719
diff changeset
65 TextWidget.__init__(self, xmlui_main, 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
720
bf0a7da558e8 browser side (xmlui): factory is instantiated on Panel init + main panel is passed as first argument to widgets
Goffi <goffi@goffi.org>
parents: 719
diff changeset
70 def __init__(self, xmlui_main, 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
720
bf0a7da558e8 browser side (xmlui): factory is instantiated on Panel init + main panel is passed as first argument to widgets
Goffi <goffi@goffi.org>
parents: 719
diff changeset
73 @param xmlui_parent
662
ebb602d8b3f2 browser_side: replace all instances of 'str' with 'unicode'
souliane <souliane@mailoo.org>
parents: 589
diff changeset
74 @param style (unicode): one of:
489
1ce6133993e4 browser side (XMLUI): implementation of read_only attribute
Goffi <goffi@goffi.org>
parents: 467
diff changeset
75 - line: a simple line
1ce6133993e4 browser side (XMLUI): implementation of read_only attribute
Goffi <goffi@goffi.org>
parents: 467
diff changeset
76 - dot: a line of dots
1ce6133993e4 browser side (XMLUI): implementation of read_only attribute
Goffi <goffi@goffi.org>
parents: 467
diff changeset
77 - dash: a line of dashes
1ce6133993e4 browser side (XMLUI): implementation of read_only attribute
Goffi <goffi@goffi.org>
parents: 467
diff changeset
78 - plain: a full thick line
1ce6133993e4 browser side (XMLUI): implementation of read_only attribute
Goffi <goffi@goffi.org>
parents: 467
diff changeset
79 - blank: a blank line/space
428
0c4547587637 browser_side (xmlui): implement the divider styles
souliane <souliane@mailoo.org>
parents: 392
diff changeset
80 """
0c4547587637 browser_side (xmlui): implement the divider styles
souliane <souliane@mailoo.org>
parents: 392
diff changeset
81 HTML.__init__(self, "<hr/>")
0c4547587637 browser_side (xmlui): implement the divider styles
souliane <souliane@mailoo.org>
parents: 392
diff changeset
82 self.addStyleName(style)
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
83
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
84
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
85 class StringWidget(xmlui.StringWidget, TextBox):
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
86
720
bf0a7da558e8 browser side (xmlui): factory is instantiated on Panel init + main panel is passed as first argument to widgets
Goffi <goffi@goffi.org>
parents: 719
diff changeset
87 def __init__(self, xmlui_main, 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
719
9a9e2fcc6347 browser side (xmlui): added basic JidInputWidget (use a StringWidget)
Goffi <goffi@goffi.org>
parents: 694
diff changeset
102 class JidInputWidget(xmlui.JidInputWidget, StringWidget):
9a9e2fcc6347 browser side (xmlui): added basic JidInputWidget (use a StringWidget)
Goffi <goffi@goffi.org>
parents: 694
diff changeset
103
720
bf0a7da558e8 browser side (xmlui): factory is instantiated on Panel init + main panel is passed as first argument to widgets
Goffi <goffi@goffi.org>
parents: 719
diff changeset
104 def __init__(self, xmlui_main, xmlui_parent, value, read_only=False):
bf0a7da558e8 browser side (xmlui): factory is instantiated on Panel init + main panel is passed as first argument to widgets
Goffi <goffi@goffi.org>
parents: 719
diff changeset
105 StringWidget.__init__(self, xmlui_main, xmlui_parent, value, read_only)
719
9a9e2fcc6347 browser side (xmlui): added basic JidInputWidget (use a StringWidget)
Goffi <goffi@goffi.org>
parents: 694
diff changeset
106
9a9e2fcc6347 browser side (xmlui): added basic JidInputWidget (use a StringWidget)
Goffi <goffi@goffi.org>
parents: 694
diff changeset
107
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 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
109
720
bf0a7da558e8 browser side (xmlui): factory is instantiated on Panel init + main panel is passed as first argument to widgets
Goffi <goffi@goffi.org>
parents: 719
diff changeset
110 def __init__(self, xmlui_main, xmlui_parent, value, read_only=False):
390
76583fab7ea0 browser_side: fix XMLUI password box initialisation
souliane <souliane@mailoo.org>
parents: 378
diff changeset
111 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
112 self.setText(value)
489
1ce6133993e4 browser side (XMLUI): implementation of read_only attribute
Goffi <goffi@goffi.org>
parents: 467
diff changeset
113 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
114
429
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
115 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
116 self.setText(value)
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
117
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
118 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
119 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
120
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
121 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
122 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
123
e8c26e24a6c7 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 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
126
720
bf0a7da558e8 browser side (xmlui): factory is instantiated on Panel init + main panel is passed as first argument to widgets
Goffi <goffi@goffi.org>
parents: 719
diff changeset
127 def __init__(self, xmlui_main, 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
128 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
129 self.setText(value)
489
1ce6133993e4 browser side (XMLUI): implementation of read_only attribute
Goffi <goffi@goffi.org>
parents: 467
diff changeset
130 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
131
429
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
132 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
133 self.setText(value)
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
134
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
135 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
136 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
137
e8c26e24a6c7 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 _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
139 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
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
e8c26e24a6c7 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 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
143
720
bf0a7da558e8 browser side (xmlui): factory is instantiated on Panel init + main panel is passed as first argument to widgets
Goffi <goffi@goffi.org>
parents: 719
diff changeset
144 def __init__(self, xmlui_main, 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
145 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
146 self.setChecked(state)
489
1ce6133993e4 browser side (XMLUI): implementation of read_only attribute
Goffi <goffi@goffi.org>
parents: 467
diff changeset
147 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
148
429
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
149 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
150 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
151
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
152 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
153 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
154
e8c26e24a6c7 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 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
156 self.addClickListener(callback)
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
157
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
158
564
fed185c95f1c browser_side: add XMLUI "int" widget type + historyPrint uses the new param "Chat history limit"
souliane <souliane@mailoo.org>
parents: 504
diff changeset
159 class IntWidget(xmlui.IntWidget, TextBox):
fed185c95f1c browser_side: add XMLUI "int" widget type + historyPrint uses the new param "Chat history limit"
souliane <souliane@mailoo.org>
parents: 504
diff changeset
160
720
bf0a7da558e8 browser side (xmlui): factory is instantiated on Panel init + main panel is passed as first argument to widgets
Goffi <goffi@goffi.org>
parents: 719
diff changeset
161 def __init__(self, xmlui_main, xmlui_parent, value, read_only=False):
564
fed185c95f1c browser_side: add XMLUI "int" widget type + historyPrint uses the new param "Chat history limit"
souliane <souliane@mailoo.org>
parents: 504
diff changeset
162 TextBox.__init__(self)
fed185c95f1c browser_side: add XMLUI "int" widget type + historyPrint uses the new param "Chat history limit"
souliane <souliane@mailoo.org>
parents: 504
diff changeset
163 self.setText(value)
fed185c95f1c browser_side: add XMLUI "int" widget type + historyPrint uses the new param "Chat history limit"
souliane <souliane@mailoo.org>
parents: 504
diff changeset
164 self.setReadonly(read_only)
fed185c95f1c browser_side: add XMLUI "int" widget type + historyPrint uses the new param "Chat history limit"
souliane <souliane@mailoo.org>
parents: 504
diff changeset
165
fed185c95f1c browser_side: add XMLUI "int" widget type + historyPrint uses the new param "Chat history limit"
souliane <souliane@mailoo.org>
parents: 504
diff changeset
166 def _xmluiSetValue(self, value):
fed185c95f1c browser_side: add XMLUI "int" widget type + historyPrint uses the new param "Chat history limit"
souliane <souliane@mailoo.org>
parents: 504
diff changeset
167 self.setText(value)
fed185c95f1c browser_side: add XMLUI "int" widget type + historyPrint uses the new param "Chat history limit"
souliane <souliane@mailoo.org>
parents: 504
diff changeset
168
fed185c95f1c browser_side: add XMLUI "int" widget type + historyPrint uses the new param "Chat history limit"
souliane <souliane@mailoo.org>
parents: 504
diff changeset
169 def _xmluiGetValue(self):
fed185c95f1c browser_side: add XMLUI "int" widget type + historyPrint uses the new param "Chat history limit"
souliane <souliane@mailoo.org>
parents: 504
diff changeset
170 return self.getText()
fed185c95f1c browser_side: add XMLUI "int" widget type + historyPrint uses the new param "Chat history limit"
souliane <souliane@mailoo.org>
parents: 504
diff changeset
171
fed185c95f1c browser_side: add XMLUI "int" widget type + historyPrint uses the new param "Chat history limit"
souliane <souliane@mailoo.org>
parents: 504
diff changeset
172 def _xmluiOnChange(self, callback):
fed185c95f1c browser_side: add XMLUI "int" widget type + historyPrint uses the new param "Chat history limit"
souliane <souliane@mailoo.org>
parents: 504
diff changeset
173 self.addChangeListener(callback)
fed185c95f1c browser_side: add XMLUI "int" widget type + historyPrint uses the new param "Chat history limit"
souliane <souliane@mailoo.org>
parents: 504
diff changeset
174
fed185c95f1c browser_side: add XMLUI "int" widget type + historyPrint uses the new param "Chat history limit"
souliane <souliane@mailoo.org>
parents: 504
diff changeset
175
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
176 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
177
720
bf0a7da558e8 browser side (xmlui): factory is instantiated on Panel init + main panel is passed as first argument to widgets
Goffi <goffi@goffi.org>
parents: 719
diff changeset
178 def __init__(self, xmlui_main, 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
179 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
180
378
3dd0b5334aef browser_side: fix typos
souliane <souliane@mailoo.org>
parents: 376
diff changeset
181 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
182 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
183
e8c26e24a6c7 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
e8c26e24a6c7 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 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
186
720
bf0a7da558e8 browser side (xmlui): factory is instantiated on Panel init + main panel is passed as first argument to widgets
Goffi <goffi@goffi.org>
parents: 719
diff changeset
187 def __init__(self, xmlui_main, 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
188 ListBox.__init__(self)
430
a927a98b398d browser_side (xmlui): fix multi-selection
souliane <souliane@mailoo.org>
parents: 429
diff changeset
189 multi_selection = 'single' not in flags
a927a98b398d browser_side (xmlui): fix multi-selection
souliane <souliane@mailoo.org>
parents: 429
diff changeset
190 self.setMultipleSelect(multi_selection)
a927a98b398d browser_side (xmlui): fix multi-selection
souliane <souliane@mailoo.org>
parents: 429
diff changeset
191 if multi_selection:
a927a98b398d browser_side (xmlui): fix multi-selection
souliane <souliane@mailoo.org>
parents: 429
diff changeset
192 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
193 for option in options:
337
ea1be522ba88 browser side: XMLUI fixes:
Goffi <goffi@goffi.org>
parents: 335
diff changeset
194 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
195 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
196 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
197
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
198 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
199 """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
200 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
201 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
202 except IndexError:
694
82123705474b massive (preventive) addition of 'u' (unicode) before the strings passed to logging functions
souliane <souliane@mailoo.org>
parents: 685
diff changeset
203 log.warning(u"Can't find value [%s] to select" % value)
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
204 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
205 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
206
429
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
207 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
208 """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
209 self.setValueSelection(values)
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
210
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
211 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
212 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
213 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
214 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
215 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
216
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
217 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
218 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
219
429
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
220 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
221 selected = self._xmluiGetSelectedValues()
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
222 for value in values:
430
a927a98b398d browser_side (xmlui): fix multi-selection
souliane <souliane@mailoo.org>
parents: 429
diff changeset
223 if value not in self._xmlui_attr_map.values():
a927a98b398d browser_side (xmlui): fix multi-selection
souliane <souliane@mailoo.org>
parents: 429
diff changeset
224 self.addItem(value)
a927a98b398d browser_side (xmlui): fix multi-selection
souliane <souliane@mailoo.org>
parents: 429
diff changeset
225 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
226 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
227 selected.append(value)
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
228 self._xmluiSelectValues(selected)
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
229
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
230
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
231 class 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
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 _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
234 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
235
e8c26e24a6c7 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 class AdvancedListContainer(xmlui.AdvancedListContainer, Grid):
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
238
720
bf0a7da558e8 browser side (xmlui): factory is instantiated on Panel init + main panel is passed as first argument to widgets
Goffi <goffi@goffi.org>
parents: 719
diff changeset
239 def __init__(self, xmlui_main, xmlui_parent, columns, selectable='no'):
337
ea1be522ba88 browser side: XMLUI fixes:
Goffi <goffi@goffi.org>
parents: 335
diff changeset
240 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
241 self.columns = columns
337
ea1be522ba88 browser side: XMLUI fixes:
Goffi <goffi@goffi.org>
parents: 335
diff changeset
242 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
243 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
244 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
245 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
246 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
247 self.addTableListener(self)
376
ab923b870fb0 browser side: XMLUI AdvancedListContainer: rows are highlighted when there are selectable
Goffi <goffi@goffi.org>
parents: 369
diff changeset
248 if self._xmlui_selectable:
ab923b870fb0 browser side: XMLUI AdvancedListContainer: rows are highlighted when there are selectable
Goffi <goffi@goffi.org>
parents: 369
diff changeset
249 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
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 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
252 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
253 return
376
ab923b870fb0 browser side: XMLUI AdvancedListContainer: rows are highlighted when there are selectable
Goffi <goffi@goffi.org>
parents: 369
diff changeset
254 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
255 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
256 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
257 except AttributeError:
439
d52f529a6d42 browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents: 430
diff changeset
258 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
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 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
261 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
262 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
263
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
264 def _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
265 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
266 self.col = 0
337
ea1be522ba88 browser side: XMLUI fixes:
Goffi <goffi@goffi.org>
parents: 335
diff changeset
267 self._xmlui_rows_idx.insert(self.row, idx)
451
1a0cec9b0f1e better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 449
diff changeset
268 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
269
e8c26e24a6c7 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 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
271 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
272
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
273 def _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
274 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
275 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
276 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
277 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
278
e8c26e24a6c7 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 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
280 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
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 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
284
720
bf0a7da558e8 browser side (xmlui): factory is instantiated on Panel init + main panel is passed as first argument to widgets
Goffi <goffi@goffi.org>
parents: 719
diff changeset
285 def __init__(self, xmlui_main, xmlui_parent):
247
fe83837d3491 browser_side: removed some trailing spaces
Goffi <goffi@goffi.org>
parents: 229
diff changeset
286 Grid.__init__(self, 0, 0)
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
287 self.row = 0
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
288 self.col = 0
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
289
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
290 def _xmluiAppend(self, widget):
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
291 if self.col == 0:
451
1a0cec9b0f1e better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 449
diff changeset
292 self.resize(self.row + 1, 2)
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
293 self.setWidget(self.row, self.col, widget)
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
294 self.col += 1
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
295 if self.col == 2:
451
1a0cec9b0f1e better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 449
diff changeset
296 self.row += 1
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
297 self.col = 0
247
fe83837d3491 browser_side: removed some trailing spaces
Goffi <goffi@goffi.org>
parents: 229
diff changeset
298
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
e8c26e24a6c7 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 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
301
720
bf0a7da558e8 browser side (xmlui): factory is instantiated on Panel init + main panel is passed as first argument to widgets
Goffi <goffi@goffi.org>
parents: 719
diff changeset
302 def __init__(self, xmlui_main, 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
303 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
304 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
305
e8c26e24a6c7 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 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
307 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
308 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
309 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
310 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
311 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
312
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
313
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
314 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
315 __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
316
720
bf0a7da558e8 browser side (xmlui): factory is instantiated on Panel init + main panel is passed as first argument to widgets
Goffi <goffi@goffi.org>
parents: 719
diff changeset
317 def __init__(self, xmlui_main, 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
318 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
319
e8c26e24a6c7 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 ## 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
322
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
323
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
324 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
325
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
326 def _xmluiShow(self):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
327 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
328
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
329 def _xmluiClose(self):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
330 pass
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
331
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
332
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
333 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
334
720
bf0a7da558e8 browser side (xmlui): factory is instantiated on Panel init + main panel is passed as first argument to widgets
Goffi <goffi@goffi.org>
parents: 719
diff changeset
335 def __init__(self, xmlui_main, xmlui_parent, title, message, level):
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
336 #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
337 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
338 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
339 Dlg.__init__(self)
720
bf0a7da558e8 browser side (xmlui): factory is instantiated on Panel init + main panel is passed as first argument to widgets
Goffi <goffi@goffi.org>
parents: 719
diff changeset
340 xmlui.MessageDialog.__init__(self, xmlui_main, xmlui_parent)
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
341 dialog.InfoDialog.__init__(self, title, message, self._xmluiValidated())
337
ea1be522ba88 browser side: XMLUI fixes:
Goffi <goffi@goffi.org>
parents: 335
diff changeset
342
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
343
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
344 class NoteDialog(xmlui.NoteDialog, MessageDialog):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
345 # TODO: separate NoteDialog
247
fe83837d3491 browser_side: removed some trailing spaces
Goffi <goffi@goffi.org>
parents: 229
diff changeset
346
720
bf0a7da558e8 browser side (xmlui): factory is instantiated on Panel init + main panel is passed as first argument to widgets
Goffi <goffi@goffi.org>
parents: 719
diff changeset
347 def __init__(self, xmlui_main, xmlui_parent, title, message, level):
bf0a7da558e8 browser side (xmlui): factory is instantiated on Panel init + main panel is passed as first argument to widgets
Goffi <goffi@goffi.org>
parents: 719
diff changeset
348 xmlui.NoteDialog.__init__(self, xmlui_main, xmlui_parent)
bf0a7da558e8 browser side (xmlui): factory is instantiated on Panel init + main panel is passed as first argument to widgets
Goffi <goffi@goffi.org>
parents: 719
diff changeset
349 MessageDialog.__init__(self, xmlui_main, xmlui_parent, title, message, level)
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
350
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
351
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
352 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
353
720
bf0a7da558e8 browser side (xmlui): factory is instantiated on Panel init + main panel is passed as first argument to widgets
Goffi <goffi@goffi.org>
parents: 719
diff changeset
354 def __init__(self, xmlui_main, xmlui_parent, title, message, level):
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
355 #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
356 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
357 message = strings.addURLToText(html_tools.XHTML2Text(message))
720
bf0a7da558e8 browser side (xmlui): factory is instantiated on Panel init + main panel is passed as first argument to widgets
Goffi <goffi@goffi.org>
parents: 719
diff changeset
358 xmlui.ConfirmDialog.__init__(self, xmlui_main, xmlui_parent)
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
359 Dlg.__init__(self)
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
360 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
361
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
362 def answered(self, validated):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
363 if validated:
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
364 self._xmluiValidated()
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
365 else:
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
366 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
367
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
368
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
369 class FileDialog(xmlui.FileDialog, Dlg):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
370 #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
371
720
bf0a7da558e8 browser side (xmlui): factory is instantiated on Panel init + main panel is passed as first argument to widgets
Goffi <goffi@goffi.org>
parents: 719
diff changeset
372 def __init__(self, xmlui_main, xmlui_parent, title, message, level, filetype):
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
373 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
374
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
375
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
376 class GenericFactory(object):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
377 # 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
378 # so an introspection workaround is used
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
379
720
bf0a7da558e8 browser side (xmlui): factory is instantiated on Panel init + main panel is passed as first argument to widgets
Goffi <goffi@goffi.org>
parents: 719
diff changeset
380 def __init__(self, xmlui_main):
bf0a7da558e8 browser side (xmlui): factory is instantiated on Panel init + main panel is passed as first argument to widgets
Goffi <goffi@goffi.org>
parents: 719
diff changeset
381 self.xmlui_main = xmlui_main
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
382 for name, cls in globals().items():
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
383 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
384 log.info("registering: %s" % name)
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
385 def createCreater(cls):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
386 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
387 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
388
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
389 def _genericCreate(self, cls, *args, **kwargs):
720
bf0a7da558e8 browser side (xmlui): factory is instantiated on Panel init + main panel is passed as first argument to widgets
Goffi <goffi@goffi.org>
parents: 719
diff changeset
390 instance = cls(self.xmlui_main, *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
391 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
392
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
393 # 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
394 # 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
395 # 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
396 # 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
397 # 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
398
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
399
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
400 class WidgetFactory(GenericFactory):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
401
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
402 def _genericCreate(self, cls, *args, **kwargs):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
403 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
404 return instance
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
405
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
406 class LiberviaXMLUIBase(object):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
407
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
408 def _xmluiLaunchAction(self, action_id, data):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
409 self.host.launchAction(action_id, data)
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
410
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
411
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
412 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
413
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 564
diff changeset
414 def __init__(self, host, parsed_xml, title=None, flags=None, callback=None, profile=C.PROF_KEY_NONE):
720
bf0a7da558e8 browser side (xmlui): factory is instantiated on Panel init + main panel is passed as first argument to widgets
Goffi <goffi@goffi.org>
parents: 719
diff changeset
415 self.widget_factory = WidgetFactory(self)
bf0a7da558e8 browser side (xmlui): factory is instantiated on Panel init + main panel is passed as first argument to widgets
Goffi <goffi@goffi.org>
parents: 719
diff changeset
416 self.host = host
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 VerticalPanel.__init__(self)
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
418 self.setSize('100%', '100%')
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 564
diff changeset
419 xmlui.XMLUIPanel.__init__(self, host, parsed_xml, title, flags, callback, profile)
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
420
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
421 def setCloseCb(self, close_cb):
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
422 self.close_cb = close_cb
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
423
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
424 def _xmluiClose(self):
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
425 if self.close_cb:
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
426 self.close_cb()
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
427 else:
439
d52f529a6d42 browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents: 430
diff changeset
428 log.warning("no close method defined")
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
429
337
ea1be522ba88 browser side: XMLUI fixes:
Goffi <goffi@goffi.org>
parents: 335
diff changeset
430 def _xmluiSetParam(self, name, value, category):
ea1be522ba88 browser side: XMLUI fixes:
Goffi <goffi@goffi.org>
parents: 335
diff changeset
431 self.host.bridge.call('setParam', None, name, value, category)
ea1be522ba88 browser side: XMLUI fixes:
Goffi <goffi@goffi.org>
parents: 335
diff changeset
432
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
433 def constructUI(self, parsed_dom):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
434 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
435 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
436 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
437 if self.type == 'form':
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
438 hpanel = HorizontalPanel()
392
f539f6f8ee9c browser_side: standardize the dialogs size and buttons display:
souliane <souliane@mailoo.org>
parents: 390
diff changeset
439 hpanel.setStyleName('marginAuto')
451
1a0cec9b0f1e better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 449
diff changeset
440 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
441 if not 'NO_CANCEL' in self.flags:
451
1a0cec9b0f1e better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 449
diff changeset
442 hpanel.add(Button('Cancel', self.onFormCancelled))
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
443 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
444 elif self.type == 'param':
451
1a0cec9b0f1e better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 449
diff changeset
445 assert(isinstance(self.children[0][0], TabPanel))
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
446 hpanel = HorizontalPanel()
392
f539f6f8ee9c browser_side: standardize the dialogs size and buttons display:
souliane <souliane@mailoo.org>
parents: 390
diff changeset
447 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
448 hpanel.add(Button('Cancel', lambda ignore: self._xmluiClose()))
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
449 self.add(hpanel)
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
450
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
451 def show(self):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
452 options = ['NO_CLOSE'] if self.type == C.XMLUI_FORM else []
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 564
diff changeset
453 _dialog = dialog.GenericDialog(self.xmlui_title, self, options=options)
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
454 self.setCloseCb(_dialog.close)
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
455 _dialog.show()
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
456
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
457
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
458 class XMLUIDialog(LiberviaXMLUIBase, xmlui.XMLUIDialog):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
459 dialog_factory = GenericFactory()
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
460
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 564
diff changeset
461 def __init__(self, host, parsed_dom, title = None, flags = None, callback=None, profile=C.PROF_KEY_NONE):
720
bf0a7da558e8 browser side (xmlui): factory is instantiated on Panel init + main panel is passed as first argument to widgets
Goffi <goffi@goffi.org>
parents: 719
diff changeset
462 self.dialog_factory = GenericFactory(self)
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 564
diff changeset
463 xmlui.XMLUIDialog.__init__(self, host, parsed_dom, title, flags, callback, profile)
720
bf0a7da558e8 browser side (xmlui): factory is instantiated on Panel init + main panel is passed as first argument to widgets
Goffi <goffi@goffi.org>
parents: 719
diff changeset
464 self.host = host
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
465
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
466 xmlui.registerClass(xmlui.CLASS_PANEL, XMLUIPanel)
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
467 xmlui.registerClass(xmlui.CLASS_DIALOG, XMLUIDialog)
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
468
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
469 def create(*args, **kwargs):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
470 dom = nativedom.NativeDOM()
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
471 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
472 return xmlui.create(*args, **kwargs)