[Idle-dev] CVS: idle configDialog.py,1.29,1.30
Stephen M. Gava
elguavas@users.sourceforge.net
Tue, 29 Jan 2002 00:34:44 -0800
Update of /cvsroot/idlefork/idle
In directory usw-pr-cvs1:/tmp/cvs-serv3404
Modified Files:
configDialog.py
Log Message:
further work on config saving
Index: configDialog.py
===================================================================
RCS file: /cvsroot/idlefork/idle/configDialog.py,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -r1.29 -r1.30
*** configDialog.py 2002/01/24 06:02:50 1.29
--- configDialog.py 2002/01/29 08:34:41 1.30
***************
*** 43,50 ****
#that config file section.
self.changedItems={'main':{},'highlight':{},'keys':{},'extensions':{}}
! #defaultItems. This dictionary is loaded with the values from the
! #default config files. It is used for comparison with self.changedItems
! #to decide which changed items actually need saving.
! self.defaultItems=self.GetDefaultItems()
self.CreateWidgets()
self.resizable(height=FALSE,width=FALSE)
--- 43,50 ----
#that config file section.
self.changedItems={'main':{},'highlight':{},'keys':{},'extensions':{}}
! # #defaultItems. This dictionary is loaded with the values from the
! # #default config files. It is used for comparison with self.changedItems
! # #to decide which changed items actually need saving.
! # self.defaultItems=self.GetDefaultItems()
self.CreateWidgets()
self.resizable(height=FALSE,width=FALSE)
***************
*** 473,476 ****
--- 473,477 ----
def AddChangedItem(self,type,section,item,value):
+ value=str(value) #make sure we use a string
if not self.changedItems[type].has_key(section):
self.changedItems[type][section]={}
***************
*** 523,526 ****
--- 524,529 ----
'Enter a name for your new Custom Key Set below.')
usedNames=idleConf.GetSectionList('user','keys')
+ for newName in self.changedItems['keys'].keys():
+ if newName not in usedNames: usedNames.append(newName)
newKeySet=GetCfgSectionNameDialog(self,'New Custom Key Set',
message,usedNames)
***************
*** 558,562 ****
#change gui over to the new key set
customKeyList=idleConf.GetSectionList('user','keys')
! customKeyList.append(newKeySetName)
customKeyList.sort()
print newKeySetName,customKeyList,self.changedItems['keys'][newKeySetName]
--- 561,566 ----
#change gui over to the new key set
customKeyList=idleConf.GetSectionList('user','keys')
! for newName in self.changedItems['keys'].keys():
! if newName not in customKeyList: customKeyList.append(newName)
customKeyList.sort()
print newKeySetName,customKeyList,self.changedItems['keys'][newKeySetName]
***************
*** 575,578 ****
--- 579,584 ----
'Enter a name for your new Custom Theme below.')
usedNames=idleConf.GetSectionList('user','highlight')
+ for newName in self.changedItems['highlight'].keys():
+ if newName not in usedNames: usedNames.append(newName)
newTheme=GetCfgSectionNameDialog(self,'New Custom Theme',
message,usedNames)
***************
*** 602,606 ****
#change gui over to the new theme
customThemeList=idleConf.GetSectionList('user','highlight')
! customThemeList.append(newThemeName)
customThemeList.sort()
print newThemeName,customThemeList,newTheme
--- 608,613 ----
#change gui over to the new theme
customThemeList=idleConf.GetSectionList('user','highlight')
! for newName in self.changedItems['highlight'].keys():
! if newName not in customThemeList: customThemeList.append(newName)
customThemeList.sort()
print newThemeName,customThemeList,newTheme
***************
*** 806,824 ****
self.LoadGeneralCfg()
def SaveConfigs(self):
"""
save configuration changes to user config files.
"""
- #DEBUG
- print self.defaultItems
- print self.changedItems
for configType in self.changedItems.keys():
for section in self.changedItems[configType].keys():
for item in self.changedItems[configType][section].keys():
- #DEBUG
value=self.changedItems[configType][section][item]
! print configType, section, item, value
! print self.changedItems
!
def Cancel(self):
self.destroy()
--- 813,840 ----
self.LoadGeneralCfg()
+ def SetUserValue(self,configType,section,item,value):
+ print idleConf.defaultCfg[configType].Get(section,item),value
+ if idleConf.defaultCfg[configType].has_option(section,item):
+ if idleConf.defaultCfg[configType].Get(section,item)==value:
+ #the setting equals a default setting, remove it from user cfg
+ return idleConf.userCfg[configType].RemoveOption(section,item)
+ #if we got here set the option
+ return idleConf.userCfg[configType].SetOption(section,item,value)
+
def SaveConfigs(self):
"""
save configuration changes to user config files.
"""
for configType in self.changedItems.keys():
+ cfgTypeHasChanges=0
for section in self.changedItems[configType].keys():
for item in self.changedItems[configType][section].keys():
value=self.changedItems[configType][section][item]
! print configType,section,item,value
! if self.SetUserValue(configType,section,item,value):
! cfgTypeHasChanges=1
! if cfgTypeHasChanges:
! idleConf.userCfg[configType].Save()
!
def Cancel(self):
self.destroy()