comparison 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
comparison
equal deleted inserted replaced
22:bb72c29f3432 23:925ab466c5ec
23 23
24 import wx 24 import wx
25 import pdb 25 import pdb
26 from xml.dom import minidom 26 from xml.dom import minidom
27 from logging import debug, info, error 27 from logging import debug, info, error
28 from tools.jid import JID
28 29
29 30
30 class Param(wx.Frame): 31 class Param(wx.Frame):
31 def __init__(self, host, title="Configuration"): 32 def __init__(self, host, title="Configuration"):
32 super(Param, self).__init__(None, title=title) 33 super(Param, self).__init__(None, title=title)
33 34
34 self.host = host 35 self.host = host
35 36
36 self.modified={} # dict of modified data (i.e. what we have to save) 37 self.modified = {} # dict of modified data (i.e. what we have to save)
38 self.ctl_list = {} # usefull to access ctrl, key = (name, category)
37 39
38 self.sizer = wx.BoxSizer(wx.VERTICAL) 40 self.sizer = wx.BoxSizer(wx.VERTICAL)
39 self.notebook=wx.Notebook(self, -1, style=wx.NB_LEFT) 41 self.notebook=wx.Notebook(self, -1, style=wx.NB_LEFT)
40 self.sizer.Add(self.notebook, 1, flag=wx.EXPAND) 42 self.sizer.Add(self.notebook, 1, flag=wx.EXPAND)
41 self.SetSizer(self.sizer) 43 self.SetSizer(self.sizer)
75 else: 77 else:
76 error("FIXME FIXME FIXME") #FIXME ! 78 error("FIXME FIXME FIXME") #FIXME !
77 raise NotImplementedError 79 raise NotImplementedError
78 ctrl.param_id=(name, category) 80 ctrl.param_id=(name, category)
79 sizer.Add(ctrl, 1, flag=wx.EXPAND) 81 sizer.Add(ctrl, 1, flag=wx.EXPAND)
82 self.ctl_list[(name, category)] = ctrl
80 panel.sizer.Add(sizer, flag=wx.EXPAND) 83 panel.sizer.Add(sizer, flag=wx.EXPAND)
81 84
82 if type=="string" or type=="password": 85 if type=="string" or type=="password":
83 panel.Bind(wx.EVT_TEXT, self.onTextChanged, ctrl) 86 panel.Bind(wx.EVT_TEXT, self.onTextChanged, ctrl)
84 elif type=="button": 87 elif type=="button":
90 cat_dom.unlink() 93 cat_dom.unlink()
91 94
92 def onTextChanged(self, event): 95 def onTextChanged(self, event):
93 """Called when a paramated is modified""" 96 """Called when a paramated is modified"""
94 self.modified[event.GetEventObject().param_id]=event.GetString() 97 self.modified[event.GetEventObject().param_id]=event.GetString()
98
99 ### FIXME # Some hacks for better presentation, should be generic # FIXME ###
100 if event.GetEventObject().param_id == ('JabberID', 'Connection'):
101 domain = JID(event.GetString()).domain
102 self.ctl_list[('Server', 'Connection')].SetValue(domain)
103 self.modified[('Server', 'Connection')] = domain
104
95 event.Skip() 105 event.Skip()
96 106
97 def onButtonClicked(self, event): 107 def onButtonClicked(self, event):
98 """Called when a paramated is modified""" 108 """Called when a paramated is modified"""
109 self.__save_parameters()
99 print "Button Clicked (%s/%s)" % event.GetEventObject().param_id 110 print "Button Clicked (%s/%s)" % event.GetEventObject().param_id
100 name, category = event.GetEventObject().param_id 111 name, category = event.GetEventObject().param_id
101 data = {"name":name, "category":category} 112 data = {"name":name, "category":category}
102 id = self.host.bridge.launchAction("button", data) 113 id = self.host.bridge.launchAction("button", data)
103 self.host.current_action_ids.add(id) 114 self.host.current_action_ids.add(id)
104 print "action id:",id 115 print "action id:",id
105 event.Skip() 116 event.Skip()
106 117
118 def __save_parameters(self):
119 for param in self.modified:
120 self.host.bridge.setParam(param[0], self.modified[param], param[1])
121 self.modified.clear()
122
107 def onClose(self, event): 123 def onClose(self, event):
108 """Close event: we have to save the params.""" 124 """Close event: we have to save the params."""
109 debug("close") 125 debug("close")
110 #now we save the modifier params 126 #now we save the modifier params
111 for param in self.modified: 127 self.__save_parameters()
112 self.host.bridge.setParam(param[0], self.modified[param], param[1])
113 128
114 self.MakeModal(False) 129 self.MakeModal(False)
115 event.Skip() 130 event.Skip()
116 131