+
   ie_vc                   s   R t ^ RIHtHtHtHtHtHtHtH	t	H
t
 ^ RIt^ RIt^ RIt^ RIHtHt ^ RIHt ]! RR4       ]! RR4       ^ 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 ]
'       d	   ^ RIHtHt ]. R3,          t]]P<                  ]].R3,          t ]]P<                  ]].R3,          t!]]P<                  ].R3,          t"]PF                  ! R4      t$Rt%R R lt&R R lt'R R lt(R R lt)R R lt*R]PV                  PX                  3R R llt-R R lt.R R lt/R  R! lt0RdR" R# llt1R$ R% lt2ReR& R' llt3R( R) lt4R* R+ lt5R, R- lt6R. R/ lt7R0 R1 lt8R2 R3 lt9R4 R5 lt:]	R6 R7 l4       t;]	R8 R9 l4       t;R: R; lt;R< R= lt<R> R? lt=R@ RA lt>RB RC lt?RD RE lt@ ! RF RG]4      tA ! RH RI4      tBRfRJ RK lltCRL RM ltDRN RO ltERP RQ ltF ! RR RS]^8  d   ]P                  M]P                  4      tI ! RT RU4      tJ ! RV RW]P                  4      tL ! RX RY4      tM ! RZ R[4      tN ! R\ R]]P                  4      tPR^RR_R/R` Ra lltQRb Rc ltRR# )gaK  GTK 3/4 Compatibility Helpers

A collection of helper functions and classes to ease the transition
from Gtk3 to Gtk4.

This helper module should not call gi.require_version() for both Gtk,
Pango, ...

Instead, let the main application decide which version to load.  This
helper module should work with whichever version is loaded.
)	ListTupleIterableOptionalCallableAnycastoverloadTYPE_CHECKINGN)Enumauto)require_versionGLibz2.0Gio)r   )r   )	GdkPixbuf)Pango)GdkGtk	GTK_MAJORGTK_VERSION)r   r   zibus-typing-boosterc                0    V ^8  d   QhR\         R\         /#    textreturnstrformat   "9/usr/share/ibus-typing-booster/engine/g_compat_helpers.py__annotate__r   F   s     . .C .C .    c                s8    \         P                  ! \        V 4      # )zGettext translation function.)gettextZdgettext
DOMAINNAMEr      &r   _r%   F   s    J--r    c                r   r   r   r   r   r   r   r   J   s      S S r    c                s    V # )z{Mark string for translation without actually translating.

Used by gettext tools to extract strings that need translation.
 r#   r$   r   N_r'   J   s	    
 Kr    c                $    V ^8  d   QhR\         /# r   r   boolr   r   r   r   r   Q   s     K KD Kr    c                 s    \         P                  P                  4       p V RJ;'       d"    RV P                  4       P	                  4       9   # )zTest whether Wayland is usedNZwayland)r   Displayget_defaultZget_nameZlower)displays    r   
is_waylandr/   Q   s>    kk%%'G$JJ90@0@0B0H0H0J#JJr    c                s\    V ^8  d   QhR\         P                  R\         P                  RR/# )r   widgetchildr   Nr   Widgetr   r   r   r   r   V   s.     Y Ycjj Y Y Yr    c                s   \         ^8  dl   \        V R4      '       d   V P                  V4       R# \        V R4      '       d   V P                  V4       R# \	        R\        V 4      P                   24      h\        V R4      '       d   V P                  V4       R# \        V R4      '       d   V P                  VRR^ 4       R# \	        R\        V 4      P                   24      h)z"Gtk3/4 compatible child insertion.	set_childappendu!   Don’t know how to add child to add
pack_startTN)	r   hasattrr4   r5   Z	TypeErrorZtype__name__r6   r7   r0   r1      &&r   	add_childr<   V   s    1}6;''U#VX&&MM% ?V@U@U?VWXX65!!JJuV\**eT43?V@U@U?VWXXr    c                H    V ^8  d   QhR\         P                  R\        RR/# )r   r0   widthr   N)r   r3   intr   r   r   r   r   i   s%     ' 'SZZ ' ' 'r    c                s
   \         ^8  dg   RV R2p\        P                  ! 4       pVP                  V\	        V4      4       V P                  4       P                  V\        P                  4       R# V P                  V4       R# )z&Gtk3/4 compatible border width settingz* { padding: zpx; }N)	r   r   ZCssProviderZload_from_datalenget_style_contextZadd_providerZ#STYLE_PROVIDER_PRIORITY_APPLICATIONset_border_width)r0   r>   ZcssZproviders   &&  r   rB   rB   i   sj    1}ugV,??$SX.  "//33	

 	&r    Tc                sh    V ^8  d   QhR\         P                  R\        R\        P                  RR/# )r   labelwrap	wrap_moder   N)r   Labelr+   r   WrapModer   r   r   r   r   w   s2      syy  #(>>LPr    c                s   \        V R4      '       d   V P                  V4       M7\        V R4      '       d   V P                  V4       M V P                  RV4       \        V R4      '       d   V P                  V4       R# \        V R4      '       d   V P                  V4       R#  V P                  RV4       R#   \         d     Lli ; i  \         d     R# i ; i)zASet wrapping and wrap mode on a Gtk.Label, Gtk3/ Gtk4 compatible.set_wrapset_line_wraprD   set_wrap_modeset_line_wrap_modez	wrap-modeN)r8   rH   rI   Zset_property	ExceptionrJ   rK   )rC   rD   rE      &&&r   set_label_wrap_moderN   w   s     uj!!t		(	(D!	vt, uo&&I&	,	-	-  +	{I6  		  		s$   
B; 'C ;C	C	CCc                <    V ^8  d   QhR\         P                  RR/# r   r0   r   Nr2   r   r   r   r   r      s      3:: $ r    c                s   \        V R4      '       d=   \        V R4      '       d+   V P                  4        F  pV P                  V4       K  	  R# \        V R4      '       d:   \        V R4      '       d(   V P                  4       pVe   V P	                  R4       R# \        V R4      '       dM   \        V R4      '       d;   V P                  4       pVe%   VP                  4       pVP                  4        TpK(  R# R# )zTRemove all child widgets from `widget`, in a way that works
for both Gtk3 and Gtk4.
get_childrenremoveN	get_childr4   get_first_childget_next_sibling)r8   rQ   rR   rS   r4   rT   rU   Zunparent)r0   r1   Z
next_child   &  r   clear_childrenrW      s    
 v~&&768+D+D((*EMM%  +v{##(D(D  "T"v())gf>P.Q.Q&&(//1JNNE
r    c                sn    V ^8  d   QhR\         P                  R\        \         P                  ,          /# r   r0   r   )r   r3   r    r   r   r   r   r      s'      

 tCJJ'7 r    c                s2   \        V R4      '       d    \        V P                  4       4      # \        V R4      '       dX    V P	                  4       pVe:   \        V\        P                  4      '       d   VP	                  4       pVe   V.# . # Ve   V.# . # \        V R4      '       dN   \        V R4      '       d<   . pV P                  4       pVe$   VP                  V4       VP                  4       pK'  V# . #   \         d     Li ; i  \         d     Li ; i)zDReturn iterable of logical children for Gtk3/Gtk4 (internal helper).rQ   rS   rT   rU   )r8   listrQ   rL   rS   
isinstancer   ZViewportrT   r5   rU   )r0   r1   ZinnerZkids   &   r   children_ofr\      s   v~&&	++-.. v{##	$$&E Zs||%D%D)"'"3w;;#/E77R7 v())gf>P.Q.Q&&(KK**,EI+  		  		s6   C7  A
D D D D 7DDDDc                sR    V ^8  d   QhR\         \        P                  ,          RR/# rP   )r   r   r3   r   r   r   r   r      s#      Xcjj) d r    c                s"   V f   R# \        V R4      '       d    V P                  4        R# \        V R4      '       d    V P                  R4       \	        V 4       F  p\        V4       K  	  R#   \         d     LPi ; i  \         d     L=i ; i)zhMake `widget` and all of its children visible (Gtk3-compatible show_all).

Works on both Gtk3 and Gtk4.
Nshow_allset_visibleT)r8   r]   rL   r^   r\   r:      & r   r]   r]      s    
 ~vz""	OO
 v}%%	t$ V$ %  		  		s"   A/ B  /A=<A= BBc                P    V ^8  d   QhR\         R\        R\        P                  /# )r   	icon_name	icon_sizer   )r   r?   r   Imager   r   r   r   r      s%      3 3 		 r    c                s    \         P                  P                  4       pVeH   \        VR4      '       d6   VP	                  W^ 4      pVe    \         P
                  P                  V4      #  \         P
                  P                  T 4      p\        TR4      '       d    TP                  T4       T# T#   \         d     LUi ; i  \         d     T# i ; i  \         d     Mi ; i \         P
                  P                  T \         P                  P                  4      pT#   \         d     Mi ; i\         P
                  ! 4       # )z}Return a Gtk.Image for icon_name sized approximately `icon_size`.

Works on both Gtk3 and Gtk4 by trying multiple fallbacks.
	load_iconset_pixel_size)r   Z	IconThemer-   r8   rd   rc   new_from_pixbufrL   new_from_icon_namere   IconSizeBUTTON)ra   rb   ZthemeZpixZimg   &&   r   icon_image_for_namerk      s!   ))+!<!<//):Cyy0055
ii**953())""9- 
s
    
  ii**9cll6I6IJ
 99;s`   A(B3 ,1C C /C 1C 3C CCC CC C$#C$(9D" "D0/D0c                r`   )r   pathsizer   )r   r?   r   r3   r   r   r   r   r      s%     - - -C -CJJ -r    c                s   \         P                  P                  V 4      p\        ^8  d{   \        P
                  P                  V4      p\        P                  P                  V4      pVP                  \        P                  P                  4       VP                  W4       V# VP                  W\         P                  P                   4      p\        P"                  P%                  V4      # )z&Load an image from a file and scale it)r   ZPixbufZnew_from_filer   r   ZTextureZnew_for_pixbufr   ZPictureZnew_for_paintableZset_content_fitZ
ContentFitZ
SCALE_DOWNZset_size_requestZscale_simpleZ
InterpTypeZBILINEARrc   rf   )rl   rm   ZpixbufZtextureZpicrj   r   image_from_file_scaledrn      s    ++D1F1}++,,V4kk++G4CNN556T(
  Y-A-A-J-JKF99$$V,,r    c                r=   )r   r0   enabler   N)r   ScrolledWindowr+   r   r   r   r   r   
  s'     , , 2 2 ,D ,D ,r    c                s~    V P                  4       pV'       d   VP                  R4       R# VP                  R4       R# )zFAdd or remove css class `scrolled-shadow` to or from a scrolled windowzscrolled-shadowN)rA   Z	add_classZremove_class)r0   ro   Zctx   && r   set_scrolled_shadowrr   
  s/    

"
"
$C'(*+r    c                s~    V ^8  d   QhR\         P                  R\         P                  R\        \        ,          RR/# )r   combobox	liststoreindexr   N)r   ZComboBox	ListStorer   r?   r   r   r   r   r     s<      ll}} C= 
	r    c                s    Vf   V P                  R4       R# \        ^8  d&   VP                  V34      pV P                  V4       R# V P                  V4       R# )zxSet the active index of a combo box with a list store (GTK 3/4 compatible).
If `index` is `None`, unset the active item.N)Zset_active_iterr   get_iterZ
set_active)rs   rt   ru   Zliststore_iters   &&& r   combobox_set_activerx     sR     }  &1}"++UH5  0r    c                sX    V ^8  d   QhR\         P                  R\         P                  /# rX   )r   r3   Windowr   r   r   r   r   #  s"     ! !

 !szz !r    c                sX    \         ^8  d   V P                  4       # V P                  4       # )z9Get the top-level window of a widget (GTK 3/4 compatible))r   get_rootZget_toplevelr0   r$   r   get_toplevel_windowr|   #  s%    1}    r    c                b    V ^8  d   QhR\         P                  R\        R\        3,          RR/# )r   r0   callback.r   Nr   r3   r   r   r   r   r   r   r   )  s.     / / /xS7I /d /r    c                sh    \         ^8  d   V P                  RV4       R# V P                  RV4       R# )a  
Connects a callback to the appropriate focus signal for a widget,
automatically handling differences between GTK3 and GTK4.

In Gtk4, the 'notify::has-focus' signal is used to detect when a widget receives focus.
In Gtk3, the 'grab-focus' signal is used for the same purpose.

:param widget: The widget to which the focus signal should be connected.
:param callback: The callback function to be called when the widget receives focus.
                 The callback should accept the widget and a GParamSpec parameter in GTK4.
:return: None
znotify::has-focusz
grab-focusN)r   connect)r0   r~   r;   r   connect_focus_signalr   )  s(     A~*H5|X.r    c                rO   rP   r2   r   r   r   r   r   ;  s     ' ' ' 'r    c                s    \        V R4      '       d   V P                  4        R# V P                  4        \        V \        P
                  4      '       d   V P                  ^ ^ 4       R# R# )z
Grabs focus for a widget without selecting its contents.
Works for both Gtk.Entry and Gtk.SpinButton in Gtk3 and Gtk4.

:param widget: The widget to grab focus (Gtk.Entry or Gtk.SpinButton).
grab_focus_without_selectingN)r8   r   Z
grab_focusrZ   r   EntryZselect_regionr{   r$   r   r   r   ;  sP     v566++-fcii((  A& )r    c                r=   )r   entrynew_textr   N)r   r   r   r   r   r   r   r   K  s%      #)) s t r    c                s    V P                  4       pV P                  V4       V\        V4      8:  d   V P                  V4       R# V P                  R4       R# )zUSet the text of a Gtk.Entry while preserving the cursor position
(Gtk 3/4 compatible)N)get_positionset_textr@   set_position)r   r   Z
cursor_posrq   r   set_entry_text_preserve_cursorr   K  sI     ##%J	NN8S]":&	rr    c                f    V ^8  d   QhR\         P                  R\        \        \        3,          /# )r   windowr   )r   ry   r   r?   r   r   r   r   r   U  s&     4 4CJJ 45c? 4r    c                s    \         ^8  d!   V P                  4       V P                  4       3# \        \        \
        \
        3,          V P                  4       4      # )z-Get the size of a window (Gtk 3/4 compatible))r   Z	get_widthZ
get_heightr   r   r?   Zget_size)r   r$   r   get_window_sizer   U  sB    1}  "F$5$5$788c3h!233r    c                s   V ^8  d   QhR\         P                  R\        R\        R\        R\        \        \
        \         P                  ,          \
        \         P                  ,          \
        \         P                  ,          3,          /# )r   treeviewxykeyboard_tipr   )	r   ZTreeViewr?   r+   r   r   Z	TreeModelTreePathTreeIterr   r   r   r   r   [  sn     A# A#,,A#A# A# 	A#
 
tXcmm,hs||.Dhs||F\\	]A#r    c                s   V P                  WV4      pV'       g   R# \        ^8  d   Vw  rVrxrV'       g   R# RWV
3# \        V4      pV^8X  di   \        V^,          \        P
                  4      '       dB   Vw  rVrzV'       g   R# V P                  4       pVf   R# VP                  V
4      p	V	f   R# RWV
3# V^8X  dm   \        V^,          \        P                  4      '       dF   Vw  rVryV'       g   R# V P                  4       pVe   V	f   R# VP                  V	4      p
V
f   R# RWV
3# V^8X  d5   Vw  rVrxp	V'       d	   Ve   V	f   R# VP                  V	4      p
V
f   R# RWV
3# R# )u   
Unified GTK3/Gtk4 wrapper around TreeView.get_tooltip_context()

Returns:
    (ok, model, path, iter)

Works with:
  • Gtk3 (returns 6-tuple in PyGObject)
  • Gtk4 <= 4.10 (returns 5-tuple)
  • Gtk4 >= 4.12 (returns 4-tuple)
T)FNNN)
Zget_tooltip_contextr   r@   rZ   r   r   Z	get_modelget_pathr   rw   )r   r   r   r   resultZis_row_x_yZmodelrl   ZitrZlengths   &&&&        r   get_treeview_contextr   [  s   $ ))!=F&&1}+1(Bt**U#%%[F {z&)S\\::$B**""$=**~~c"<**U#%%{z&)S\\::%B**""$=DL**nnT";**U#%%{&,#Bt$,**nnT";**U#%%""r    c                s    V ^8  d   QhR\         P                  R\        \         P                  .\        3,          RR/# )r   buttonr~   r   N)r   r3   r   Buttonr   r   r   r   r   r     s:      JJ

|S() 
r    c                     R # Nr&   r   r~   r;   r   connect_fast_clickr         
 r    c                s    V ^8  d   QhR\         P                  R\        R\        \        \        .\
        3,          RR/# )r   r   r~   Gtk.GestureClickr   N)r   r3   r   r?   floatr   r   r   r   r   r     s>      JJ*C>CD 
r    c                 r   r   r&   r   r;   r   r   r     r   r    c                r}   )r   r   r~   .r   Nr   r   r   r   r   r     s3      
  
JJ 
sCx  
 
 
r    c                s    \         ^8  dL   \        P                  ! 4       pVP                  ^ 4       VP	                  RV4       V P                  V4       R# V P	                  RV4       R# )a  
Connect a 'fast click' handler that preserves Gtk3/Gtk4 signal signatures.

Unified implementation, the ovrload above are for precise type checking.

Gtk 3:
    Connects to 'clicked', which emits (button)

Gtk 4:
    Creates a GtkGestureClick, connects to 'pressed', which emits
    (gesture, n_press, x, y)

The callback signature is preserved exactly, and type checkers
will infer the correct signature depending on use.
pressedclickedN)r   r   GestureClick
set_buttonr   add_controller)r   r~   gesturerq   r   r   r     s]    & 1}""$1	
 	g& 		
r    c                rO   )r   rC   r   Nr   rF   r   r   r   r   r     s     	$ 	$ 	$t 	$r    c                s   \         P                  ! R4      p\        ^8  d   V P                  V4       R# \         P                  ! V4      p\         P
                  ! 4       pVP                  V4       V P                  V4       R# )z9Make label use a monospace font (Gtk3 + Gtk4 compatible).Z	MonospaceN)r   ZFontDescriptionr   Zmodify_fontZattr_font_desc_newZAttrListZinsertZset_attributes)rC   ZfontZattrZattrsr[   r   set_monospacer     s]      -D1}$''- TU#r    c                r=   )r   
parent_boxdetails_textr   N)r   Boxr   r   r   r   r   r     s%     6  6 SWW 6 C 6 D 6 r    c                s  a S'       g   R# \         P                  P                  \         P                  P                  ^4      p\        W4       VP                  \         P                  P                  4       VP                  R4       \         P                  ! RR7      pVP                  R4       \        W#4       \         P                  P                  \         P                  P                  ^ 4      p\        W$4       VP                  R4       \         P                  ! RR7      pVP                  R4       \        W%4       R V3R	 llpVP                  R
V4       \         P                  ! 4       pVP                  R4       VP!                  R4       \         P"                  ! 4       pVP%                  ^ 4       VP'                  ^ 4       VP)                  R4       VP+                  R4       VP-                  S4       VP/                  ^4       VP1                  ^4       VP3                  ^4       VP5                  ^4       VP7                  \         P8                  P:                  4       VP=                  ^P4       \?        VR\@        PB                  PD                  R7       \G        V4       \        Wx4       \        W74       R# )z{
Adds an expander containing details_text (monospace, scrollable)
and a copy-to-clipboard button.

Works in Gtk3 and Gtk4.
NTDetails)rC   FZCopyzCopy details to clipboardc                rO   )r   r%   r   N)r   r   r   r   r   r   Z*_add_details_section.<locals>.__annotate__  s     - -CJJ -4 -r    c                 s  < \         ^8  dB   \        P                  P                  \        P
                  4      pVP                  SR4       R# \        P                  P                  4       pVP                  4       pVP                  S4       R# )   Nr   )
r   r   Z	Clipboardgetr   ZSELECTION_CLIPBOARDr   r,   r-   Zget_clipboard)r%   Z	clipboardr.   r      &  r   _on_copy_clickedZ._add_details_section.<locals>._on_copy_clicked  sb    q=))#*A*ABI|R0kk--/G--/I|,r    r   rD   rE   )$r   r   ZnewOrientation
HORIZONTALr<   
set_halignAlignZFILLset_hexpandZExpanderZset_expandedr   set_tooltip_textr   rp   Zset_vexpandrF   
set_xalignZ
set_yalignZset_selectableZset_use_markupr   set_margin_topset_margin_bottomset_margin_startset_margin_endZset_justifyZJustificationZLEFTset_max_width_charsrN   r   rG   	WORD_CHARr   )	r   r   Z
header_boxZexpanderZspacerZcopy_btnr   ZscrollrC   s	   &f       r   _add_details_sectionr     s     S__77;Jj%#))..)4 ||),H% j#WW[[33Q7Fj!
tzz'H9:j#- - Y 01!F
t
tIIKE	Q	Q			NN< 		A	1		c'',,-	b!DENN4L4LM%fhr    c                r   rX   r   r3   r   r?   r   r   r   r   r     s&      

 uS#X r    c                    \         ^8  d   \        V P                  4       4      # V P                  \        P
                  P                  R4      w  r pW3# )zL
Return (minimum, natural) width of a widget in a Gtk3/Gtk4 compatible way.
r   )r   tupleget_preferred_widthmeasurer   r   r   r0   Zmin_sizeZnat_sizer%   r[   r   r   r     sI     1}V//122%~~coo.H.H"MH1r    c                r   rX   r   r   r   r   r   r     s&       c3h r    c                r   )zM
Return (minimum, natural) height of a widget in a Gtk3/Gtk4 compatible way.
r   )r   r   get_preferred_heightr   r   r   VERTICALr   r[   r   r   r     sI     1}V00233%~~coo.F.FKH1r    c                s,    V ^8  d   QhRRRRR\         /# )r   	event_keyzGdk.EventKeyr   z	Gtk.Entryr   r*   r   r   r   r   r   $  s"     * *. * *QU *r    c                s   V P                   pV P                  ;'       g    RpVP                  4       pV\        P                  8X  d;   V^ 8  d2   VP                  V^,
          V4       VP                  V^,
          4       R# V\        P                  8X  d,   VP                  WD^,           4       VP                  V4       R# V\        P                  8X  d"   V^ 8  d   VP                  V^,
          4       R# V\        P                  8X  d9   V\        VP                  4       4      8  d   VP                  V^,           4       R# V\        P                  8X  d   VP                  ^ 4       R# V\        P                  8X  d+   VP                  \        VP                  4       4      4       R# V'       d5   VP                  W44       VP                  V\        V4      ,           4       R# R# )z
Forward a Gdk.EventKey into a Gtk.Entry (or Gtk.SearchEntry) in a way
compatible with both GTK3 and GTK4.

Handles:
  - character insertion
  - Backspace
  - Delete
  - Left/Right/Home/End cursor movement
 TF)keyvalstringr   r   ZKEY_BackSpaceZdelete_textr   Z
KEY_DeleteZKEY_LeftZ	KEY_Rightr@   Zget_textZKEY_HomeZKEY_EndZinsert_text)r   r   r   r   Zposrj   r   forward_key_event_to_entryr   $  sm    F!!rD



C"""7cAgs+sQw'#Qw'37sQw'U^^%&&sQw'13u~~/01$$3T?+r    c                   s    ] tR tRtRt]! 4       t]! 4       t]! 4       t]! 4       t	]! 4       t
]! 4       t]! 4       t]! 4       t]! 4       tRtR# )	PopupKindiP  z2Enumerate the different possible types of popoversr&   N)r9   
__module____qualname____firstlineno____doc__r
   ZEMOJI_SELECTEDZ	SKIN_TONEZ
EMOJI_INFOZFONT_SELECTIONZ	MAIN_MENUZADD_DICTIONARYZADD_INPUT_METHODZINPUT_METHOD_OPTIONSZADD_AUTOSETTING__static_attributes__r&   r    r   r   r   P  sF    <VNIJVNIVNv6fOr    r   c                   s   a  ] tR tRt o R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V 3R lR lt	V 3R lR lt
RtV tR# )PopupManageri\  zh
Manages Gtk.Popover lifetimes safely across GTK3/GTK4.
Tracks which kind of popup is currently active.
c                   < V ^8  d   QhRR/# r   r   Nr&   r   __classdict__   "r   r   PopupManager.__annotate__a  s     / /$ /r    c                s"    R V n         R V n        R # r   _current_kindselfr$   r   __init__ZPopupManager.__init__a  s    /3*.
r    c                s>   < V ^8  d   QhRS[ P                  RS[RR/# )r   popoverkindr   N)r   Popoverr   r   r   r   r   r   e  s&     $ $S[[ $	 $d $r    c                s   a a S P                   pSS n         VS n        Ve   S P                  V4       R VV 3R llp\        P                  ! V4       R# )z
Safely popup a popover after.
If an old popover exists, pop it down first.

This avoids GTK4 grab violations ('Tried to map a grabbing popup...')
and works correctly on Wayland.
Nc                r(   r)   r*   r   r   r   r   Z(PopupManager.popup.<locals>.__annotate__s  s     	 	d 	r    c                  sx   < SP                   S Jd   R # \        R8  d   S P                  4        \        S 4       R # )F   i   i    )r   r   popupr]   )r   r   s   r   _popup_laterZ(PopupManager.popup.<locals>._popup_laters  s.    }}G+j(Wr    )r   r   _popdownr   Zidle_add)r   r   r   Zoldr   s   ff&  r   r   ZPopupManager.popupe  sE     mm
?MM#	 	 	l#r    Nc                s4   < V ^8  d   QhRS[ S[,          RR/# )r   r   r   Nr   r   r   r   r   r   r   }  s      
 
HY$7 
4 
r    c                s    Ve   V P                   V8w  d   R# V P                  e,   V P                  V P                  4       RV n        RV n         R# R# )zPops down the current popover if it is of the specified kind

If kind is None, popdown the current popover no matter what kind it is.
N)r   r   r   r   r   r;   r   popdown_currentZPopupManager.popdown_current}  sE    
 

d 2==$MM$--( DMDJ %r    c                s8   < V ^8  d   QhRS[ P                  RR/# )r   r   r   N)r   r   r   r   r   r   r     s     # # # #r    c                s^    \         R8  d   VP                  4        VP                  R4       R# )r   FNr   )r   Zpopdownr^   )r   r   r;   r   r   ZPopupManager._popdown  s"    *$OOE"r    c                s0   < V ^8  d   QhRS[ S[,          /# r)   r   r   r   r   r   r     s      hy1 r    c                s    V P                   # )z8Returns the kind of the currently active popup, or None.r   r   r$   r   active_popupZPopupManager.active_popup  s    zzr    c                s&   < V ^8  d   QhRS[ RS[/# )r   r   r   )r   r+   r   r   r   r   r     s     " "i "D "r    c                s     V P                   V8H  # )z9Returns True if the given popup kind is currently active.r   r   r;   r   	is_activeZPopupManager.is_active  s    zzT!!r    r   r   )r9   r   r   r   r   r   r   r   r   r   r   r   __classdictcell__r      @r   r   r   \  sF     / /$ $0
 
# #
 " "r    r   c                sr    V ^8  d   QhR\         P                  R\        R,          R\         P                  /# )r   pointing_topositionzGtk.PositionTyper   )r   r3   r   r   r   r   r   r   r     s4     ! !ZZ!-.! 	[[!r    c                s   \         P                  ! 4       p\        ^8  Ed   V P                  4       pVf   \	        R4      hVP                  V4       V P                  V4      w  rEV'       d   \        P                  ! 4       p\        VP                  P                  4      Vn        \        VP                  P                  4      Vn        \        VP                  P                  4      Vn        \        VP                  P                  4      Vn        VP!                  V4       MVP#                  V 4       Ve   VP%                  V4       V# )a  
Create a Gtk.Popover correctly for both GTK3 and GTK4.

- Gtk3: uses set_relative_to()
- Gtk4: sets toplevel parent + pointing rectangle via compute_bounds()

This helper avoids common Gtk4 pitfalls such as:
- non-topmost parent warnings
- grabbing popup freezes (Wayland)
z4create_popover(): pointing_to widget has no root yet)r   r   r   rz   ZRuntimeErrorZ
set_parentZcompute_boundsr   Z	Rectangler?   Zoriginr   r   rm   r>   ZheightZset_pointing_toZset_relative_tor   )r   r   r   ZtoplevelZokZgrectZgdk_rects   &&     r   create_popoverr     s     kkmGA~'')FH H8$..x8	}}HU\\^^,HJU\\^^,HJ !1!12HN!%**"3"34HO##H-,X&Nr    c                s<    V ^8  d   QhRRR\         P                  /# )r   	event_boxClickableEventBoxCompatr   r   r   r   r   r   r     s      ' ','14'r    c                sX    \         ^8  d   V P                  4       # V P                  4       # )z8Returns the Gtk.Label child of a ClickableEventBoxCompat)r   rS   rT   )r   r$   r   (clickable_event_box_compat_get_gtk_labelr     s)     1}""$$$$&&r    c                n    V ^8  d   QhR\         P                  R\        \         P                  ,          /# r   flowboxr   )r   FlowBoxr    ZFlowBoxChildr   r   r   r   r     s)     & &#++ &$s7G7G2H &r    c                s    \        V R4      '       d   \        V P                  4       4      # \        \        V 4      4      # )z"Returns a list of flowbox childrenrQ   )r8   rY   rQ   r\   )r   r$   r   flowbox_get_childrenr     s3    w''G((*++G$%%r    c                r   r   )r   r   r    rF   r   r   r   r   r     s*     S Sckk Sd399o Sr    c                s   \        V R4      '       d<   V P                  4        Uu. uF   qP                  4       P                  4       NK"  	  up# \        V 4       Uu. uF   qP                  4       P	                  4       NK"  	  up# u upi u upi )zqReturns a list of (emoji)-labels in a Gtk.FlowBox as used in emoji_picker.py
Compatible with both Gtk3 and Gtk4.
rQ   )r8   rQ   rS   r\   rT   )r   r1   r_   r   emoji_flowbox_get_labelsr     sr     w'';B;O;O;QR;Q%!++-;QRR=H=QR=QEOO--/=QRR SRs   &B&B	c                   s   a a ] tR tRt oRtV3R lV 3R lltV3R lV 3R llt]^8  d$   V3R lR ltV3R	 lR
 lt	V3R lR lt
RtVtV ;t# V3R lR ltV3R lR ltV3R lR ltRtVtV ;t# )r   i  uP  
A compatibility wrapper that provides EventBox-like clickable behavior
in both Gtk3 and Gtk4, including unified signals:

    - 'clicked'      → callback(widget, button)
    - 'released'     → callback(widget, button)
    - 'long-pressed' → callback(widget)

All differences between Gtk3 and Gtk4 event handling are hidden here.
c                r   r   r&   r   r   r   r   $ClickableEventBoxCompat.__annotate__  s     - -$ -r    c                sX  < \         ^8  d   \        SV `	  4        V P                  R4       V P	                  R4       V P                  R4       V P                  \        P                  P                  \        P                  P                  ,          4       EMo\        SV `	  \        P                  P                  R7       V P                  R4       V P	                  R4       V P                  R4       \        P                   ! 4       pVP#                  ^ 4       VP%                  \        P&                  P(                  4       VP+                  RV P,                  4       VP+                  RV P.                  4       V P1                  V4       \        P2                  ! 4       pVP5                  R4       VP%                  \        P&                  P(                  4       VP+                  RV P6                  4       V P1                  V4       . V n        . V n        . V n        RV n        RV n         R# )r   TF)orientationr   releasedN)!r   superr   Zset_above_childZset_can_focusZset_visible_windowZ
add_eventsr   Z	EventMaskZBUTTON_PRESS_MASKZBUTTON_RELEASE_MASKr   r   r   Zset_sensitiveZset_focusabler   r   Zset_propagation_phaseZPropagationPhaseZCAPTUREr   _on_click_pressed_on_click_releasedr   ZGestureLongPressZset_touch_only_on_longpress_gtk4_click_handlers_release_handlers_longpress_handlers_gtk3_longpress_timer_gtk3_button_down)r   ZclickZ	longpress	__class__r   r   r   Z ClickableEventBoxCompat.__init__  s   q=G  &u%##D)OOCMM;;MM==> ? G)C)CDt$u%u%$$&EQ''(<(<(D(DEMM)T%;%;<MM*d&=&=>&,,.I$$U+++C,@,@,H,HIi)@)@A	*LNPRTV 48"',r    c                sF   < V ^8  d   QhRS[ RS[RS[3,          RS[RS[/# )r   signal_namer~   .	user_datar   )r   r   r   r?   r   r   r   r   r     s<     M M"M.6sCx.@MNQM	Mr    c                s"  < VR8X  d   V P                   P                  W#34       ^# VR8X  d   V P                  P                  W#34       ^# VR8X  d   V P                  P                  W#34       ^# \	        \
        \        SV `  ! W.VO5!  4      # )zK
A unified connect() that works for all 3 events on
Gtk3 and Gtk4 equally.
r   r   zlong-pressed)r  r5   r  r  r   r?   r  r   )r   r  r~   r  r
  s   &&&*r   r   ZClickableEventBoxCompat.connect  s     )#  ''(=>*$""))8*?@.($$++X,ABCKKLLr    c                $   < V ^8  d   QhRRRS[ /# r   event_buttonzGdk.EventButtonr   r*   r   r   r   r   r     s     	 	$5	:>	r    c                s    VP                   p\        P                  RV4       RV n        V^8X  d(   \        P
                  ! RV P                  4      V n        MRV n        V P                   F  w  r4V! W.VO5!   K  	  R# )u<   GTK3 button press → triggers click + schedules long press.z$Gtk3 do_button_press_event button=%sTi  NF)	r   LOGGERinfor	  r   Ztimeout_add_gtk3_longpress_triggerr  r  r   r  r   cbuserrj   r   do_button_press_eventZ-ClickableEventBoxCompat.do_button_press_event  sw     '--FKK>G%)D"{-1-=-=55.7* .2* 004'$' 1r    c                r  r  r*   r   r   r   r   r     s     	 	$5	:>	r    c                s    VP                   p\        P                  RV4       V P                  e(   \        P
                  ! V P                  4       RV n        RV n        V P                   F  w  r4V! W.VO5!   K  	  R# )u=   GTK3 button release → triggers release, cancels long press.z&Gtk3 do_button_release_event button=%sNF)r   r  r  r  r   Zsource_remover	  r  r  rj   r   do_button_release_eventZ/ClickableEventBoxCompat.do_button_release_event  sp     '--FKK@&I))5""4#=#=>-1*%*D" 224'$' 3r    c                s    < V ^8  d   QhRS[ /# r)   r*   r   r   r   r   r   ,  s     	 	T 	r    c                sv    V P                   '       d    V P                   F  w  rV! V .VO5!   K  	  RV n        R# )z#Timer callback for GTK3 long press.NF)r	  r  r  )r   r  r  rV   r   r  Z/ClickableEventBoxCompat._gtk3_longpress_trigger,  s6    %%% $ 8 8HBtOdO !9)-D&r    c          
      4   < V ^8  d   QhRRRS[ RS[RS[RR/# r   r   r   _n_pressr   r   r   Nr?   r   r   r   r   r   r   5  5     	( 	(1	(=@	(FK	(QV	(	(r    c                d    VP                  4       pV P                   F  w  rgV! W.VO5!   K  	  R # r   )get_current_buttonr  r   r   r  r   r   r   r  r     &&&&&   r   r  Z)ClickableEventBoxCompat._on_click_pressed5  s1     //1F 004'$' 1r    c          
      r  r  r  r   r   r   r   r   <  r  r    c                r  r   )r  r  r  r   r   r  Z*ClickableEventBoxCompat._on_click_released<  s1     //1F 224'$' 3r    c                s.   < V ^8  d   QhRRRS[ RS[ RR/# )r   _gesturezGtk.GestureLongPressr   r   r   N)r   r   r   r   r   r   C  s-     	  	  6	 <A	 GL	 	 r    c                sD    V P                    F  w  rEV! V .VO5!   K  	  R # r   )r  )r   r!  r   r   r  r  s   &&&&  r   r  Z*ClickableEventBoxCompat._on_longpress_gtk4C  s!     !444$ 5r    )r  r	  r  r  r  )r9   r   r   r   r   r   r   r   r  r  r  r  r  r  r   r   __classcell__r
  r      @@r   r   r     sp     	- -BM M$ 1}	 	 	 		 	 		( 	(	( 	(	  	  	 r    r   c                   s6   a  ] tR tRt o RtV 3R lR ltRtV tR# )FakeEventKeyiI  a  
Minimal stand-in for Gdk.EventKey when running under GTK4.

GTK3 delivers key-press-event callbacks with a Gdk.EventKey instance,
which provides attributes such as .keyval, .hardware_keycode, .state,
and .string.

GTK4 does NOT provide Gdk.EventKey. Instead, Gtk.EventControllerKey
emits (keyval, keycode, state) parameters. This class reconstructs
the small subset of a GTK3 GdkEventKey that EmojiPickerUI expects,
allowing the existing GTK3 key handling logic to run unchanged.
c                s.   < V ^8  d   QhRS[ RS[ RRRR/# )r   r   keycodestatezGdk.ModifierTyper   N)r?   r   r   r   r   ZFakeEventKey.__annotate__V  s+     ' 's 'S '9K 'PT 'r    c                s    Wn         W n        W0n        \        P                  ! V4      pV'       d   \        V4      MR V n        ^ V n        ^ V n        RV n	        R# )r   FN)
r   hardware_keycoder'  r   Zkeyval_to_unicodeZchrr   timegroupis_modifier)r   r   r&  r'  Zuc   &&&& r   r   ZFakeEventKey.__init__V  sG    !%,).
''/&(3r7b	
!&r    )r*  r(  r+  r   r'  r   r)  N)r9   r   r   r   r   r   r   r   r   r   r   r%  r%  I  s     ' 'r    r%  c                   sr   a a ] tR tRt oRtV3R lV 3R lltV3R lV 3R lltV3R lV 3R lltR	tVt	V ;t
# )
HeaderBarCompati`  zK
A GTK3/GTK4-compatible HeaderBar with working set_title(), set_subtitle()
c                r   r   r&   r   r   r   r   HeaderBarCompat.__annotate__d  s     3 3$ 3r    c                s  < \         SV `  4        \        ^8  d   V P                  R4       MV P	                  R4       \
        P                  ! \
        P                  P                  ^ R7      V n	        V P                  P                  \        ^8  d   ^ M^4       V P                  P                  \
        P                  P                  4       V P                  P                  \
        P                  P                  4       V P                  P                  R4       \
        P                   ! 4       V n        \
        P                   ! 4       V n        V P"                  V P$                  3 F  pVP'                  \(        P*                  P,                  4       VP                  R4       VP                  \
        P                  P                  4       VP/                  R4       \        ^8  d   V P                  P1                  V4       K  V P                  P3                  VRR^ 4       K  	  \        ^8  d   V P5                  V P                  4       R# R# )r   Tr   ZspacingFg      ?N)r  r   r   Zset_show_title_buttonsZset_show_close_buttonr   r   r   r   
_title_boxZset_spacingr   r   ZCENTERZ
set_valignr   rF   _title_label_subtitle_labelZset_ellipsizer   ZEllipsizeModeZENDr   r5   r7   Zset_title_widget)r   rC   r
  s   & r   r   ZHeaderBarCompat.__init__d  s   >''-&&t,''coo.F.FPQR##aAQ?""399#3#34""399#3#34##D)IIK"yy{'')=)=>E 3 3 7 78e$SYY--.S!A~&&u-**5%B ? >!!$//2 r    c                $   < V ^8  d   QhRS[ RR/# r   r   r   Nr   r   r   r   r   r.    s     ' 'c 'd 'r    c                  < \         ^8  d   \        SV `	  V4       R# V'       d   \        P                  ! V4      MRpV'       d"   V P
                  P                  RV R24       R# V P
                  P                  R4       R# )zs
Set the header bar title (rendered bold). Empty string clears the title.
Escaped using GLib.markup_escape_text().
Nr   <b></b>)r   r  	set_titler   markup_escape_textr1  
set_markupr   r   r   Zescapedr
     && r   r8  ZHeaderBarCompat.set_title  sg    
 q=Gd#37$))$/R((3wit)<=""2&r    c                r3  r4  r   r   r   r   r   r.    s     * * * *r    c                r5  )zn
Set the header bar subtitle (smaller text). Empty string clears it.
Escaped using GLib.markup_escape_text().
Nr   z<small>z</small>)r   r  set_subtitler   r9  r2  r:  r   r;  r<  r   r=  ZHeaderBarCompat.set_subtitle  sg    
 q=G &37$))$/R  ++ggYh,GH%%b)r    )r2  r0  r1  )r9   r   r   r   r   r   r8  r=  r   r   r"  r#  r$  r   r-  r-  `  s-     3 36' '* * *r    r-  c                   s  a  ] tR tRt o Rt]P                  P                  R]P                  P                  R]P                  P                  R]P                  P                  R]P                  P                  R/tRRR	]P                  P                  R
RRRRRRRRR/V 3R lR lltV 3R lR ltV 3R lR ltV 3R lR ltRtV tR# )MessageDialogCompati  a  
Gtk3/Gtk4-compatible informational / warning / error dialog.

Usage:
    MessageDialogCompat(
        parent=self,
        message='Operation completed successfully!',
        message_type=Gtk.MessageType.INFO,
        details='Stack trace or additional error details...',
        details_label='Details',
        title='Information',
        button_label='OK',
        on_close: close_function,
    ).show()
dialog-informationzdialog-warningzdialog-errorzdialog-questionparentNmessage_typedetailsdetails_labelr   titlebutton_label_OKon_closec                s   < V ^8  d   QhRS[ S[P                  ,          RS[RS[P                  RS[ S[,          RS[RS[ S[,          RS[RS[ S[. R	3,          ,          R
R	/	# )r   r@  messagerA  rB  rC  rD  rE  rG  Nr   )r   r   r3   r   MessageTyper   r   r   r   r    MessageDialogCompat.__annotate__  s       $ 	
 oo #  }  8BH-. 
r    c               s|   Wn         W n        W0n        W@n        WPn        T;'       g    R V n        Wpn        Wn        \        P                  ! V P
                  V P                   RR7      V n
        V P                  P                  V P                  \        P                  P                  4       V P                  4        R# )r   TrD  Ztransient_forZmodalN)r@  rH  rA  rB  rC  rD  rE  rG  r   Dialogdialog
add_buttonResponseTypeOK_build_content)	r   r@  rH  rA  rB  rC  rD  rE  rG  s	   &$$$$$$$$r   r   ZMessageDialogCompat.__init__  s     (*[[b
( jj**++

 	t00#2B2B2E2EFr    c                r   r   r&   r   r   r   r   rJ    s       r    c                s   V P                   P                  4       p\        P                  ! \        P                  P
                  ^R7      pVP                  ^4       VP                  ^4       VP                  ^4       VP                  ^4       V P                  P                  V P                  R4      p\        ^8  d2   \        P                  P                  V4      pVP!                  ^04       M8\        P                  P                  V\        P"                  P$                  4      p\'        W$4       \        P                  ! \        P                  P(                  ^R7      p\        P*                  ! 4       pVP-                  R\.        P0                  ! V P2                  4       R24       VP5                  ^ 4       VP7                  ^(4       \9        VR\:        P<                  P>                  R7       \'        WV4       V P@                  '       d   \C        WPP@                  4       \'        W%4       \'        W4       \E        V4       R# )z%Builds the dialog UI for Gtk3 + Gtk4.r/  r?  r6  r7  Tr   N)#rM  get_content_arear   r   r   r   r   r   r   r   ICONSr   rA  r   rc   rg   re   rh   ZDIALOGr<   r   rF   r:  htmlescaperH  r   r   rN   r   rG   r   rB  r   r]   )r   Zcontent_areaZouterra   imageZtext_boxrC   s   &      r   rQ  Z"MessageDialogCompat._build_content  s   {{335COO$>$>KR #r"R JJNN4#4#46JK	>II00;E  $II003<<..0E%77s'?'?K		3t{{4<<89>?!!"%E8P8PQ("<<< <<8%",&r    c                R   < V ^8  d   QhRS[ P                  RS[ P                  RR/# r   rM  	_responser   Nr   rL  rO  r   r   r   r   rJ    s,      3:: #:J:J t r    c                sn    VP                  4        V P                  '       d   V P                  4        R # R # r   )destroyrG  )r   rM  rY  rM   r   _on_responseZ MessageDialogCompat._on_response  s#    ===MMO r    c                r   r   r&   r   r   r   r   rJ    s      d r    c                sZ  a a \         ^8  d9   S P                  P                  4       pS P                  S P                  V4       R# \        P
                  ! 4       oR VV 3R llpS P                  P                  RV4       S P                  P                  4        SP                  4        R# )z
Gtk3:
    Uses dialog.run() (blocks)
Gtk4:
    Emulates run() by spinning a temporary GLib main loop
    until a response is received.
Nc                s\    V ^8  d   QhR\         P                  R\         P                  RR/# rX  rZ  r   r   r   r   Z.MessageDialogCompat.show.<locals>.__annotate__  s+     	 	

 	s7G7G 	D 	r    c                 s   < V P                  4        SP                  '       d   SP                  4        SP                  4        R # r   )r[  rG  quit)rM  rY  loopr   s   &&r   on_responseZ-MessageDialogCompat.show.<locals>.on_response  s(    NN}}}IIKr    response)r   rM  runr\  r   MainLoopr   present)r   r`  r_  r^  s   f  @r   showZMessageDialogCompat.show  sw     q={{(Hdkk84}}	 	 	J4
r    )	rE  rB  rC  rM  rH  rA  rG  r@  rD  )r9   r   r   r   r   r   rI  ZINFOZWARNINGZERRORZQUESTIONZOTHERrS  r   rQ  r\  rd  r   r   r   r   r   r>  r>    s     " 	2!1~  "33E (,
 ),(<(< "& '  $ " 26 : < 
 r    r>  c            
       s   a  ] tR tRt o RtRRRRRRR	R
RR
/V 3R lR lltV 3R lR ltV 3R lR ltV 3R lR ltRt	V t
R
# )ConfirmDialogCompati  aM  
A Gtk3/Gtk4 compatible confirmation dialog with asynchronous callbacks.

Usage:
    dlg = ConfirmDialogCompat(
        parent=self,
        question='Delete everything?',
        title='Confirm',
        ok_label='_OK',
        cancel_label='_Cancel',
        on_ok=callback,
        on_cancel=cancel_callback,
    )
    dlg.show()
rD  zAre you sure?ok_labelrF  cancel_label_Cancelon_okN	on_cancelc                s|   < V ^8  d   QhRS[ P                  RS[RS[RS[RS[RS[S[,          RS[S[,          RR	/# )
r   r@  questionrD  rf  rg  ri  rj  r   N)r   r3   r   r   ResponseCallbackr   r   r   r    ConfirmDialogCompat.__annotate__  sm     " " 

" 	"
 " " " ()" ,-" 
"r    c               s   Wn         W n        W0n        W@n        WPn        W`n        Wpn        \        P                  ! V P                  V P                   R R7      V n	        V P                  P                  V P                  \        P                  P                  4       V P                  P                  V P                  \        P                  P                  4       V P                  4        R# )TrK  N)r@  rk  rD  rf  rg  ri  rj  r   rL  rM  rN  rO  CANCELrP  _add_message_label)r   r@  rk  rD  rf  rg  ri  rj  s   &$$$$$$$r   r   ZConfirmDialogCompat.__init__  s      
 (
"jj**++

 	t00#2B2B2I2IJt}}c.>.>.A.AB!r    c                r   r   r&   r   r   r   r   rm  9  s      D r    c                s   V P                   P                  4       p\        P                  ! 4       pVP	                  R\
        P                  ! V P                  4       R24       VP                  ^(4       VP                  ^ 4       \        VR\        P                  P                  R7       ^
pVP                  V4       VP                  V4       VP!                  V4       VP#                  V4       \%        W4       \'        V4       R# )zDInternal: add message label to content area, with wrapping + markup.z&<span size="large" color="#ff0000"><b>z</b></span>Tr   N)rM  rR  r   rF   r:  rT  rU  rk  r   r   rN   r   rG   r   r   r   r   r   r<   r]   )r   ZboxrC   Zmarginr[   r   ro  Z&ConfirmDialogCompat._add_message_label9  s    kk**,		4T[[5O4PP[\	
 	!!"%(@(@	Bv&V$V$'#r    c                rW  )r   rM  response_idr   NrZ  r   r   r   r   rm  M  s-      3:: C<L<L QU r    c                s    VP                  4        V\        P                  P                  8X  d%   V P                  '       d   V P	                  4        R# V P
                  '       d   V P                  4        R# R# )z@Internal: Handles both Gtk3 and Gtk4 dialog results identically.N)r[  r   rO  rP  ri  rj  )r   rM  rp  rM   r   r\  Z ConfirmDialogCompat._on_responseM  sM    #**---zzz

>>>NN r    c                r   r   r&   r   r   r   r   rm  W  s      d r    c                s   \         ^8  d9   V P                  P                  4       pV P                  V P                  V4       R# V P                  P	                  RV P                  4       V P                  P                  4        R# )ze
Gtk3:
    Blocks internally (dialog.run())
    Then triggers callbacks
Gtk4:
    Fully asynchronous
Nr`  )r   rM  ra  r\  r   rc  )r   r`  r_   r   rd  ZConfirmDialogCompat.showW  s\     q={{(Hdkk84J(9(9:r    )rg  rM  rf  rj  ri  r@  rk  rD  )r9   r   r   r   r   r   ro  r\  rd  r   r   r   r   r   re  re    sd     "
 %" " &" -1" 15" "6 (  r    re  c                   sj   a a ] tR tRt oRtR
V3R lV 3R llltV3R lR ltV3R lR ltR	tVt	V ;t
# )CompatButtonif  a-  
A Gtk.Button subclass that behaves like Gtk4's Gtk.Button even on Gtk3.
Supports:
    - label=
    - child=
    - icon_name=
    - tooltip_text=
    - Gtk4 construction semantics
    - set_label() to update the label later

If the button gets a label, use_markup is always set to True for the label.
c                s   < V ^8  d   QhRS[ S[,          RS[ S[P                  ,          RS[ S[,          RS[ S[,          RS[ S[,          RS[RR/# )	r   rC   r1   ra   tooltip_textuse_underlinekwargsr   N)r   r   r   r3   r+   r   r   r   r   r   CompatButton.__annotate__s  sj     0 0}0 

#0 C=	0
 sm0  ~0 0 
0r    c                s   < \         SV `  ! R/ VB  R V n        R V n        Ve   \	        W4       MVf   Ve   V P                  WV4       V'       d   V P                  V4       R # R # )Nr&   )r  r   _label_widget_boxr<   _setup_commonr   )r   rC   r1   ra   rr  rs  rt  r
  s   &&&&&&,r   r   ZCompatButton.__init__s  sc     	"6"26'+	d" I$9""5]C!!,/ r    c                s`   < V ^8  d   QhRS[ S[,          RS[ S[,          RS[ S[,          RR/# )r   rC   ra   rs  r   N)r   r   r+   r   r   r   r   ru    s?     # #}# C=#  ~	#
 
#r    c                sv   \         P                  ! \         P                  P                  ^R7      V n        Ve   \
        ^8  d2   \         P                  P                  V4      pVP                  ^4       M8\         P                  P                  V\         P                  P                  4      p\        V P                  V4       Ve]   \         P                  ! VRR7      V n        Ve   V P                  P                  V4       \        V P                  V P                  4       \        W P                  4       R# )i   r/  NT)rC   Z
use_markup)r   r   r   r   rw  r   rc   rg   re   rh   ri   r<   rF   rv  Zset_text_with_mnemonic)r   rC   ra   rs  rV  r,  r   rx  ZCompatButton._setup_common  s     GG(B(BAN	 A~		44Y?$$R(		44Y@S@STdii'!$4!HD(""99%@dii!3!34$		"r    c                r3  r4  r   r   r   r   r   ru    s     / /c /d /r    c                s\    V P                   e   V P                   P                  V4       R# R# )z&Set or update the label of the button.N)rv  	set_label)r   r   r;   r   ry  ZCompatButton.set_label  s'    )((. *r    )rw  rv  )NNNNN)r9   r   r   r   r   r   rx  ry  r   r   r"  r#  r$  r   rq  rq  f  s-     0 0,# #*/ / /r    rq  rD  initial_folderc          	      s    V ^8  d   QhR\         P                  R\        \        ,          R\        \        ,          R\        \        ,          /# )r   r@  rD  rz  r   )r   r3   r   r   r   r   r   r   r     sB     = =

= }= !	=
 c]=r    c                s  a	a
 Vf   \        R4      p\        ^8  d   \        P                  ! VV \        P                  P
                  R7      pVP                  R\        P                  P                  4       VP                  R\        P                  P                  4       V'       d    VP                  V4       VP                  4       pRpV\        P                  P                  8X  d   VP                  4       pVP                  4        V# \        P                  ! 4       pVP!                  V4       V'       d1   \"        P$                  P'                  V4      pVP)                  V4       \*        P,                  ! 4       o	Ro
R V	V
3R llpVP/                  V RV4       S	P                  4        S
#   \         d     ELi ; i)z~
Cross-GTK3/Gtk4 file-open dialog.
Blocks in Gtk3, async but wrapped to block in Gtk4.
Returns the selected filename or None.
NzOpen File ...)rD  r@  Zactionrh  rF  c                s\    V ^8  d   QhR\         P                  R\        P                  RR/# )r   rM  taskr   N)r   
FileDialogr   ZAsyncResultr   r   r   r   Z&choose_file_open.<locals>.__annotate__  s.      NN// 
r    c                 s   <  V P                  V4      pV'       d   VP                  4       oSP	                  4        R #   \        P                   d    R o L+i ; i  SP	                  4        i ; ir   )Zopen_finishr   r   ZErrorr]  )rM  r{  gfiler^  r   s   && r   	on_finishZ#choose_file_open.<locals>.on_finish  sX    
	&&t,E) IIK zz 	F	 IIKs!   )> AA AA A-)r%   r   r   ZFileChooserDialogZFileChooserActionZOPENrN  rO  rn  rP  Zset_current_folderrL   ra  Zget_filenamer[  r|  r8  r   ZFileZnew_for_pathZset_initial_folderr   rb  Zopen)r@  rD  rz  rM  r`  ZfilenameZfile_dialogr}  r~  r^  r   s   $$$      @@r   choose_file_openr    se    }/"1}&&((--

 	)S%5%5%<%<=%!1!1!4!45)).9 ::<s''*****,H .."K% %%n5&&u-==?D F  VT9-HHJMI  s   +F3 3GGc                sz    V ^8  d   QhR\         P                  R\        \        ,          R\         P                  /# )r   storevaluesr   )r   rv   r   r   r   r   r   r   r   r     s-        CMM  8C=  S\\  r    c                sr    V P                  4       p\        V4       F  w  r4V P                  W#V4       K  	  V# )a  
Append a row to a Gtk.ListStore in a way that is compatible with all
versions of GTK and PyGObject (GTK3, GTK4 on Fedora/Debian/Ubuntu, and
GTK4 on RHEL9).

Why this function is needed:
    PyGObject normally allows:
        store.append([value0, value1, ...])
    but this depends on the underlying GTK method
    `Gtk.ListStore.insert_with_valuesv()`.  Some distributions
    (notably RHEL9 with GTK 4.12.3) ship incomplete GIR/typelib
    files that *omit* this method.  When Python tries to call
    append([...]), it fails with:

        AttributeError: 'ListStore' object has no attribute 'insert_with_valuesv'

    To avoid this, we append an empty row first and then fill in
    the values using `store.set()`, which is guaranteed to exist
    in all GTK versions.  This makes the function portable across
    all supported platforms.

Args:
    store: A Gtk.ListStore instance.
    values: An iterable of column values for the newly inserted row.

Returns:
    Gtk.TreeIter: The iter pointing to the newly created row.
)r5   Z	enumerateZset)r  r  Ziter_ZcolumnZvaluerj   r   liststore_appendr    s3    :  ,,.E"6*		%' +Lr    )i0   )Tr   )Sr   Ztypingr    r   r   r   r   r   r   r   r   rT  Zloggingr!   Zenumr	   r
   Zgir   Zgi.repositoryr   r   r   r   Zitb_gtkr   r   r   r   rl  r3   r?   ZClickCallbackZReleaseCallbackZLongPressCallbackZ	getLoggerr  r"   r%   r'   r/   r<   rB   rG   ZWORDrN   rW   r\   r]   rk   rn   rr   rx   r|   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   ZEventBoxr   r%  Z	HeaderBarr-  r>  re  r   rq  r  r  r&   r    r   <module>r     s:  &

 
 
        u    #  4 4 'BH% #**c3/56CJJS1478cjj#.45 			0	1"
.K
Y&' 8<49NN4G4G,482@-,"!/$' 4A#F 
 
 
 
 
D	$6 p*X
 
8" 8"t!F'&Sw acggS\\ w r' '.9*cmm 9*vq qfV Vp;/3:: ;/z=  $= )-	=~ r    