Show
Ignore:
Timestamp:
07/05/08 09:43:06 (5 months ago)
Author:
rob
Message:

Fixed #393: added ApplySettingsSameMode? to make view settings default for current mode
* added ApplySettingsAll? to erase default values in the GlobalPrefs? for subclasses of FundamentalMode? so that the settings become the defaults for all modes

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/peppy/fundamental_menu.py

    r1453 r1457  
    1010from peppy.actions.minibuffer import * 
    1111from peppy.fundamental import * 
     12from peppy.lib.userparams import * 
    1213 
    1314 
     
    312313 
    313314 
     315class ApplySettingsSameMode(OnDemandActionNameMixin, SelectAction): 
     316    """Apply view settings to all tabs""" 
     317    name = "As Defaults for %s Mode" 
     318    default_menu = ("View/Apply Settings", 100) 
     319 
     320    def getMenuItemName(self): 
     321        """Override in subclass to provide the menu item name.""" 
     322        return self.name % self.mode.keyword 
     323 
     324    def action(self, index=-1, multiplier=1): 
     325        locals = {} 
     326        locals[self.mode.__class__] = self.mode.classprefsDictFromLocals() 
     327        Publisher().sendMessage('peppy.preferences.changed', locals) 
     328        # Make the local values the defaults so that they'll become persistent 
     329        # by getting saved in the configuration file 
     330        self.mode.classprefsCopyFromLocals() 
     331 
     332 
     333class ApplySettingsAll(SelectAction): 
     334    """Apply view settings to editors""" 
     335    name = "As Defaults for All Modes" 
     336    default_menu = ("View/Apply Settings", 110) 
     337 
     338    def action(self, index=-1, multiplier=1): 
     339        msg_data = {} 
     340        settings = self.mode.classprefsDictFromLocals() 
     341        msg_data[FundamentalMode] = settings 
     342        msg_data['subclass'] = FundamentalMode 
     343        Publisher().sendMessage('peppy.preferences.changed', msg_data) 
     344         
     345        FundamentalMode.classprefsOverrideSubclassDefaults(settings) 
     346 
     347 
    314348class FundamentalMenu(IPeppyPlugin): 
    315349    """Trac plugin that provides the global menubar and toolbar. 
     
    343377                    EOLModeSelect, SelectBraces, 
    344378                     
    345                     ElectricReturn, ElectricDelete, ElectricBackspace] 
     379                    ElectricReturn, ElectricDelete, ElectricBackspace, 
     380                     
     381                    ApplySettingsSameMode, ApplySettingsAll, 
     382                    ] 
    346383        return []