+
    Qi:  c                   s  a  R t0 t R tRtRtRtRtRt^ RIt^ RIt]P                  ! RR4       ^ R	I
Ht ^R
IHt ^RIHt ^RIHt ^RIHt ^RIHt ^RIHt ^RIHtHtHtHt  ! R R4      t]! 4       t] ^ k R R ltR# )Manages Orca's scripts.z$Id$z
$Revision$z$Date$z$Copyright (c) 2011-2024 Igalia, S.L.ZLGPLNAtspiz2.0)r   )braille)debug)settings_manager)speech_and_verbosity_manager)AXObject)AXUtilities)appsdefault	sleepmodetoolkitsc                   sB  a  ] tR t^1t o RtV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR	 ltV 3R
 lR lt	V 3R lR lt
V 3R lR ltR"V 3R lR lltR"V 3R lR lltV 3R lR ltR"V 3R lR lltV 3R lR ltV 3R lR ltR#V 3R lR lltV 3R lR  ltR!tV tR# )$ScriptManagerr    c                   < V ^8  d   QhRR/#    returnN format__classdict__   "8/usr/lib/python3.14/site-packages/orca/script_manager.py__annotate__ScriptManager.__annotate__4   s     	S 	S$ 	S    c                s    \         P                  ! \         P                  R R4       / V n        / V n        / V n        / V n        RV n        RV n        RV n	        \         P                  ! \         P                  RR4       R# )zSCRIPT MANAGER: InitializingTNFzSCRIPT MANAGER: Initialized)
r   print_message
LEVEL_INFOapp_scriptstoolkit_scriptscustom_scripts_sleep_mode_scripts_default_script_active_script_activeself   &r   __init__ZScriptManager.__init__4   sk    E,,.LdS!#%'$&)+ 6:59"E,,.KTRr   c                r   r   r   r   r   r   r   r   ?   s     Q Q$ Qr   c                s   \         P                  ! \         P                  RRR4       V P                  '       d)   \         P                  ! \         P                  RR4       R# V P	                  R4      V n        V P
                  P                  4        V P                  V P
                  R4       RV n        \         P                  ! \         P                  RR4       R# )z-Called when this script manager is activated.zSCRIPT MANAGER: ActivatingTz!SCRIPT MANAGER: Already activatedNactivatezSCRIPT MANAGER: Activated)r   r   r   r"   get_default_scriptr    Zregister_event_listenersset_active_scriptr#   r%   r   r'   ZScriptManager.activate?   s     	E,,.JDRVW<<< 0 02UW[\#66t<557t33Z@E,,.I4Pr   c                r   r   r   r   r   r   r   r   M   s     S SD Sr   c                s   \         P                  ! \         P                  RRR4       V P                  '       g)   \         P                  ! \         P                  RR4       R# V P                  e   V P                  P                  4        RV n        V P                  RR4       / V n        / V n        / V n	        RV n        \         P                  ! \         P                  RR4       R# )z/Called when this script manager is deactivated.SCRIPT MANAGER: DeactivatingTz#SCRIPT MANAGER: Already deactivatedN
deactivateFzSCRIPT MANAGER: Deactivated)
r   r   r   r"   r    Zderegister_event_listenersr)   r   r   r   r#   r%   r   r+   ZScriptManager.deactivateM   s     	E,,.LdTXY||| 0 02WY]^+  ;;=#t\2! E,,.KTRr   c                sV   < V ^8  d   QhRS[ P                  R,          RS[R,          /# r   appNr   r   
Accessiblestrr   r   r   r   r   _   s*     ' '5#3#3d#: 'sTz 'r   c                s   Vf+   Rp\         P                  ! \         P                  VR4       R# \        P                  ! V4      pV'       g+   Rp\         P                  ! \         P                  VR4       R# RRRRRR	R
RRRRRRR	/p\        VP                  4       4      pVP                  R4      '       d   VP                  R4      ^ ,          pM/VP                  R4      '       d   VP                  R4      R,          pV Uu. uF)  qfP                  4       VP                  4       8X  g   K'  VNK+  	  ppV'       d   VP                  V^ ,          R4      pMo\        P                  \        P                  3 FK  pV Uu. uF)  qfP                  4       VP                  4       8X  g   K'  VNK+  	  ppV'       g   KB  V^ ,          p M	  RVRV.p	\         P                  ! \         P                  V	R4       V# u upi u upi )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gtk-window-decoratorZswitcherZmarcozmate-notification-daemonznotification-daemonZmetacityzbudgie-daemonZplumaZgeditzxfce4-notifyd. zSCRIPT MANAGER: MappedZto)z.pyz.bin)zorg.zcom.i)r   r   r   r   Zget_namelistkeysZendswithZsplitZ
startswithZlowergetr   Z__all__r   print_tokens)
r$   r-   msgnameZ	app_namesZ	alt_namesZnnamesZ	name_listtokenss
   &&        r   get_module_nameZScriptManager.get_module_name_   s    ;GC 0 0#t<  %KC 0 0#t<+Zj/1F$jg$&;=	 )*	==))::c?1%D__-..::c?2&D%CIqdjjl)BIC==q2.D"llH,<,<=	$-KIqdjjl1JIK5 8D	 > +Ct<5++VT: D
 Ls   $G3,G3=$G8&G8c                sH   < V ^8  d   QhRS[ P                  RS[R,          /# )r   objr   Nr.   r   r   r   r   r      s%     % %u'7'7 %C$J %r   c                s^    RRRR/p\         P                  ! VR4      pVP                  W34      # )z4Returns the name of the toolkit associated with obj.ZGTKZgtkZGAILZtoolkit)r   Zget_attributer5   )r$   r<   r9   r8   s   &&  r   _toolkit_for_objectZ!ScriptManager._toolkit_for_object   s3     vu-%%c95yy$$r   c                s:   < V ^8  d   QhRS[ P                  RS[/# )r   r<   r   r.   r   r   r   r   r      s!      E$4$4  r   c                sB    \         P                  ! V4      '       d   R# R# )z&Returns the role-based script for obj.Zterminalr2   )r   Zis_terminal)r$   r<   s   &&r   _script_for_roleZScriptManager._script_for_role   s     ""3''r   c                sb   < V ^8  d   QhRS[ P                  RS[RS[P                  R,          /# )r   r-   r8   r   N)r   r/   r0   r	   Scriptr   r   r   r   r      s2      U%5%5 S W^^VZEZ r   c                s   V'       d	   V'       g   R# . R	OpRpV F  pRP                  WR34      p \        P                  ! V4      pRT.p	\
        P                  ! \
        P                  T	R4        \        XR4      '       d   TP                  T4      pMTP                  T4      p T# 	  V#   \         d     K  \         d8   pRTRT.p	\
        P                  ! \
        P                  T	RR4        Rp?LRp?ii ; i  \        \        \        3 d:   pRTRT.p	\
        P                  ! \
        P                  T	RR4        Rp?EK/  Rp?ii ; i)
zEReturns a script based on this module if it was located and loadable.Nr1   zEXCEPTION: Could not import:TzSCRIPT MANAGER: Found
get_scriptzEXCEPTION: Could not load)zorca-scriptszorca.scriptszorca.scripts.appszorca.scripts.toolkits)Zjoin	importlibZimport_moduleImportErrorZOSErrorr   r6   r   ZhasattrrA   r?   AttributeErrorZ	TypeError)
r$   r-   r8   ZpackagesscriptZpackagemodule_nameZmoduleerrorr:   s
   &&&       r   _new_named_scriptZScriptManager._new_named_script   s;    aG((G?3KI"00= .{;Fu//>I6<00#..s3F#]]3/F
 -  , %   I7c5Q""5#3#3VT4HHI #I{; I5{CO""5#3#3VT4HHIs;   B.25D .C=<C=C=-C88C= E-E

ENc                sv   < V ^8  d   QhRS[ P                  RS[ P                  R,          RS[P                  /# )r   r-   r<   Nr   r   r/   r	   r?   r   r   r   r   r      s:      ##*/*:*:T*A	r   c                s   V P                  V4      ;'       g    RpV P                  W4      pV'       d   V# V P                  V4      ;'       g    RpV P                  W4      pV'       d   V# \        P                  ! V4      pV'       d   V'       d   V P                  W4      pV'       g?   V P                  V4      pRVRVR.p\        P                  ! \        P                  VR4       V# )z8For the given application, create a new script instance.r2   z*SCRIPT MANAGER: Default script created forz(obj: Z)T)	r;   rH   r=   r   Zget_application_toolkit_namer(   r   r6   r   )r$   r-   r<   rF   rE   obj_toolkitZtoolkit_namer:   s   &&&     r   _create_scriptZScriptManager._create_script   s    
 **3/552''9M..s399r''9M"??D<++C>F,,S1FBCSVX[\Fu//>r   c                s\   < V ^8  d   QhRS[ P                  R,          RS[P                  /# r,   rI   r   r   r   r   r      s*     
 
e&6&6&= 
 
r   c                s    V'       g   V P                   '       d   V P                   # \        P                  ! V4      pV'       g   W n         V# )zReturns the default script.)r    r	   r?   r$   r-   rE      && r   r(   Z ScriptManager.get_default_script   s:     t+++'''$#) r   c                sN   < V ^8  d   QhRS[ P                  RS[P                  /# )r   r-   r   )r   r/   r
   r?   r   r   r   r   r      s'     	 	53C3C 		HXHX 	r   c                s    V P                   P                  V4      pVe   V# \        P                  ! V4      pW P                   V&   V# )z%Gets or crates the sleep mode script.)r   r5   r
   r?   rL   rM   r   get_or_create_sleep_mode_scriptZ-ScriptManager.get_or_create_sleep_mode_script   sH     ))--c2M!!#&(.  %r   c                s   < V ^8  d   QhRS[ P                  R,          RS[ P                  R,          RS[P                  /# )r   r-   Nr<   r   rI   r   r   r   r   r      sD     @ @##d*@161A1AD1H@	@r   c                sH   RW.p\         P                  ! \         P                  VR4       RpRpRpV P                  V4      pV'       dY   V P                  P                  V/ 4      pVP                  V4      pV'       g   V P                  W4      pWHV&   WP                  V&   V P                  V4      p	V	'       dY   V P                  P                  V/ 4      p
V
P                  V	4      pV'       g   V P                  W4      pWjV	&   WP                  V&    V'       g   V P                  4       pMEWP                  9   d   V P                  V,          pM!V P                  VR4      pWPP                  V&    VP                  4       P!                  V4      '       d<   RWQ.p\         P                  ! \         P                  VR4       V P#                  V4      # V'       d-   RV.p\         P                  ! \         P                  VR4       V# V'       d   \$        P&                  ! V4      '       go   \$        P(                  ! V4      '       gS   \+        VP,                  VP,                  4      '       g-   RV.p\         P                  ! \         P                  VR4       V# R	V.p\         P                  ! \         P                  VR4       V#   \        \        \        3 dH   pRTRT.p\         P                  ! \         P                  TR4       T P                  4       p Rp?ELRp?ii ; i)
z3Get a script for an app (and make it if necessary).z"SCRIPT MANAGER: Getting script forTNz+EXCEPTION: Exception getting app script forr@   z)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)r   r6   r   r>   r   r5   rH   r=   r   rK   r(   r   KeyErrorrD   rC   Zget_sleep_mode_managerZis_active_for_apprN   r   Zis_frameZis_status_barZ
issubclassZ	__class__)r$   r-   r<   r:   Zcustom_script
app_scriptZtoolkit_scriptZ	role_namer   rJ   r   rG   s   &&&         r   rA   ZScriptManager.get_script   s   
 7A5++VT:/3,0
04))#.	!0044S"=N*..y9M  $ 6 6s F,9y)'5$..s3"2266sB?O,00=N!!%!4!4S!>/=,(7  %	3!446
(((!--c2
!00d;
(2  % ,,.@@EEA:SFu//>77<<?OFu//>   ;#7#7#<#<@Y@YZ]@^@^j22N4L4LMM@.QFu//>!!8*E5++VT:5 .+6 	3CS#uUFu//>002J	3s*   K K -#K  K L!<LL!c                B   < V ^8  d   QhRS[ P                  R,          /# r   )r	   r?   r   r   r   r   r   *  s     # #7>>D#8 #r   c                s    RV P                   .p\        P                  ! \        P                  VR4       V P                   # )zReturns the active script.z!SCRIPT MANAGER: Active script is:T)r!   r   r6   r   r$   r:      & r   get_active_scriptZScriptManager.get_active_script*  s8     6t7J7JK5++VT:"""r   c                rQ   r   )r   r/   r   r   r   r   r   1  s     ' 'u'7'7$'> 'r   c                s    V P                   f   R# RV P                   P                  .p\        P                  ! \        P                  VR4       V P                   P                  # )z2Returns the app associated with the active script.Nz%SCRIPT MANAGER: Active script app is:T)r!   r-   r   r6   r   rR   rS   r   get_active_script_appZ#ScriptManager.get_active_script_app1  sS     &94;N;N;R;RS5++VT:""&&&r   c                sL   < V ^8  d   QhRS[ P                  R,          RS[RR/# )r   
new_scriptNreasonr   )r	   r?   r0   r   r   r   r   r   ;  s1     J JGNNT,A J3 JX\ Jr   c                sD   V P                   V8X  d   R# V P                   eQ   RV P                   RV.p\        P                  ! \        P                  VR4       V P                   P	                  4        V P                   pWn         Vf   R# \
        P                  ! 4       p/ pV'       d,   VP                  VP                  8X  d   VP                  4       pRVRV.p\        P                  ! \        P                  VR4       VP                  4        VP                  4        F  w  rxVP                  Wx4       K  	  \        P                  ! 4        \        P                  ! VP                  P!                  4       4       \"        P                  ! 4       P%                  4        R# )z$Set the active script to new_script.Nr*   zreason:Tz(SCRIPT MANAGER: Setting active script to)r!   r   r6   r   r+   r   get_managerr-   Zget_runtime_settingsr'   ZitemsZset_settingr   ZcheckBrailleSettingZsetupKeyRangesZbraille_bindingsr4   r   Zcheck_speech_setting)	r$   rV   rW   r:   Z
old_scriptZmanagerZruntime_settingsZkeyZvalues	   &&&      r   r)   ZScriptManager.set_active_script;  sE    *,*4d6I6I9V\]Fu//>**,((
("..0*..JNN:&;;=<j)U[\5++VT:*002JC+ 3 	##%z::??AB$002GGIr   c                r   r   r   r   r   r   r   r   \  s     $ $ $r   c                s   Rp\         P                  ! \         P                  VR4       \        V P                  P                  4       4      pV F  p\        P                  ! V4      '       d   K!   V P                  P                  V4      pRYDP                  .p\         P                  ! \         P                  TR4        T P                  P                  T4        T P                  P                  T4        T P                  P                  T4       K  	  R#   \         d1    RTR.p\         P                  ! \         P                  TR4        EK  i ; i  \         d     Li ; i  \         d     L~i ; i  \         d     EK:  i ; i)zaCompares the list of known scripts to the list of known apps,
deleting any scripts as necessary.
z1SCRIPT MANAGER: Checking and cleaning up scripts.TzSCRIPT MANAGER:znot found in app_scriptsz)SCRIPT MANAGER: Old script for app found:N)r   r   r   r3   r   r4   r   Zis_application_in_desktopZpoprO   r6   r-   r   r   r   )r$   r7   Zapp_listr-   rP   r:   s   &     r   reclaim_scriptsZScriptManager.reclaim_scripts\  sZ   
 BE,,c48((--/0C44S99!--11#6
 B:~~^Fu//>((,,S1$$((-##'',3   +S2LM""5#3#3VTB  
  
  sH   0D EE(8E96EEE%$E%(E65E69F	F	)r"   r!   r    r   r   r   r   )N)r2   )Z__name__Z
__module__Z__qualname__Z__firstlineno____doc__r&   r'   r+   r;   r=   r>   rH   rK   r(   rN   rA   rT   rU   r)   rY   Z__static_attributes__Z__classdictcell__)r      @r   r   r   1   s     !	S 	SQ QS S$' 'R% %  @ 4
 
	 	@ @D# #' 'J JB$ $r   r   c                s$    V ^8  d   QhR\         /# )r   r   )r   r      "r   r   r     s      ] r   c                 s    \         # )z%Returns the Script Manager singleton.)_managerr   r   r   rX   rX     s    Or   c                s@    V ^8  d   Qh/ ^ \         9   d
   \        ;R&   # )r   r^   )__conditional_annotations__r   r\   r]   r   r   r      s      V * )- )W r   )r_   rZ   Z__id__Z__version__Z__date__Z__copyright__Z__license__rB   ZgiZrequire_versionZgi.repositoryr   r2   r   r   r   r   Z	ax_objectr   Zax_utilitiesr   Zscriptsr   r	   r
   r   r   r^   rX   r   )r_   r[   r   <module>r`      su   . 6  	   7E " 
    *  % 7 7O Ob
 (/ )r   