Mini Shell

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

3

�p5[�X�@s�dZdZdZdZdZdZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZyddlmZed	d
�ZWndZYnXyLejdd�dd
lmZejdd�ddlmZejdd�ddlmZWnYnXddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z ddlm!Z!ddlm"Z"ddlm#Z#ddlm$Z$ddlm%Z%dd lm&Z&dd!l'm(Z(ej)�Z*e"j)�Z+e$j)�Z,ej-�Z.d"d#�Z/d$d%�Z0d&d'�Z-d(Z1da2d)a3e#j4e#j5a6d*a7d*a8dYd,d-�Z9d.d/�Z:d0d1�Z;d2d3�Z<d4d5�Z=d6d7�Z>d8d9�Z?gfd:d;�Z@dZd<d=�ZAd>d?�ZBd[d@dA�ZCd\dBdC�ZDd]dDdE�ZEd^dFdG�ZFd_dHdI�ZGd*aHdJdK�ZIdLdM�ZJd`dNdO�ZKdadPdQ�ZLdbdRdS�ZMdaNdTdU�ZOdcdVdW�ZPeQdXk�r�ejReP��dS)dz+The main module for the Orca screen reader.z$Id$z
$Revision$z$Date$zqCopyright (c) 2004-2009 Sun Microsystems Inc.Copyright (c) 2010-2011 The Orca TeamCopyright (c) 2012 Igalia, S.L.ZLGPL�N)�Settingsz#org.gnome.desktop.a11y.applications)Z	schema_id�Gtkz3.0)r�Gdk)rZGdkX11)�	X11Screen�)�braille)�debug)�
event_manager)�keybindings)�logger)�messages)�notification_messages)�
orca_state)�
orca_platform)�script_manager)�settings)�settings_manager)�speech)�sound)�BrailleEventc	Cs2y|j|�}Wn
dS|dkr.|r.t�dS)Nzscreen-reader-enabled)Zget_boolean�shutdown)Zgsetting�keyZenabled�r�/usr/lib/python3.6/orca.py�onEnabledChangedXsrcCstS)N)�_settingsManagerrrrr�getSettingsManagerasrcCstS)N)�_loggerrrrr�	getLoggerdsr�2�FTc
Csr|r(|tjkr(d}tjtj|d�dS|rXtjrXtjjrXtj|j	|j
�}tj|d�tj}y|j�Wn$d}tjtj|d�d}YnX|s�d}tjtj|d�dt_dStj�rtjj
j|�r�d|}tjtj|d�dStjj
j|��rd|}tjtj|d�dSd	||f}tjtj|d�|t_|�s<dStj�s\d
}tjtj|d�dStjj||tj�dS)a�Sets the locus of focus (i.e., the object with visual focus) and
    notifies the script of the change should the script wish to present
    the change to the user.

    Arguments:
    - event: if not None, the Event that caused this to happen
    - obj: the Accessible with the new locus of focus.
    - notifyScript: if True, propagate this event
    - force: if True, don't worry if this is the same object as the
      current locusOfFocus
    z3ORCA: Setting locusOfFocus to existing locusOfFocusTNzSetting locusOfFocusz)ORCA: Old locusOfFocus is null or defunctz.ORCA: New locusOfFocus is null (being cleared)z5ERROR: New locusOfFocus (%s) is zombie. Not updating.z3ERROR: New locusOfFocus (%s) is dead. Not updating.z)ORCA: Changing locusOfFocus from %s to %sz9ORCA: Cannot notify active script because there isn't one)r�locusOfFocusr�println�
LEVEL_INFO�activeScriptZapp�_scriptManagerZ	getScriptZhost_application�sourceZsetActiveScriptZgetRole�	utilitiesZisZombieZisDeadZlocusOfFocusChanged)�event�objZnotifyScript�force�msg�scriptZoldFocusrrr�setLocusOfFocus{sL

r-c	Csfd}t|�}|jdtjkr$tj�|t_ytj	|�}Wnt
jt
j�YnX|rbtj
rbd}|S)z�Called whenever a  key is pressed on the Braille display.

    Arguments:
    - command: the BrlAPI event for the key that was pressed.

    Returns True if the event was consumed; otherwise False
    FZcommandT)rr(rZdontInteruptSpeechKeysr�stoprZlastInputEvent�
_eventManagerZprocessBrailleEventr�printException�LEVEL_SEVERE�learnModeEnabled)r(�consumedrrr�_processBrailleEvent�s	r4cCsF|j�rdS|jtjkr,tjr,t�dadStrBtjrBt�dadS)zFUnsupported convenience method to call sad hacks which should go away.NTF)	ZisPressedKeyZevent_stringr�orcaModifierKeysrZbypassNextCommand�_restoreXmodmap�_restoreOrcaKeys�_createOrcaXmodmap)Z
keyboardEventrrr�updateKeyMap�sr9cCs0tjdddtjdgtjddd�}|j|�dS)z#Set the keyboard map using xkbcomp.�xkbcompz-w0�-�DISPLAYN)�stdin�stdout�stderr)�
subprocess�Popen�os�environ�PIPE�communicate)Zxkbmap�prrr�_setXmodmap�srGc
Cs�tjdtj�}tjdtj�}tjdtj�}d}d}tjd�jd�}d}x�t|�D]�\}}	|sl|j|	�r�d	}qP|r�|j|	�r�|||<tt	dj
|�d��d
Sn*|j|	�r�|||<tt	dj
|�d��d
S|	jd�rPd
SqPWd
S)zCEnable or disable use of the caps lock key as an Orca modifier key.z=^\s*interpret\s+Caps[_+]Lock[_+]AnyOfOrNone\s*\(all\)\s*{\s*$zR^\s*action\s*=\s*SetMods\s*\(\s*modifiers\s*=\s*Lock\s*,\s*clearLocks\s*\)\s*;\s*$zB^\s*action\s*=\s*LockMods\s*\(\s*modifiers\s*=\s*Lock\s*\)\s*;\s*$z)        action= LockMods(modifiers=Lock);z3        action= SetMods(modifiers=Lock,clearLocks);zUTF-8�
FTN�})�re�compile�I�_originalXmodmap�decode�split�	enumerate�matchrG�bytes�join�find)
�enableZinterpretCapsLineProgZcapsModLineProgZnormalCapsLineProgZnormalCapsLineZcapsModLine�linesZfoundCapsInterpretSection�i�linerrr�_setCapsLockAsOrcaModifier�s2






rYcCs0g}dtjkrtd�dantr,td�dadS)z�Makes an Orca-specific Xmodmap so that the keys behave as we
    need them to do. This is especially the case for the Orca modifier.
    Z	Caps_LockTFN)rr5rY�_capsLockCleared)�cmdrrrr8s
r8cCstjdtjddg�adS)z�Save the original xmodmap for the keys in keyList before we alter it.

    Arguments:
    - keyList: A list of named keys to look for.
    r:r<r;N)r@Zcheck_outputrBrCrM)�keyListrrr�
_storeXmodmap$sr]cCs4datjdddtjdgtjddd�}|jt�dS)z�Restore the original xmodmap values for the keys in keyList.

    Arguments:
    - keyList: A list of named keys to look for. An empty list means
      to restore the entire saved xmodmap.
    Fr:z-w0r;r<N)r=r>r?)rZr@rArBrCrDrErM)r\rFrrrr6.s	r6cCs tjtjdd�tj�}|j�tj�tj�tj	�d}t
r�tjd�d}ytj
|�a
tj|�d}Wq�tk
r�tjtj�Yq�tjtj�Yq�XnLtj}ytj
|�a
Wn6tk
r�tjtj�Yntjtj�YnX|s�tj�}tj|�tjd��rTy&tj�|�r6|�r6|jtj�Wntjtj�YnXnd}tjtj|d�tjd��r�ytjttj�Wn,tjtj�d	}tjtj|d�YnXtjd
��r�|j�dd�tjD�}t|7at�r�t t�t!t�t"�tj#�t$j#�tjtjd
d�dS)z�Loads (and reloads) the user settings module, reinitializing
    things such as speech if necessary.

    Returns True to indicate the input event has been consumed.
    zORCA: Loading User SettingsTFZ
activeProfiler�enableSpeechz'ORCA: Speech is not enabled in settings�
enableBraillez1ORCA: Could not initialize connection to braille.�enableSoundcSsg|]}|tkr|�qSr)�_orcaModifiers)�.0�krrr�
<listcomp>�sz$loadUserSettings.<locals>.<listcomp>zORCA: User Settings Loaded)%rr"r#r�	getPlayerrrrr%�
deactivate�
_userSettingsr�
getSetting�getGeneralSettingsZ
setProfile�ImportErrorr0r1�profile�getDefaultScriptZloadAppSettings�initZspeakMessagerZSETTINGS_RELOADEDr4rZttyZ
LEVEL_WARNINGr5rarMr6r]r8Zactivater/)r,�
inputEventZskipReloadMessage�playerZreloadedZ_profiler+Zcustomrrr�loadUserSettings<sn


rpcCs|tjrtjj�dSytjdd�}Wntjtj�dStj	j
tjtj
dd�}|j|d|�t_tjj|�tjj�dS)Nz.orca_gui_prefs�orcaZuiz
orca-setup.uiZorcaSetupWindow)rZorcaOSZshowGUI�	importlib�
import_modulerr0r1rB�pathrSrZdatadir�packageZOrcaSetupGUIrm)r,�prefs�moduleZuiFilerrr�_showPreferencesUI�s

rxcCs:i}xtjD]}tj|�||<qW|p*tj}t||�dS)z�Displays the user interface to configure the settings for a
    specific applications within Orca and set up those app-specific
    user preferences using a GUI.

    Returns True to indicate the input event has been consumed.
    T)rZuserCustomizableSettingsrrhrr$rx)r,rnrvrrrr�showAppPreferencesGUI�s

rycCs"tjtj�}tj�}t||�dS)z�Displays the user interface to configure Orca and set up
    user preferences using a GUI.

    Returns True to indicate the input event has been consumed.
    T)rrirkr%rlrx)r,rnrvrrr�showPreferencesGUI�s
rzcCs6dt_d}|r|d|7}tjtjj�|tj��dS)z}Show Orca Help window (part of the GNOME Access Guide).

    Returns True to indicate the input event has been consumed.
    Fz	help:orcaz?%sT)rr2rZshow_urirZScreenZget_defaultZget_current_event_time)r,rnZpageZurirrr�helpForOrca�s
r{cCs
t�dS)z�Quit Orca. Check if the user wants to confirm this action.
    If so, show the confirmation GUI otherwise just shutdown.

    Returns True to indicate the input event has been consumed.
    T)r)r,rnrrr�quitOrca�sr|c	Cs6ytjdd�}|j�Wntjtj�YnXdS)zzDisplays the user interface to perform an Orca Find.

    Returns True to indicate the input event has been consumed.
    z.orca_gui_findrqN)rrrsZ
showFindUIrr0r1)r,rnrwrrr�showFindGUI�s
r}cCs�tjtjdd�tr tj�r dStjrLtjdkrLt	j	t	j
tj�t	jtj�t�tjrltjdkrlt	jd�dat
r�t
jdt�tjtjdd�dS)aBInitialize the orca module, which initializes the speech and braille
    modules.  Also builds up the application list, registers for AT-SPI events,
    and creates scripts for all known applications.

    Returns True if the initialization procedure has run, or False if this
    module has already been initialized.
    zORCA: InitializingTFrZchangedzORCA: Initialized)rr"r#�_initializedrZisScreenReaderServiceEnabledr�timeoutCallback�timeoutTime�signal�SIGALRM�alarmrp�a11yAppSettingsZconnectr)�registryrrrrm�s	
rmcCs�tjtjdd�tst|�tjrHtjdkrHtjtj	tj�tj
tj�tjrbtjdkrbtj
d�|rrtjtj
�tj�d}tjtj|d�tjtjdd�|jdd�dS)	zStarts Orca.
    zORCA: StartingTrz(ORCA: Startup complete notification madezORCA: Starting registryF)ZgilN)rr"r#r~rmrrr�r�r�r��pyatspiZ
setCacheLevelZCACHE_PROPERTIESrZnotify_startup_complete�start)r��cacheValuesr+rrrr�s
r�cCsLtj�}|tkr"tj|tj�dSt�tj|�|dkrHtj|tj	�dS)Nr)
rB�getpid�EXIT_CODE_HANG�killr��SIGKILLr�sys�exit�SIGTERM)ZexitCode�pidrrr�die.s
r�cCs4d}tjtj|d�tjtj�tj�tt�dS)Nz&TIMEOUT: something has hung. Aborting.T)rr"r1Z
printStackZ	LEVEL_ALLZexamineProcessesr�r�)�signum�framer+rrr�timeout:s
r�cCs�tjtjdd�tsdStjrDtjdkrDtjtjtj�tj	tj�t
jjt
j�tj�tj�tjrptj�tjr~tj�tjr�tj�}|j�tjr�tjdkr�tj	d�datt�tjtjdd�tjj�tjtjdd�dS)z�Exits Orca.  Unregisters any event listeners and cleans up.

    Returns True if the shutdown procedure ran or False if this module
    was never initialized.
    zORCA: Shutting downTFrzORCA: Stopping registryzORCA: Shutdown complete)rr"r#r~rrr�r�r�r�rr$�presentMessagerZ	STOP_ORCAr%rfr/r^rrr_rr`rrer6rar��Registryr.)r,rnrorrrrAs0

rc	Cs�d|}tjtj|d�tr&t|�ntd7atjrZtjdkrZtjtj	tj�tj
tj�y"trht�nt
j�t�d}Wnd}YnXtjr�tjdkr�tj
d�|s�tt�dS)Nz0ORCA: Shutting down and exiting due to signal=%dTrrF)rr"r#�	exitCountr�rrr�r�r�r�r~rrr�)r�r�r+Z	cleanExitrrr�shutdownOnSignalrs(


r�cCstjr(tjjtjj�r(tjtjdd�ntjdd�tt	_
tjtjt
�tjtjt
�tjtjt
�tjtjt
�tj�s�tjd�ttj�ytj}tj�}|j|�Wntjtj�YnXtj}|r�|j j!�}|r�tj"r�t#d|�yt$tj|�Wnt%t&�YnXdS)a1The main entry point for Orca.  The exit codes for Orca will
    loosely be based on signals, where the exit code will be the
    signal used to terminate Orca (if a signal was used).  Otherwise,
    an exit code of 0 means normal completion and an exit code of 50
    means Orca exited because of a hang.F)�file�all_threads)r�TNr)'rZ	debugFilerBrt�exists�name�faulthandlerrUr�rrr��SIGHUPr��SIGINTr��SIGQUITrZisAccessibilityEnabledZsetAccessibilityrmr�r�rZ
START_ORCAr%rlr�r0r1rr$r'ZactiveWindowr!r-r�r�r�)r��messager,Zwindowrrr�main�s6



r��__main__)TF)NNF)NN)NN)NNr )NN)NN)r)NN)NN)T)S�__doc__Z__id__�__version__Z__date__Z
__copyright__Z__license__r�ZgirrrBr�rJr�r@r�Zgi.repository.Giorr�Zrequire_versionZ
gi.repositoryrrZgi.repository.GdkX11rr rrr	r
rrr
rrrrrrrZinput_eventrZ
getManagerr/r%rrrrrr�rgrMZDESKTOP_MODIFIER_KEYSZLAPTOP_MODIFIER_KEYSrarZr7r-r4r9rGrYr8r]r6rprxryrzr{r|r}r~rmr�r�r�rr�r�r��__name__r�rrrr�<module>s�
	
B"

U




&


0'
/