Mercurial > libervia-backend
comparison frontends/src/wix/main_window.py @ 1106:e2e1e27a3680
frontends: XMLUI refactoring + dialogs:
- there are now XMLUIPanel and XMLUIDialog both inheriting from XMLUIBase
- following dialogs are managed:
- MessageDialog
- NoteDialog
- ConfirmDialog
- FileDialog
- XMLUI creation is now made using xmlui.create(...) instead of instanciating directly XMLUI
- classes must be registed in frontends
- "parent" attribute renamed to "_xmlui_parent" to avoid name conflicts with frontends toolkits
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 13 Aug 2014 14:48:49 +0200 |
parents | a096b8579a3c |
children | 75025461141f |
comparison
equal
deleted
inserted
replaced
1105:018bdd687747 | 1106:e2e1e27a3680 |
---|---|
23 from sat_frontends.quick_frontend.quick_chat_list import QuickChatList | 23 from sat_frontends.quick_frontend.quick_chat_list import QuickChatList |
24 from sat_frontends.quick_frontend.quick_app import QuickApp | 24 from sat_frontends.quick_frontend.quick_app import QuickApp |
25 import wx | 25 import wx |
26 from sat_frontends.wix.contact_list import ContactList | 26 from sat_frontends.wix.contact_list import ContactList |
27 from sat_frontends.wix.chat import Chat | 27 from sat_frontends.wix.chat import Chat |
28 from sat_frontends.wix.xmlui import XMLUI | 28 from sat_frontends.wix import xmlui |
29 from sat_frontends.wix.profile import Profile | 29 from sat_frontends.wix.profile import Profile |
30 from sat_frontends.wix.profile_manager import ProfileManager | 30 from sat_frontends.wix.profile_manager import ProfileManager |
31 import os.path | 31 import os.path |
32 from sat.tools.jid import JID | 32 from sat.tools.jid import JID |
33 from sat.core.log import getLogger | 33 from sat.core.log import getLogger |
190 x=(wx.DisplaySize()[0]-popup.GetSize()[0])/2 | 190 x=(wx.DisplaySize()[0]-popup.GetSize()[0])/2 |
191 popup.SetPosition((x,0)) | 191 popup.SetPosition((x,0)) |
192 popup.Show() | 192 popup.Show() |
193 wx.CallLater(5000,popup.Destroy) | 193 wx.CallLater(5000,popup.Destroy) |
194 | 194 |
195 def showDialog(self, message, title="", type="info", answer_cb = None, answer_data = None): | 195 def showDialog(self, message, title="", type_="info", answer_cb = None, answer_data = None): |
196 if type == 'info': | 196 if type_ == 'info': |
197 flags = wx.OK | wx.ICON_INFORMATION | 197 flags = wx.OK | wx.ICON_INFORMATION |
198 elif type == 'error': | 198 elif type_ == 'error': |
199 flags = wx.OK | wx.ICON_ERROR | 199 flags = wx.OK | wx.ICON_ERROR |
200 elif type == 'yes/no': | 200 elif type_ == 'yes/no': |
201 flags = wx.YES_NO | wx.ICON_QUESTION | 201 flags = wx.YES_NO | wx.ICON_QUESTION |
202 else: | 202 else: |
203 flags = wx.OK | wx.ICON_INFORMATION | 203 flags = wx.OK | wx.ICON_INFORMATION |
204 log.error(_('unmanaged dialog type: %s'), type) | 204 log.error(_('unmanaged dialog type: %s'), type_) |
205 dlg = wx.MessageDialog(self, message, title, flags) | 205 dlg = wx.MessageDialog(self, message, title, flags) |
206 answer = dlg.ShowModal() | 206 answer = dlg.ShowModal() |
207 dlg.Destroy() | 207 dlg.Destroy() |
208 if answer_cb: | 208 if answer_cb: |
209 data = [answer_data] if answer_data else [] | 209 data = [answer_data] if answer_data else [] |
241 if not data: | 241 if not data: |
242 # action was a one shot, nothing to do | 242 # action was a one shot, nothing to do |
243 pass | 243 pass |
244 elif "xmlui" in data: | 244 elif "xmlui" in data: |
245 log.debug (_("XML user interface received")) | 245 log.debug (_("XML user interface received")) |
246 XMLUI(self, xml_data = data['xmlui']) | 246 ui = xmlui.create(self, xml_data = data['xmlui']) |
247 ui.show() | |
247 elif "authenticated_profile" in data: | 248 elif "authenticated_profile" in data: |
248 assert("caller" in data) | 249 assert("caller" in data) |
249 if data["caller"] == "profile_manager": | 250 if data["caller"] == "profile_manager": |
250 assert(self.profile_pan.IsShown()) | 251 assert(self.profile_pan.IsShown()) |
251 self.profile_pan.getXMPPParams(data['authenticated_profile']) | 252 self.profile_pan.getXMPPParams(data['authenticated_profile']) |
343 title = _('Form') | 344 title = _('Form') |
344 if data['type_'] == _('registration'): | 345 if data['type_'] == _('registration'): |
345 title = _('Registration') | 346 title = _('Registration') |
346 misc['target'] = data['target'] | 347 misc['target'] = data['target'] |
347 misc['action_back'] = self.bridge.gatewayRegister | 348 misc['action_back'] = self.bridge.gatewayRegister |
348 XMLUI(self, title=title, xml_data = data['xml'], misc = misc) | 349 xmlui.create(self, title=title, xml_data = data['xml'], misc = misc) |
349 elif type_ == "RESULT": | 350 elif type_ == "RESULT": |
350 self.current_action_ids.remove(id_) | 351 self.current_action_ids.remove(id_) |
351 if self.current_action_ids_cb.has_key(id_): | 352 if self.current_action_ids_cb.has_key(id_): |
352 callback = self.current_action_ids_cb[id_] | 353 callback = self.current_action_ids_cb[id_] |
353 del self.current_action_ids_cb[id_] | 354 del self.current_action_ids_cb[id_] |
411 self.__updateStatus() | 412 self.__updateStatus() |
412 | 413 |
413 def onParam(self, e): | 414 def onParam(self, e): |
414 log.debug(_("Param request")) | 415 log.debug(_("Param request")) |
415 def success(params): | 416 def success(params): |
416 XMLUI(self, xml_data=params, title=_("Configuration")) | 417 xmlui.create(self, xml_data=params, title=_("Configuration")) |
417 | 418 |
418 def failure(error): | 419 def failure(error): |
419 dlg = wx.MessageDialog(self, error.message, | 420 dlg = wx.MessageDialog(self, error.message, |
420 error.fullname, | 421 error.fullname, |
421 wx.OK | wx.ICON_ERROR | 422 wx.OK | wx.ICON_ERROR |