Changeset 72
- Timestamp:
- 11/16/07 20:10:03
- Files:
-
- action_groups/trunk/ActionBrowser.py (modified) (9 diffs)
- action_groups/trunk/action_tree.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
action_groups/trunk/ActionBrowser.py
r70 r72 102 102 def _onExamine(self, button): 103 103 acc = self.groups_tree.get_selected_acc() 104 if acc :104 if acc is not None: 105 105 self.node.update(acc) 106 106 … … 127 127 def _onSelectionChanged(self, selection): 128 128 acc = self.groups_tree.get_selected_acc(selection) 129 if acc: 130 Blinker(acc) 129 if acc is not None: 130 try: 131 ci = acc.queryComponent() 132 except: 133 return 134 extents = ci.getExtents(pyatspi.DESKTOP_COORDS) 135 print extents 136 Blinker(extents) 131 137 132 138 def _onSwitchDown(self, widget, device, switch): … … 153 159 self.append_column(tvc) 154 160 155 self.next_children = False;161 pyatspi.Registry.registerEventListener(self._onAccEventState, 'object:state-changed') 156 162 #self.set_property('fixed-height-mode', True) # speed display 157 163 … … 171 177 def _getSelection(self, selection=None): 172 178 selection = selection or self.get_selection() 173 # if selection is None:174 # return (self.get_model(), None, None)175 179 model, iter = selection.get_selected() 176 if iter :180 if iter is not None: 177 181 acc = model[iter][ProgressiveTreeModel.COL_ACC] 178 182 else: … … 185 189 186 190 def get_acc_from_path(self, path): 187 if not self.get_model(): 191 try: 192 acc = self.get_model()[path][ProgressiveTreeModel.COL_ACC] 193 except: 188 194 return None 189 return self.get_model()[path][ProgressiveTreeModel.COL_ACC]190 195 return acc 196 191 197 def set_top_acc(self, acc): 192 198 model = ProgressiveTreeModel(acc) 193 199 model.popLevel(None) # top 194 200 self.set_model(model) 195 pyatspi.Registry.registerEventListener(self._onAccEventState, 'object:state-changed')196 201 197 202 def __del__(self): … … 218 223 self.next_children = True; 219 224 self.select(nextiter) 220 225 221 226 def _onAccEventState(self, event): 222 227 ''' … … 233 238 if acc is None: 234 239 return 235 print event.type, event.detail1, event.detail2, event.source, acc, event.source.parent236 if acc.getRole() == pyatspi.ROLE_MENU :237 print 'menu'238 if event.source.parent == acc._acc :239 print 'parent'240 if event.type in ('object:state-changed:showing'):241 showing = event.detail1242 path = model.get_path(iter)243 if showing == 1 \244 and not model.iter_has_child(iter):245 model.makeExpandable(iter)246 model.popLevel(iter)247 self.expand_row(path, False)248 elif showing == 0 \249 and self.row_expanded(path):250 self.collapse_row(path)251 model.dePopLevel(iter, all=True)252 240 print event.type, event.detail1, event.detail2, event.source, acc, repr(event.source.getRole()) 241 if event.source.getRole() == pyatspi.ROLE_WINDOW \ 242 and event.type in ('object:state-changed:showing'): 243 showing = bool(event.detail1) 244 path = model.get_path(iter) 245 if showing \ 246 and not model.iter_has_child(iter): 247 model.makeExpandable(iter) 248 model.popLevel(iter) 249 self.expand_row(path, False) 250 elif not showing: 251 menu_iter = model.iter_parent_with_role(iter, pyatspi.ROLE_MENU) 252 if menu_iter: 253 menu_path = model.get_path(menu_iter) 254 if self.row_expanded(menu_path): 255 self.collapse_row(menu_path) 256 model.dePopLevel(menu_iter, all=True) 257 253 258 def do_action(self): 254 259 model, iter, acc = self._getSelection() … … 271 276 class Blinker(object): 272 277 max_blinks = 6 273 def __init__(self, acc): 278 def __init__(self, extents): 279 self.extents = extents 274 280 display = gtk.gdk.display_get_default() 275 281 screen = display.get_default_screen() … … 282 288 self.inv = gtk.Invisible() 283 289 self.inv.set_screen(screen) 284 285 try: 286 ci = acc.queryComponent() 287 except: 288 return 289 290 self.extents = ci.getExtents(pyatspi.DESKTOP_COORDS) 290 291 291 self.blinks = 0 292 292 gobject.timeout_add(30, self._drawRectangle) action_groups/trunk/action_tree.py
r71 r72 47 47 return req_states.issubset(act_states) 48 48 49 def getStates(self, *states): 50 return self._acc.getState().getStates() 51 49 52 def hasStateIn(self, *states): 50 53 act_states = set(self._acc.getState().getStates()) … … 81 84 82 85 def isInteractive(self): 83 if not self.hasStates(pyatspi.STATE_SHOWING): 84 return False 86 if self.hasRoleIn(pyatspi.ROLE_SEPARATOR) \ 87 or not self.hasStates(pyatspi.STATE_SHOWING, pyatspi.STATE_VISIBLE, pyatspi.STATE_SENSITIVE): 88 return False 89 #print self, self.getStates() 85 90 return self.isSelectable() or self.hasInterfaceIn('Action','EditableText') 86 91 … … 119 124 child.is_group = self.isActionGroup(child) 120 125 if child.isInteractive() or child.is_group: 121 print child122 126 self.items.append(child) 123 127 else: … … 140 144 141 145 def isActionGroup(self, acc): 142 if not acc.hasStates(pyatspi.STATE_SHOWING): 146 if not acc.hasStates(pyatspi.STATE_SHOWING) \ 147 or acc.getRole() == pyatspi.ROLE_MENU: 143 148 return False 144 149 if acc.getRole() == pyatspi.ROLE_DOCUMENT_FRAME: … … 214 219 self[iter][self.COL_FILLED] = False 215 220 221 def iter_parent_with_role(self, iter, role): 222 while iter is not None: 223 if self[iter][ProgressiveTreeModel.COL_ACC].getRole() == role: 224 return iter 225 iter = self.iter_parent(iter) 226 return None 227
