[Idle-dev] CVS: idle configDialog.py,1.30,1.31

Stephen M. Gava elguavas@users.sourceforge.net
Thu, 31 Jan 2002 17:32:03 -0800


Update of /cvsroot/idlefork/idle
In directory usw-pr-cvs1:/tmp/cvs-serv30594

Modified Files:
	configDialog.py 
Log Message:
more work on configuration saving


Index: configDialog.py
===================================================================
RCS file: /cvsroot/idlefork/idle/configDialog.py,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -r1.30 -r1.31
*** configDialog.py	2002/01/29 08:34:41	1.30
--- configDialog.py	2002/02/01 01:32:01	1.31
***************
*** 37,50 ****
              'Shell Stdout Text':('stdout','10'),
              'Shell Stderr Text':('stderr','11')}
!         #changedItems. When any config item is changed in this dialog, an entry
!         #should be made in the relevant section (config type) of this 
!         #dictionary. The key should be the config file section name and the 
!         #value a dictionary, whose key:value pairs are item=value pairs for
!         #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)
--- 37,41 ----
              'Shell Stdout Text':('stdout','10'),
              'Shell Stderr Text':('stderr','11')}
!         self.ResetChangedItems() #load initial values in changed items dict
          self.CreateWidgets()
          self.resizable(height=FALSE,width=FALSE)
***************
*** 445,449 ****
          element=self.themeElements[self.highlightTarget.get()][0]
          self.AddChangedItem('highlight',theme,element,value)
-         print params
          
      def VarChanged_keyBinding(self,*params):
--- 436,439 ----
***************
*** 451,457 ****
          keySet=self.customKeys.get()
          event=self.listBindings.get(ANCHOR).split()[0]
!         self.AddChangedItem('keys',keySet,event,value)
!         print params
! 
      def VarChanged_winWidth(self,*params):
          value=self.winWidth.get()
--- 441,452 ----
          keySet=self.customKeys.get()
          event=self.listBindings.get(ANCHOR).split()[0]
!         if idleConf.IsCoreBinding(event):
!             #this is a core keybinding
!             self.AddChangedItem('keys',keySet,event,value)
!         else: #this is an extension key binding
!             extName=idleConf.GetExtnNameForEvent(event)
!             extKeybindSection=extName+'_cfgBindings'
!             self.AddChangedItem('extensions',extKeybindSection,event,value)
!         
      def VarChanged_winWidth(self,*params):
          value=self.winWidth.get()
***************
*** 472,475 ****
--- 467,478 ----
          self.AddChangedItem('extensions',extension,'enabled',value)
  
+     def ResetChangedItems(self):
+         #changedItems. When any config item is changed in this dialog, an entry
+         #should be made in the relevant section (config type) of this 
+         #dictionary. The key should be the config file section name and the 
+         #value a dictionary, whose key:value pairs are item=value pairs for
+         #that config file section.
+         self.changedItems={'main':{},'highlight':{},'keys':{},'extensions':{}}
+ 
      def AddChangedItem(self,type,section,item,value):
          value=str(value) #make sure we use a string
***************
*** 477,481 ****
              self.changedItems[type][section]={}    
          self.changedItems[type][section][item]=value
-         print type,section,item,value
      
      def GetDefaultItems(self):
--- 480,483 ----
***************
*** 553,562 ****
          else:  
              keySetName=self.customKeys.get()
-         prevKeySet=idleConf.GetKeySet(keySetName)
          #add the new key set to changedItems
!         for event in prevKeySet.keys():
              eventName=event[2:-2] #trim off the angle brackets
              self.AddChangedItem('keys',newKeySetName,eventName,
!                     prevKeySet[event])
          #change gui over to the new key set
          customKeyList=idleConf.GetSectionList('user','keys')
--- 555,564 ----
          else:  
              keySetName=self.customKeys.get()
          #add the new key set to changedItems
!         prevCoreKeys=idleConf.GetCoreKeys(keySetName)
!         for event in prevCoreKeys.keys(): #add core key set to changed items
              eventName=event[2:-2] #trim off the angle brackets
              self.AddChangedItem('keys',newKeySetName,eventName,
!                     string.join(prevCoreKeys[event]))
          #change gui over to the new key set
          customKeyList=idleConf.GetSectionList('user','keys')
***************
*** 564,568 ****
              if newName not in customKeyList: customKeyList.append(newName)
          customKeyList.sort()
-         print newKeySetName,customKeyList,self.changedItems['keys'][newKeySetName]
          self.optMenuKeysCustom.SetMenu(customKeyList,newKeySetName)
          self.keysAreDefault.set(0)
--- 566,569 ----
***************
*** 611,615 ****
              if newName not in customThemeList: customThemeList.append(newName)
          customThemeList.sort()
-         print newThemeName,customThemeList,newTheme
          self.optMenuThemeCustom.SetMenu(customThemeList,newThemeName)
          self.themeIsBuiltin.set(0)
--- 612,615 ----
***************
*** 761,765 ****
              else:
                  self.optMenuKeysCustom.SetMenu(itemList,itemList[0])
!         else: #user theme selected
              itemList=idleConf.GetSectionList('user','keys')
              itemList.sort()
--- 761,765 ----
              else:
                  self.optMenuKeysCustom.SetMenu(itemList,itemList[0])
!         else: #user key set selected
              itemList=idleConf.GetSectionList('user','keys')
              itemList.sort()
***************
*** 814,818 ****
          
      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:
--- 814,817 ----
***************
*** 831,840 ****
                  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()
--- 830,839 ----
                  for item in self.changedItems[configType][section].keys():
                      value=self.changedItems[configType][section][item]
                      if self.SetUserValue(configType,section,item,value):
                          cfgTypeHasChanges=1
              if cfgTypeHasChanges: 
                  idleConf.userCfg[configType].Save()                
!         self.ResetChangedItems() #clear the changed items dict
!          
      def Cancel(self):
          self.destroy()