Changeset 69
- Timestamp:
- 11/16/07 12:53:05
- Files:
-
- action_groups/trunk/action_tree.py (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
action_groups/trunk/action_tree.py
r68 r69 42 42 top_hbox.pack_start(scrolled_window) 43 43 44 generate_button = gtk.Button(' Generate')44 generate_button = gtk.Button('_Generate', use_underline=True) 45 45 generate_button.connect('clicked', self._onGenerate) 46 46 bottom_hbox.pack_start(generate_button, False) 47 47 48 examine_button = gtk.Button('E xamine')48 examine_button = gtk.Button('E_xamine', use_underline=True) 49 49 examine_button.connect('clicked', self._onExamine) 50 50 bottom_hbox.pack_start(examine_button, False) 51 51 52 scan_button = gtk.Button('Start Scan')52 scan_button = gtk.Button('Start _Scan', use_underline=True) 53 53 scan_button.connect('clicked', self._onScan) 54 54 bottom_hbox.pack_start(scan_button, False) 55 55 56 action_button = gtk.Button('Action') 56 action_button = gtk.Button('_Action', 57 use_underline=True) 57 58 action_button.connect('clicked', self._onAction) 58 59 bottom_hbox.pack_start(action_button, False) … … 73 74 gobject.timeout_add(1000, self._onScanStep) 74 75 self.is_scanning = not self.is_scanning 75 label = ('Stop Scan' if self.is_scanning else 'StartScan')76 label = ('Stop _Scan' if self.is_scanning else 'Start _Scan') 76 77 button.set_label(label) 77 78 … … 192 193 class ActionGroup(object): 193 194 def __init__(self, root_acc): 194 assert root_acc 195 assert root_acc is not None 195 196 #REVIEW test if is a valid action group and throw if not ? 196 197 self.parent_acc = root_acc … … 200 201 def _populateChildren(self, parent_acc): 201 202 for child_acc in parent_acc: 203 if child_acc is None: continue 202 204 child = AccDecorator(child_acc) 203 205 child.is_group = self.isActionGroup(child) … … 294 296 self.remove(first_iter) 295 297 296 def dePopLevel(self, iter ):298 def dePopLevel(self, iter, all=False): 297 299 self.append(iter, ['', '', None, True, False]) 298 300 child_iter = self.iter_children(iter) 299 301 iter_valid = bool(child_iter) 300 while iter_valid and not self[child_iter][self.COL_DUMMY]:302 while iter_valid and (all or not self[child_iter][self.COL_DUMMY]): 301 303 iter_valid = self.remove(child_iter) 302 304 self[iter][self.COL_FILLED] = False … … 328 330 def _onExpanded(self, treeview, iter, path): 329 331 # don't repopulate if it has been filled before 330 # print 'expanding %s' % path331 332 if self.get_model()[iter][ProgressiveTreeModel.COL_FILLED]: 332 333 return … … 338 339 def _getSelection(self, selection=None): 339 340 selection = selection or self.get_selection() 341 # if selection is None: 342 # return (self.get_model(), None, None) 340 343 model, iter = selection.get_selected() 341 344 if iter: … … 346 349 347 350 def get_selected_acc(self, selection=None): 348 model, iter, acc = self._getSelection( )351 model, iter, acc = self._getSelection(selection) 349 352 return acc 350 353 351 354 def get_acc_from_path(self, path): 352 return self.model[path][ProgressiveTreeModel.COL_ACC] 355 if not self.get_model(): 356 return None 357 return self.get_model()[path][ProgressiveTreeModel.COL_ACC] 353 358 354 359 def set_top_acc(self, acc): … … 356 361 model.popLevel(None) # top 357 362 self.set_model(model) 358 363 pyatspi.Registry.registerEventListener(self._onAccEventState, 'object:state-changed') 364 365 def __del__(self): 366 self.deRegisterEventListener(self._onAccEventState, 'object:state-changed') 367 359 368 def select(self, iter): 360 369 selection = self.get_selection() … … 364 373 selection = self.get_selection() 365 374 model, iter = selection.get_selected() 366 if not iter:375 if iter is None: 367 376 nextiter = model.get_iter_root() 368 elif self. next_children:377 elif self.row_expanded(model.get_path(iter)): 369 378 nextiter = model.iter_children(iter) 370 self.next_children = False;371 379 else: 372 380 nextiter = model.iter_next(iter) 373 if n ot nextiter:381 if nextiter is None: 374 382 nextiter = model.iter_parent(iter) 375 if n ot nextiter:383 if nextiter is None: 376 384 nextiter = model.get_iter_root() 377 385 else: … … 379 387 self.select(nextiter) 380 388 389 def _onAccEventState(self, event): 390 ''' 391 Callback for accessible state changes. Repopulates the states model. 392 393 @param event: Event that triggered this callback. 394 @type event: Accessibility.Event 395 ''' 396 if not self.get_model(): 397 return 398 if event.source.getApplication() <> self.get_acc_from_path(0).getApplication(): 399 return 400 model, iter, acc = self._getSelection() 401 if acc is None: 402 return 403 print event.type, event.detail1, event.detail2, event.source, acc, event.source.parent 404 if acc.getRole() == pyatspi.ROLE_MENU : 405 print 'menu' 406 if event.source.parent == acc._acc : 407 print 'parent' 408 if event.type in ('object:state-changed:showing'): 409 showing = event.detail1 410 path = model.get_path(iter) 411 if showing == 1 \ 412 and not model.iter_has_child(iter): 413 model.makeExpandable(iter) 414 model.popLevel(iter) 415 self.expand_row(path, False) 416 elif showing == 0 \ 417 and self.row_expanded(path): 418 self.collapse_row(path) 419 model.dePopLevel(iter, all=True) 420 381 421 def do_action(self): 382 422 model, iter, acc = self._getSelection() 383 if not acc: return423 if acc is None: return 384 424 path = model.get_path(iter) 385 print 'path', path386 425 is_interactive = acc.isInteractive() 387 426 if is_interactive: … … 389 428 action_if = acc.queryAction() 390 429 action_if.doAction(0) 391 # assume menu for now392 if self.row_expanded(path):393 self.collapse_row(path)394 else:395 model.makeExpandable(iter)396 model.popLevel(model.get_iter(path))397 self.expand_row(path, False)398 430 except: 399 431 pass
