Mini Shell

Direktori : /lib/python3.6/site-packages/orca/__pycache__/
Upload File :
Current File : //lib/python3.6/site-packages/orca/__pycache__/mouse_review.cpython-36.pyc

3

�p5[+�	@sdZdZdZdZdZdZddlZddlZddlZddl	Z	ddl
mZy ejd	d
�ddl
m
Z
dZWnd
ZYnXddlmZddlmZddlmZddlmZddlmZddlmZddlmZej�Zej�Zej�ZGdd�d�ZGdd�d�ZGdd�d�Ze�ZdS)zMouse review mode.z$Id$z
$Revision$z$Date$z@Copyright (c) 2008 Eitan IsaacsonCopyright (c) 2016 Igalia, S.L.ZLGPL�N)�Gdk�Wnckz3.0)rTF�)�debug)�
event_manager)�messages)�
orca_state)�script_manager)�settings_manager)�speechc@s*eZdZdZddd�Zdd�Zd	d
�ZdS)�_StringContextz8The textual information associated with an _ItemContext.N�rcCs&t|�|_||_||_||_||_dS)a�Initialize the _StringContext.

        Arguments:
        - string: The human-consumable string
        - obj: The accessible object associated with this string
        - start: The start offset with respect to entire text, if one exists
        - end: The end offset with respect to the entire text, if one exists
        - script: The script associated with the accessible object
        N)�hash�_obj�_script�_string�_start�_end)�self�obj�script�string�start�end�r�"/usr/lib/python3.6/mouse_review.py�__init__:s

z_StringContext.__init__cCs8|dk	o6|j|jko6|j|jko6|j|jko6|j|jkS)N)rrrr)r�otherrrr�__eq__Ks
z_StringContext.__eq__cCsX|jo
|jsdS|jjj|jd�}|jjj|j�}|jj||dd�|jj|jd�dS)z"Presents this context to the user.F)r)�voice�	interruptrT���)rr�speechGeneratorr�	utilitiesZadjustForRepeatsZspeakMessageZdisplayBrailleMessage)rrrrrr�presentRsz_StringContext.present)Nr
rr)�__name__�
__module__�__qualname__�__doc__rrr$rrrrr7s
rc@s2eZdZdZddd�Zdd�Zdd	�Zd
d�ZdS)
�_ItemContextz;Holds all the information of the item at a specified point.rNcCs,||_||_||_||_||_|j�|_dS)aIInitialize the _ItemContext.

        Arguments:
        - x: The X coordinate
        - y: The Y coordinate
        - obj: The accessible object of interest at that coordinate
        - frame: The containing accessible object (often a top-level window)
        - script: The script associated with the accessible object
        N)�_x�_yr�_framer�_getStringContextr)r�x�yr�framerrrrrbsz_ItemContext.__init__cCs,|dk	o*|j|jko*|j|jko*|j|jkS)N)r,rr)rrrrrrtsz_ItemContext.__eq__cCs�|jo
|jst|j�Stj|j�}d|kr8t|j|j�S|jj�}|jtj�sVtj}ntj	}|jj
j|j|j|j
|d�\}}}|r�|jj
j|j�r�|jjj|j�}t|j|j|||�S)z?Returns the _StringContext associated with the specified point.ZText)�boundary)rrr�pyatspiZlistInterfacesZgetState�containsZSTATE_SELECTABLEZTEXT_BOUNDARY_WORD_STARTZTEXT_BOUNDARY_LINE_STARTr#ZtextAtPointr*r+Z
isTextArear"ZgetRoleName)rZ
interfaces�stater1rrrrrrr-zs

z_ItemContext._getStringContextcCs�||krdS|jr|j|jkpFtj|j|jd|j|jd�dk}|rV|jj�|jrz|j|jkrz|jj|jdd�|j	|j	kr�|j	j
�r�dS|jr�|j|jkr�|jj|j�dS)z"Presents this context to the user.F��T)ZalreadyFocused)r�mathZsqrtr*r+rZpresentationInterruptr,Z
presentObjectrr$)rZpriorr rrrr$�s*
z_ItemContext.present)rrNNN)r%r&r'r(rrr-r$rrrrr)_s

r)c@sneZdZdZdd�Zdd�Zdd�Zdd	�Zddd�Zd
d�Z	ddd�Z
ddd�Zdd�Zdd�Z
dd�Zd
S)�
MouseReviewerz(Main class for the mouse-review feature.cCs�tjd�|_t�|_d|_g|_i|_tsBd}t	j
t	j|d�dStj
j�}ytj
j|�}|j�|_Wn(tk
r�d}t	j
t	j|d�dSX|js�dS|j�dS)N�enableMouseReviewz)MOUSE REVIEW ERROR: Wnck is not availableTz.MOUSE REVIEW ERROR: Gtk+ 3.20 is not available)�_settingsManagerZ
getSetting�_activer)�_currentMouseOver�_pointer�_windows�_handlerIds�_mouseReviewCapabler�println�
LEVEL_INFOrZDisplay�get_defaultZget_default_seatZget_pointer�AttributeError�activate)r�msgZdisplayZseatrrrr�s(
zMouseReviewer.__init__cCs
d|jiS)z8Returns the accessible-event listeners for mouse review.z	mouse:abs)�	_listener)rrrr�_get_listeners�szMouseReviewer._get_listenerscCs8tj|j��tjj�}|r4|jd|j�}||j|<dS)zActivates mouse review.zwindow-stacking-changedN)	�
_eventManagerZregisterModuleListenersrHrZScreenrCZconnect�_on_stacking_changedr?)r�screen�irrrrE�s

zMouseReviewer.activatecCs:tj|j��x |jj�D]\}}|j|�qWi|_dS)zDeactivates mouse review.N)rIZderegisterModuleListenersrHr?�itemsZ
disconnect)r�key�valuerrr�
deactivate�szMouseReviewer.deactivateNcCsZtsdS|j|_tjd|j�|js6|j�tj}n|j�tj}t	j
rVt	j
j|�dS)z!Toggle mouse reviewing on or off.Nr9)r@r;r:Z
setSettingrPrZMOUSE_REVIEW_DISABLEDrEZMOUSE_REVIEW_ENABLEDr�activeScriptZpresentMessage)rr�eventrFrrr�toggle�s
zMouseReviewer.togglecCs|j�}|j�||_dS)z3Callback for Wnck's window-stacking-changed signal.N)Zget_windows_stacked�reverser>)rrKZstackedrrrrJ�sz"MouseReviewer._on_stacking_changedc
Cs0|dkrtj}y|j�j|||�SdSdS)NF)r2�DESKTOP_COORDS�queryComponentr3)rrr.r/�	coordTyperrr�_contains_point�szMouseReviewer._contains_pointc	Cs<|dkrtj}y|j�j|�}Wn
dSt|�t|�kS)z2Returns True if the bounding box of obj is bounds.NF)r2rUrVZ
getExtents�list)rrZboundsrWZextentsrrr�_has_bounds�szMouseReviewer._has_boundscs:d}x\�jD]R}|j�\}}}}|�ko6||knr|�koR||knr|}PqW|sjdSd}	|j�j�}
x&tjjd�D]}|j�|
kr�|}	Pq�W|	s�dS���fdd�|	D�}t|�dkr�|dS|j	���fdd�|D�}
t|
�dk�r|
dS|j
����fdd�|D�}
t|
�dk�r6|
dSdS)z;Returns the accessible window at the specified coordinates.Nrcsg|]}�j|���r|�qSr)rX)�.0�o)�pX�pYrrr�
<listcomp>#sz=MouseReviewer._accessible_window_at_point.<locals>.<listcomp>rcsg|]}|j�kr|�qSr)�name)r[r\)r`rrr_(scsg|]}�j|��r|�qSr)rZ)r[r\)�bboxrrrr_-s)r>Zget_geometryZget_applicationZget_pidr2ZRegistryZ
getDesktopZget_process_id�lenZget_nameZget_client_window_geometry)rr]r^�window�wr.r/�widthZheightZapp�pid�aZ
candidatesZmatchesr)rar`r]r^rr�_accessible_window_at_points88z)MouseReviewer._accessible_window_at_pointc
Cs�|jj�\}}}|j||�}d|||f}tjtj|d�|sBdStj}|sPdS|jj	|||�}d|||f}tjtj|d�t
j|j�|�}t
|||||�}	|	j|j�|	|_dS)zCallback for mouse:abs events.z&MOUSE REVIEW: Window at (%i, %i) is %sTNz&MOUSE REVIEW: Object at (%i, %i) is %s)r=Zget_positionrhrrArBrrQr#ZdescendantAtPoint�_scriptManagerZ	getScriptZgetApplicationr)r$r<)
rrRrKr]r^rcrFrr�newrrr�_on_mouse_moved3s zMouseReviewer._on_mouse_movedcCsjtj�}d|j}tjtj|d�|jjd�r8|j|�dtj�|}|d|j7}tjtj|d�dS)z2Generic listener, mainly to output debugging info.z$
vvvvv PROCESS OBJECT EVENT %s vvvvvFz	mouse:abszTOTAL PROCESSING TIME: %.4f
z$^^^^^ PROCESS OBJECT EVENT %s ^^^^^
N)�time�typerrArB�
startswithrk)rrRZ	startTimerFrrrrGJs

zMouseReviewer._listener)NN)N)N)r%r&r'r(rrHrErPrSrJrXrZrhrkrGrrrrr8�s	

	

'r8)r(Z__id__�__version__Z__date__Z
__copyright__Z__license__Zgir7r2rlZ
gi.repositoryrZrequire_versionrr@r
rrrrr	r
rZ
getManagerrIrir:rr)r8Zreviewerrrrr�<module>s>
(J1