comparison frontends/src/wix/profile_manager.py @ 587:952322b1d490

Remove trailing whitespaces.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Fri, 18 Jan 2013 17:55:34 +0100
parents ca13633d3b6b
children 84a6e83157c2
comparison
equal deleted inserted replaced
586:6a718ede8be1 587:952322b1d490
54 button_panel.sizer.Add(button_new) 54 button_panel.sizer.Add(button_new)
55 button_panel.sizer.Add(button_del) 55 button_panel.sizer.Add(button_del)
56 self.sizer.Add(button_panel, flag=wx.CENTER) 56 self.sizer.Add(button_panel, flag=wx.CENTER)
57 self.Bind(wx.EVT_BUTTON, self.onNewProfile, button_new) 57 self.Bind(wx.EVT_BUTTON, self.onNewProfile, button_new)
58 self.Bind(wx.EVT_BUTTON, self.onDeleteProfile, button_del) 58 self.Bind(wx.EVT_BUTTON, self.onDeleteProfile, button_del)
59 59
60 login_box = wx.StaticBox(self, -1, _("Login")) 60 login_box = wx.StaticBox(self, -1, _("Login"))
61 self.login_sizer = wx.StaticBoxSizer(login_box, wx.VERTICAL) 61 self.login_sizer = wx.StaticBoxSizer(login_box, wx.VERTICAL)
62 self.sizer.Add(self.login_sizer, 1, wx.EXPAND | wx.ALL) 62 self.sizer.Add(self.login_sizer, 1, wx.EXPAND | wx.ALL)
63 self.login_jid = wx.TextCtrl(self, -1) 63 self.login_jid = wx.TextCtrl(self, -1)
64 self.login_sizer.Add(wx.StaticText(self, -1, "JID:"), 0, flag=wx.ALIGN_CENTER) 64 self.login_sizer.Add(wx.StaticText(self, -1, "JID:"), 0, flag=wx.ALIGN_CENTER)
65 self.login_sizer.Add(self.login_jid, flag=wx.EXPAND) 65 self.login_sizer.Add(self.login_jid, flag=wx.EXPAND)
66 self.login_pass = wx.TextCtrl(self, -1, style = wx.TE_PASSWORD) 66 self.login_pass = wx.TextCtrl(self, -1, style = wx.TE_PASSWORD)
67 self.login_sizer.Add(wx.StaticText(self, -1, _("Password:")), 0, flag=wx.ALIGN_CENTER) 67 self.login_sizer.Add(wx.StaticText(self, -1, _("Password:")), 0, flag=wx.ALIGN_CENTER)
68 self.login_sizer.Add(self.login_pass, flag=wx.EXPAND) 68 self.login_sizer.Add(self.login_pass, flag=wx.EXPAND)
69 69
70 loggin_button = wx.Button(self, -1, _("Connect")) 70 loggin_button = wx.Button(self, -1, _("Connect"))
71 self.Bind(wx.EVT_BUTTON, self.onConnectButton, loggin_button) 71 self.Bind(wx.EVT_BUTTON, self.onConnectButton, loggin_button)
72 self.login_sizer.Add(loggin_button, flag=wx.ALIGN_CENTER) 72 self.login_sizer.Add(loggin_button, flag=wx.ALIGN_CENTER)
73 73
74 self.sizer.Add(wx.Window(self, -1), 1) 74 self.sizer.Add(wx.Window(self, -1), 1)
75 75
76 #Now we can set the default value 76 #Now we can set the default value
77 self.__setDefault() 77 self.__setDefault()
78 78
79 79
80 def __setDefault(self): 80 def __setDefault(self):
81 profile_default = self.host.bridge.getProfileName("@DEFAULT@") 81 profile_default = self.host.bridge.getProfileName("@DEFAULT@")
82 if profile_default: 82 if profile_default:
83 self.profile_name.SetValue(profile_default) 83 self.profile_name.SetValue(profile_default)
84 self.onProfileChange(None) 84 self.onProfileChange(None)
85 85
86 def __refillProfiles(self): 86 def __refillProfiles(self):
87 """Update profiles with current names. Must be called after a profile change""" 87 """Update profiles with current names. Must be called after a profile change"""
88 self.profile_name.Clear() 88 self.profile_name.Clear()
89 profiles = self.host.bridge.getProfilesList() 89 profiles = self.host.bridge.getProfilesList()
90 profiles.sort() 90 profiles.sort()
91 for profile in profiles: 91 for profile in profiles:
92 self.profile_name.Append(profile) 92 self.profile_name.Append(profile)
93 93
94 94
95 def onNewProfile(self, event): 95 def onNewProfile(self, event):
96 dlg = wx.TextEntryDialog(self, _("Please enter the new profile name"), _("New profile"), style = wx.OK | wx.CANCEL) 96 dlg = wx.TextEntryDialog(self, _("Please enter the new profile name"), _("New profile"), style = wx.OK | wx.CANCEL)
97 if dlg.ShowModal() == wx.ID_OK: 97 if dlg.ShowModal() == wx.ID_OK:
98 name = dlg.GetValue() 98 name = dlg.GetValue()
99 if name: 99 if name:
102 else: 102 else:
103 profile = self.host.bridge.createProfile(name) 103 profile = self.host.bridge.createProfile(name)
104 self.__refillProfiles() 104 self.__refillProfiles()
105 self.profile_name.SetValue(name) 105 self.profile_name.SetValue(name)
106 dlg.Destroy() 106 dlg.Destroy()
107 107
108 def onDeleteProfile(self, event): 108 def onDeleteProfile(self, event):
109 name = self.profile_name.GetValue() 109 name = self.profile_name.GetValue()
110 if not name: 110 if not name:
111 return 111 return
112 dlg = wx.MessageDialog(self, _("Are you sure to delete the profile [%s]") % name, _("Confirmation"), wx.ICON_QUESTION | wx.YES_NO) 112 dlg = wx.MessageDialog(self, _("Are you sure to delete the profile [%s]") % name, _("Confirmation"), wx.ICON_QUESTION | wx.YES_NO)
134 if name[0]=='@': 134 if name[0]=='@':
135 wx.MessageDialog(self, _("A profile name can't start with a @"), _("Bad profile name"), wx.ICON_ERROR).ShowModal() 135 wx.MessageDialog(self, _("A profile name can't start with a @"), _("Bad profile name"), wx.ICON_ERROR).ShowModal()
136 return 136 return
137 profile = self.host.bridge.getProfileName(name) 137 profile = self.host.bridge.getProfileName(name)
138 assert(profile) 138 assert(profile)
139 139
140 self.host.bridge.asyncGetParamA("JabberID", "Connection", profile_key=profile, callback=lambda old_jid: self.__old_jidReceived(old_jid, profile), errback=self.getParamError) 140 self.host.bridge.asyncGetParamA("JabberID", "Connection", profile_key=profile, callback=lambda old_jid: self.__old_jidReceived(old_jid, profile), errback=self.getParamError)
141 141
142 def __old_jidReceived(self, old_jid, profile): 142 def __old_jidReceived(self, old_jid, profile):
143 self.host.bridge.asyncGetParamA("Password", "Connection", profile_key=profile, callback=lambda old_pass: self.__old_passReceived(old_jid, old_pass, profile), errback=self.getParamError) 143 self.host.bridge.asyncGetParamA("Password", "Connection", profile_key=profile, callback=lambda old_pass: self.__old_passReceived(old_jid, old_pass, profile), errback=self.getParamError)
144 144
145 def __old_passReceived(self, old_jid, old_pass, profile): 145 def __old_passReceived(self, old_jid, old_pass, profile):
146 new_jid = self.login_jid.GetValue() 146 new_jid = self.login_jid.GetValue()
147 new_pass = self.login_pass.GetValue() 147 new_pass = self.login_pass.GetValue()
148 if old_jid != new_jid: 148 if old_jid != new_jid:
149 debug(_('Saving new JID and server')) 149 debug(_('Saving new JID and server'))
151 self.host.bridge.setParam("Server", JID(new_jid).domain, "Connection", profile) 151 self.host.bridge.setParam("Server", JID(new_jid).domain, "Connection", profile)
152 if old_pass != new_pass: 152 if old_pass != new_pass:
153 debug(_('Saving new password')) 153 debug(_('Saving new password'))
154 self.host.bridge.setParam("Password", new_pass, "Connection", profile) 154 self.host.bridge.setParam("Password", new_pass, "Connection", profile)
155 self.host.plug_profile(profile) 155 self.host.plug_profile(profile)
156 156
157 157
158 def getParamError(self, ignore): 158 def getParamError(self, ignore):
159 wx.MessageDialog(self, _("Can't get profile parameter"), _("Profile error"), wx.ICON_ERROR).ShowModal() 159 wx.MessageDialog(self, _("Can't get profile parameter"), _("Profile error"), wx.ICON_ERROR).ShowModal()