'''
Defines a user interface for Accerciser.

Provides a workaraound that allows page tabs to be announced correctly.

@author: Eitan Isaacson
@organization: IBM Corporation
@copyright: Copyright (c) 2007
@license: BSD

All rights reserved. This program and the accompanying materials are made 
available under the terms of the BSD license which accompanies 
this distribution, and is available at
U{http://www.opensource.org/licenses/bsd-license.php}
'''
# import useful modules for Perks
import Perk, Task, AEConstants
from POR import POR
from i18n import bind, _

# metadata describing this Perk
__uie__ = dict(kind='perk', tier='accerciser', all_tiers=False)

# to support translation of strings in this Perk, uncomment the following line
# and provide the proper domain and path to your translation file
# _ = bind(domain, locale_dir)

class AccerciserPerk(Perk.Perk):
  '''
  Provides an alternative selector task instead of L{BasicSpeechPerk} that 
  reads the page tab's accessible's name instead of the faulty text interface.
  '''
  def init(self):
    self.registerTask(HandleSelectorChange('read page tab'))
                         
  def getDescription(self):
    return _('Defines a user interface for Accerciser.')

class HandleSelectorChange(Task.SelectorTask):
  '''  
  Example Task that reports when some component gains the focus.
  '''   
  def executeActive(self, por, text, **kwargs):
    if self.hasAccRole('page tab'):
      self.doTask('read item details', por=por, text=self.getAccName())
      return False
