Mercurial > libervia-backend
annotate frontends/src/wix/xmlui.py @ 767:318acc83a392
quick_frontend: fix presence/status update (do not share between different resources)
author | souliane <souliane@mailoo.org> |
---|---|
date | Wed, 18 Dec 2013 09:55:02 +0100 |
parents | aed7d99276b8 |
children | bfabeedbf32e |
rev | line source |
---|---|
35
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
1 #!/usr/bin/python |
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
2 # -*- coding: utf-8 -*- |
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
3 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
4 # wix: a SAT frontend |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
5 # Copyright (C) 2009, 2010, 2011, 2012, 2013 Jérôme Poisson (goffi@goffi.org) |
35
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
6 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
7 # This program is free software: you can redistribute it and/or modify |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
8 # it under the terms of the GNU Affero General Public License as published by |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
9 # the Free Software Foundation, either version 3 of the License, or |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
10 # (at your option) any later version. |
35
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
11 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
12 # This program is distributed in the hope that it will be useful, |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
15 # GNU Affero General Public License for more details. |
35
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
16 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
17 # You should have received a copy of the GNU Affero General Public License |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
35
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
19 |
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
20 |
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
21 |
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
22 import wx |
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
23 import pdb |
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
24 from xml.dom import minidom |
91 | 25 from logging import debug, info, warning, error |
225
fd9b7834d98a
distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
223
diff
changeset
|
26 from sat.tools.jid import JID |
35
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
27 |
762
aed7d99276b8
core (xml_tools), frontends: added a prefix to XMLUI form names in result data, to avoid name conflicts (e.g.: if a form has name "submit", and this name is also used internally by SàT)
Goffi <goffi@goffi.org>
parents:
760
diff
changeset
|
28 SAT_FORM_PREFIX = "SAT_FORM_" |
aed7d99276b8
core (xml_tools), frontends: added a prefix to XMLUI form names in result data, to avoid name conflicts (e.g.: if a form has name "submit", and this name is also used internally by SàT)
Goffi <goffi@goffi.org>
parents:
760
diff
changeset
|
29 |
35
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
30 |
103 | 31 class XMLUI(wx.Frame): |
32 """Create an user interface from a SàT xml""" | |
91 | 33 |
555
1d58758689e9
primitivus, wix: fixed bad defaults values for XMLUI class
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
34 def __init__(self, host, xml_data='', title="Form", options = None, misc = None): |
759
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
609
diff
changeset
|
35 if options is None: |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
609
diff
changeset
|
36 options = [] |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
609
diff
changeset
|
37 style = wx.DEFAULT_FRAME_STYLE & ~wx.CLOSE_BOX if 'NO_CANCEL' in options else wx.DEFAULT_FRAME_STYLE #FIXME: Q&D tmp hack |
103 | 38 super(XMLUI, self).__init__(None, title=title, style=style) |
35
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
39 |
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
40 self.host = host |
759
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
609
diff
changeset
|
41 self.options = options |
555
1d58758689e9
primitivus, wix: fixed bad defaults values for XMLUI class
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
42 self.misc = misc or {} |
107 | 43 self.ctrl_list = {} # usefull to access ctrl |
35
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
44 |
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
45 self.sizer = wx.BoxSizer(wx.VERTICAL) |
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
46 self.SetSizer(self.sizer) |
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
47 self.SetAutoLayout(True) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
48 |
35
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
49 #events |
91 | 50 if not 'NO_CANCEL' in self.options: |
51 self.Bind(wx.EVT_CLOSE, self.onClose, self) | |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
52 |
35
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
53 self.MakeModal() |
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
54 |
103 | 55 self.constructUI(xml_data) |
35
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
56 |
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
57 self.Show() |
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
58 |
104 | 59 def __parseElems(self, node, parent): |
60 """Parse elements inside a <layout> tags, and add them to the parent sizer""" | |
61 for elem in node.childNodes: | |
103 | 62 if elem.nodeName != "elem": |
63 message=_("Unmanaged tag") | |
64 error(message) | |
65 raise Exception(message) | |
66 _proportion = 0 | |
106 | 67 id = elem.getAttribute("id") |
103 | 68 name = elem.getAttribute("name") |
69 type = elem.getAttribute("type") | |
70 value = elem.getAttribute("value") if elem.hasAttribute('value') else u'' | |
71 if type=="empty": | |
72 ctrl = wx.Window(parent, -1) | |
73 elif type=="text": | |
74 try: | |
75 value = elem.childNodes[0].wholeText | |
149 | 76 except IndexError: |
103 | 77 warning (_("text node has no child !")) |
78 ctrl = wx.StaticText(parent, -1, value) | |
79 elif type=="label": | |
80 ctrl = wx.StaticText(parent, -1, value+": ") | |
81 elif type=="string": | |
82 ctrl = wx.TextCtrl(parent, -1, value) | |
107 | 83 self.ctrl_list[name] = ({'type':type, 'control':ctrl}) |
103 | 84 _proportion = 1 |
85 elif type=="password": | |
86 ctrl = wx.TextCtrl(parent, -1, value, style=wx.TE_PASSWORD) | |
107 | 87 self.ctrl_list[name] = ({'type':type, 'control':ctrl}) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
88 _proportion = 1 |
107 | 89 elif type=="textbox": |
90 ctrl = wx.TextCtrl(parent, -1, value, style=wx.TE_MULTILINE) | |
91 self.ctrl_list[name] = ({'type':type, 'control':ctrl}) | |
103 | 92 _proportion = 1 |
183
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
149
diff
changeset
|
93 elif type=="bool": |
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
149
diff
changeset
|
94 ctrl = wx.CheckBox(panel, -1, "", style = wx.CHK_2STATE) |
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
149
diff
changeset
|
95 ctrl.SetValue(value=="true") |
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
149
diff
changeset
|
96 self.ctrl_list[name] = ({'type':type, 'control':ctrl}) |
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
149
diff
changeset
|
97 _proportion = 1 |
103 | 98 elif type=="list": |
107 | 99 style=wx.LB_MULTIPLE if elem.getAttribute("multi")=='yes' else wx.LB_SINGLE |
760
73a0077f80cc
backend, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents:
759
diff
changeset
|
100 _options = [(option.getAttribute("label"), option.getAttribute("value")) for option in elem.getElementsByTagName("option")] |
73a0077f80cc
backend, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents:
759
diff
changeset
|
101 attr_map = {label: value for label, value in _options} |
73a0077f80cc
backend, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents:
759
diff
changeset
|
102 ctrl = wx.ListBox(parent, -1, choices=[option[0] for option in _options], style=style) |
73a0077f80cc
backend, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents:
759
diff
changeset
|
103 self.ctrl_list[name] = ({'type':type, 'control':ctrl, 'attr_map': attr_map}) |
103 | 104 _proportion = 1 |
105 | 105 elif type=="button": |
106 | 106 callback_id = elem.getAttribute("callback_id") |
107 ctrl = wx.Button(parent, -1, value) | |
107 | 108 ctrl.param_id = (callback_id,[field.getAttribute('name') for field in elem.getElementsByTagName("field_back")]) |
106 | 109 parent.Bind(wx.EVT_BUTTON, self.onButtonClicked, ctrl) |
103 | 110 else: |
111 error(_("FIXME FIXME FIXME: type [%s] is not implemented") % type) #FIXME ! | |
112 raise NotImplementedError | |
104 | 113 parent.sizer.Add(ctrl, _proportion, flag=wx.EXPAND) |
103 | 114 |
104 | 115 def __parseChilds(self, parent, current_param, elem, wanted = ['layout']): |
116 """Recursively parse childNodes of an elemen | |
117 @param parent: parent wx.Window | |
118 @param current_param: current wx.Window (often wx.Panel) or None if we must create one | |
119 @param elem: element from which childs will be parsed | |
120 @param wanted: list of tag names that can be present in the childs to be SàT XMLUI compliant""" | |
121 for node in elem.childNodes: | |
122 if wanted and not node.nodeName in wanted: | |
123 raise Exception("Invalid XMLUI") #TODO: make a custom exception | |
124 if node.nodeName == "layout": | |
105 | 125 _proportion = 0 |
104 | 126 type = node.getAttribute('type') |
127 if type == "tabs": | |
128 current = wx.Notebook(parent, -1, style=wx.NB_LEFT if self.type=='param' else 0) | |
129 self.__parseChilds(current, None, node, ['category']) | |
105 | 130 _proportion = 1 |
104 | 131 else: |
132 if current_param == None: | |
133 current = wx.Panel(parent, -1) | |
134 else: | |
135 current = current_param | |
136 if type == "vertical": | |
137 current.sizer = wx.BoxSizer(wx.VERTICAL) | |
138 elif type == "pairs": | |
139 current.sizer = wx.FlexGridSizer(cols=2) | |
140 current.sizer.AddGrowableCol(1) #The growable column need most of time to be the right one in pairs | |
141 else: | |
142 warning(_("Unknown layout, using default one")) | |
143 current.sizer = wx.BoxSizer(wx.VERTICAL) | |
144 current.SetSizer(current.sizer) | |
145 self.__parseElems(node, current) | |
146 if parent: | |
105 | 147 parent.sizer.Add(current, _proportion, flag=wx.EXPAND) |
104 | 148 elif node.nodeName == "category": |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
149 name = node.getAttribute('name') |
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
150 label = node.getAttribute('label') |
104 | 151 if not node.nodeName in wanted or not name or not isinstance(parent,wx.Notebook): |
152 raise Exception("Invalid XMLUI") #TODO: make a custom exception | |
153 notebook = parent | |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
154 tab_panel = wx.Panel(notebook, -1) |
104 | 155 tab_panel.sizer = wx.BoxSizer(wx.VERTICAL) |
156 tab_panel.SetSizer(tab_panel.sizer) | |
183
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
149
diff
changeset
|
157 notebook.AddPage(tab_panel, label or name) |
104 | 158 self.__parseChilds(tab_panel, None, node, ['layout']) |
159 | |
160 else: | |
161 message=_("Unknown tag") | |
162 error(message) | |
163 raise Exception(message) #TODO: raise a custom exception here | |
103 | 164 |
165 | |
166 def constructUI(self, xml_data): | |
35
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
167 panel=wx.Panel(self) |
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
168 panel.sizer = wx.BoxSizer(wx.VERTICAL) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
169 |
35
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
170 cat_dom = minidom.parseString(xml_data.encode('utf-8')) |
103 | 171 top= cat_dom.documentElement |
172 self.type = top.getAttribute("type") | |
107 | 173 self.title = top .getAttribute("title") |
760
73a0077f80cc
backend, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents:
759
diff
changeset
|
174 self.session_id = top.getAttribute("session_id") or None |
759
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
609
diff
changeset
|
175 self.submit_id = top.getAttribute("submit") or None |
107 | 176 if self.title: |
177 self.SetTitle(self.title) | |
103 | 178 if top.nodeName != "sat_xmlui" or not self.type in ['form', 'param', 'window']: |
104 | 179 raise Exception("Invalid XMLUI") #TODO: make a custom exception |
103 | 180 |
104 | 181 self.__parseChilds(panel, None, cat_dom.documentElement) |
35
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
182 |
103 | 183 if self.type == 'form': |
184 dialogButtons = wx.StdDialogButtonSizer() | |
185 submitButton = wx.Button(panel,wx.ID_OK, label=_("Submit")) | |
186 dialogButtons.AddButton(submitButton) | |
187 panel.Bind(wx.EVT_BUTTON, self.onFormSubmitted, submitButton) | |
188 if not 'NO_CANCEL' in self.options: | |
189 cancelButton = wx.Button(panel,wx.ID_CANCEL) | |
190 dialogButtons.AddButton(cancelButton) | |
191 panel.Bind(wx.EVT_BUTTON, self.onFormCancelled, cancelButton) | |
192 dialogButtons.Realize() | |
193 panel.sizer.Add(dialogButtons, flag=wx.ALIGN_CENTER_HORIZONTAL) | |
35
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
194 |
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
195 panel.SetSizer(panel.sizer) |
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
196 panel.SetAutoLayout(True) |
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
197 panel.sizer.Fit(self) |
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
198 self.sizer.Add(panel, 1, flag=wx.EXPAND) |
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
199 cat_dom.unlink() |
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
200 |
106 | 201 ###events |
202 | |
203 def onButtonClicked(self, event): | |
204 """Called when a button is pushed""" | |
107 | 205 callback_id, fields = event.GetEventObject().param_id |
206 for field in fields: | |
207 ctrl = self.ctrl_list[field] | |
208 if isinstance(ctrl['control'], wx.ListBox): | |
209 data[field] = '\t'.join([ctrl['control'].GetString(idx) for idx in ctrl['control'].GetSelections()]) | |
210 else: | |
211 data[field] = ctrl['control'].GetValue() | |
212 | |
759
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
609
diff
changeset
|
213 self.host.launchAction(callback_id, None, profile_key = self.host.profile) |
106 | 214 event.Skip() |
215 | |
36 | 216 def onFormSubmitted(self, event): |
217 """Called when submit button is clicked""" | |
70 | 218 debug(_("Submitting form")) |
760
73a0077f80cc
backend, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents:
759
diff
changeset
|
219 selected_values = [] |
107 | 220 for ctrl_name in self.ctrl_list: |
762
aed7d99276b8
core (xml_tools), frontends: added a prefix to XMLUI form names in result data, to avoid name conflicts (e.g.: if a form has name "submit", and this name is also used internally by SàT)
Goffi <goffi@goffi.org>
parents:
760
diff
changeset
|
221 escaped = u"%s%s" % (SAT_FORM_PREFIX, ctrl_name) |
107 | 222 ctrl = self.ctrl_list[ctrl_name] |
91 | 223 if isinstance(ctrl['control'], wx.ListBox): |
760
73a0077f80cc
backend, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents:
759
diff
changeset
|
224 label = ctrl['control'].GetStringSelection() |
73a0077f80cc
backend, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents:
759
diff
changeset
|
225 value = ctrl['attr_map'][label] |
762
aed7d99276b8
core (xml_tools), frontends: added a prefix to XMLUI form names in result data, to avoid name conflicts (e.g.: if a form has name "submit", and this name is also used internally by SàT)
Goffi <goffi@goffi.org>
parents:
760
diff
changeset
|
226 selected_values.append((escaped, value)) |
183
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
149
diff
changeset
|
227 elif isinstance(ctrl['control'], wx.CheckBox): |
762
aed7d99276b8
core (xml_tools), frontends: added a prefix to XMLUI form names in result data, to avoid name conflicts (e.g.: if a form has name "submit", and this name is also used internally by SàT)
Goffi <goffi@goffi.org>
parents:
760
diff
changeset
|
228 selected_values.append((escaped, "true" if ctrl['control'].GetValue() else "false")) |
91 | 229 else: |
762
aed7d99276b8
core (xml_tools), frontends: added a prefix to XMLUI form names in result data, to avoid name conflicts (e.g.: if a form has name "submit", and this name is also used internally by SàT)
Goffi <goffi@goffi.org>
parents:
760
diff
changeset
|
230 selected_values.append((escaped, ctrl['control'].GetValue())) |
91 | 231 if self.misc.has_key('action_back'): #FIXME FIXME FIXME: WTF ! Must be cleaned |
760
73a0077f80cc
backend, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents:
759
diff
changeset
|
232 id = self.misc['action_back']("SUBMIT",self.misc['target'], selected_values) |
91 | 233 self.host.current_action_ids.add(id) |
234 elif self.misc.has_key('callback'): | |
760
73a0077f80cc
backend, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents:
759
diff
changeset
|
235 self.misc['callback'](selected_values) |
759
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
609
diff
changeset
|
236 |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
609
diff
changeset
|
237 elif self.submit_id is not None: |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
609
diff
changeset
|
238 data = dict(selected_values) |
760
73a0077f80cc
backend, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents:
759
diff
changeset
|
239 if self.session_id is not None: |
73a0077f80cc
backend, frontends: XMLUI refactoring:
Goffi <goffi@goffi.org>
parents:
759
diff
changeset
|
240 data["session_id"] = self.session_id |
759
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
609
diff
changeset
|
241 self.host.launchAction(self.submit_id, data, profile_key=self.host.profile) |
91 | 242 else: |
243 warning (_("The form data is not sent back, the type is not managed properly")) | |
37
a61beb21d16d
Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents:
36
diff
changeset
|
244 self.MakeModal(False) |
a61beb21d16d
Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents:
36
diff
changeset
|
245 self.Destroy() |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
246 |
36 | 247 def onFormCancelled(self, event): |
248 """Called when cancel button is clicked""" | |
70 | 249 debug(_("Cancelling form")) |
37
a61beb21d16d
Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents:
36
diff
changeset
|
250 self.MakeModal(False) |
a61beb21d16d
Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents:
36
diff
changeset
|
251 self.Close() |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
252 |
35
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
253 def onClose(self, event): |
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
254 """Close event: we have to send the form.""" |
70 | 255 debug(_("close")) |
35
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
256 self.MakeModal(False) |
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
257 event.Skip() |
c45deebb40a5
Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
258 |