comparison frontends/src/wix/profile_manager.py @ 893:308a96bc7c1b

core, frontends: add method asyncDeleteProfile, remove synchronous methods createProfile and deleteProfile
author souliane <souliane@mailoo.org>
date Mon, 03 Mar 2014 09:59:10 +0100
parents 1fe00f0c9a91
children 5a6354ff468c
comparison
equal deleted inserted replaced
892:58107179cd97 893:308a96bc7c1b
19 19
20 20
21 21
22 from sat.core.i18n import _ 22 from sat.core.i18n import _
23 import wx 23 import wx
24 import pdb
25 from logging import debug, info, error 24 from logging import debug, info, error
26 from sat.tools.jid import JID 25 from sat.tools.jid import JID
27 import pdb
28 26
29 27
30 class ProfileManager(wx.Panel): 28 class ProfileManager(wx.Panel):
31 def __init__(self, host): 29 def __init__(self, host):
32 super(ProfileManager, self).__init__(host) 30 super(ProfileManager, self).__init__(host)
97 name = dlg.GetValue() 95 name = dlg.GetValue()
98 if name: 96 if name:
99 if name[0]=='@': 97 if name[0]=='@':
100 wx.MessageDialog(self, _("A profile name can't start with a @"), _("Bad profile name"), wx.ICON_ERROR).ShowModal() 98 wx.MessageDialog(self, _("A profile name can't start with a @"), _("Bad profile name"), wx.ICON_ERROR).ShowModal()
101 else: 99 else:
102 profile = self.host.bridge.createProfile(name) 100 def cb():
103 self.__refillProfiles() 101 self.__refillProfiles()
104 self.profile_name.SetValue(name) 102 self.profile_name.SetValue(name)
103 self.host.bridge.asyncCreateProfile(name, callback=cb)
105 dlg.Destroy() 104 dlg.Destroy()
106 105
107 def onDeleteProfile(self, event): 106 def onDeleteProfile(self, event):
108 name = self.profile_name.GetValue() 107 name = self.profile_name.GetValue()
109 if not name: 108 if not name:
110 return 109 return
111 dlg = wx.MessageDialog(self, _("Are you sure to delete the profile [%s]") % name, _("Confirmation"), wx.ICON_QUESTION | wx.YES_NO) 110 dlg = wx.MessageDialog(self, _("Are you sure to delete the profile [%s]") % name, _("Confirmation"), wx.ICON_QUESTION | wx.YES_NO)
112 if dlg.ShowModal() == wx.ID_YES: 111 if dlg.ShowModal() == wx.ID_YES:
113 self.host.bridge.deleteProfile(name) 112 def cb():
114 self.__refillProfiles() 113 self.__refillProfiles()
115 self.__setDefault() 114 self.__setDefault()
115 self.host.bridge.asyncDeleteProfile(name, callback=cb)
116 dlg.Destroy() 116 dlg.Destroy()
117 117
118 def onProfileChange(self, event): 118 def onProfileChange(self, event):
119 """Called when a profile is choosen in the combo box""" 119 """Called when a profile is choosen in the combo box"""
120 def setJID(jabberID): 120 def setJID(jabberID):