--- nfo/projects/netfraggle/bin/fraggleDialogPrefs.py 2004/08/27 21:14:02 1.6 +++ nfo/projects/netfraggle/bin/fraggleDialogPrefs.py 2004/08/30 12:51:36 1.9 @@ -89,6 +89,9 @@ parent=self, pos=wxPoint(80, 8), size=wxSize(124, 16), style=0, validator=wxDefaultValidator, value='') self.comboBoxProfile.SetLabel('') + EVT_COMBOBOX(self.comboBoxProfile, + wxID_FRAGGLEDIALOGPREFSCOMBOBOXPROFILE, + self.OnComboboxprofileCombobox) self.staticText6 = wxStaticText(id=wxID_FRAGGLEDIALOGPREFSSTATICTEXT6, label='Profile', name='staticText6', parent=self, pos=wxPoint(16, @@ -97,19 +100,35 @@ self.buttonProfileSave = wxButton(id=wxID_FRAGGLEDIALOGPREFSBUTTONPROFILESAVE, label='Save', name='buttonProfileSave', parent=self, pos=wxPoint(272, 8), size=wxSize(40, 16), style=0) + EVT_BUTTON(self.buttonProfileSave, + wxID_FRAGGLEDIALOGPREFSBUTTONPROFILESAVE, + self.OnButtonprofilesaveButton) self.buttonProfileDel = wxButton(id=wxID_FRAGGLEDIALOGPREFSBUTTONPROFILEDEL, label='Delete', name='buttonProfileDel', parent=self, pos=wxPoint(320, 8), size=wxSize(40, 16), style=0) + EVT_BUTTON(self.buttonProfileDel, + wxID_FRAGGLEDIALOGPREFSBUTTONPROFILEDEL, + self.OnButtonprofiledelButton) self.buttonProfileLoad = wxButton(id=wxID_FRAGGLEDIALOGPREFSBUTTONPROFILELOAD, label='Load', name='buttonProfileLoad', parent=self, pos=wxPoint(216, 8), size=wxSize(48, 16), style=0) - + EVT_BUTTON(self.buttonProfileLoad, + wxID_FRAGGLEDIALOGPREFSBUTTONPROFILELOAD, + self.OnButtonprofileloadButton) + + def __init_profiles(self): + list = self.parent.preferencesCtl.getProfileList() + print list + for i in list: + self.comboBoxProfile.Append(i) + def __init__(self, parent): self.parent = parent self._init_ctrls(parent) - + self.__init_profiles() + def OnBtsaveButton(self, event): # convert from utf-8: required for win32 @@ -128,18 +147,51 @@ event.Skip() def loadConfig(self): - engine = FraggleEngine() - prefsfile = os.path.join(engine.getDefaultDir(), 'prefs.xml') + prefsfile = os.path.join(self.parent.preferencesCtl.getDefaultDir(), 'prefs.xml') self.parent.preferencesCtl.loadConfig(prefsfile) def updateConfig(self): config = self.parent.preferencesCtl.getConfig() - self.textCtrlUsername.SetValue(config["username"]) - self.textCtrlPassword.SetValue(config["password"]) - self.textCtrlServer.SetValue(config["url"]) - self.textCtrlRetrieval.SetValue(config["retrieval"]) - + try: + self.textCtrlUsername.SetValue(config["username"]) + self.textCtrlPassword.SetValue(config["password"]) + self.textCtrlServer.SetValue(config["url"]) + self.textCtrlRetrieval.SetValue(config["retrieval"]) + except TypeError: + self.textCtrlUsername.SetValue("username") + self.textCtrlPassword.SetValue("password") + self.textCtrlServer.SetValue("url") + self.textCtrlRetrieval.SetValue("retrieval") + def OnButton1Button(self, event): self.Hide() event.Skip() + + def OnButtonprofilesaveButton(self, event): + username = self.textCtrlUsername.GetValue() + password = self.textCtrlPassword.GetValue() + url = self.textCtrlServer.GetValue() + retrieval = self.textCtrlRetrieval.GetValue() + self.parent.preferencesCtl.setConfig(username,password,url,retrieval) + i = self.parent.preferencesCtl.appendProfile(self.comboBoxProfile.GetValue(),self.parent.preferencesCtl.configList) + if i == 0: + self.comboBoxProfile.Append(self.comboBoxProfile.GetValue()) + + self.parent.preferencesCtl.saveProfiles() + event.Skip() + + def OnButtonprofileloadButton(self, event): + self.parent.preferencesCtl.loadProfile(self.comboBoxProfile.GetValue()) + self.updateConfig() + event.Skip() + + def OnButtonprofiledelButton(self, event): + self.parent.preferencesCtl.deleteProfile(self.comboBoxProfile.GetValue()) + self.comboBoxProfile.Delete(self.comboBoxProfile.FindString(self.comboBoxProfile.GetValue())) + self.parent.preferencesCtl.saveProfiles() + self.updateConfig() + event.Skip() + + def OnComboboxprofileCombobox(self, event): + event.Skip() \ No newline at end of file