+
    Ki!:  c                   sF   R t ^ RIt^ RIHt ^ RIHt ^ RIHtHtH	t	 ^ RI
HtHt ^ RIHtHt ^ RIHt ^ RIHt ^ R	IHt ^ R
IHt ^ RIHtHt ^ RIHt ^ RIHt R R lt ! R R]4      t  ! R R] 4      t! ! R R]!4      t" ! R R]!4      t# ! R R]!4      t$ ! R R]4      t%R# )z+Widget generators and their signal handlersN)abstractmethod)gettext)AnyDictOptional)GtkPango)settings
sysoptions)LutrisConfig)Game)WidgetGenerator)VBox)InvalidRunnerErrorimport_runner)logger)clear_wine_version_cachec                sZ    V ^8  d   QhR\         P                  R\        \        ,          /# )   wrapper
class_name)r   Widgetr   strformat   "</usr/lib/python3.14/site-packages/lutris/gui/config/boxes.py__annotate__r      s"     
, 
,CJJ 
,HSM 
,    c                s    V P                  4       pVP                  4        F5  pVP                  R4      '       g   K  W18w  g   K$  VP                  V4       K7  	  V'       d   VP	                  V4       R# R# )zSets a particular CSS class on a wrapper, and removes any other classes that start
with 'option-wrapper-' so there's only one o these classes.zoption-wrapper-N)get_style_contextZlist_classesZ
startswithZremove_class	add_class)r   r   Zstyle_contextZclss   &&  r   set_option_wrapper_style_classr      s`     --/M))+>>+,,1B&&s+ , 
+ r   c                   s   a a ] tR t^&t oRtV3R lV 3R llt]R 4       t]P                  R 4       t]	R 4       t
RtVtV ;t# )AdvancedSettingsBoxzDIntermediate vbox class for expsoing the Advanced Visibility optionsc                   < V ^8  d   QhRR/# )r   returnN r   __classdict__   "r   r   Z AdvancedSettingsBox.__annotate__)   s     * *D *r   c                s6   < \         SV `  ! R/ VB  R V n        R# )FNr"   )super__init___advanced_visibility)selfkwargs	__class__s   &,r   r'   ZAdvancedSettingsBox.__init__)   s    "6"$)!r   c                    V P                   # Nr(   r)      &r   advanced_visibility'AdvancedSettingsBox.advanced_visibility-   s    (((r   c                s2    Wn         V P                  4        R# )zgSets the visibility of every 'advanced' option and every section that
contains only 'advanced' options.N)r(   update_widgetsr)   value   &&r   r1   r2   1   s     %*!r   c                s    \        4       h)zTUpdates widgets on visibility change; this method must be
implemented by a subclass.)ZNotImplementedErrorr/   r0   r   r3   Z"AdvancedSettingsBox.update_widgets8   s     "##r   r.   )__name__
__module____qualname____firstlineno____doc__r'   propertyr1   setterr    r3   __static_attributes____classdictcell____classcell__r+   r$      @@r   r   r   &   sY     N* * ) )    $ $ $r   r   c                   s   a a ] tR t^?t oRt]tRV3R lV 3R lllt]V3R lR l4       t	]	P                  V3R lR l4       t	R tV3R	 lR
 ltV3R lR ltR tR tRtVtV ;t# )	ConfigBoxz8Dynamically generate a vbox built upon on a python dict.c                s0   < V ^8  d   QhRS[ RS[RS[RR/# )r   config_levellutris_configgamer!   Nr   r	   r
   r#   r%   r   r   ConfigBox.__annotate__D   s*     < <S < <T <gk <r   c                s.  < \         SV `  ! R/ VB  . V n        Wn        W n        W0n        R V n        R V n        . V n        R V n	        R V n
        RV n        RV n        \        P                  ! \        P                  P                   \        P                  P                   R7      V n        V P"                  P%                  R4       V P"                  P'                  \(        P*                  P,                  4       V P/                  V P"                  RR^ 4       R # )N )ZhalignZvalignTr"   )r&   r'   optionsrD   rE   rF   config
raw_configfilesfiles_list_store_widget_generator_filter_filter_textr   LabelAlignCENTERno_options_labelset_line_wrapZset_line_wrap_moder   ZWrapModeZ	WORD_CHARpack_end)r)   rD   rE   rF   r*   r+   s   &&&&,r   r'   ZConfigBox.__init__D   s    "6"(*	
 $!% #		1A1A#))JZJZ [++D1001I1IJd++T4;r   c                s    < V ^8  d   QhRS[ /# r   r!   r   r#   r%   r   r   rH   X   s       r   c                r,   r-   )rP   r/   r0   r   filterConfigBox.filterW   s    ||r   c                $   < V ^8  d   QhRS[ RR/# )r   r5   r!   NrY   r#   r%   r   r   rH   \   s      C D r   c                s\    Wn         VP                  4       V n        V P                  4        R# )zQSets the visibility of the options that have some text in the label or
help-text.N)rP   casefoldrQ   r3   r4   r6   r   rZ   r[   [   s$     !NN,r   c                s   \         P                  ! 4       pVP                  ^4       VP                  ^4       VP	                  ^4       \         P
                  P                  R\         P                  P                  4      pVP                  VRR^4       \         P                  ! RV,          4      pVP                  R4       VP                  ^ R4       VP                  R4       VP                  VRR^4       V P                  VRR^ 4       V P                  \         P                  ! 4       RR^4       VP                  4        R# )z<Add a top section with general help text for the current tabzdialog-informationFz	<i>%s</i>Tg      ?N)r   Boxset_margin_leftZset_margin_rightset_margin_bottomZImagenew_from_icon_nameIconSizeMENU
pack_startrR   rV   Zset_alignmentZset_use_markupZ
HSeparatorZshow_all)r)   ZtextZhelp_boxZiconZtitle_labels   &&   r   generate_top_info_boxZConfigBox.generate_top_info_boxc   s    779  $!!"%""1%yy++,@#,,BSBSTD%2iid 23!!$'!!!S)""4(Kq9%2(%;r   c                r    )r   r!   ConfigWidgetGeneratorr"   r#   r%   r   r   rH   x   s      &= r   c                s   V P                   '       d   V P                   # \        V 4      pV P                  '       d9   V P                  P                  '       d   V P                  P                  Vn        MV P                  '       dC   V P                  P
                  '       d'   V P                  P                  P                  Vn        MV P                  '       dS   V P                  P                  P                  R4      ;'       g     \        P                  P                  R4      Vn        M$\        P                  P                  R4      Vn        Wn         V# )zReturns an object that creates option widgets and tracks them; this is
lazy-initialized, but repeated calls return the same generator.Z	game_pathZ~)rO   rf   rF   Z	directoryZdefault_directoryZ
has_runnerrunnerZworking_dirrE   system_configgetosZpathZ
expanduser)r)   gen   & r   get_widget_generatorZConfigBox.get_widget_generatorx   s     !!!)))#D)999,,,$(II$7$7C!YYY499///$(II$4$4$@$@C!$($6$6$D$D$H$H$U$p$pY[Y`Y`YkYkloYpC!$&GG$6$6s$;C!!$
r   c                s:   < V ^8  d   QhRS[ P                  RS[/# )r   option_containerr!   )r   r   boolr#   r%   r   r   rH      s      cjj T r   c                s\   V P                   '       g2   \        VR4      ;'       d    VP                  pV'       d
   RVn        R# V P                  pV'       dU   \        VR4      '       dC   VP
                  P                  4       pVP                  P                  4       pW49  d	   W59  d   R# R# )zhCalled by the widget generate to filter option containers; return true for
those that should be visible.lutris_advancedTFlutris_option_label)r1   Zhasattrrp   lutris_advanced_hiddenrQ   rq   r]   Zlutris_option_helptext)r)   rn   Zis_advancedZfilter_textZlabelZhelptexts   &&    r   filter_widgetZConfigBox.filter_widget   s     '''!"24EFkkK[KkKkK ;? 7''7#35JKK$88AACE'>>GGIH'K,Gr   c                s>   V P                   R8X  d8   V P                  P                  V n        V P                  P                  V n        MV P                   R8X  d8   V P                  P                  V n        V P                  P                  V n        MGV P                   R8X  d7   V P                  P                  V n        V P                  P                  V n        V P                  4       pV P                   F6  p RV9   d   V P                  VR,          9  d   K%  VP                  V4       K8  	  \$        P&                  ! R4      R	8H  pW@n        VP+                  4        R#   \         d3   p\        P                   ! RTP#                  R4      T4        Rp?K  Rp?ii ; i)
z7Parse the config dict and generates widget accordingly.rF   rg   systemZscopez-Failed to generate option widget for '%s': %soptionNZshow_advanced_optionsZTrue)config_sectionrE   Zgame_configrK   Zraw_game_configrL   Zrunner_configZraw_runner_configrh   Zraw_system_configrm   rJ   rD   Zadd_containerZ	Exceptionr   Z	exceptionri   r   Zread_settingr(   r3   )r)   rk   ru   ZexZshow_advanceds   &    r   generate_widgetsZConfigBox.generate_widgets   sS    &(,,88DK"00@@DO  H,,,::DK"00BBDO  H,,,::DK"00BBDO'') llFlf$((w?  !!&) # !--.EF&P$1!  l  !PRXR\R\]eRfhjkkls   8EEF*'FFc                sb    V P                   '       d   V P                   P                  4        R # R # r-   )rO   r3   r/   r0   r   r3   ZConfigBox.update_widgets   s%    !!!""113 "r   )r(   rP   rQ   rO   rK   rD   rM   rN   rF   rE   rU   rJ   rL   r-   )r7   r8   r9   r:   r;   ZNotImplementedrv   r'   r<   rZ   r=   re   rm   rs   rw   r3   r>   r?   r@   rA   rB   r   rC   rC   ?   sk     B#N< <&   ]] * ( (>4 4r   rC   c                   s6   a  ] tR t^t o RtV 3R lR ltRtV tR# )GameBoxrF   c                ,   < V ^8  d   QhRS[ RS[RS[/# r   rD   rE   rF   rG   r#   r%   r   r   ZGameBox.__annotate__   s'     D DS D DT Dr   c                s    \         P                  ! WW#3/ VB  VP                  V n        V P                  '       d   V P                  P                  V n        R# \
        P                  ! R 4       R# )z%No runner in game supplied to GameBoxN)rC   r'   rg   Zgame_optionsrJ   r   Zwarningr)   rD   rE   rF   r*      &&&&,r   r'   ZGameBox.__init__   sI    4}MfMkk;;;;;33DLNNBCr   rJ   rg   Nr7   r8   r9   r:   rv   r'   r>   r?   r$      @r   rx   rx      s     ND Dr   rx   c                   sP   a a ] tR t^t oRtRtRV3R lR lltV 3R ltRtVt	V ;t
# )	RunnerBoxz-Configuration box for runner specific optionsrg   c                ry   rz   rG   r#   r%   r   r   ZRunnerBox.__annotate__   s"      S  T r   c                sv   \         P                  ! WW#3/ VB   \        V P                  P                  4      ! 4       V n        V P
                  '       d    V P
                  P                  4       V n        VP                  R8X  d   V P                  \        R4      4       R # R #   \         d    R T n         Lti ; i)NrF   zYIf modified, these options supersede the same options from the base runner configuration.)rC   r'   r   rE   runner_slugrg   r   Zget_runner_optionsrJ   Zlevelre   _r{   r|   r   r'   ZRunnerBox.__init__   s    4}MfM	'(:(:(F(FGIDK ;;;;;99;DL&(&&mn ) " 	DK	s   )B# #B87B8c                s4   < \        4        \        SV `	  4       # r-   )r   r&   rw   )r)   r+   s   &r   rw   ZRunnerBox.generate_widgets   s     	!"w'))r   r}   r-   )r7   r8   r9   r:   r;   rv   r'   rw   r>   r?   r@   rA   rB   r   r   r      s!     7N * *r   r   c                   s6   a  ] tR t^t o RtV 3R lR ltRtV tR# )SystemConfigBoxrt   c                s*   < V ^8  d   QhRS[ RS[RR/# )r   rD   rE   r!   N)r   r	   r#   r%   r   r   ZSystemConfigBox.__annotate__   s#      S  TX r   c                s   \         P                  ! WV3/ VB  R V n        V P                  P                  pV'       d   \
        P                  ! V4      V n        M\
        P                  V n        VP                  '       d%   V'       d   V P                  \        R4      4       R # V'       d   V P                  \        R4      4       R # R # )NzIf modified, these options supersede the same options from the base runner configuration, which themselves supersede the global preferences.zRIf modified, these options supersede the same options from the global preferences.)rC   r'   rg   rE   r   r   Zwith_runner_overridesrJ   Zsystem_optionsZgame_config_idre   r   )r)   rD   rE   r*   r   s   &&&, r   r'   ZSystemConfigBox.__init__   s    4}GG((44%;;KHDL%44DL'''K&&. &&fg r   r}   Nr~   r   r   r   r   r      s     N r   r   c                   s   a a ] tR tRt oV3R lV 3R lltV3R lR l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V3R lV 3R llt	V 3R lt
R tV 3R ltRtVtV ;t# )rf   i  c                r\   )r   parentr!   N)rC   r#   r%   r   r   "ConfigWidgetGenerator.__annotate__  s     	7 	7y 	7T 	7r   c                s   < \         SV `  WP                  4       VP                  e   VP                  f   \        R4      hVP                  V n        VP                  V n        VP                  V n        / V n        R # )Nz<Widgets can't be generated before the config is initialized.)r&   r'   rE   rK   rL   ZRuntimeErrorreset_buttons)r)   r   r+   s   &&r   r'   ZConfigWidgetGenerator.__init__  se    !5!56== F$5$5$=]^^mm ++#1146r   c                s,   < V ^8  d   QhRS[ RS[RS[/# )r   
option_keydefaultr!   )r   r   r#   r%   r   r   r     s"      c C C r   c                s\    WP                   9   d   V P                   P                  V4      # V# r-   )rK   ri   )r)   r   r   s   &&&r   get_settingZ!ConfigWidgetGenerator.get_setting  s$    $;;??:..Nr   c                sR   < V ^8  d   QhRS[ P                  RS[ P                  RR/# )r   	containerr   r!   N)r   	Containerr#   r%   r   r   r     s.     > > >QTQ^Q^ >cg >r   c                s   < \         SV `  WV4       VR ,          pW@P                  9   d   \        VR4       R# V P	                  V4      pV P                  WE4      pWe8w  d   \        VR4       R# \        VR4       R# )ru   zoption-wrapper-assigned-herezoption-wrapper-non-defaultN)r&   update_option_containerrL   r   Zget_defaultr   )r)   ru   r   r   r   r   r5   r+   s   &&&&   r   r   Z-ConfigWidgetGenerator.update_option_container  sl    '7CH%
(*74RS&&v.G$$Z9E.w8TU.w=r   c                sj   < V ^8  d   QhRS[ S[S[3,          RS[P                  RS[P
                  /# )r   ru   r   r!   )r   r   r   r   r   r   r#   r%   r   r   r   '  s:     H Hd38n Hszz HVYVcVc Hr   c                s  < VR ,          p\         P                  ! RR7      pVP                  ^4       VP                  VRR^ 4       \         P                  P                  R\         P                  P                  4      pVP                  4       P                  R4       VP                  \         P                  P                  4       VP                  \         P                  P                  4       VP                  ^4       VP                  \         P                   P"                  4       VP%                  \'        R4      4       VP)                  RV P*                  V4       WPP,                  V&   W0P.                  9  d#   VP1                  R4       VP3                  R4       \         P                  ! 4       pVP5                  ^R4       VP                  VRR^ 4       VP7                  VRR^4       \8        SV `u  W4      # )	ru   T)Zvisiblezedit-undo-symboliczreset-buttonz(Reset option to global or default configZclickedFi)r   r^   r_   rd   ZButtonra   rb   rc   r   r   Z
set_valignrS   rT   Z
set_halignr`   Z
set_reliefZReliefStyleZNONEZset_tooltip_textr   Zconnecton_reset_button_clickedr   rL   set_visibleZset_no_show_allZset_size_requestrW   r&   create_option_container)r)   ru   r   r   Zreset_containerZreset_buttonZplaceholderr+   s   &&&    r   r   Z-ConfigWidgetGenerator.create_option_container'  s~   H%
''$/''+""7D$:zz445I3<<K\K\]&&(22>B		 0 01		 0 01&&q) 4 45%%a(R&STY(D(DfM)5:&__,$$U+((.ggi$$R,|UE1=  eUA>w.vGGr   c                s<   < V ^8  d   QhRS[ S[S[3,          RS[/# )r   ru   r!   )r   r   r   ro   r#   r%   r   r   r   B  s#     ; ;T#s(^ ; ;r   c                s   < V P                   VR ,          ,          pRVn        \        SV `  V4      pV'       g   R# V P                  P                  V4      # )ru   F)option_containersrr   r&   get_visibilityr   rs   )r)   ru   rn   Zoption_visibilityr+   s   &&  r   r   Z$ConfigWidgetGenerator.get_visibilityB  sN    11&2BC27/!G26: {{(()9::r   c                sB   < V ^8  d   QhRS[ S[S[3,          RS[RS[/# )r   ru   r5   r   )r   r   r   r#   r%   r   r   r   L  s*      $sCx.  s r   c                s   < \         SV `  WV4      pVR ,          pW#8w  d6   WPP                  9  d&   V'       d
   VR,           MRpV\        R4      ,          pV# )ru   z

rI   zV<i>(Italic indicates that this option is modified in a lower configuration level.)</i>)r&   get_tooltiprL   r   )r)   ru   r5   r   Ztooltipr   r+   s   &&&&  r   r   Z!ConfigWidgetGenerator.get_tooltipL  sP    '%fW=H%

// A*1g&rGqqrrGr   c                s4  <a  \         SS `  4        R  V 3R llpV! 4       pV'       dL   S P                  P                  P	                  V4       S P                  P                  P                  4        R# S P                  P                  P                  4        R# )c                s:    V ^8  d   QhR\         \        ,          /# rX   )r   r   r   r   r   r   Z:ConfigWidgetGenerator.update_widgets.<locals>.__annotate__W  s     	- 	- 	-r   c                  s   < SP                   '       d   SP                   P                  4        F  p V P                  4       '       g   K   R # 	  SP                  P                  '       d'   \        R4      SP                  P                  ,          # \        ;QJ d4    R SP                   P                  4        4       F  '       g   K   RM)	  RM%! R SP                   P                  4        4       4      '       d   \        R4      # \        R4      # )NzNo options match '%s'c              3   s8   "   T F  qP                   x  K  	  R # 5ir-   )rr   )Z.0Zcrl   r   Z	<genexpr>ZWConfigWidgetGenerator.update_widgets.<locals>.get_no_options_message.<locals>.<genexpr>_  s     [;Za11;Zs   TFzOnly advanced options availablezNo options available)r   ZvaluesZget_visibler   rZ   r   Zany)r   r)   s    r   get_no_options_messageZDConfigWidgetGenerator.update_widgets.<locals>.get_no_options_messageW  s    %%%!%!7!7!>!>!@I ,,..# "A ;;%%%458J8JJJS[4;Q;Q;X;X;Z[SSS[4;Q;Q;X;X;Z[[[>??+,,r   N)r&   r3   r   rU   Zset_textZshowZhide)r)   r   Zmessager+   s   f  r   r3   Z$ConfigWidgetGenerator.update_widgetsT  si     	- 	- )*KK((11':KK((--/KK((--/r   c                s   VR,          pV P                   V,          pVP                  R4       V P                  P                  VR4       V P                  P                  4        V P                  W$R7       V P                  4        R# )z7Clear option (remove from config, reset option widget).ru   FN)r   )Zwrappersr   rL   ZpoprE   Zupdate_cascaded_configZgenerate_widgetr3   )r)   Zbtnru   r   r   s   &&&  r   r   Z-ConfigWidgetGenerator.on_reset_button_clickedk  si    H%
--
+J-113V5r   c                s   < W P                   V&   W P                  V&   V P                  P                  V4      pV'       d   VP	                  R4       \
        SV `  W4       R# )z-Common actions when value changed on a widgetTN)rL   rK   r   ri   r   r&   
on_changed)r)   r   Z	new_valueZ	reset_btnr+   s   &&& r   r   Z ConfigWidgetGenerator.on_changedx  sO    &/
#"+J&&**:6	!!$':1r   )rK   rE   rL   r   )r7   r8   r9   r:   r'   r   r   r   r   r   r3   r   r   r>   r?   r@   rA   rB   r   rf   rf     sW     	7 	7 > >H H6; ; 0.	2 	2r   rf   )&r;   rj   Zabcr    r   r   Ztypingr   r   r   Zgi.repositoryr   r   Zlutrisr   r   Zlutris.configr	   Zlutris.gamer
   Z"lutris.gui.config.widget_generatorr   Zlutris.gui.widgets.commonr   Zlutris.runnersr   r   Zlutris.util.logr   Zlutris.util.wine.winer   r   r   rC   rx   r   r   rf   r"   r   r   <module>r      s    1 	  ! & & % ( &  > * < " :
,$$ $2B4# B4J	Di 	D*	 *6i 6{2O {2r   