def focusCommand(self, event): try: path = pyatspi.getPath(event.source) except RuntimeError: path = [] self.last_focused = (event.source.name, path, event.source.getRole())
def onEvent(self, event): """ Event callback. @param event: Event that has triggered this callback. @type event: Accessibility.Event """ if ( (self._acc_name is None or self._acc_name == event.source.name) and (self._acc_path is None or self._acc_path == pyatspi.getPath(event.source)) and (self._acc_role is None or self._acc_role == event.source.getRole()) ): self.stepDone()
def onEvent(self, event): ''' Event callback. @param event: Event that has triggered this callback. @type event: Accessibility.Event ''' if (self._acc_name is None or \ self._acc_name == event.source.name) and \ (self._acc_path is None or \ self._acc_path == pyatspi.getPath(event.source)) and \ (self._acc_role is None or \ self._acc_role == event.source.getRole()): self.stepDone()
def bookmarkCurrent(self): ''' Bookmark the currently selected application-wide node. @return: Tree iter of new bookmark. @rtype: gtk.TreeIter ''' if self.node.acc in (self.node.desktop, None): return None if self.node.tree_path is not None: path = ','.join(map(str, self.node.tree_path)) else: path = ','.join(map(str, getPath(self.node.acc))) app = self.node.acc.getApplication() role = self.node.acc.getLocalizedRoleName() first_bm_name = '%s in %s' % (self.node.acc.name or role, app.name) bm_name = first_bm_name i = 1 while self._nameIsTaken(bm_name): bm_name = '%s (%d)' % (first_bm_name, i) i += 1 return self.addBookmark(bm_name, app.name, path)
def _onFocus(self, event): ''' Callback for focus events. Calls the script factory and flushes it's queue. @param event: Focus at-spi event. @type event: Accessibility.Event ''' if self._isMyApp(event.source): return app = event.source.getApplication() triggering_hotkey = None if getattr(app, 'name', None) == 'gnome-panel': if event.source.getRole() == pyatspi.ROLE_MENU and \ event.source.parent.getRole() == pyatspi.ROLE_MENU_BAR: # A wild assumption that this was triggered with <Alt>F1 triggering_hotkey = '<Alt>F1' if event.source.getRole() == pyatspi.ROLE_COMBO_BOX: triggering_hotkey = '<Alt>F2' elif getattr(app, 'name', None) == 'gnome-screenshot' and \ event.source.getRole() == pyatspi.ROLE_TEXT and \ pyatspi.getPath(event.source) == [0, 0, 0, 0, 1, 1]: triggering_hotkey = 'Print' if triggering_hotkey is not None: fake_event = _FakeDeviceEvent(triggering_hotkey, pyatspi.KEY_PRESSED_EVENT) self._onKeystroke(fake_event) self.script_factory.focusCommand(event) if triggering_hotkey is not None: fake_event = _FakeDeviceEvent(triggering_hotkey, pyatspi.KEY_RELEASED_EVENT) self._onKeystroke(fake_event) while self.script_factory.commands_queue.qsize(): self._appendText(self.script_factory.commands_queue.get_nowait())
def focusCommand(self, event): self.last_focused = (event.source.name, pyatspi.getPath(event.source), event.source.getRole())