Changeset 94

Show
Ignore:
Timestamp:
12/17/07 18:19:33
Author:
slee
Message:

fixes to page tabs

Files:

Legend:

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

    r85 r94  
    144144    except NotImplementedError: 
    145145      return 
    146     rect = ci.getExtents(0
     146    rect = ci.getExtents(pyatspi.DESKTOP_COORDS
    147147    x = int(rect.x + rect.width / 2) 
    148148    y = int(rect.y + rect.height / 2) 
     
    151151    reg.generateMouseEvent(x, y, pyatspi.MOUSE_B1R) 
    152152    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 
    154161  def doAction(self): 
    155162    try: 
  • action_groups/trunk/ActionBrowser.py

    r86 r94  
    145145    acc = self.groups_tree.get_selected_acc(selection) 
    146146    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     
    154152  def blink(self, extents): 
    155153    if self.bl: 
  • action_groups/trunk/ActionModel.py

    r93 r94  
    1818 
    1919  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() 
    2124    for child_acc in parent_acc: 
    2225      if child_acc is None: continue 
    2326      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) 
    2529      child.is_interactive = self._isInteractive(child) 
    2630      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 '')) 
    3034      elif child.hasStates(pyatspi.STATE_SHOWING): 
    31         self._populateChildren(child
     35        self._findInterestingChildren(child, items
    3236 
    3337  def __len__(self): 
     
    4549    return 'root: %s + items {%s}' % (self.parent_acc,  
    4650                                      ', '.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]))   
    4754   
    4855  def _isActionGroup(self, acc): 
     
    5360      # menus are handled as dynamic groups 
    5461      return False 
    55     if role in (pyatspi.ROLE_DOCUMENT_FRAME): 
     62    elif role in (pyatspi.ROLE_DOCUMENT_FRAME, pyatspi.ROLE_TOOL_BAR): 
    5663      return True 
    57     if role == pyatspi.ROLE_FRAME: 
     64    elif role == pyatspi.ROLE_FRAME: 
    5865      app = acc.getApplication() 
    5966      if app.childCount == 1: 
    6067        # Top level frames of single framed apps can't be groups 
    6168        return False 
     69    return self._hasInteractiveDecendants(acc) 
     70 
     71  def _hasInteractiveDecendants(self, acc): 
     72    role = acc.getRole() 
    6273    n_interactive = 0 
     74    if role == pyatspi.ROLE_PAGE_TAB: 
     75      items=[] 
     76      self._findInterestingChildren(acc, items) 
     77      if len(items): 
     78        return True 
    6379    for child in acc: 
    6480      if child is None: continue 
     
    6783        continue 
    6884      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])): 
    7087        n_interactive += 1 
    7188      if n_interactive == 2: 
    7289        return True 
    73     return n_interactive > 1 or role == pyatspi.ROLE_PAGE_TAB 
     90    return (n_interactive > 1) 
    7491 
    7592  def _isInteractive(self, acc): 
    7693    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)) \ 
    7895       or not acc.hasStates(pyatspi.STATE_SHOWING, pyatspi.STATE_VISIBLE, pyatspi.STATE_SENSITIVE): 
    7996      return False 
     
    183200        ac = acc._acc 
    184201      path = self.acc_cache[acc] 
     202      while path == None: 
     203        acc = acc.parent 
     204        path = self.acc_cache[acc] 
    185205      return path 
    186206    except KeyError: 
    187207      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   
     223class 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  
    8484    selection = self.get_selection() 
    8585    selection.select_iter(iter) 
     86    self.current_acc = self.get_acc_from_path(self.get_model().get_path(iter)) 
    8687 
    8788  def next(self): 
     
    100101          self.next_children = True; 
    101102    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       
    103114  def focus(self): 
    104115    model, iter, acc = self._getSelection() 
     
    128139     
    129140    s = formatEvent(event) 
    130     #PrintMessage(s).sendMENU() 
     141    #PrintMessage(s).send() 
    131142 
    132143    if event.type == 'focus:' and \ 
     
    146157      top = parent_acc_with_role(event.source, pyatspi.ROLE_DIALOG,  
    147158                                        pyatspi.ROLE_ALERT,  
    148                                         pyatspi.ROLE_FRAME
     159                                        pyatspi.ROLE_FRAME, pyatspi.ROLE_WINDOW
    149160      try: 
    150161        model = self.get_model() 
     
    163174      model = self.get_model() 
    164175      path = model.getAccPath(source_acc)  
    165       if path is None: 
    166         path = model.getAccPath(source_acc.parent) 
    167176      if path is not None: 
    168177        ChildChangedMessage(path).send() 
     
    174183        ChildChangedMessage(None).send() 
    175184        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() 
    176191         
    177192    elif event.source.getRole() == pyatspi.ROLE_MENU: 
     
    280295          acc.toggleSectable() 
    281296          acc.doAction() 
     297      elif acc.hasRoleIn(pyatspi.ROLE_PAGE_TAB): 
     298        acc.toggleSectable() 
     299        self._do_actionGroup(iter) # race condition? 
    282300      else: 
    283           acc.toggleSectable() 
     301        print 'toggle' 
     302        acc.toggleSectable() 
    284303                      
    285304    # TODO: use template DP for toolkit and application 
     
    300319           
    301320    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   
    308332  def goToPath(self, path): 
    309333    if len(path) > 1: