[Idle-dev] CVS: idle configDialog.py,1.36,1.37
Stephen M. Gava
elguavas@users.sourceforge.net
Sun, 17 Feb 2002 17:42:10 -0800
Update of /cvsroot/idlefork/idle
In directory usw-pr-cvs1:/tmp/cvs-serv19166
Modified Files:
configDialog.py
Log Message:
handle user theme and key set deletion
Index: configDialog.py
===================================================================
RCS file: /cvsroot/idlefork/idle/configDialog.py,v
retrieving revision 1.36
retrieving revision 1.37
diff -C2 -r1.36 -r1.37
*** configDialog.py 11 Feb 2002 03:45:22 -0000 1.36
--- configDialog.py 18 Feb 2002 01:42:08 -0000 1.37
***************
*** 227,231 ****
self.optMenuThemeCustom=DynOptionMenu(frameTheme,
self.customTheme,None,command=None)
! self.buttonDeleteCustomTheme=Button(frameTheme,text='Delete Custom Theme')
##widget packing
#body
--- 227,232 ----
self.optMenuThemeCustom=DynOptionMenu(frameTheme,
self.customTheme,None,command=None)
! self.buttonDeleteCustomTheme=Button(frameTheme,text='Delete Custom Theme',
! command=self.DeleteCustomTheme)
##widget packing
#body
***************
*** 294,298 ****
self.optMenuKeysCustom=DynOptionMenu(frameKeySets,
self.customKeys,None,command=None)
! self.buttonDeleteCustomKeys=Button(frameKeySets,text='Delete Custom Key Set')
##widget packing
#body
--- 295,300 ----
self.optMenuKeysCustom=DynOptionMenu(frameKeySets,
self.customKeys,None,command=None)
! self.buttonDeleteCustomKeys=Button(frameKeySets,text='Delete Custom Key Set',
! command=self.DeleteCustomKeys)
##widget packing
#body
***************
*** 457,462 ****
def VarChanged_customTheme(self,*params):
value=self.customTheme.get()
! self.AddChangedItem('main','Theme','name',value)
! self.PaintThemeSample()
def VarChanged_themeIsBuiltin(self,*params):
--- 459,465 ----
def VarChanged_customTheme(self,*params):
value=self.customTheme.get()
! if value != '- no custom themes -':
! self.AddChangedItem('main','Theme','name',value)
! self.PaintThemeSample()
def VarChanged_themeIsBuiltin(self,*params):
***************
*** 487,492 ****
def VarChanged_customKeys(self,*params):
value=self.customKeys.get()
! self.AddChangedItem('main','Keys','name',value)
! self.LoadKeysList(value)
def VarChanged_keysAreBuiltin(self,*params):
--- 490,496 ----
def VarChanged_customKeys(self,*params):
value=self.customKeys.get()
! if value != '- no custom keys -':
! self.AddChangedItem('main','Keys','name',value)
! self.LoadKeysList(value)
def VarChanged_keysAreBuiltin(self,*params):
***************
*** 595,599 ****
def GetNewKeysName(self,message):
! usedNames=idleConf.GetSectionList('user','keys')
newKeySet=GetCfgSectionNameDialog(self,'New Custom Key Set',
message,usedNames).result
--- 599,604 ----
def GetNewKeysName(self,message):
! usedNames=(idleConf.GetSectionList('user','keys')+
! idleConf.GetSectionList('default','keys'))
newKeySet=GetCfgSectionNameDialog(self,'New Custom Key Set',
message,usedNames).result
***************
*** 658,661 ****
--- 663,718 ----
self.listBindings.select_anchor(listIndex)
+ def DeleteCustomKeys(self):
+ keySetName=self.customKeys.get()
+ if not tkMessageBox.askyesno('Delete Key Set','Are you sure you wish '+
+ 'to delete the key set '+`keySetName`+' ?'):
+ return
+ #remove key set from config
+ idleConf.userCfg['keys'].remove_section(keySetName)
+ if self.changedItems['keys'].has_key(keySetName):
+ del(self.changedItems['keys'][keySetName])
+ #write changes
+ idleConf.userCfg['keys'].Save()
+ #reload user key set list
+ itemList=idleConf.GetSectionList('user','keys')
+ itemList.sort()
+ if not itemList:
+ self.radioKeysCustom.config(state=DISABLED)
+ self.optMenuKeysCustom.SetMenu(itemList,'- no custom keys -')
+ else:
+ self.optMenuKeysCustom.SetMenu(itemList,itemList[0])
+ #revert to default key set
+ self.keysAreBuiltin.set(idleConf.defaultCfg['main'].Get('Keys','default'))
+ self.builtinKeys.set(idleConf.defaultCfg['main'].Get('Keys','name'))
+ #user can't back out of these changes, they must be applied now
+ self.Apply()
+ self.SetKeysType()
+
+ def DeleteCustomTheme(self):
+ themeName=self.customTheme.get()
+ if not tkMessageBox.askyesno('Delete Theme','Are you sure you wish '+
+ 'to delete the theme '+`themeName`+' ?'):
+ return
+ #remove theme from config
+ idleConf.userCfg['highlight'].remove_section(themeName)
+ if self.changedItems['highlight'].has_key(themeName):
+ del(self.changedItems['highlight'][themeName])
+ #write changes
+ idleConf.userCfg['highlight'].Save()
+ #reload user theme list
+ itemList=idleConf.GetSectionList('user','highlight')
+ itemList.sort()
+ if not itemList:
+ self.radioThemeCustom.config(state=DISABLED)
+ self.optMenuThemeCustom.SetMenu(itemList,'- no custom themes -')
+ else:
+ self.optMenuThemeCustom.SetMenu(itemList,itemList[0])
+ #revert to default theme
+ self.themeIsBuiltin.set(idleConf.defaultCfg['main'].Get('Theme','default'))
+ self.builtinTheme.set(idleConf.defaultCfg['main'].Get('Theme','name'))
+ #user can't back out of these changes, they must be applied now
+ self.Apply()
+ self.SetThemeType()
+
def GetColour(self):
target=self.highlightTarget.get()
***************
*** 690,694 ****
def GetNewThemeName(self,message):
! usedNames=idleConf.GetSectionList('user','highlight')
newTheme=GetCfgSectionNameDialog(self,'New Custom Theme',
message,usedNames).result
--- 747,752 ----
def GetNewThemeName(self,message):
! usedNames=(idleConf.GetSectionList('user','highlight')+
! idleConf.GetSectionList('default','highlight'))
newTheme=GetCfgSectionNameDialog(self,'New Custom Theme',
message,usedNames).result
***************
*** 1026,1029 ****
--- 1084,1098 ----
self.ResetChangedItems() #clear the changed items dict
+ def ActivateConfigChanges(self):
+ #things that need to be done to make
+ #applied config changes dynamic:
+ #
+ #update editor/shell font and repaint
+ #dynamically update indentation setttings
+ #update theme and repaint
+ #update keybindings and re-bind
+ #update user help sources menu
+ pass
+
def Cancel(self):
self.destroy()
***************
*** 1035,1038 ****
--- 1104,1108 ----
def Apply(self):
self.SaveAllChangedConfigs()
+ self.ActivateConfigChanges()
def Help(self):