Changeset 94
- Timestamp:
- 12/17/07 18:19:33
- Files:
-
- action_groups/trunk/AccDecorator.py (modified) (2 diffs)
- action_groups/trunk/ActionBrowser.py (modified) (1 diff)
- action_groups/trunk/ActionModel.py (modified) (5 diffs)
- action_groups/trunk/ActionTree.py (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
action_groups/trunk/AccDecorator.py
r85 r94 144 144 except NotImplementedError: 145 145 return 146 rect = ci.getExtents( 0)146 rect = ci.getExtents(pyatspi.DESKTOP_COORDS) 147 147 x = int(rect.x + rect.width / 2) 148 148 y = int(rect.y + rect.height / 2) … … 151 151 reg.generateMouseEvent(x, y, pyatspi.MOUSE_B1R) 152 152 reg.generateMouseEvent(x, y, pyatspi.MOUSE_B1C) 153 153 154 def getExtents(self, which=pyatspi.DESKTOP_COORDS): 155 try: 156 ci = self.queryComponent() 157 return ci.getExtents(which) 158 except NotImplementedError: 159 return None 160 154 161 def doAction(self): 155 162 try: action_groups/trunk/ActionBrowser.py
r86 r94 145 145 acc = self.groups_tree.get_selected_acc(selection) 146 146 if acc is not None: 147 try: 148 ci = acc.queryComponent() 149 except: 150 return 151 extents = ci.getExtents(pyatspi.DESKTOP_COORDS) 152 self.blink(extents) 153 147 from AccDecorator import AccDecorator 148 extents = AccDecorator(acc).getExtents(pyatspi.DESKTOP_COORDS) 149 if extents: 150 self.blink(extents) 151 154 152 def blink(self, extents): 155 153 if self.bl: action_groups/trunk/ActionModel.py
r93 r94 18 18 19 19 def _populateChildren(self, parent_acc): 20 isSelection = parent_acc.isSelection() 20 self._findInterestingChildren(parent_acc, self.items) 21 22 def _findInterestingChildren(self, parent_acc, items): 23 # isSelection = parent_acc.isSelection() 21 24 for child_acc in parent_acc: 22 25 if child_acc is None: continue 23 26 child = AccDecorator(child_acc) 24 child.is_group = not isSelection and self._isActionGroup(child) 27 # child.is_group = not isSelection and self._isActionGroup(child) 28 child.is_group = self._isActionGroup(child) 25 29 child.is_interactive = self._isInteractive(child) 26 30 if child.is_interactive or child.is_group: 27 self.items.append(child)28 #print '%s %s%s ' % (child._acc, ('i' if child.is_interactive else ''),29 #('g' if child.is_group else ''))31 items.append(child) 32 print '%s %s%s ' % (child._acc, ('i' if child.is_interactive else ''), 33 ('g' if child.is_group else '')) 30 34 elif child.hasStates(pyatspi.STATE_SHOWING): 31 self._ populateChildren(child)35 self._findInterestingChildren(child, items) 32 36 33 37 def __len__(self): … … 45 49 return 'root: %s + items {%s}' % (self.parent_acc, 46 50 ', '.join((str_item(item) for item in self.items))) 51 52 def _hasOneInteractiveChild(self, acc): 53 return acc.childCount == 1 and self._isInteractive(AccDecorator(acc[0])) 47 54 48 55 def _isActionGroup(self, acc): … … 53 60 # menus are handled as dynamic groups 54 61 return False 55 if role in (pyatspi.ROLE_DOCUMENT_FRAME):62 elif role in (pyatspi.ROLE_DOCUMENT_FRAME, pyatspi.ROLE_TOOL_BAR): 56 63 return True 57 if role == pyatspi.ROLE_FRAME:64 elif role == pyatspi.ROLE_FRAME: 58 65 app = acc.getApplication() 59 66 if app.childCount == 1: 60 67 # Top level frames of single framed apps can't be groups 61 68 return False 69 return self._hasInteractiveDecendants(acc) 70 71 def _hasInteractiveDecendants(self, acc): 72 role = acc.getRole() 62 73 n_interactive = 0 74 if role == pyatspi.ROLE_PAGE_TAB: 75 items=[] 76 self._findInterestingChildren(acc, items) 77 if len(items): 78 return True 63 79 for child in acc: 64 80 if child is None: continue … … 67 83 continue 68 84 if self._isInteractive(child) or \ 69 child.childCount == 1 and self._isInteractive(AccDecorator(child[0])): 85 self._hasOneInteractiveChild(child._acc) or \ 86 (child.childCount == 1 and self._hasOneInteractiveChild(child[0])): 70 87 n_interactive += 1 71 88 if n_interactive == 2: 72 89 return True 73 return n_interactive > 1 or role == pyatspi.ROLE_PAGE_TAB90 return (n_interactive > 1) 74 91 75 92 def _isInteractive(self, acc): 76 93 if acc.hasRoleIn(pyatspi.ROLE_SEPARATOR) \ 77 or ( acc.hasRoleIn(pyatspi.ROLE_MENU) and acc.parent.getRole() == pyatspi.ROLE_COMBO_BOX) \94 or ((acc.hasRoleIn(pyatspi.ROLE_MENU) and acc.parent.getRole() == pyatspi.ROLE_COMBO_BOX)) \ 78 95 or not acc.hasStates(pyatspi.STATE_SHOWING, pyatspi.STATE_VISIBLE, pyatspi.STATE_SENSITIVE): 79 96 return False … … 183 200 ac = acc._acc 184 201 path = self.acc_cache[acc] 202 while path == None: 203 acc = acc.parent 204 path = self.acc_cache[acc] 185 205 return path 186 206 except KeyError: 187 207 return None 208 209 def getScrollBarAcc(self, acc): 210 pacc = acc.parent 211 while pacc is not None: 212 if pacc.getRole() == pyatspi.ROLE_PANE: 213 return pacc 214 pacc=acc.parent 215 216 def isAncestor(self, acc, accA): 217 while acc is not None: 218 acc = acc.parent 219 if acc == accA: 220 return True 221 return False 222 223 class scrollable(): 224 def __init__(self, pane): 225 self._pane=pane 226 v_scrollbar = pane.self.childAtIndex(pane.childCount-1) 227 if v_scrollbar.getRole() <> pyatspi.ROLE_SCROLL_BAR: 228 raise Exception() 229 self.v_scrollbar = v_scrollbar.queryValue() 230 def scrollIntoView(y): 231 self.v_scrollbar.currentValue = y 232 233 #class List(Scrollable): 234 # def __init__(self, pane): action_groups/trunk/ActionTree.py
r93 r94 84 84 selection = self.get_selection() 85 85 selection.select_iter(iter) 86 self.current_acc = self.get_acc_from_path(self.get_model().get_path(iter)) 86 87 87 88 def next(self): … … 100 101 self.next_children = True; 101 102 self.select(nextiter) 102 103 104 if acc is not None and acc.isSelectable() and acc.parent is not None: 105 selection = AccDecorator(acc.parent) 106 if not selection.isSelection(): return 107 try: 108 scrollbar = selection.scrollbar 109 except AttributeError: 110 return 111 extents = acc.getExtents(pyatspi.DESKTOP_COORDS) 112 scrollbar.currentValue += extents.height 113 103 114 def focus(self): 104 115 model, iter, acc = self._getSelection() … … 128 139 129 140 s = formatEvent(event) 130 #PrintMessage(s).send MENU()141 #PrintMessage(s).send() 131 142 132 143 if event.type == 'focus:' and \ … … 146 157 top = parent_acc_with_role(event.source, pyatspi.ROLE_DIALOG, 147 158 pyatspi.ROLE_ALERT, 148 pyatspi.ROLE_FRAME )159 pyatspi.ROLE_FRAME, pyatspi.ROLE_WINDOW) 149 160 try: 150 161 model = self.get_model() … … 163 174 model = self.get_model() 164 175 path = model.getAccPath(source_acc) 165 if path is None:166 path = model.getAccPath(source_acc.parent)167 176 if path is not None: 168 177 ChildChangedMessage(path).send() … … 174 183 ChildChangedMessage(None).send() 175 184 self.id = gobject.timeout_add(500, self._onChildAddTimeout) 185 186 elif event.type in ('object:visible-data-changed'): 187 PrintMessage(s).send() 188 model = self.get_model() 189 if model.isAncestor(self.current_acc, source_acc._acc): 190 ChildChangedMessage(None).send() 176 191 177 192 elif event.source.getRole() == pyatspi.ROLE_MENU: … … 280 295 acc.toggleSectable() 281 296 acc.doAction() 297 elif acc.hasRoleIn(pyatspi.ROLE_PAGE_TAB): 298 acc.toggleSectable() 299 self._do_actionGroup(iter) # race condition? 282 300 else: 283 acc.toggleSectable() 301 print 'toggle' 302 acc.toggleSectable() 284 303 285 304 # TODO: use template DP for toolkit and application … … 300 319 301 320 elif acc.is_group: 302 if self.row_expanded(path): 303 self.collapse_row(path) 304 elif model.iter_has_child(iter): 305 self.expand_row(path, False) 306 self.next() # select 1st item 307 321 self._do_actionGroup(iter) 322 323 def _do_actionGroup(self, iter): 324 model = self.get_model() 325 path = model.get_path(iter) 326 if self.row_expanded(path): 327 self.collapse_row(path) 328 elif model.iter_has_child(iter): 329 self.expand_row(path, False) 330 self.next() # select 1st item 331 308 332 def goToPath(self, path): 309 333 if len(path) > 1:
