Changeset 147
- Timestamp:
- 03/23/08 19:41:42 (10 months ago)
- Files:
-
- trunk/conf/config-example.py (modified) (3 diffs)
- trunk/pycawm/menu.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/conf/config-example.py
r146 r147 32 32 from pycawm.menu import (Menu, FocusesMenu, IconifiedClientsMenu, 33 33 ClientsSwitchMenu, ApplicationMenu, WindowManagerMenu, 34 ConfigMenu, AddPluginMenu, RemovePluginMenu) 34 ConfigMenu, AddPluginMenu, DynamicAddPluginMenu, 35 RemovePluginMenu) 35 36 from pycawm.plugins import (ActionButtonBox, MiniIconBox, MovePos, Pager, 36 37 RemoteREPL, StickyRootEdges) … … 145 146 RemoteREPL: dict(), 146 147 Pager: dict(x=0, y=0)}))), 148 ('Add Plugin (dynamic)', Menu.sub_menu, 149 (lambda menu, x, y: 150 DynamicAddPluginMenu(self, parent=menu, 151 x=x, y=y))), 147 152 ('Remove Plugin', Menu.sub_menu, 148 153 lambda menu, x, y: RemovePluginMenu(self, … … 196 201 # * the plugin class. 197 202 # * the arguments we want to give to the plugin when the wm instantiates it. 203 204 # DynamicAddPluginMenu is a menu which can dynamically reload plugins launched 205 # by calling the PycaWM.add_plugin method 206 DynamicAddPluginMenu.start(pika) 198 207 199 208 # Put a pager at (0, 0) trunk/pycawm/menu.py
r146 r147 38 38 from decorators import good_menu 39 39 from hookmanager import (add_pre_hook, remove_pre_hook, 40 add_post_hook, remove_post_hook, 40 41 add_instance_overriding_hook, 41 42 remove_instance_overriding_hook) … … 774 775 return elements 775 776 777 class DynamicAddPluginMenu(Menu): 778 elements = dict() 779 780 @classmethod 781 def start(cls, wm): 782 add_post_hook(wm.add_plugin, cls.add_plugin) 783 784 @classmethod 785 def add_plugin(cls, wm, plugin, params=dict(), name=None, force=False): 786 plugin_name = name if name is not None else plugin.__name__ 787 cls.elements[plugin_name] = \ 788 (('Add ' + plugin_name, Menu.python, 789 (lambda plugin=plugin, params=params, name=name, force=force: 790 wm.add_plugin(plugin, params, name=name, force=force)))) 791 792 @classmethod 793 def stop(cls, wm): 794 remove_post_hook(wm.add_plugin, cls.add_plugin) 795 796 def __init__(self, wm, x, y, parent=None): 797 Menu.__init__(self, wm, x, y, self.elements.values(), parent=parent) 798 776 799 class RemovePluginMenu(Menu): 777 800 def __init__(self, wm, x, y, parent=None):
