+
     iG!  c                  s    ^ RI Ht ^ RIt^ RIHt ^ RIHtHtHtH	t	 ^ RI
HtHtHt ^ RIHt ^ t^t^t^t^t^t]! 4        ! R R4      4       t ! R	 R
4      tR t]! 4       t ! R R4      tRR lt ! R R4      tR# )    )annotationsN)	dataclass)ListCallableDictOptional)GtkGLibGdk)loggerc                  sT    ] tR t^(t$ R]R&   R]R&   R]R&   R]R&   R	]R
&   R]R&   RtR# )DebounceInfozOptional[Callable]functionobjectotherZintkeyZlistargsZdictkwargszOptional[int]glib_timeout N)__name__
__module____qualname____firstlineno____annotations____static_attributes__r       </usr/lib/python3.14/site-packages/inputremapper/gui/utils.pyr   r   (   s&     ! M	H JLr   r   c                  s`    ] tR t^5t$ Rt/ tR]R&   R tR R ltR t	R t
R	 R
 ltR tR tRtR# )DebounceManagerz(Stops all debounced functions if needed.zDict[int, DebounceInfo]debounce_infosc                	s    \        VR V. / V P                  W4      R7      pV P                  W4      pW0P                  V&   V# )N)r   r   r   r   r   r   )r   _get_keyr   )selfr   r   debounce_infor   s   &&&  r   	_registerZDebounceManager._register:   sK    $e.
 mmE,#0C r   c               s$    V ^8  d   QhRRRRRR/# )   r   r   r   r   returnzOptional[DebounceInfo]r   Zformat   "r   __annotate__DebounceManager.__annotate__G   s"     , , ,8 ,8N ,r   c                sZ    V P                  W4      pV P                  P                  V4      # )z7Find the debounce_info that matches the given callable.)r   r   get)r   r   r   r      &&& r   r(   ZDebounceManager.getG   s'    mmE,""&&s++r   c                	s6    \        V4       R VP                   2# )Z,)Zidr   )r   r   r      &&&r   r   ZDebounceManager._get_keyL   s    U)Ah//011r   c                s  a aaaaa S P                  SS4      pVf   S P                  SS4      pSVn        SVn        VP                  pVe   \
        P                  ! V4       VVVVV 3R lo\
        P                  ! VV3R l4      Vn        R# )z-Call this function with the given args later.Nc                 s@   < SP                  SS4       S! S.S O5/ SB # N)stop)r   r   r   r   r   s   r   runZ%DebounceManager.debounce.<locals>.run\   s&    IIeX&E3D3F33r   c                 s   < S ! 4       # r+   r   )r-   s   r   Z<lambda>Z*DebounceManager.debounce.<locals>.<lambda>b   s    CEr   )r(   r!   r   r   r   r   source_removeZtimeout_add)	r   r   r   Z
timeout_msr   r   r    r   r-   s	   fff&jl  @r   debounceZDebounceManager.debounceO   s}    1  NN5(;M!%$11#|,	4 	4 &*%5%5&
"r   c                    V ^8  d   QhRRRR/# )r"   r   r   r   r   r   r$   r%   r   r&   r'   e   s     . .& .H .r   c                s    V P                  W4      pVf   \        P                  ! R4       R# VP                  e*   \        P
                  ! VP                  4       RVn        R# R# )z{Stop the current debounce timeout of this function and don't call it.

New calls to that function will be debounced again.
Nz6Tried to stop function that is not currently scheduled)r(   r
   Zdebugr   r   r.   )r   r   r   r    r)   r   r,   ZDebounceManager.stope   sU    
 1 LLQR%%1}99:)-M& 2r   c                s    V P                   P                  4        F)  pV P                  VP                  VP                  4       K+  	  R# )zpNo debounced function should be called anymore after this.

New calls to that function will be debounced again.
N)r   valuesr,   r   r   )r   r       & r   stop_allZDebounceManager.stop_alls   s7    
 "00779MIIm))=+A+AB :r   c                s   V P                   P                  4        F  pVP                  f   K  V P                  VP                  VP
                  4        \        P                  ! RVP
                  P                  4       VP
                  ! VP                  .VP                  O5/ VP                  B  K  	  R#   \         d"   p\        P                  ! T4        Rp?K  Rp?ii ; i)zDon't wait any longer.Nz Running "%s" now without waiting)r   r1   r   r,   r   r   r
   warningr   r   r   Z	Exceptionerror)r   r    Z	exceptions   &  r   run_all_nowZDebounceManager.run_all_now{   s    !00779M))1IIm))=+A+AB(6!**33 &&!''"'' $** :   ( Y''	(s   AB::C&C!!C&r   N)r   r   r   r   __doc__r   r   r!   r(   r   r/   r,   r3   r6   r   r   r   r   r   r   5   s4    2.0N+0,
2
,.C(r   r   c                s   a  V 3R lpV# )zDebounce a method call to improve performance.

Calling this with a millisecond value creates the decorator, so use something like

@debounce(50)
def function(self):
    ...

In tests, run_all_now can be used to avoid waiting to speed them up.
c                s:   <a  V V3R  lpS P                   Vn         V# )c                s@   < \         P                  ! V SS.VO5/ VB  R # r+   )debounce_managerr/   )r   r   r   r   timeouts   &*,r   wrappedZ,debounce.<locals>.decorator.<locals>.wrapped   s    %%dHgOOOr   )r   )r   r:   r9   s   f r   	decoratorZdebounce.<locals>.decorator   s    
	P $,,r   r   )r9   r;   s   f r   r/   r/      s     r   c                  s2    ] tR t^tRtR R ltR tR tRtR# )HandlerDisabledzZSafely modify a widget without causing handlers to be called.

Use in a `with` statement.
c               r0   )r"   widgetz
Gtk.Widgethandlerr   r   r$   r%   r   r&   ZHandlerDisabled.__annotate__   s      z H r   c                	s    Wn         W n        R # r+   )r=   r>   )r   r=   r>   r*   r   __init__ZHandlerDisabled.__init__   s    r   c                	s     V P                   P                  V P                  4       R#   \         d#   p\        P
                  ! R T4        Rp?R# Rp?ii ; i)z"HandlerDisabled entry failed: "%s"N)r=   Zhandler_block_by_funcr>   	TypeErrorr
   r4   )r   r5   r2   r   	__enter__ZHandlerDisabled.__enter__   sD    	HKK--dll; 	H NN?GG	H   %) AAAc                	s     V P                   P                  V P                  4       R#   \         d#   p\        P
                  ! R T4        Rp?R# Rp?ii ; i)z!HandlerDisabled exit failed: "%s"N)r=   Zhandler_unblock_by_funcr>   r@   r
   r4   )r   _r5   s   &* r   __exit__ZHandlerDisabled.__exit__   sB    	GKK//= 	GNN>FF	GrB   )r>   r=   N)	r   r   r   r   r7   r?   rA   rD   r   r   r   r   r<   r<      s    
HGr   r<   c                s   \         P                  ! 4       '       d   \         P                  ! 4        K2  \        V 4       FK  p\        P
                  ! R4       \         P                  ! 4       '       g   K6  \         P                  ! 4        K4  	  R# )z!Iterate while events are pending.gMb`?N)r   Zevents_pendingZmain_iterationZrangetimeZsleep)Z
iterationsrC   r2   r   gtk_iterationrF      sS    




:

5  ""  r   c                  sp   ] tR t^tRt]P                  ! RRR^4      t]P                  ! RRR^4      t]P                  ! ^^^^4      t	]P                  ! RRR^4      t
]P                  ! RRR^4      t]R R	 l4       t]R
 R l4       t]R R l4       t]R R l4       t]R R l4       t]R R l4       tRtR# )ColorszdLooks up colors from the GTK theme.

Defaults to libadwaita-light theme colors if the lookup fails.
gzG?gp=
ף?g{Gz?g\(\?gףp=
?g?c               s$    V ^8  d   QhRRRRRR/# )r"   namesz	List[str]fallbackGdk.RGBAr#   r   r$   r%   r   r&   Colors.__annotate__   s!       h 8 r   c                s|    V  F5  p\         P                  ! 4       P                  V4      w  r4V'       g   K3  Vu # 	  V# )z?Get theme colors. Provide multiple names for fallback purposes.)r   ZStyleContextZlookup_color)rH   rI   ZnameZfoundZcolors   &&   r   	get_colorZColors.get_color   s:     D++-::4@LEu 
 r   c                   V ^8  d   QhRR/# r"   r#   rJ   r   r$   r%   r   r&   rK      s     
 
h 
r   c                 sN    \         P                  RR.\         P                  4      # )z0Look up the accent color from the current theme.Zaccent_bg_colorZtheme_selected_bg_color)rG   rL   fallback_accentr   r   r   get_accent_colorZColors.get_accent_color   s)      9:""
 	
r   c               rM   rN   r   r$   r%   r   r&   rK      s     
 
( 
r   c                 L    \         P                  R.\         P                  4      # )z4Look up the background-color from the current theme.Ztheme_bg_color)rG   rL   fallback_backgroundr   r   r   get_background_colorZColors.get_background_color   s&     &&
 	
r   c               rM   rN   r   r$   r%   r   r&   rK           
 
H 
r   c                 rQ   )z.Look up the base-color from the current theme.Ztheme_base_color)rG   rL   fallback_baser   r   r   get_base_colorZColors.get_base_color   s&        
 	
r   c               rM   rN   r   r$   r%   r   r&   rK     s     E Eh Er   c                 rQ   )*Look up the border from the current theme.Zborders)rG   rL   fallback_borderr   r   r   get_border_colorZColors.get_border_color  s     V-C-CDDr   c               rM   rN   r   r$   r%   r   r&   rK     rT   r   c                 rQ   )rW   Ztheme_fg_color)rG   rL   fallback_fontr   r   r   get_font_colorZColors.get_font_color
  s&       
 	
r   r   N)r   r   r   r   r7   r	   ZRGBArO   rR   rU   rX   rZ   ZstaticmethodrL   rP   rS   rV   rY   r[   r   r   r   r   rG   rG      s    
 hhtT43O((4tQ7HHQ1a(MhhtT43OHHT4q1M  
 
 
 
 
 
 E E 
 
r   rG   )r    )Z
__future__r   rE   Zdataclassesr   Ztypingr   r   r   r   Zgi.repositoryr   r   r	   Zinputremapper.logging.loggerr
   ZCTX_SAVEZ	CTX_APPLYZCTX_KEYCODEZ	CTX_ERRORZCTX_WARNINGZCTX_MAPPINGr   r   r/   r8   r<   rF   rG   r   r   r   <module>r\      s   ( #  ! 1 1 ( ( / 		 	  	  	 \( \(~: #$ G G2!9
 9
r   