
    g
f                        d Z dZdZdZdZdZddlZ ej                  dd	       dd
lm	Z	 ddl
mZ ddlmZ ddlmc mc mZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ  G d dej@                        Z y)zCustom script for pidgin.z$Id$z
$Revision$z$Date$z#Copyright (c) 2010 Joanmarie Diggs.LGPL    NAtspiz2.0)r   )AXObject)AXTable)AXUtilities   )Chat	UtilitiesSpeechGeneratorc                        e Zd Z fdZd Zd Zd Z fdZd Zd Z	d Z
d	 Z fd
Z fdZ fdZ fdZ fdZ fdZ xZS )Scriptc                    t         j                  j                  t         j                  j                  t         j                  j                  t         j                  j
                  t         j                  j                  t         j                  j                  t         j                  j                  gg| _        t        | )  |       y)zCreates a new script for the given application.

        Arguments:
        - app: the application to create a script for.
        N)r   Role
TREE_TABLESCROLL_PANEFILLERPAGE_TABPAGE_TAB_LISTFRAME_buddyListAncestriessuper__init__)selfapp	__class__s     A/usr/lib/python3/dist-packages/orca/scripts/apps/pidgin/script.pyr   zScript.__init__/   s~     ',jj&;&;&+jj&<&<&+jj&7&7&+jj&9&9&+jj&>&>&+jj&7&7&+jj&6&6&8 %9! 	    c                 .    t        | | j                        S )z)Returns the 'chat' class for this script.)r	   r   r   s    r   getChatzScript.getChatB   s     D$3344r   c                     t        |       S )z.Returns the speech generator for this script. r   r!   s    r   getSpeechGeneratorzScript.getSpeechGeneratorG   s     t$$r   c                     t        |       S )z&Returns the utilities for this script.r
   r!   s    r   getUtilitieszScript.getUtilitiesL   s     r   c                     t         |           | j                  j                  | j                  j                         y)zDefines InputEventHandler fields for this script that can be
        called by the key and braille bindings. Here we need to add the
        handlers for chat functionality.
        N)r   setupInputEventHandlersinputEventHandlersupdatechat)r   r   s    r   r(   zScript.setupInputEventHandlersQ   s.     	')&&tyy'C'CDr   c                 .    | j                   j                  S )z=Returns the application-specific keybindings for this script.)r+   keyBindingsr!   s    r   getAppKeyBindingszScript.getAppKeyBindingsZ   s     yy$$$r   c                 6    | j                   j                         S )zReturn a GtkGrid containing the application unique configuration
        GUI items for the current application. The chat-related options get
        created by the chat module.)r+   getAppPreferencesGUIr!   s    r   r0   zScript.getAppPreferencesGUI_   s    
 yy--//r   c                 6    | j                   j                         S )z7Returns a dictionary with the app-specific preferences.)r+   getPreferencesFromGUIr!   s    r   r2   zScript.getPreferencesFromGUIf   s     yy..00r   c                    t        j                  d       t        j                  |j                        rt        j                  d       |j                  j                  d      rnt        j                  j                  t        j                  j                  t        j                  j                  g}| j                  j                  |j                  |      rd}t        j                  |j                  d       }t        j                   |      }|syt        j"                  |j                        D ]  }|t        j                   |      k(  sd} n |r|t        j$                  |j                  d      }t        j                   |      }|rDt&        j(                  |z  }| j*                  j-                  ||      }	| j/                  ||		       yyyyy)
z>Callback for object:children-changed:add accessibility events.zchildren-changed event.zobject:children-changed:addFc                 b    t        j                  |       t        j                  j                  k(  S )N)r   get_roler   r   r   )xs    r   <lambda>z(Script.onChildrenAdded.<locals>.<lambda>   s#    9J9J19MQVQ[Q[QaQa9a r   NT)objstring)voice)r   clear_cache_nowr   is_table_relatedsourcer   type
startswithr   r   r   r   r   	utilitieshasMatchingHierarchyfind_ancestorget_nameiter_children	get_childmessagesCHAT_NEW_TABspeechGeneratorr;   speakMessage)
r   event	rolesList	nameFoundframe	frameNamechild	childNameliner;   s
             r   onChildrenAddedzScript.onChildrenAddedk   s    	  !:;''5##$=>
 ::  !>?11**))+I ~~225<<K "	 ..u||/ac$--e4	 %33ELLA E H$5$5e$<<$(	 $..u||R@E ( 1 1% 8I '44y@ $ 4 4 : :uT : R))$e)< ! % L	 @r   c                 p    | j                   j                  |j                        ryt        |   |       y)zhCalled whenever a property on an object changes.

        Arguments:
        - event: the Event
        N)r+   isInBuddyListr>   r   onNameChangedr   rK   r   s     r   rV   zScript.onNameChanged   +     99""5<<0e$r   c                 p    | j                   j                  |j                        ryt        |   |       y)zgCalled whenever text is deleted from an object.

        Arguments:
        - event: the Event
        N)r+   rU   r>   r   onTextDeletedrW   s     r   rZ   zScript.onTextDeleted   rX   r   c                 \    | j                   j                  |      ryt        |   |       y)z+Called whenever text is added to an object.N)r+   presentInsertedTextr   onTextInsertedrW   s     r   r]   zScript.onTextInserted   s'     99((/u%r   c                 p    | j                   j                  |j                        ryt        |   |       y)zCalled whenever an object's value changes.  Currently, the
        value changes for non-focused objects are ignored.

        Arguments:
        - event: the Event
        N)r+   rU   r>   r   onValueChangedrW   s     r   r_   zScript.onValueChanged   s+     99""5<<0u%r   c                    t         j                  s7d}t        j                  t        j                  |d       t
        |   |       yd}t        j                  t        j                  |d       t        j                  |j                         d}t        j                  t        j                  |d       t
        |   |       y)z/Called whenever a toplevel window is activated.z(PIDGIN: Hack for missing events disabledTNz(PIDGIN: Starting hack for missing eventsz3PIDGIN: Hack to work around missing events complete)
settingsenableSadPidginHackdebugprintMessage
LEVEL_INFOr   onWindowActivatedr   find_all_page_tabsr>   )r   rK   msgr   s      r   rf   zScript.onWindowActivated   s     ++<Cu//d;G%e,85++S$7
 	&&u||4C5++S$7!%(r   c                     |j                   }| j                  j                  |      r)t        j                  |      }| j                  |d       yt        |   |       y)z@Callback for object:state-changed:expanded accessibility events.T)alreadyFocusedN)r>   r+   rU   r   get_next_siblingpresentObjectr   onExpandedChanged)r   rK   r9   r   s      r   rm   zScript.onExpandedChanged   sS     ll99""3'++C0Cs48!%(r   )__name__
__module____qualname__r   r"   r$   r&   r(   r.   r0   r2   rS   rV   rZ   r]   r_   rf   rm   __classcell__)r   s   @r   r   r   -   sU    &5
%

E%
01
&=P
%
%&&)*
) 
)r   r   )!__doc____id____version____date____copyright____license__girequire_versiongi.repositoryr   
orca.debugrc   orca.messagesrG   orca.scripts.toolkits.gtkscriptstoolkitsgtkorca.settingsra   orca.ax_objectr   orca.ax_tabler   orca.ax_utilitiesr   r+   r	   script_utilitiesr   speech_generatorr   r    r   r   <module>r      sn   *  5 	   7E "     ' '   # ! )  ' -r)SZZ r)r   