%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/orca/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/orca/__pycache__/braille_generator.cpython-312.pyc

�

g
f~R��@�dZdZdZdZdZdZddlZejdd	�dd
lm	Z	ddl
mZdd
l
mZddl
m
Z
ddl
mZddl
mZddl
mZddl
mZddl
mZddlmZddlmZddlmZddlmZddlmZGd�d�Ze�gZGd�dej>�Z y)z:Utilities for obtaining braille presentations for objects.z$Id$z
$Revision$z$Date$z-Copyright (c) 2005-2009 Sun Microsystems Inc.�LGPL�N�Atspiz2.0)r�)�braille)�debug)�
focus_manager)�	generator)�messages)�object_properties)�settings)�settings_manager)�AXObject)�AXText)�AXUtilities)�AXValue)�shortRoleNamesc��eZdZdZdd�Zy)�SpacezxA dummy class to indicate we want to insert a space into an
    utterance, but only if there is text prior to the space.c��||_y�N)�	delimiter��selfrs  �8/usr/lib/python3/dist-packages/orca/braille_generator.py�__init__zSpace.__init__2s	��"���N�� )�__name__�
__module__�__qualname__�__doc__r�rrrr/s
��@�#rrc���eZdZdZej
jej
jej
jej
jej
jej
jfZd�Z
d�Zd�Zd�Zd�Z�fd�Zd�Zd	�Zd
�Zd�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Z�fd�Z�fd�Zd�Z d�Z!d�Z"dd�Z#dd�Z$�xZ%S)�BrailleGeneratoraTakes accessible objects and produces a list of braille Regions
    for those objects.  See the generateBraille method, which is the
    primary entry point.  Subclasses can feel free to override/extend
    the brailleGenerators instance field as they see fit.c�F�tjj||d�y)Nr)r	�	Generatorr)r�scripts  rrzBrailleGenerator.__init__Ds�����$�$�T�6�9�=rc��tjj||�|j|d<tj
|d<tj|d<tj|d<tj|d<|j|d<y)zCOther things to make available from the formatting string.
        �space�	Component�Region�Text�Link�asStringN)
r	r'�_addGlobalsr*rr+r,r-r.r/)r�globalsDicts  rr0zBrailleGenerator._addGlobalsGsp��	���'�'��k�:�#�z�z��G��#*�#4�#4��K� � '����H��%�l�l��F��%�l�l��F��"&�-�-��J�rc��t|tjtjf�syt	j
||j�sytj|�tj|j�k(S)NF)	�
isinstancerr+r-r�have_same_role�
accessibler�get_name)r�obj�regions   r�_isCandidateFocusedRegionz*BrailleGenerator._isCandidateFocusedRegionRs^���&�7�#4�#4�g�l�l�"C�D���)�)�#�v�/@�/@�A��� � ��%��):�):�6�;L�;L�)M�M�Mrc����tj�jd�sLtj�jd�s)tjtj
dd�gdgS�t
j�j�k(r|jdd�sd|d<�j�fi|��}	|d}|D�]}t|tjtjf�r8�jj j#|j$�d�r|}||gSt|tj�r>t'j(��r)t+j,|j$��k(r|}||gSt|tj�s��t'j.��s��t+j,|j$��k(s��|}||gS��fd�}t1t3||��}d	�d
|g}tj4tj
|d�t7|�dk(r|d}||gS#t$rd}Y���wxYw)N�
enableBraille�enableBrailleMonitorz&BRAILLE GENERATOR: generation disabledT�
formatType�focusedrc�(���j�|�Sr)r9)�xr7rs ��r�predz.BrailleGenerator.generateBraille.<locals>.pred�s����5�5�c�1�=�=rz9BRAILLE GENERATOR: Could not determine focused region forzCandidates:r)r
�
getManager�
getSettingr�printMessage�
LEVEL_INFOr�get_locus_of_focus�get�generate�	Exceptionr3rr+r-�_script�	utilities�isSameObjectr5r�is_combo_boxr�
get_parent�
is_table_cell�list�filter�printTokens�len)	rr7�args�result�
focusedRegionr8rA�
candidates�tokenss	``       r�generateBraillez BrailleGenerator.generateBraille[s����*�*�,�7�7��H�#�.�.�0�;�;�<R�S����u�/�/�1Y�[_�`���:���-�*�*�,�?�?�A�A��8�8�L�$�/�!*�D�������s�+�d�+��	!�"�1�I�M��	.�F��&�7�#4�#4�g�l�l�"C�D��<�<�)�)�6�6�v�7H�7H�#�t�T� &�
��.�
�&�&�-�F�G�L�L�1� �-�-�c�2��(�(��):�):�;�s�B� &�
��$�
�&�&�#�F�G�$5�$5�6� �.�.�s�3��(�(��):�):�;�s�B� &�
���
�&�&�7	.�"
>��f�T�6�2�3�J�Q��=�*�6�F����e�.�.���=��:��!�#� *�1�
�
��
�&�&��=�	!� �M�	!�s�I�I�Ic��|jd�r%tj�jd�sgSg}|jdt	j
|��}tj�jd�}tjjtjjtjjtjjtjjg}tjt	j|��r$|j!t	j
|��|t"j$k(rC|j'tjj(tjj*g�|tjj,k(rI|j.j0j3|�}|j!t4j6|z�|S|t"j8k(r8|jdd�s&||vr"|j!|j:|fi|���|S)aReturns the role name for the object in an array of strings, with
        the exception that the Atspi.Role.UNKNOWN role will yield an
        empty array.  Note that a 'role' attribute in args will
        override the accessible role of the obj.
        �isProgressBarUpdate�brailleProgressBarUpdates�role�brailleVerbosityLevel�
readingRowF)rGr
rBrCr�get_roler�Role�UNKNOWN�REDUNDANT_OBJECT�FILLER�EXTENDED�LINKr�is_list_boxrN�appendr�VERBOSITY_LEVEL_BRIEF�extend�ICON�CANVAS�HEADINGrJrK�headingLevelr�ROLE_HEADING_LEVEL_BRAILLE�VERBOSITY_LEVEL_VERBOSE�getLocalizedRoleName)rr7rTrUr]�verbosityLevel�doNotPresent�levels        r�_generateRoleNamez"BrailleGenerator._generateRoleName�s����8�8�)�*�#�.�.�0�;�;�<W�X��I����x�x��� 1� 1�#� 6�7��)�4�4�6�A�A�BY�Z���
�
�*�*��
�
�3�3��
�
�)�)��
�
�+�+��
�
���	)���"�"�8�#6�#6�s�#;�<����� 1� 1�#� 6�7��X�;�;�;���������%�*�*�2C�2C� D�E��5�:�:�%�%�%��L�L�*�*�7�7��<�E��M�M�+�F�F��N�O�
�
��x�?�?�
?��8�8�L�%�0�T��5M��M�M�3�$�3�3�C�@�4�@�A��
rc���tj�jd�tjk(r>|jdt
j|��}tj
|�}|r|St�|�(|fi|��S)z�Returns the localized name of the given Accessible object; the name
        is suitable to be brailled.

        Arguments:
        - obj: an Accessible object
        �brailleRolenameStyler])r
rBrCr�BRAILLE_ROLENAME_STYLE_SHORTrGrr`r�superrq)rr7rTr]�rv�	__class__s     �rrqz%BrailleGenerator.getLocalizedRoleName�ss����&�&�(�3�3�4J�K��8�8�9��8�8�F�H�$5�$5�c�$:�;�D��#�#�D�)�B���	��w�+�C�8�4�8�8rc��g}|jjj|�}|D]&}|j|fi|��}|j	|��(|Sr)rJrK�unrelatedLabels�
_generateNamerj)rr7rTrU�labels�label�names       r�_generateUnrelatedLabelsz)BrailleGenerator._generateUnrelatedLabels�sZ�������'�'�7�7��<���	 �E�%�4�%�%�e�4�t�4�D��M�M�$��	 ��
rc��tj�jd�}|tjk(rgSg}|j
jj|�\}}}|r|jd|zdz�|S)z�Returns an array of strings (and possibly voice and audio
        specifications) that represent the accelerator for the object,
        or an empty array if no accelerator can be found.
        r^�(�))	r
rBrCrrirJrK�mnemonicShortcutAcceleratorrh)rr7rTrrrU�mnemonic�shortcut�accelerators        r�_generateAcceleratorz%BrailleGenerator._generateAccelerator�sw��*�4�4�6�A�A�BY�Z���X�;�;�;��I����L�L�"�"�>�>�s�C�	*��8�[���M�M�#��+�c�1�2��
rc���g}	|jjj|�}|dkDr$|j	tj|��|S#t$rd}Y�8wxYw)z�Returns an array of strings that says how many alerts and dialogs
        are associated with the application for this object.  [[[WDW -
        I wonder if this string should be moved to settings.py.]]]
        r)rJrK�unfocusedAlertAndDialogCountrIrhr
�dialogCountBraille)rr7rTrU�alertAndDialogCounts     r�_generateAlertAndDialogCountz-BrailleGenerator._generateAlertAndDialogCount�si��
��	$����&�&�C�C�C�H�
 ���"�
�]�]�8�6�6�7J�K�
L��
���	$�"#��	$�s�%A�A"�!A"c��g}tj�jd�s|Sd|d<|jdt	j
|��}|tjjk(}t	j|�}|r6t	j
|�|jvrt	j|�}|�r�g}t	j
|�}|tjjk7r�|tjjk7r�|tjjk7rw|tjjk7rZ|tjjk7r=|j j"j%|�s||d<|j&|fi|��}|tjjtjj(fvrr|j j"j+|�}|rKt-|�r@|j/�s0|s,t	j
|�|d<|j&|fi|��}nd}|r&|r$|j1t3j4d��|j7|�|tjj8k(rnt	j|�}|r���|j;�|S)aEReturns an array of strings (and possibly voice and audio
        specifications) that represent the text of the ancestors for
        the object.  This is typically used to present the context for
        an object (e.g., the names of the window, the panels, etc.,
        that the object is contained in).  If the 'priorObj' attribute
        of the args dictionary is set, only the differences in
        ancestry between the 'priorObj' and the current obj will be
        computed.  The 'priorObj' is typically set by Orca to be the
        previous object with focus.
        �enableBrailleContextF�includeContextr]r)r
rBrCrGrr`rra�RADIO_BUTTON�get_parent_checked�SKIP_CONTEXT_ROLESrd�INVALID�SECTION�
SPLIT_PANE�
DESKTOP_FRAMErJrK�isLayoutOnlyrH�PANEL�displayedLabelrS�isspacerhrr,rj�EMBEDDED�reverse)	rr7rTrUr]�excludeRadioButtonGroup�parent�parentResultr�s	         r�_generateAncestorsz#BrailleGenerator._generateAncestorss+�����*�*�,�7�7�8N�O��M�!&��
���x�x��� 1� 1�#� 6�7��"&�%�*�*�*A�*A�"A���,�,�S�1���x�(�(��0�D�4K�4K�K��0�0��8�F���L��$�$�V�,�D��u�z�z�(�(�(��E�J�J�.�.�.��E�J�J�.�.�.��E�J�J�1�1�1��E�J�J�4�4�4����.�.�;�;�F�C�#��V��,�t�}�}�V�<�t�<����
�
�)�)�5�:�:�+;�+;�<�<����.�.�=�=�f�E���S��Z��
�
��2�'/�'8�'8��'@��V��'4�t�}�}�V�'D�t�'D��27�/��,��
�
�g�n�n�S�1�2��M�M�,�'��u�z�z�*�*�*���0�0��8�F�M�N	�����
rc���g}|jdtj|��}|tjj
tjjfvr|Stj|�r&|jjj|�}ntj|�g}|r|ds|St|j|�D]}|j|��|S)Nr]r)rGrr`rra�LIST�LIST_BOX�supports_selectionrJrK�selectedChildrenr�get_focused_object�mapr~rj)rr7rTrUr]�items�items       r�_generateFocusedItemz%BrailleGenerator._generateFocusedItemJs������x�x��� 1� 1�#� 6�7����
�
������)<�)<�=�=��M��&�&�s�+��L�L�*�*�;�;�C�@�E� �3�3�C�8�9�E��%��(��M���*�*�E�2�	 �D��M�M�$��	 ��
rc��|jjj|�}|dkrgSdtj|��d�gS)Nrr�r�)rJrK�getValueCountForTermr
�valueCountForTerm)rr7rT�counts    r�_generateTermValueCountz(BrailleGenerator._generateTermValueCount\sF�����&�&�;�;�C�@���1�9��I��H�.�.�u�5�6�a�8�9�9rc�:�tj|�sgS|jjj	|�}|r||gk(rgSg}|D]M}|j|d��}|s�|j
|�|jtjd���O|S�NF)r�r)
r�
is_status_barrJrK�statusBarItemsrHrjrhrr,)rr7rTr�rU�child�childResults       r�_generateStatusBarz#BrailleGenerator._generateStatusBarcs����(�(��-��I����&�&�5�5�c�:����#����I����	3�E��-�-��e�-�D�K���
�
�k�*��
�
�g�n�n�S�1�2�		3��
rc��tjtj|��sgSg}tj|�D]H}|j|j
|d���|jtjd���J|Sr�)
rrgrrN�get_all_widgetsrjrHrhrr,)rr7rTrU�widgets     r�_generateListBoxItemWidgetsz,BrailleGenerator._generateListBoxItemWidgetstst���&�&�x�':�':�3�'?�@��I���!�1�1�#�6�	/�F��M�M�$�-�-��u�-�E�F��M�M�'�.�.��-�.�	/��
rc��|jd�r|j|fi|��sgS|j�\}}}||k7r|j|�\}}|�gSgS)Nr[)rG�_shouldPresentProgressBarUpdate�_getMostRecentProgressBarUpdate�getProgressBarNumberAndCount)rr7rT�acc�
updateTime�updateValue�numberr�s        r�_generateProgressBarIndexz*BrailleGenerator._generateProgressBarIndex~sh���x�x�-�.�6�$�6�6�s�C�d�C��I�'+�'K�'K�'M�$��Z���#�:� �=�=�c�B�M�F�E��h�=� ��	rc���|jd�r|j|fi|��sgS|j|fi|��}|tj�j�k(r|sdgS|S)Nr[�)rGr��_generatePercentagerrBrF)rr7rTrUs    r�_generateProgressBarValuez*BrailleGenerator._generateProgressBarValue�sh���8�8�)�*�7�4�7�7��D�t�D��I�)��)�)�#�6��6���-�*�*�,�?�?�A�A�&��4�K��
rc�@�tj|�}|�|�d�gSgS)N�%)r�get_value_as_percent)rr7rT�percents    rr�z$BrailleGenerator._generatePercentage�s+���.�.�s�3�����i�q�M�?�"��	rc���tj�jd�}|�t�|��St|�S)N�progressBarBrailleInterval)r
rBrCry�_getProgressBarUpdateInterval�int)r�intervalr{s  �rr�z.BrailleGenerator._getProgressBarUpdateInterval�s;���#�.�.�0�;�;�<X�Y�����7�8�:�:��8�}�rc�l��tj�jd�syt�|�|fi|��S)Nr\F)r
rBrCryr�)rr7rTr{s   �rr�z0BrailleGenerator._shouldPresentProgressBarUpdate�s3����*�*�,�7�7�8S�T���w�6�s�C�d�C�Crc�8�g}|jjj|�}|D]%}|j|j|fi|���n|sF|jd|�}|j|j|fi|���|j
||�|S)z�If this scroll pane is labelled by a page tab, then return the page
        tab information for the braille context instead. Thunderbird
        folder properties is such a case. See bug #507922 for more
        details.
        �REAL_ROLE_SCROLL_PANE)rJrK�labelsForObjectrjrH�
_overrideRole�_restoreRole)rr7rTrUrr��oldRoles       r�_generateAsPageTabOrScrollPanez/BrailleGenerator._generateAsPageTabOrScrollPane�s��������'�'�7�7��<���	�E��M�M�-�$�-�-��6��6�7��	���(�(�)@�$�G�G��M�M�-�$�-�-��4�t�4�5����g�t�,��
rc���|jd�rytj�jd�}|s|S|jj
j
|�stj|�r�tj|�ddk(}|retj|tjj�}|r5|jj
j
|j!d��}|S)z]Returns True or False to indicate whether context should be
        included or not.
        r[Fr�rr)rGr
rBrCrJrK�
isTextArear�is_labelr�get_line_at_offsetr�get_relationr�RelationType�
FLOWS_FROM�
get_target)rr7rT�include�relations     r�_generateIncludeContextz(BrailleGenerator._generateIncludeContext�s���
�8�8�)�*��#�-�-�/�:�:�;Q�R����N��<�<�!�!�,�,�S�1�[�5I�5I�#�5N��/�/��4�Q�7�1�<�G��#�0�0��e�6H�6H�6S�6S�T���"&�,�,�"8�"8�"C�"C�H�DW�DW�XY�DZ�"[�[�G��rc�^�tj�jd�rgStj|�s'|j
jj|�sgS|jdd�s|j|d<d|d<|j
jjdi|��gS)N�disableBrailleEOL�mode�eol�
stringTyper#)r
rBrCr�is_editablerJrK�isCoderG�_mode�
formatting�	getString)rr7rTs   r�_generateEolzBrailleGenerator._generateEol�s����&�&�(�3�3�4G�H��I��'�'��,����0F�0F�0M�0M�c�0R��I��x�x���%��:�:�D��L�"��\��1����'�'�1�1�9�D�9�:�:rc�0�|dk(rtSt|�gS)Nr)�SPACErrs  rr*zBrailleGenerator.space�s������L��)�$�%�%rc���d}d}t|t�r|}|S|r�t|t�r�|r.t|dt�r|dd}|rt|dt�r�|r.t|dt�r|dd}|rt|dt�r�|D]^}t|t�r|r||jz
}d}�'|j|�}|jjj|||�}�`|S)Nr�rr���)	r3�strrPrrr/rJrK�appendString)r�contentr�combined�prior�elements      rr/zBrailleGenerator.asString�s��������g�s�#��H� ����G�T�2��j����U�;�!�!�"�+���j����U�;��j����e�<�!�!�B�-���j����e�<�"�
4���g�u�-�%��� 1� 1�1�H� �E� �M�M�'�2�E�#�|�|�5�5�B�B� �%�� 4�H�

4��rr)&rr r!r"rra�MENU�MENU_BAR�
PAGE_TAB_LISTrcrb�	COMBO_BOXr�rr0r9rYrurqr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r*r/�
__classcell__)r{s@rr%r%7s����=�
 �*�*�/�/��*�*�-�-��*�*�2�2��*�*�5�5��*�*�,�,��*�*�.�.�0��>�	0�N�4'�x#�J9�"��.� E�N�$:��"�
�	���D��.�<
;�&�rr%)!r"�__id__�__version__�__date__�
__copyright__�__license__�gi�require_version�
gi.repositoryrr�rrrr	r
rrr
�	ax_objectr�ax_textr�ax_utilitiesr�ax_valuer�braille_rolenamesrrr�r'r%r#rr�<module>rs���(A�������?�
���	�����7�E�"������������%��-�#�#�
��	��S�y�*�*�Sr

Zerion Mini Shell 1.0