Changeset 96
- Timestamp:
- 12/20/07 17:58:03
- Files:
-
- action_groups/trunk/ActionBrowser.py (modified) (4 diffs)
- action_groups/trunk/ActionModel.py (modified) (2 diffs)
- action_groups/trunk/ActionTree.py (modified) (4 diffs)
- action_groups/trunk/MessageTransport.py (modified) (2 diffs)
- action_groups/trunk/README (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
action_groups/trunk/ActionBrowser.py
r94 r96 16 16 from ActionTree import ActionTree 17 17 from Blinker import Blinker 18 import MessageTransport 18 19 19 20 _ = lambda x: x 21 22 ACTION_KEY_DOWN, ACTION_SWITCH_DOWN, ACTION_MOUSE_CLICK = xrange(3) 23 24 _mt = MessageTransport.MessageTransport() 25 class DeviceMessage(MessageTransport.Message): 26 transport = _mt 20 27 21 28 if not is_plugin: … … 105 112 106 113 self.show_all() 114 115 pyatspi.Registry.registerKeystrokeListener( 116 self._onKeyDown, 117 kind=(pyatspi.KEY_PRESSED_EVENT,)) 107 118 108 119 def _onGenerate(self, button): … … 158 169 self.bl.start() 159 170 171 def _onKeyDown(self, event): 172 gm = DeviceMessage(ACTION_KEY_DOWN, event.id) 173 gm.send(handler=self._onDeviceAction) 174 160 175 def _onSwitchDown(self, widget, device, switch): 161 if switch in (0, 4): 162 self.groups_tree.next() 163 elif switch in (1, 6): 164 self.groups_tree.do_action() 165 176 gm = DeviceMessage(ACTION_SWITCH_DOWN, switch) 177 gm.send(handler=self._onDeviceAction) 178 166 179 def _onButtonPressEvent(self, widget, event): 167 180 SINGLE, DOUBLE = event.type == gtk.gdk.BUTTON_PRESS \ … … 170 183 , event.button == 3 \ 171 184 , event.button == 2 172 ALT, CONTROL, SHIFT = event.state & gtk.gdk.MOD1_MASK <> 0 \ 173 , event.state & gtk.gdk.CONTROL_MASK <> 0 \ 174 , event.state & gtk.gdk.SHIFT_MASK <> 0 175 x, y = int(event.x), int(event.y) 176 177 if MIDDLE and SINGLE: 178 self.groups_tree.next() 179 return False 180 181 elif RIGHT and SINGLE: 182 self.groups_tree.do_action() 185 if SINGLE and (MIDDLE or RIGHT): 186 gm = DeviceMessage(ACTION_MOUSE_CLICK, event.button) 187 gm.send(handler=self._onDeviceAction) 183 188 return False 184 189 185 190 return True 191 192 def _onDeviceAction(self, action, id): 193 LEFT, RIGHT, MIDDLE = 1, 3, 2 194 195 # map gestures to actions 196 if (action == ACTION_KEY_DOWN and id in (gtk.keysyms.Control_L,)) or \ 197 (action == ACTION_SWITCH_DOWN and id in (0, 4)) or \ 198 (action == ACTION_MOUSE_CLICK) and id == MIDDLE: 199 self.groups_tree.next() 200 elif (action == ACTION_KEY_DOWN and id in (gtk.keysyms.space,)) or \ 201 (action == ACTION_SWITCH_DOWN and id in (1, 6)) or \ 202 (action == ACTION_MOUSE_CLICK) and id == RIGHT: 203 self.groups_tree.do_action() 204 return True action_groups/trunk/ActionModel.py
r95 r96 228 228 229 229 class Scrollable(AccDecorator): 230 V_SCROLLBAR, H_SCROLLBAR = xrange(2) 230 231 def __init__(self, acc): 231 232 AccDecorator.__init__(self, acc) … … 239 240 return None 240 241 def scrollIntoView(y): 241 self.get Scrollbar().currentValue = y242 self.getVScrollbar().currentValue = y 242 243 243 244 class ScrollableSelection(Scrollable): action_groups/trunk/ActionTree.py
r95 r96 7 7 from ActionModel import ActionModel 8 8 from AccDecorator import AccDecorator 9 from MessageTransport import Message 9 import MessageTransport 10 10 from KeyGenerator import sendKeyCombination 11 11 … … 36 36 self.app = None 37 37 self.adding_children = False 38 self.mt = MessageTransport.MessageTransport() 38 39 #self.set_property('fixed-height-mode', True) # speed display 39 40 … … 142 143 143 144 source_acc = AccDecorator(event.source) 144 145 class PrintMessage(Message): 146 _handler = self._onPrint 147 class ShowMenuMessage(Message): 148 _handler = self._onShowMenu 149 class HideMenuMessage(Message): 150 _handler = self._onHideMenu 151 class WindowActivateMessage(Message): 152 _handler = self._onWindowActivate 153 class ChildChangedMessage(Message): 154 _handler = self._onChildChanged 145 146 class MyMessage(MessageTransport.Message): 147 transport = self.mt 148 class PrintMessage(MyMessage): 149 handler = self._onPrint 150 class ShowMenuMessage(MyMessage): 151 handler = self._onShowMenu 152 class HideMenuMessage(MyMessage): 153 handler = self._onHideMenu 154 class WindowActivateMessage(MyMessage): 155 handler = self._onWindowActivate 156 class ChildChangedMessage(MyMessage): 157 handler = self._onChildChanged 155 158 156 159 s = formatEvent(event) … … 225 228 226 229 def _onPrint(self, data): 227 print data 230 #print data 231 pass 228 232 229 233 def _onWindowActivate(self, top): action_groups/trunk/MessageTransport.py
r81 r96 9 9 class MessageTransport(): 10 10 '''sending events from a ATSP Listener to a handler ''' 11 def __init__(self, handler ):11 def __init__(self, handler=lambda msg: msg.handle()): 12 12 self._queue = [] 13 13 self._handler = handler … … 29 29 return False # remove this from idle processing 30 30 31 mt = MessageTransport(lambda msg: msg.handle())32 33 31 class Message(): 34 32 ''' ABC for messages ''' 35 _handler = None # defined in subclass 33 transport = None # defined in subclass 34 handler = None # defined in subclass 36 35 def __init__(self, *data): 37 36 self._data = data 37 def setTransport(self, transport): 38 self.transport = transport 39 def setHandler(self, handler): 40 self.handler = handler 38 41 def handle(self): 39 self._handler(*self._data) 40 def send(self): 41 mt.send(self) 42 self.handler(*self._data) 43 def send(self, transport=None, handler=None): 44 if transport: self.transport=transport 45 if handler: self.handler=handler 46 self.transport.send(self) action_groups/trunk/README
r88 r96 5 5 Make sure gedit is already open and make it the active application again to be safe. 6 6 7 You really need a couple of USB switches as menus get messed with the mouse; 8 However if you leave the pointer in the spaces between the buttons then middle click is next and right click is action. 9 Or use scan and right click 7 Gestures 8 -------- 9 Thanks to Eitan Isaacson you can operate using the keyboard 10 11 next item -> Left Ctrl key, USB Switch 0 or 4, middle mouse button 12 action item -> space key, USB switch 1 or 6, right mouse button 13 14 For mouse you need to leave the pointer in the spaces between the buttons and menus do not display properly. 10 15 11 16 Known Bugs
