%PDF- %PDF-
Mini Shell

Mini Shell

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

�

J
f�<��|�dZdZdZdZdZddlZddlmZdd	lm	Z	dd
l
mZddlm
Z
mZGd�d
�Ze�Zd�Zy)z$Id$z
$Revision$z$Date$zCopyright (c) 2011. Orca Team.�LGPL�N�)�debug)�AXObject)�AXUtilities)�apps�toolkitsc�z�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	dd	�Z
dd
�Zd�Zd�Z
dd
�Zd�Zd�Zdd�Zd�Zd�Zy)�
ScriptManagerc
��tjtjdd�i|_i|_i|_i|_tj|_	tj|_d|_gd�|_
dddddddd	d	d
�	|_dddd
�|_d|_d|_tjtjdd�y)NzSCRIPT MANAGER: InitializingT)zorca-scriptszorca.scriptszorca.scripts.appszorca.scripts.toolkits�Thunderbird�Banshee�	gcalctool�switcherznotification-daemon�gedit)	�Icedove�Nereidzgnome-calculatorzgtk-window-decorator�marcozmate-notification-daemon�metacity�plumazorg.gnome.gedit�	WebKitGtk�gtk)�	WebKitGTK�GTK�GAILFzSCRIPT MANAGER: Initialized)r�printMessage�
LEVEL_INFO�
appScripts�toolkitScripts�
customScripts�_sleepModeScriptsr�__all__�_appModulesr	�_toolkitModules�_defaultScript�_scriptPackages�	_appNames�
_toolkitNames�
_activeScript�_active��selfs �5/usr/lib/python3/dist-packages/orca/script_manager.py�__init__zScriptManager.__init__%s���
���5�+�+�-K�T�R���� ������!#����<�<���'�/�/���"���
&�	
��&� �!,�%/� �)>�#�� '�	
�	
��&�e�U�C�	
��"������
���5�+�+�-J�D�Q�c�>�tjtjdd�|jd�|_|jj�|j
|jd�d|_tjtjdd�y)z-Called when this script manager is activated.zSCRIPT MANAGER: ActivatingTN�activatezSCRIPT MANAGER: Activated)rrr�	getScriptr%�registerEventListeners�setActiveScriptr*r+s r-r1zScriptManager.activateEsv��	���5�+�+�-I�4�P�"�n�n�T�2������2�2�4����T�0�0�*�=����
���5�+�+�-H�$�Or/c�N�tjtjdd�|jr|jj	�d|_|jdd�i|_i|_i|_d|_	tjtjdd�y)z/Called when this script manager is deactivated.zSCRIPT MANAGER: DeactivatingTN�
deactivateFzSCRIPT MANAGER: Deactivated)
rrrr%�deregisterEventListenersr4rrr r*r+s r-r6zScriptManager.deactivateOs���	���5�+�+�-K�T�R�������8�8�:�"������T�<�0���� ���������
���5�+�+�-J�D�Qr/c��|�(d}tjtj|d�ytj|�}|s(d}tjtj|d�yt|jj��}|jd�s|jd�r|jd�d}n6|jd	�s|jd
�r|jd�d}|D�cgc]&}|j�|j�k(s�%|��(}}|r|jj|d�}nW|j|jfD]<}|D�cgc]&}|j�|j�k(s�%|��(}}|s�7|d}nd|d
|g}tjtj|d�|Scc}wcc}w)zAReturns the module name of the script to use for application app.Nz3SCRIPT MANAGER: Cannot get module name for null appTz7SCRIPT MANAGER: Cannot get module name for nameless appz.pyz.bin�.rzorg.zcom.���zSCRIPT MANAGER: Mapped�to)rrrr�get_name�listr'�keys�endswith�split�
startswith�lower�getr#r$�printTokens)	r,�app�msg�name�altNames�n�names�nameList�tokenss	         r-�
getModuleNamezScriptManager.getModuleName]s����;�G�C����u�/�/��d�;��� � ��%���K�C����u�/�/��d�;������+�+�-�.���=�=���4�=�=��#8��:�:�c�?�1�%�D�
�_�_�V�
$�����(?��:�:�c�?�2�&�D�$�B�q����	�T�Z�Z�\�(A��B��B���>�>�%�%�e�A�h�/�D�!�-�-�t�/C�/C�D�
��$,�J�q����	�T�Z�Z�\�0I��J��J�� ��8�D��	
�+�C��t�<��
���%�*�*�F�D�9����C��
Ks�>&G�%G�+&G�Gc�f�tj|d�}|jj||�S)z4Returns the name of the toolkit associated with obj.�toolkit)r�
get_attributer(rC)r,�objrGs   r-�_toolkitForObjectzScriptManager._toolkitForObjects/���%�%�c�9�5���!�!�%�%�d�D�1�1r/c�0�tj|�ryy)N�terminal�)r�is_terminal)r,rQs  r-�_scriptForRolezScriptManager._scriptForRole�s���"�"�3�'��r/c��|r|syd}|jD]�}dj||f�}	tj|�}d|g}t
jtj|d�	td�r|j|�}|S|j|�}|S|S#t$rY��t
$rt
j�Y��wxYw#t$r5}d|d|g}t
jtj|d�Yd}~��d}~wwxYw)zkAttempts to locate and load the named module. If successful, returns
        a script based on this module.Nr9zSCRIPT MANAGER: FoundTr2zSCRIPT MANAGER: Could not load�:)r&�join�	importlib�
import_module�ImportError�OSErrorr�examineProcessesrDr�hasattrr2�Script�	Exception)	r,rErG�script�package�
moduleName�modulerL�errors	         r-�_newNamedScriptzScriptManager._newNamedScript�s$��������+�+�	B�G����7�D�/�2�J�
)�"�0�0��<��.�z�:�F����e�.�.���=�
B��6�;�/�#�-�-�c�2�F��
�
�
$�]�]�3�/�F��
�
�+	B�*�
��#�
���
)��&�&�(�
)���
B�:�J��U�S���!�!�%�"2�"2�F�D�A�A��
B�s5�B!�*C�
C�!	C�,C�
C�	D�+D�DNc�v�|j|�}|j||�}|r|S|j|�}|j||�}|r|Stj|�}|r|r|j||�}|s=|j|�}d|d|dg}t
jtj|d�|S)z8For the given application, create a new script instance.z*SCRIPT MANAGER: Default script created forz(obj: �)T)	rMrhrRr�get_application_toolkit_name�getDefaultScriptrrDr)r,rErQrerc�
objToolkit�toolkitNamerLs        r-�
_createScriptzScriptManager._createScript�s����'�'��,�
��%�%�c�:�6����M��+�+�C�0�
��%�%�c�:�6����M��;�;�C�@���;��)�)�#�{�;�F���*�*�3�/�F�B�C��SV�X[�\�F����e�.�.���=��
r/c�z�|s|jr|jSddlm}|j|�}|s||_|S)Nr)�default)r%�scriptsrqra)r,rErqrcs    r-rlzScriptManager.getDefaultScript�s:���t�*�*��&�&�&�$�����$���"(�D���
r/c��|jj|�}|�|Sddlm}|j	|�}||j|<|S)Nr)�	sleepmode)r!rCrrrtra)r,rErcrts    r-�getOrCreateSleepModeScriptz(ScriptManager.getOrCreateSleepModeScript�sK���'�'�+�+�C�0�����M�&��!�!�#�&��&,����s�#��
r/c��|js|Stj|j�r|S|j	|j�}|r|Sd|jg}tjt
j|d�|S)Nz/WARNING: Failed to get a replacement script forT)r*r�is_application_in_desktoprE�_getScriptForAppReplicantrrDr)r,rc�	newScriptrLs    r-�sanityCheckScriptzScriptManager.sanityCheckScript�sm���|�|��M��0�0����<��M��2�2�6�:�:�>�	����C�V�Z�Z�P��
���%�*�*�F�D�9��
r/c���d||d|��g}tjtj|d�d}d}d}|j|�}|rU|jj|i�}	|	j|�}|s|j
||�}||	|<|	|j|<|j|�}
|
rU|jj|i�}|j|
�}|s|j||�}|||
<||j|<	|s|j�}n?||jvr|j|}n!|j|d�}||j|<|j�j|�r;d||g}tjtj|d�|j|�S|r+d|g}tjtj|d�|S|rut!j"|�s`t!j$|�sKt'|j(|j(�s+d	|g}tjtj|d�|S|r|r|j+|�}d
|g}tjtj|d�|S#t$rF}d|d|g}tjtj|d�|j�}Yd}~���d}~wwxYw)z�Get a script for an app (and make it if necessary).  This is used
        instead of a simple calls to Script's constructor.

        Arguments:
        - app: the Python app

        Returns an instance of a Script.
        z"SCRIPT MANAGER: Getting script forzsanity check: TNz0SCRIPT MANAGER: Exception getting app script forrYz)SCRIPT MANAGER: Sleep-mode toggled on forz'SCRIPT MANAGER: Script is custom scriptz(SCRIPT MANAGER: Script is toolkit scriptz$SCRIPT MANAGER: Script is app script)rrDrrWr rCrhrRrrorlrrb�getSleepModeManager�is_active_for_apprur�is_frame�
is_status_bar�
issubclass�	__class__rz)
r,rErQ�sanityCheckrL�customScript�	appScript�
toolkitScript�roleNamer rmrrgs
             r-r2zScriptManager.getScript�s���7��S�N�S^�R_�B`�a��
���%�*�*�F�D�9����	��
��&�&�s�+��� �.�.�2�2�3��;�M�(�,�,�X�6�L��#�3�3�C��B��*6�
�h�'�&3�D���s�#��+�+�C�0�
��!�0�0�4�4�S�"�=�N�*�.�.�z�:�M� � $� 2� 2�3�� <�
�-:��z�*�'5�D����$�	0�� �1�1�3�	�����'� �O�O�C�0�	� �.�.�s�D�9�	�'0�����$��(�(�*�<�<�S�A�A�9�c�R�F����e�.�.���=��2�2�3�7�7��?��N�F����e�.�.���=����+�"6�"6�s�";�{�?X�?X�Y\�?]��i�1�1�=�3J�3J�K�@�-�P�F����e�.�.���=� � ��;��.�.�y�9�I�8�)�D��
���%�*�*�F�D�9����9�	0�H�#�s�TY�Z�F����e�.�.���=��-�-�/�I��	0�s�AJ�	K%�;K � K%c��d|jg}tjtj|dd�|jS)zReturns the active script.z!SCRIPT MANAGER: Active script is:T)r)rrDr�r,rLs  r-�getActiveScriptzScriptManager.getActiveScript0s:��6�t�7I�7I�J��
���%�*�*�F�D�$�?��!�!�!r/c���|j�yd|jjg}tjtj|d�|jjS)z2Returns the app associated with the active script.Nz%SCRIPT MANAGER: Active script app is:T)r)rErrDrr�s  r-�getActiveScriptAppz ScriptManager.getActiveScriptApp7sS�����%��9�4�;M�;M�;Q�;Q�R��
���%�*�*�F�D�9��!�!�%�%�%r/c��|j|k(ry|j�|jj�||_|�yd|d|g}tjtj|d�|j�y)znSet the new active script.

        Arguments:
        - newScript: the new script to be made active.
        Nz(SCRIPT MANAGER: Setting active script tozreason:T)r)r6rrDrr1)r,ry�reasonrLs    r-r4zScriptManager.setActiveScriptAsw������*�����)����)�)�+�&������<�i��TZ�[��
���%�*�*�F�D�9����r/c�0�|jsytj|�}|dk(ry|jj	�}|D]�\}}tj|�|k7r�||k7s�%tj|�s�;|j�||_d||jg}tjtj|d�|jj|�}|r.d|dg}tjtj|d�|cS|cSy)Nr:z)SCRIPT MANAGER: Script for app replicant:TzSCRIPT MANAGER: Replicantz has sleep mode script. Using it.)
r*r�get_process_idr�itemsrrwrErrDrr!rC)r,rE�pidr��arcrL�sleepModeScripts        r-rxz'ScriptManager._getScriptForAppReplicantVs����|�|���%�%�c�*���"�9�����%�%�'���	�I�A�v��&�&�q�)�S�0���C�x�K�A�A�!�D��:�:�%�!"�F�J�E�v�v�z�z�Z���!�!�%�"2�"2�F�D�A�"&�"8�"8�"<�"<�Q�"?��"�9�1�>`�a�F��%�%�e�&6�&6���E�*�*��
�	� r/c���d}tjtj|d�t|jj��}|D�]�}t
j|�r�	|jj|�}d||jg}tjtj|d�|j|�}|r�d||jg}tjtj|d�|j�}|j�D]=\}}	d|d|	g}tjtj|d�t|||	��?~	|j j|�}
d	|g}tjtj|d�~
	|j"j|�}|j%�D]}~�		|j&j|�}
|
j%�D]}~�	~���y
#t$r.d|dg}tjtj|d�Y���wxYw#t$rY��wxYw#t$rY��wxYw#t$rY�hwxYw)zqCompares the list of known scripts to the list of known apps,
        deleting any scripts as necessary.
        z1SCRIPT MANAGER: Checking and cleaning up scripts.TzSCRIPT MANAGER:znot found in appScriptsz)SCRIPT MANAGER: Old script for app found:z(SCRIPT MANAGER: Transferring attributes:zSCRIPT MANAGER: Settingr;z.SCRIPT MANAGER: Deleting sleep mode script forN)rrrr=rr>rrw�pop�KeyErrorrDrErx�getTransferableAttributesr��setattrr!r�valuesr )r,rF�appListrEr�rLry�attrs�attr�valuercrr�r r�s               r-�reclaimScriptszScriptManager.reclaimScriptsqsd��
B��
���5�+�+�S�$�7��t���+�+�-�.���3	�C��4�4�S�9��
� �O�O�/�/��4�	�B�9�i�m�m�\�F����e�.�.���=��6�6�s�;�I��D�i�QZ�Q^�Q^�_���!�!�%�"2�"2�F�D�A�!�;�;�=��#(�;�;�=�4�K�D�%�7��t�U�K�F��%�%�e�&6�&6���E��I�t�U�3�4�
�
��/�/�3�3�C�8��K�C�P���!�!�%�"2�"2�F�D�A��
&�!%�!4�!4�!8�!8��!=��&4�%:�%:�%<�&�M�%�&�
%� $� 2� 2� 6� 6�s� ;�
�%2�$8�$8�$:�%�L�$�%��g3	���
�+�S�2K�L���!�!�%�"2�"2�F�D�A��
��,�
��
���
��
���
��
�sH�(H� I
�&I�I(�3I�I�
	I�I�	I%�$I%�(	I4�3I4�N)NF)�__name__�
__module__�__qualname__r.r1r6rMrRrWrhrorlrurzr2r�r�r4rxr��r/r-rr#s^��R�@P�R� �D2���>�0
��
�G�R"�&��*�6<r/rc��tSr�)�_managerr�r/r-�
getManagerr��s���Or/)�__id__�__version__�__date__�
__copyright__�__license__r[rUr�	ax_objectr�ax_utilitiesrrrrr	rr�r�r�r/r-�<module>r�sJ��*������0�
������%�#�J�J�X�?��r/

Zerion Mini Shell 1.0