Changeset 1140:1231dd5d7bc6 for pida/core/actions.py
- Timestamp:
- 04/19/08 21:26:27 (8 months ago)
- Children:
- 1141:8e72fb661f77, 1147:30ad236e42c0
- Files:
-
- 1 modified
-
pida/core/actions.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
pida/core/actions.py
r873 r1140 32 32 from pida.core.base import BaseConfig 33 33 from pida.core.options import OptionItem, manager, OTypeString 34 35 ( 36 TYPE_RADIO, 37 TYPE_TOGGLE, 38 TYPE_NORMAL, 39 TYPE_MENUTOOL, 40 ) = range(4) 34 import warnings 41 35 42 36 … … 55 49 56 50 57 _ACTIONS = { 58 TYPE_NORMAL: gtk.Action, 59 TYPE_TOGGLE: gtk.ToggleAction, 60 TYPE_RADIO: gtk.RadioAction, 61 TYPE_MENUTOOL: PidaMenuToolAction, 62 } 51 TYPE_NORMAL = gtk.Action 52 TYPE_TOGGLE = gtk.ToggleAction 53 TYPE_RADIO = gtk.RadioAction 54 TYPE_MENUTOOL = PidaMenuToolAction 63 55 64 56 … … 107 99 108 100 def create_action(self, name, atype, label, tooltip, stock_id, 109 callback=None, accel _string='NOACCEL'):101 callback=None, accel=None): 110 102 """ 111 103 Create an action for this service. … … 132 124 The callback function to be called when the action is activated. 133 125 This function should take the action as a parameter. 134 :param accel _string:126 :param accel: 135 127 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. 137 129 To be used these actions must be proxied as items in one of the 138 130 menus or toolbars. 139 131 """ 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) 142 133 self._actions.add_action(act) 143 134 if callback is None: … … 145 136 if callback is not None: 146 137 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): 151 147 opt = OptionItem(self._get_group_name(), name, label, OTypeString, 152 accel _string, tooltip, self._on_shortcut_notify)148 accel, tooltip, self._on_shortcut_notify) 153 149 opt.action = act 154 150 opt.stock_id = act.get_property('stock-id')
