diff frontends/wix/param.py @ 23:925ab466c5ec

better presentation for register new account - error message when no user, pass or server given - server is now automatically updated when jid change in connection category
author Goffi <goffi@goffi.org>
date Tue, 01 Dec 2009 06:07:20 +0100
parents bb72c29f3432
children a544b376b6f0
line wrap: on
line diff
--- a/frontends/wix/param.py	Tue Dec 01 04:56:08 2009 +0100
+++ b/frontends/wix/param.py	Tue Dec 01 06:07:20 2009 +0100
@@ -25,6 +25,7 @@
 import pdb
 from xml.dom import minidom
 from logging import debug, info, error
+from tools.jid  import JID
 
 
 class Param(wx.Frame):
@@ -33,7 +34,8 @@
 
         self.host = host
 
-        self.modified={}  # dict of modified data (i.e. what we have to save)
+        self.modified = {}  # dict of modified data (i.e. what we have to save)
+        self.ctl_list = {}  # usefull to access ctrl, key = (name, category)
 
         self.sizer = wx.BoxSizer(wx.VERTICAL)
         self.notebook=wx.Notebook(self, -1, style=wx.NB_LEFT)
@@ -77,6 +79,7 @@
                 raise NotImplementedError
             ctrl.param_id=(name, category)
             sizer.Add(ctrl, 1, flag=wx.EXPAND)
+            self.ctl_list[(name, category)] = ctrl
             panel.sizer.Add(sizer, flag=wx.EXPAND)
 
             if type=="string" or type=="password":
@@ -92,10 +95,18 @@
     def onTextChanged(self, event):
         """Called when a paramated is modified"""
         self.modified[event.GetEventObject().param_id]=event.GetString()
+        
+        ### FIXME # Some hacks for better presentation, should be generic # FIXME ###
+        if event.GetEventObject().param_id == ('JabberID', 'Connection'):
+            domain = JID(event.GetString()).domain
+            self.ctl_list[('Server', 'Connection')].SetValue(domain)
+            self.modified[('Server', 'Connection')] = domain 
+
         event.Skip()
         
     def onButtonClicked(self, event):
         """Called when a paramated is modified"""
+        self.__save_parameters()
         print "Button Clicked (%s/%s)" % event.GetEventObject().param_id
         name, category = event.GetEventObject().param_id
         data = {"name":name, "category":category}
@@ -104,12 +115,16 @@
         print "action id:",id
         event.Skip()
 
+    def __save_parameters(self):
+        for param in self.modified:
+            self.host.bridge.setParam(param[0], self.modified[param], param[1])
+        self.modified.clear()
+
     def onClose(self, event):
         """Close event: we have to save the params."""
         debug("close")
         #now we save the modifier params
-        for param in self.modified:
-            self.host.bridge.setParam(param[0], self.modified[param], param[1])
+        self.__save_parameters()
 
         self.MakeModal(False)
         event.Skip()