Mini Shell
3
�p5[�X � @ s� d Z dZdZdZdZdZddlZddlZddlZddl Z ddl
Z
ddlZddlZddl
Z
ddlZyddlmZ ed d
�ZW n dZY nX yLejdd� dd
lmZ ejdd� ddlmZ ejdd� ddlmZ W n Y nX ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm 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#j5 a6d*a7d*a8dYd,d-�Z9d.d/� Z:d0d1� Z;d2d3� Z<d4d5� Z=d6d7� Z>d8d9� Z?g fd: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)r ZGdkX11)� X11Screen� )�braille)�debug)�
event_manager)�keybindings)�logger)�messages)�notification_messages)�
orca_state)�
orca_platform)�script_manager)�settings)�settings_manager)�speech)�sound)�BrailleEventc C s2 y| j |�}W n
d S |dkr.| r.t� d S )Nzscreen-reader-enabled)Zget_boolean�shutdown)Zgsetting�keyZenabled� r �/usr/lib/python3.6/orca.py�onEnabledChangedX s r c C s t S )N)�_settingsManagerr r r r �getSettingsManagera s r c C s t S )N)�_loggerr r r r � getLoggerd s r �2 � FTc
C sr | r(|t jkr(d}tjtj|d� dS | rXt jrXt jj rXtj| j | j
�}tj|d� t j}y|j� W n$ d}tjtj|d� d}Y nX |s�d}tjtj|d� dt _dS t j�rt jj
j|�r�d| }tjtj|d� dS t jj
j|��rd| }tjtj|d� dS d ||f }tjtj|d� |t _|�s<dS t j�s\d
}tjtj|d� dS t jj| |t j� 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�objZnotifyScript�force�msg�scriptZoldFocusr r r �setLocusOfFocus{ sL
r- c C sf d}t | �} | jd tjkr$tj� | t_ytj | �}W n t
jt
j� Y nX | 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)r r( r ZdontInteruptSpeechKeysr �stopr ZlastInputEvent�
_eventManagerZprocessBrailleEventr �printException�LEVEL_SEVERE�learnModeEnabled)r( �consumedr r r �_processBrailleEvent� s r4 c C sF | j � rdS | jtjkr,tjr,t� dadS trBtj rBt� dadS )zFUnsupported convenience method to call sad hacks which should go away.NTF) ZisPressedKeyZevent_stringr �orcaModifierKeysr ZbypassNextCommand�_restoreXmodmap�_restoreOrcaKeys�_createOrcaXmodmap)Z
keyboardEventr r r �updateKeyMap� s r9 c C s0 t jdddtjd gt jddd�}|j| � dS )z#Set the keyboard map using xkbcomp.�xkbcompz-w0�-�DISPLAYN)�stdin�stdout�stderr)�
subprocess�Popen�os�environ�PIPE�communicate)Zxkbmap�pr r r �_setXmodmap� s rG c
C s� t jdt j�}t jdt j�}t jdt j�}d}d}tjd�jd�}d}x�t|�D ]�\}} |sl|j| �r�d }qP| r�|j| �r�|||<