Changeset 82

Show
Ignore:
Timestamp:
12/12/07 14:31:07
Author:
slee
Message:

AccDecorator? del bug fix and partial selection support

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • action_groups/trunk/AccDecorator.py

    r80 r82  
    2323    base_klass = acc.__class__ 
    2424    this_klass = self.__class__ 
    25     for name in ('__del__', '__iter__', '__str__', '__getitem__', '__len__'): 
     25    for name in ('__iter__', '__str__', '__getitem__', '__len__'): 
    2626      if hasattr(base_klass, name): 
    2727        #Set attribute to be a function that delegates to base class 
  • action_groups/trunk/ActionModel.py

    r81 r82  
    1313    assert root_acc is not None 
    1414    #REVIEW test if is a valid action group and throw if not ? 
    15     self.parent_acc = root_acc 
     15    self.parent_acc = AccDecorator(root_acc) 
    1616    self.items = [] 
    1717    self._populateChildren(self.parent_acc) 
    1818 
    1919  def _populateChildren(self, parent_acc): 
     20    isSelection = parent_acc.isSelection() 
    2021    for child_acc in parent_acc: 
    2122      if child_acc is None: continue 
    2223      child = AccDecorator(child_acc) 
    23       child.is_group = self._isActionGroup(child) 
     24      child.is_group = not isSelection and self._isActionGroup(child) 
    2425      child.is_interactive = self._isInteractive(child) 
    2526      if child.is_interactive or child.is_group: 
     
    2829                                         ('g' if child.is_group else '')) 
    2930      elif child.hasStates(pyatspi.STATE_SHOWING): 
    30         self._populateChildren(child_acc
     31        self._populateChildren(child
    3132 
    3233  def __len__(self): 
     
    4849    role = acc.getRole() 
    4950    if not acc.hasStates(pyatspi.STATE_SHOWING) \ 
    50       or role == pyatspi.ROLE_MENU: 
     51       or role == pyatspi.ROLE_MENU: 
     52      # must be showing 
     53      # menus are handled as dynamic groups 
    5154      return False 
    52     if role in (pyatspi.ROLE_DOCUMENT_FRAME, pyatspi.ROLE_FRAME, pyatspi.ROLE_DIALOG): 
    53       return True 
    54     #if role == pyatspi.ROLE_FRAME: 
    55       #app = acc.getApplication() 
    56       #if app.childCount == 1: 
     55#    if role in (pyatspi.ROLE_DOCUMENT_FRAME, pyatspi.ROLE_FRAME, pyatspi.ROLE_DIALOG) \ 
     56#       or acc.isSelection(): 
     57#      return True 
     58    if role == pyatspi.ROLE_FRAME: 
     59      app = acc.getApplication() 
     60      if app.childCount == 1: 
    5761        # Top level frames of single framed apps can't be groups 
    58         #return False 
     62        return False 
    5963    if acc.childCount == 1: 
    6064      # A container with one interactive child can't be a group 
     
    7882    return acc.isSelectable() or acc.isActionable() or acc.isEditable() 
    7983         
    80  
    81   def _hasInteractiveChild(self): 
    82     rv = None 
    83     for child in self._acc: 
    84       # REVIEW we can stop desending a tree if not SHOWING - add filter to findDesc? 
    85       rv = pyatspi.findDescendant(child, self._isInteractive) 
    86       if rv is not None: break 
    87     return bool(rv) 
    8884 
    8985class ActionModel(gtk.TreeStore): 
     
    137133    iter = self.append(parent_iter,  
    138134                       [acc.name, acc.getRoleName(), acc, False, False]) 
    139  
    140135    #print self.get_path(iter) 
    141136    if acc.is_group: 
    142137      self.makeExpandable(iter) 
    143  
    144138    #remove previous dummy as now have other children  
    145139    first_iter = self.iter_children(parent_iter) 
  • action_groups/trunk/ActionTree.py

    r81 r82  
    4848    model = self.get_model() 
    4949    model.popLevel(iter) 
    50     self.next_children = True; 
    5150 
    5251  def _getSelection(self, selection=None): 
     
    8685 
    8786  def next(self): 
    88     selection = self.get_selection() 
    89     model, iter = selection.get_selected() 
     87    model, iter, acc = self._getSelection() 
    9088    if iter is None:  
    9189      nextiter = model.get_iter_root() 
     
    137135        return None 
    138136      model = self.get_model() 
    139       root_acc = model.getRootAcc()  
    140137      top = parent_acc_with_role(event.source, pyatspi.ROLE_DIALOG, pyatspi.ROLE_FRAME) 
    141       print '%s %s' % (root_acc, top) 
    142       # for some reason they are not the same accessible (well I can't see how they ever are) 
    143       if not(top.getRole() == root_acc.getRole() and top.name == root_acc.name): 
     138      print '%s %s' % (model.getRootAcc(), top) 
     139      try: 
     140        root = model.getRootAcc() 
     141        root.parent  # access it 
     142      except LookupError: 
     143        root = None 
     144      # for some reason they are not always the same accessible 
     145      # even though we expect them to be compared by hash 
     146      if root is None or not(top.getRole() == root.getRole() and top.name == root.name): 
    144147        WindowActivateMessage(top).send() 
    145148