'''
<insert purpose of Perk here>

@author: <author's name>
@organization: <author's organization (or None)>
@copyright: Copyright (c) <year and copyright holder>
@license: <license name>

All rights reserved. This program and the accompanying materials are made 
available under the terms of the <license name> which is available at
U{<license URL>}
'''
# 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=%(tier)s, all_tiers=%(all_tiers)s)

# 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 %(name)s(Perk.Perk):
  '''
  Example Perk template. Use this file as a way to get started writing your 
  own Tasks and creating your own keyboard bindings. The getDescription method
  should be changed to return a translated description of this Perk. The 
  description should include a statement of which Tiers this Perk applies to
  by default.
  '''
  def init(self):
    self.registerTask(HandleFocusChange('read test focus'))
    self.registerTask(ReadPerkName('read perk name'))
    kbd = self.getInputDevice(None, 'keyboard')
    self.addInputModifiers(kbd, kbd.AEK_CAPS_LOCK)
    self.registerCommand(kbd, 'read perk name', False, 
                         [kbd.AEK_CAPS_LOCK, kbd.AEK_A])
                         
  def getDescription(self):
    return _('Applies to %(desc)s by default.')

class ReadPerkName(Task.InputTask):
  '''
  Example Task that announces the name of this Perk.
  '''
  def execute(self, **kwargs):
    self.stopNow()
    self.sayInfo(text='%(name)s handling an input gesture')

class HandleFocusChange(Task.FocusTask):
  '''  
  Example Task that reports when some component gains the focus.
  '''   
  def executeGained(self, por, **kwargs):
    # stop current output
    self.mayStop()
    # don't stop this output with an immediate next event
    self.inhibitMayStop()
    self.sayInfo(text='%(name)s handling a focus change')
