annotate src/browser/sat_browser/xmlui.py @ 1000:4cc4d49e1d0f

pages (chat): moved rendering preparation in prepare_render, and redirect to page_select if no jid is specified.
author Goffi <goffi@goffi.org>
date Fri, 05 Jan 2018 16:30:05 +0100
parents 8f2c1ea36e96
children f2170536ba23
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
964
fd4eae654182 misc: date update (yes it's a bit late :p )
Goffi <goffi@goffi.org>
parents: 958
diff changeset
5 # Copyright (C) 2011-2017 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
784
f3cd261ea12f browser side: workaround for a pyjamas bug which freeze the browser in some case with addURLToText regex
Goffi <goffi@goffi.org>
parents: 779
diff changeset
23 from sat_browser import strings
721
102bab805ec1 browser side(xmlui): basic JidsList implementation (read-only) using ContactsPanel, to fix params display
Goffi <goffi@goffi.org>
parents: 720
diff changeset
24 from sat_frontends.tools import jid
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
25 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
26 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
27 from sat_browser import html_tools
721
102bab805ec1 browser side(xmlui): basic JidsList implementation (read-only) using ContactsPanel, to fix params display
Goffi <goffi@goffi.org>
parents: 720
diff changeset
28 from sat_browser import contact_panel
449
981ed669d3b3 /!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents: 439
diff changeset
29
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
30 from pyjamas.ui.VerticalPanel import VerticalPanel
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
31 from pyjamas.ui.HorizontalPanel import HorizontalPanel
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
32 from pyjamas.ui.TabPanel import TabPanel
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
33 from pyjamas.ui.Grid import Grid
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
34 from pyjamas.ui.Label import Label
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
35 from pyjamas.ui.TextBox import TextBox
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
36 from pyjamas.ui.PasswordTextBox import PasswordTextBox
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
37 from pyjamas.ui.TextArea import TextArea
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
38 from pyjamas.ui.CheckBox import CheckBox
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
39 from pyjamas.ui.ListBox import ListBox
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
40 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
41 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
42
467
97c72fe4a5f2 browser_side: import fixes:
Goffi <goffi@goffi.org>
parents: 451
diff changeset
43 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
44
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
45
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
46 class 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
47
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
48 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
49 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
50
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
51
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
52 class 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
53
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
54 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
55 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
56
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
57
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
58 class 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
59
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
60 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
61 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
62
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
63
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
64 class JidWidget(xmlui.JidWidget, TextWidget):
337
ea1be522ba88 browser side: XMLUI fixes:
Goffi <goffi@goffi.org>
parents: 335
diff changeset
65
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
66 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
67 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
68
e8c26e24a6c7 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
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
70 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
71
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
72 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
73 """Add a divider
0c4547587637 browser_side (xmlui): implement the divider styles
souliane <souliane@mailoo.org>
parents: 392
diff changeset
74
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
75 @param xmlui_parent
662
ebb602d8b3f2 browser_side: replace all instances of 'str' with 'unicode'
souliane <souliane@mailoo.org>
parents: 589
diff changeset
76 @param style (unicode): one of:
489
1ce6133993e4 browser side (XMLUI): implementation of read_only attribute
Goffi <goffi@goffi.org>
parents: 467
diff changeset
77 - line: a simple line
1ce6133993e4 browser side (XMLUI): implementation of read_only attribute
Goffi <goffi@goffi.org>
parents: 467
diff changeset
78 - dot: a line of dots
1ce6133993e4 browser side (XMLUI): implementation of read_only attribute
Goffi <goffi@goffi.org>
parents: 467
diff changeset
79 - dash: a line of dashes
1ce6133993e4 browser side (XMLUI): implementation of read_only attribute
Goffi <goffi@goffi.org>
parents: 467
diff changeset
80 - plain: a full thick line
1ce6133993e4 browser side (XMLUI): implementation of read_only attribute
Goffi <goffi@goffi.org>
parents: 467
diff changeset
81 - blank: a blank line/space
428
0c4547587637 browser_side (xmlui): implement the divider styles
souliane <souliane@mailoo.org>
parents: 392
diff changeset
82 """
0c4547587637 browser_side (xmlui): implement the divider styles
souliane <souliane@mailoo.org>
parents: 392
diff changeset
83 HTML.__init__(self, "<hr/>")
0c4547587637 browser_side (xmlui): implement the divider styles
souliane <souliane@mailoo.org>
parents: 392
diff changeset
84 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
85
e8c26e24a6c7 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
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
87 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
88
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
89 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
90 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
91 self.setText(value)
489
1ce6133993e4 browser side (XMLUI): implementation of read_only attribute
Goffi <goffi@goffi.org>
parents: 467
diff changeset
92 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
93
429
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
94 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
95 self.setText(value)
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
96
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
97 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
98 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
99
e8c26e24a6c7 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 def _xmluiOnChange(self, callback):
378
3dd0b5334aef browser_side: fix typos
souliane <souliane@mailoo.org>
parents: 376
diff changeset
101 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
102
e8c26e24a6c7 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
719
9a9e2fcc6347 browser side (xmlui): added basic JidInputWidget (use a StringWidget)
Goffi <goffi@goffi.org>
parents: 694
diff changeset
104 class JidInputWidget(xmlui.JidInputWidget, StringWidget):
9a9e2fcc6347 browser side (xmlui): added basic JidInputWidget (use a StringWidget)
Goffi <goffi@goffi.org>
parents: 694
diff changeset
105
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
106 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
107 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
108
9a9e2fcc6347 browser side (xmlui): added basic JidInputWidget (use a StringWidget)
Goffi <goffi@goffi.org>
parents: 694
diff changeset
109
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
110 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
111
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
112 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
113 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
114 self.setText(value)
489
1ce6133993e4 browser side (XMLUI): implementation of read_only attribute
Goffi <goffi@goffi.org>
parents: 467
diff changeset
115 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
116
429
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
117 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
118 self.setText(value)
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
119
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
120 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
121 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
122
e8c26e24a6c7 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 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
124 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
125
e8c26e24a6c7 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
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
127 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
128
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
129 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
130 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
131 self.setText(value)
489
1ce6133993e4 browser side (XMLUI): implementation of read_only attribute
Goffi <goffi@goffi.org>
parents: 467
diff changeset
132 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
133
429
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
134 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
135 self.setText(value)
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
136
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
137 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
138 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
139
e8c26e24a6c7 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 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
141 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
142
e8c26e24a6c7 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
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
144 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
145
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
146 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
147 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
148 self.setChecked(state)
489
1ce6133993e4 browser side (XMLUI): implementation of read_only attribute
Goffi <goffi@goffi.org>
parents: 467
diff changeset
149 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
150
429
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
151 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
152 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
153
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
154 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
155 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
156
e8c26e24a6c7 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 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
158 self.addClickListener(callback)
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
159
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
160
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
161 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
162
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
163 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
164 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
165 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
166 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
167
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 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
169 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
170
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 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
172 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
173
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 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
175 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
176
fed185c95f1c browser_side: add XMLUI "int" widget type + historyPrint uses the new param "Chat history limit"
souliane <souliane@mailoo.org>
parents: 504
diff changeset
177
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
178 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
179
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
180 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
181 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
182
378
3dd0b5334aef browser_side: fix typos
souliane <souliane@mailoo.org>
parents: 376
diff changeset
183 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
184 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
185
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
186
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
187 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
188
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
189 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
190 ListBox.__init__(self)
430
a927a98b398d browser_side (xmlui): fix multi-selection
souliane <souliane@mailoo.org>
parents: 429
diff changeset
191 multi_selection = 'single' not in flags
a927a98b398d browser_side (xmlui): fix multi-selection
souliane <souliane@mailoo.org>
parents: 429
diff changeset
192 self.setMultipleSelect(multi_selection)
a927a98b398d browser_side (xmlui): fix multi-selection
souliane <souliane@mailoo.org>
parents: 429
diff changeset
193 if multi_selection:
a927a98b398d browser_side (xmlui): fix multi-selection
souliane <souliane@mailoo.org>
parents: 429
diff changeset
194 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
195 for option in options:
337
ea1be522ba88 browser side: XMLUI fixes:
Goffi <goffi@goffi.org>
parents: 335
diff changeset
196 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
197 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
198 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
199
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
200 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
201 """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
202 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
203 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
204 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
205 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
206 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
207 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
208
429
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
209 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
210 """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
211 self.setValueSelection(values)
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
212
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
213 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
214 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
215 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
216 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
217 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
218
e8c26e24a6c7 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 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
220 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
221
429
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
222 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
223 selected = self._xmluiGetSelectedValues()
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
224 for value in values:
430
a927a98b398d browser_side (xmlui): fix multi-selection
souliane <souliane@mailoo.org>
parents: 429
diff changeset
225 if value not in self._xmlui_attr_map.values():
a927a98b398d browser_side (xmlui): fix multi-selection
souliane <souliane@mailoo.org>
parents: 429
diff changeset
226 self.addItem(value)
a927a98b398d browser_side (xmlui): fix multi-selection
souliane <souliane@mailoo.org>
parents: 429
diff changeset
227 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
228 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
229 selected.append(value)
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
230 self._xmluiSelectValues(selected)
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
231
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
721
102bab805ec1 browser side(xmlui): basic JidsList implementation (read-only) using ContactsPanel, to fix params display
Goffi <goffi@goffi.org>
parents: 720
diff changeset
233 class JidsListWidget(contact_panel.ContactsPanel, xmlui.JidsListWidget):
102bab805ec1 browser side(xmlui): basic JidsList implementation (read-only) using ContactsPanel, to fix params display
Goffi <goffi@goffi.org>
parents: 720
diff changeset
234
102bab805ec1 browser side(xmlui): basic JidsList implementation (read-only) using ContactsPanel, to fix params display
Goffi <goffi@goffi.org>
parents: 720
diff changeset
235 def __init__(self, xmlui_main, xmlui_parent, jids, styles):
102bab805ec1 browser side(xmlui): basic JidsList implementation (read-only) using ContactsPanel, to fix params display
Goffi <goffi@goffi.org>
parents: 720
diff changeset
236 contact_panel.ContactsPanel.__init__(self, xmlui_main.host, merge_resources=False)
779
fc941d0d97f8 browser_side: fixed ContactsPanel scrolling
souliane <souliane@mailoo.org>
parents: 723
diff changeset
237 self.addStyleName("xmlui-JidsListWidget")
721
102bab805ec1 browser side(xmlui): basic JidsList implementation (read-only) using ContactsPanel, to fix params display
Goffi <goffi@goffi.org>
parents: 720
diff changeset
238 self.setList([jid.JID(jid_) for jid_ in jids])
102bab805ec1 browser side(xmlui): basic JidsList implementation (read-only) using ContactsPanel, to fix params display
Goffi <goffi@goffi.org>
parents: 720
diff changeset
239
102bab805ec1 browser side(xmlui): basic JidsList implementation (read-only) using ContactsPanel, to fix params display
Goffi <goffi@goffi.org>
parents: 720
diff changeset
240 def _xmluiGetSelectedValues(self):
102bab805ec1 browser side(xmlui): basic JidsList implementation (read-only) using ContactsPanel, to fix params display
Goffi <goffi@goffi.org>
parents: 720
diff changeset
241 # XXX: there is not selection in this list, so we return all non empty values
102bab805ec1 browser side(xmlui): basic JidsList implementation (read-only) using ContactsPanel, to fix params display
Goffi <goffi@goffi.org>
parents: 720
diff changeset
242 return self.getJids()
102bab805ec1 browser side(xmlui): basic JidsList implementation (read-only) using ContactsPanel, to fix params display
Goffi <goffi@goffi.org>
parents: 720
diff changeset
243
102bab805ec1 browser side(xmlui): basic JidsList implementation (read-only) using ContactsPanel, to fix params display
Goffi <goffi@goffi.org>
parents: 720
diff changeset
244
102bab805ec1 browser side(xmlui): basic JidsList implementation (read-only) using ContactsPanel, to fix params display
Goffi <goffi@goffi.org>
parents: 720
diff changeset
245
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 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
247
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
248 def _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
249 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
250
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
251
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
252 class AdvancedListContainer(xmlui.AdvancedListContainer, Grid):
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
253
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
254 def __init__(self, xmlui_main, xmlui_parent, columns, selectable='no'):
337
ea1be522ba88 browser side: XMLUI fixes:
Goffi <goffi@goffi.org>
parents: 335
diff changeset
255 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
256 self.columns = columns
337
ea1be522ba88 browser side: XMLUI fixes:
Goffi <goffi@goffi.org>
parents: 335
diff changeset
257 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
258 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
259 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
260 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
261 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
262 self.addTableListener(self)
376
ab923b870fb0 browser side: XMLUI AdvancedListContainer: rows are highlighted when there are selectable
Goffi <goffi@goffi.org>
parents: 369
diff changeset
263 if self._xmlui_selectable:
ab923b870fb0 browser side: XMLUI AdvancedListContainer: rows are highlighted when there are selectable
Goffi <goffi@goffi.org>
parents: 369
diff changeset
264 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
265
e8c26e24a6c7 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 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
267 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
268 return
376
ab923b870fb0 browser side: XMLUI AdvancedListContainer: rows are highlighted when there are selectable
Goffi <goffi@goffi.org>
parents: 369
diff changeset
269 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
270 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
271 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
272 except AttributeError:
439
d52f529a6d42 browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents: 430
diff changeset
273 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
274
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
275 def _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
276 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
277 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
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 _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
280 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
281 self.col = 0
337
ea1be522ba88 browser side: XMLUI fixes:
Goffi <goffi@goffi.org>
parents: 335
diff changeset
282 self._xmlui_rows_idx.insert(self.row, idx)
451
1a0cec9b0f1e better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 449
diff changeset
283 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
284
e8c26e24a6c7 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 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
286 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
287
e8c26e24a6c7 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 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
289 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
290 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
291 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
292 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
293
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
294 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
295 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
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
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
298 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
299
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
300 def __init__(self, xmlui_main, xmlui_parent):
247
fe83837d3491 browser_side: removed some trailing spaces
Goffi <goffi@goffi.org>
parents: 229
diff changeset
301 Grid.__init__(self, 0, 0)
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
302 self.row = 0
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
303 self.col = 0
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
304
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 def _xmluiAppend(self, widget):
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
306 if self.col == 0:
451
1a0cec9b0f1e better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 449
diff changeset
307 self.resize(self.row + 1, 2)
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
308 self.setWidget(self.row, self.col, widget)
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
309 self.col += 1
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
310 if self.col == 2:
451
1a0cec9b0f1e better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 449
diff changeset
311 self.row += 1
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
312 self.col = 0
247
fe83837d3491 browser_side: removed some trailing spaces
Goffi <goffi@goffi.org>
parents: 229
diff changeset
313
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
314
958
3c81203840a4 browser (xmlui): added LabelContainer (use PairsContainer to handle it for now)
Goffi <goffi@goffi.org>
parents: 818
diff changeset
315 class LabelContainer(PairsContainer, xmlui.LabelContainer):
3c81203840a4 browser (xmlui): added LabelContainer (use PairsContainer to handle it for now)
Goffi <goffi@goffi.org>
parents: 818
diff changeset
316 pass
3c81203840a4 browser (xmlui): added LabelContainer (use PairsContainer to handle it for now)
Goffi <goffi@goffi.org>
parents: 818
diff changeset
317
3c81203840a4 browser (xmlui): added LabelContainer (use PairsContainer to handle it for now)
Goffi <goffi@goffi.org>
parents: 818
diff changeset
318
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
319 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
320
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
321 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
322 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
323 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
324
723
afbe061b2d66 browser_side (xmlui): allow to select a tab when adding it
souliane <souliane@mailoo.org>
parents: 722
diff changeset
325 def _xmluiAddTab(self, label, 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
326 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
327 self.add(tab_panel, label)
723
afbe061b2d66 browser_side (xmlui): allow to select a tab when adding it
souliane <souliane@mailoo.org>
parents: 722
diff changeset
328 count = len(self.getChildren())
afbe061b2d66 browser_side (xmlui): allow to select a tab when adding it
souliane <souliane@mailoo.org>
parents: 722
diff changeset
329 if count == 1 or selected:
afbe061b2d66 browser_side (xmlui): allow to select a tab when adding it
souliane <souliane@mailoo.org>
parents: 722
diff changeset
330 self.selectTab(count - 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
331 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
332
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
333
e8c26e24a6c7 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 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
335 __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
336
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
337 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
338 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
339
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
340
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
341 ## 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
342
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
343
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
344 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
345
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
346 def _xmluiShow(self):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
347 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
348
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
349 def _xmluiClose(self):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
350 pass
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
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
353 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
354
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
355 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
356 #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
357 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
358 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
359 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
360 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
361 dialog.InfoDialog.__init__(self, title, message, self._xmluiValidated())
337
ea1be522ba88 browser side: XMLUI fixes:
Goffi <goffi@goffi.org>
parents: 335
diff changeset
362
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
363
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
364 class NoteDialog(xmlui.NoteDialog, MessageDialog):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
365 # TODO: separate NoteDialog
247
fe83837d3491 browser_side: removed some trailing spaces
Goffi <goffi@goffi.org>
parents: 229
diff changeset
366
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
367 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
368 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
369 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
370
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
371
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
372 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
373
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
374 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
375 #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
376 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
377 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
378 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
379 Dlg.__init__(self)
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
380 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
381
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
382 def answered(self, validated):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
383 if validated:
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
384 self._xmluiValidated()
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
385 else:
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
386 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
387
500
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 class FileDialog(xmlui.FileDialog, Dlg):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
390 #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
391
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
392 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
393 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
394
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
395
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
396 class GenericFactory(object):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
397 # 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
398 # so an introspection workaround is used
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
399
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
400 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
401 self.xmlui_main = xmlui_main
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
402 for name, cls in globals().items():
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
403 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
404 log.info("registering: %s" % name)
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
405 def createCreater(cls):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
406 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
407 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
408
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
409 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
410 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
411 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
412
e8c26e24a6c7 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 # 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
414 # 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
415 # 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
416 # 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
417 # 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
418
e8c26e24a6c7 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
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
420 class WidgetFactory(GenericFactory):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
421
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
422 def _genericCreate(self, cls, *args, **kwargs):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
423 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
424 return instance
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
425
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
426 class LiberviaXMLUIBase(object):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
427
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
428 def _xmluiLaunchAction(self, action_id, data):
722
242dde89e698 browser side (xmlui): default callback is used for launchAction
Goffi <goffi@goffi.org>
parents: 721
diff changeset
429 self.host.launchAction(action_id, data, callback=self._defaultCb)
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
430
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
431
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
432 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
433
965
8f2c1ea36e96 browser (XMLUI): added new ignore argument
Goffi <goffi@goffi.org>
parents: 964
diff changeset
434 def __init__(self, host, parsed_xml, title=None, flags=None, callback=None, ignore=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
435 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
436 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
437 VerticalPanel.__init__(self)
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
438 self.setSize('100%', '100%')
965
8f2c1ea36e96 browser (XMLUI): added new ignore argument
Goffi <goffi@goffi.org>
parents: 964
diff changeset
439 xmlui.XMLUIPanel.__init__(self,
8f2c1ea36e96 browser (XMLUI): added new ignore argument
Goffi <goffi@goffi.org>
parents: 964
diff changeset
440 host,
8f2c1ea36e96 browser (XMLUI): added new ignore argument
Goffi <goffi@goffi.org>
parents: 964
diff changeset
441 parsed_xml,
8f2c1ea36e96 browser (XMLUI): added new ignore argument
Goffi <goffi@goffi.org>
parents: 964
diff changeset
442 title = title,
8f2c1ea36e96 browser (XMLUI): added new ignore argument
Goffi <goffi@goffi.org>
parents: 964
diff changeset
443 flags = flags,
8f2c1ea36e96 browser (XMLUI): added new ignore argument
Goffi <goffi@goffi.org>
parents: 964
diff changeset
444 callback = callback,
8f2c1ea36e96 browser (XMLUI): added new ignore argument
Goffi <goffi@goffi.org>
parents: 964
diff changeset
445 profile = profile)
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
446
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
447 def setCloseCb(self, close_cb):
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
448 self.close_cb = close_cb
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
449
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
450 def _xmluiClose(self):
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
451 if self.close_cb:
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
452 self.close_cb()
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
453 else:
439
d52f529a6d42 browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents: 430
diff changeset
454 log.warning("no close method defined")
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
455
337
ea1be522ba88 browser side: XMLUI fixes:
Goffi <goffi@goffi.org>
parents: 335
diff changeset
456 def _xmluiSetParam(self, name, value, category):
ea1be522ba88 browser side: XMLUI fixes:
Goffi <goffi@goffi.org>
parents: 335
diff changeset
457 self.host.bridge.call('setParam', None, name, value, category)
ea1be522ba88 browser side: XMLUI fixes:
Goffi <goffi@goffi.org>
parents: 335
diff changeset
458
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
459 def constructUI(self, parsed_dom):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
460 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
461 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
462 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
463 if self.type == 'form':
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
464 hpanel = HorizontalPanel()
392
f539f6f8ee9c browser_side: standardize the dialogs size and buttons display:
souliane <souliane@mailoo.org>
parents: 390
diff changeset
465 hpanel.setStyleName('marginAuto')
451
1a0cec9b0f1e better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 449
diff changeset
466 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
467 if not 'NO_CANCEL' in self.flags:
451
1a0cec9b0f1e better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 449
diff changeset
468 hpanel.add(Button('Cancel', self.onFormCancelled))
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
469 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
470 elif self.type == 'param':
451
1a0cec9b0f1e better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 449
diff changeset
471 assert(isinstance(self.children[0][0], TabPanel))
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
472 hpanel = HorizontalPanel()
806
cab7bf950fa0 browser_side (xmlui): center the Save/Cancel buttons of parameters dialog
souliane <souliane@mailoo.org>
parents: 784
diff changeset
473 hpanel.setStyleName('marginAuto')
392
f539f6f8ee9c browser_side: standardize the dialogs size and buttons display:
souliane <souliane@mailoo.org>
parents: 390
diff changeset
474 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
475 hpanel.add(Button('Cancel', lambda ignore: self._xmluiClose()))
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
476 self.add(hpanel)
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
477
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
478 def show(self):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
479 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
480 _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
481 self.setCloseCb(_dialog.close)
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
482 _dialog.show()
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
483
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
484
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
485 class XMLUIDialog(LiberviaXMLUIBase, xmlui.XMLUIDialog):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
486 dialog_factory = GenericFactory()
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
487
965
8f2c1ea36e96 browser (XMLUI): added new ignore argument
Goffi <goffi@goffi.org>
parents: 964
diff changeset
488 def __init__(self, host, parsed_dom, title = None, flags = None, callback=None, ignore=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
489 self.dialog_factory = GenericFactory(self)
965
8f2c1ea36e96 browser (XMLUI): added new ignore argument
Goffi <goffi@goffi.org>
parents: 964
diff changeset
490 xmlui.XMLUIDialog.__init__(self,
8f2c1ea36e96 browser (XMLUI): added new ignore argument
Goffi <goffi@goffi.org>
parents: 964
diff changeset
491 host,
8f2c1ea36e96 browser (XMLUI): added new ignore argument
Goffi <goffi@goffi.org>
parents: 964
diff changeset
492 parsed_dom,
8f2c1ea36e96 browser (XMLUI): added new ignore argument
Goffi <goffi@goffi.org>
parents: 964
diff changeset
493 title=title,
8f2c1ea36e96 browser (XMLUI): added new ignore argument
Goffi <goffi@goffi.org>
parents: 964
diff changeset
494 flags=flags,
8f2c1ea36e96 browser (XMLUI): added new ignore argument
Goffi <goffi@goffi.org>
parents: 964
diff changeset
495 callback=callback,
8f2c1ea36e96 browser (XMLUI): added new ignore argument
Goffi <goffi@goffi.org>
parents: 964
diff changeset
496 ignore=ignore,
8f2c1ea36e96 browser (XMLUI): added new ignore argument
Goffi <goffi@goffi.org>
parents: 964
diff changeset
497 profile=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
498 self.host = host
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
499
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
500 xmlui.registerClass(xmlui.CLASS_PANEL, XMLUIPanel)
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
501 xmlui.registerClass(xmlui.CLASS_DIALOG, XMLUIDialog)
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
502
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
503 def create(*args, **kwargs):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
504 dom = nativedom.NativeDOM()
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
505 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
506 return xmlui.create(*args, **kwargs)