Changeset 76

Show
Ignore:
Timestamp:
11/29/07 15:18:46
Author:
slee
Message:

hyperlinks

Files:

Legend:

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

    r75 r76  
    8989 
    9090  def isEditable(self): 
    91     return self.hasInterface('EditableText') 
     91    return self.hasInterface('EditableText') \ 
     92           and self.hasStates(pyatspi.STATE_EDITABLE) 
    9293 
    9394  def isActionable(self): 
    94     return self.hasInterface('Action') 
     95    return self.hasInterface('Action') or self.getHyperlinkObject() <> None 
    9596   
    9697  def isSelectable(self): 
     
    145146  def doAction(self): 
    146147    try: 
    147       action_if = acc.queryAction() 
     148      action_if = self.queryAction() 
    148149      action_if.doAction(0) 
    149     except: 
    150       pass 
     150    except NotImplementedError: 
     151      try: 
     152        ao = self.getHyperlinkObject(0) 
     153        if ao is not None: 
     154          if ao.isValid(): 
     155            action_if = ao.queryAction() 
     156            action_if.doAction(0) 
     157      except:           
     158        pass 
    151159 
     160  def getHyperlinkObject(self, nAnchor = 0): 
     161    try: 
     162      hi = self._acc.queryHyperlink() 
     163      if hi.getURI(nAnchor) == '': 
     164        return None 
     165      return hi.getObject(nAnchor) 
     166    except NotImplementedError: 
     167      return None 
     168 
     169  def isHyperlink(self): 
     170    return self.getHyperlinkObject() is not None 
  • action_groups/trunk/ActionBrowser.py

    r75 r76  
    123123 
    124124  def _onRowActivated(self, treeview, path, column): 
    125     self._onExamine(self, None) 
     125    self._onExamine(None) 
    126126    #acc = self.groups_tree.get_acc_from_path(path) 
    127127    #self.node.update(acc) 
     
    240240    if acc is None:  
    241241      return 
    242     printEvent(event) 
     242    #printEvent(event) 
    243243    if event.source.getRole() == pyatspi.ROLE_WINDOW \ 
    244244       and event.type in ('object:state-changed:showing'): 
     
    258258        if menu_iter: 
    259259          menu_path = model.get_path(menu_iter) 
    260         if self.row_expanded(menu_path): 
    261             self.collapse_row(menu_path) 
    262             model.dePopLevel(menu_iter, all=True) 
    263             acc.is_group = False 
    264             self.get_selection().select_iter(menu_iter) 
     260          if self.row_expanded(menu_path): 
     261              self.collapse_row(menu_path) 
     262              model.dePopLevel(menu_iter, all=True) 
     263              acc.is_group = False 
     264              self.get_selection().select_iter(menu_iter) 
    265265 
    266266  def do_action(self): 
     
    270270    acc.grabFocus() 
    271271 
     272    if acc.isEditable(): 
     273      try: 
     274        MessageBox(None, 'You are now editing the text:\r\n%s' % acc.getText()) 
     275      except: 
     276        raise 
     277       
    272278    # TODO: use template DP for toolkit and application 
    273     if acc.isActionable(): 
     279    elif acc.isActionable(): 
    274280      if not (acc.getRole() == pyatspi.ROLE_MENU and self.row_expanded(path)): 
    275281        if acc.hasRoleIn(pyatspi.ROLE_MENU, pyatspi.ROLE_MENU_ITEM) and acc.hasToolkitIn('Gecko'): 
     
    277283        else: 
    278284          acc.doAction() 
    279        
    280     elif acc.isEditable(): 
    281       try: 
    282         MessageBox(None, 'You are now editing the text:\r\n%s' % acc.getText()) 
    283       except: 
    284         raise 
    285        
     285      if acc.isHyperlink(): 
     286        # need to refresh - this is heavy handed 
     287        iter = model.iter_parent_with_role(iter, pyatspi.ROLE_DOCUMENT_FRAME) 
     288        path = model.get_path(iter) 
     289        acc = model[model.get_iter_root()][ActionModel.COL_ACC] 
     290        self.set_top_acc(acc) 
     291        selection = self.get_selection() 
     292        selection.select_path(path) 
     293 
     294           
    286295    elif acc.isSelectable(): 
    287296      acc.toggleSectable() 
    288  
     297              
    289298    if acc.is_group:  
    290299      if self.row_expanded(path): 
  • action_groups/trunk/ActionModel.py

    r75 r76  
    2727        print '%s %s%s ' % (child._acc, ('i' if child.is_interactive else ''), 
    2828                                         ('g' if child.is_group else '')) 
    29       else
     29      elif child.hasStates(pyatspi.STATE_SHOWING)
    3030        self._populateChildren(child_acc) 
    3131 
     
    6363    for child in acc: 
    6464      child = AccDecorator(child) 
    65       if not child.hasStates(pyatspi.STATE_SHOWING): 
     65      if not child.hasStates(pyatspi.STATE_SHOWING, pyatspi.STATE_VISIBLE): 
    6666        continue 
    6767      if self._isInteractive(child) or \ 
     
    7575      return False 
    7676    #print self, self.getStates() 
    77     return acc.isSelectable() or acc.hasInterfaceIn('Action','EditableText', 'Hypertext') 
     77    return acc.isSelectable() or acc.isActionable() or acc.isEditable() 
     78         
    7879 
    79   def hasInteractiveChild(self): 
     80  def _hasInteractiveChild(self): 
    8081    rv = None 
    8182    for child in self._acc: