Show
Ignore:
Timestamp:
04/19/08 21:26:27 (8 months ago)
Author:
Ronny Pfannschmidt <Ronny.Pfannschmidt@…>
Children:
1141:8e72fb661f77, 1147:30ad236e42c0
Message:

code simplifications and unittest fixes/removals

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pida/core/actions.py

    r873 r1140  
    3232from pida.core.base import BaseConfig 
    3333from pida.core.options import OptionItem, manager, OTypeString 
    34  
    35 ( 
    36 TYPE_RADIO, 
    37 TYPE_TOGGLE, 
    38 TYPE_NORMAL, 
    39 TYPE_MENUTOOL, 
    40 ) = range(4) 
     34import warnings 
    4135 
    4236 
     
    5549 
    5650 
    57 _ACTIONS = { 
    58     TYPE_NORMAL: gtk.Action, 
    59     TYPE_TOGGLE: gtk.ToggleAction, 
    60     TYPE_RADIO: gtk.RadioAction, 
    61     TYPE_MENUTOOL: PidaMenuToolAction, 
    62 } 
     51TYPE_NORMAL = gtk.Action 
     52TYPE_TOGGLE = gtk.ToggleAction 
     53TYPE_RADIO = gtk.RadioAction 
     54TYPE_MENUTOOL = PidaMenuToolAction 
    6355 
    6456 
     
    10799 
    108100    def create_action(self, name, atype, label, tooltip, stock_id, 
    109                       callback=None, accel_string='NOACCEL'): 
     101                      callback=None, accel=None): 
    110102        """ 
    111103        Create an action for this service. 
     
    132124            The callback function to be called when the action is activated. 
    133125            This function should take the action as a parameter. 
    134         :param accel_string: 
     126        :param accel: 
    135127            The accelerator string set as the default accelerator for this 
    136             action, or 'NOACCEL' for actions that do not need an accelerator. 
     128            action, or `None` for actions that do not need an accelerator. 
    137129            To be used these actions must be proxied as items in one of the 
    138130            menus or toolbars. 
    139131        """ 
    140         aclass = _ACTIONS[atype] 
    141         act = aclass(name=name, label=label, tooltip=tooltip, stock_id=stock_id) 
     132        act = atype(name=name, label=label, tooltip=tooltip, stock_id=stock_id) 
    142133        self._actions.add_action(act) 
    143134        if callback is None: 
     
    145136        if callback is not None: 
    146137            act.connect('activate', callback) 
    147         if accel_string != 'NOACCEL': 
    148             self._create_key_option(act, name, label, tooltip, accel_string) 
    149  
    150     def _create_key_option(self, act, name, label, tooltip, accel_string): 
     138         
     139        if accel == 'NOACCEL': 
     140            warnings.warn('the accel `NOACCEL` is deprecated, use None', 
     141                    DeprecationWarning, 2) 
     142 
     143        if accel != 'NOACCEL' and accel is not None: 
     144            self._create_key_option(act, name, label, tooltip, accel) 
     145 
     146    def _create_key_option(self, act, name, label, tooltip, accel): 
    151147        opt = OptionItem(self._get_group_name(), name, label, OTypeString, 
    152                          accel_string, tooltip, self._on_shortcut_notify) 
     148                         accel, tooltip, self._on_shortcut_notify) 
    153149        opt.action = act 
    154150        opt.stock_id = act.get_property('stock-id')