+
    KiG  c                   s8   R t ^ RIHt ^ RIHt ^ RIHt ^ RIHtH	t	H
t
 ^ RIHt ^ RIHtHt ^ RIHtHtHt ^ RIHt ^ R	IHt ^ R
IHtHtHtHtHt ^ RIHt ^ RI H!t! ^ RI"H#t# ^ RI$H%t% ^ RI&H't' ^ RI(H)t) ^ RI*H+t+ ^ RI,H-t-H.t.  ! R R]]4      t/ ! R R]4      t0R# )zShared config dialog stuff)gettext)Gtk)settings)LutrisConfigmake_game_config_idrename_config)Game)DIALOG_HEIGHTDIALOG_WIDTH)GameBox	RunnerBoxSystemConfigBox)GameInfoBox)WidgetWarningMessageBox)DirectoryDialogErrorDialogQuestionDialogSavableModelessDialogdisplay_error)DialogInstallUIDelegate)
MoveDialog)send_notification)import_runner)download_lutris_media)	AsyncCall)logger)parse_playtimeslugifyc                   s  a a ] tR t^t oRt]! R4      tR#V 3R llt]R 4       t	R t
R tR tR tR	 tR
 tR$R ltR tR tR tR tR tR tR tR%R ltR tR tR tR tR tR tR tR t R t!R t"V 3R lt#V3R lR  lt$R! t%R"t&Vt'V ;t(# )&GameDialogCommonzBase class for config dialogsz$Select a runner in the Game Info tabc                s  < \         SV `  W^ R7       W n        V P                  \        \
        4       V P                  P                  ^ 4       RV n        RV n	        RV n
        RV n        RV n        RV n        \        4       V n        \        4       V n        . V n        . V n        RV n        RV n        RV n        RV n        / V n        / V n        V P3                  4        R# )i    )parentZborder_widthN)super__init__config_levelZset_default_sizer   r   vboxZset_border_widthnotebookinfo_box
runner_boxtimer_idgamesavedZsetoption_page_indicessearchable_page_indicesadvanced_switch_widgetsheader_bar_widgetsgame_box
system_boxrunner_namelutris_confignotebook_page_generatorsnotebook_page_updaterbuild_header_bar)selftitler    r   	__class__s   &&&&B/usr/lib/python3.14/site-packages/lutris/gui/config/game_common.pyr   ZGameDialogCommon.__init__    s    A>(lM:		""1%	
#&5 '*u$')$"$!(*%%'"    c                s    \         P                  ! RR7      pVP                  \         P                  P                  \         P                  P                  4       VP                  V 4       V# )z2Return a scrolled window containing config widgetsTvisible)r   ZScrolledWindowZ
set_policyZ
PolicyTypeZ	AUTOMATICadd)widgetZscrolled_window   & r6   build_scrolled_windowZ&GameDialogCommon.build_scrolled_window;   sL     ,,T:""3>>#;#;S^^=U=UVF#r7   c                s   \         P                  ! R R7      V n        V P                  P                  R4       V P                  P	                  RV P
                  4       V P                  P                  V P                  R R ^ 4       R# )Tr8   Fzswitch-pageN)r   ZNotebookr"   Zset_show_borderconnecton_notebook_switch_pager!   
pack_startr3      &r6   build_notebookZGameDialogCommon.build_notebookC   sZ    T2%%e,mT-I-IJ		T]]D$:r7   c                s   V P                   P                  V4      pV'       d   V! 4        V P                   V M*V P                  P                  V4      pV'       d   V! 4        V P                  V4       V P	                  V4       R # N)r0   getr1   !update_advanced_switch_visibilityupdate_search_entry_visibility)r3   r"   ZpageZindexZ	generatorZupdaters   &&&&  r6   r?   Z(GameDialogCommon.on_notebook_switch_pageI   sh    1155e<	K--e40044U;G	..u5++E2r7   c                s.   RV n         V P                  R8X  d!   V P                  4        V P                  4        V P	                  4        V P                  4        V P                  P                  4       pV P                  V4       V P                  V4       R# )z'Build tabs (for game and runner levels)Nr&   )
r%   r    _build_info_tab_build_game_tab_build_runner_tab_build_system_tabr"   get_current_pagerF   rG   )r3   current_page_indexr<   r6   
build_tabsZGameDialogCommon.build_tabsV   sx    &  "  "  !]];;=../AB++,>?r7   c                sN    V P                    F  pVP                  V4       K  	  R # rD   )r+   set_visible)r3   valuer;      && r6   !set_header_bar_widgets_visibilityZ2GameDialogCommon.set_header_bar_widgets_visibilityc   s     --Fu% .r7   c                s    V P                   '       d5   WP                  9   pV P                   F  pVP                  V4       K  	  R # R # rD   )r"   r(   r*   rO   )r3   rM   Zshow_switchr;   s   &&  r6   rF   Z2GameDialogCommon.update_advanced_switch_visibilityg   s<    ===,0H0HHK66"";/ 7 r7   c                sl    V P                   '       d"   WP                  9   pV P                  V4       R# R# )zNShows or hides the search entry according to what page is currently displayed.N)r"   r)   set_search_entry_visibility)r3   rM   show_searchrQ   r6   rG   Z/GameDialogCommon.update_search_entry_visibilitym   s,    ===,0L0LLK,,[9 r7   c                sR   V P                  4       pV'       d~   V P                  '       dl   VP                  V P                  4       V P                  P                  T;'       g    V P	                  4       4       V P                  P                  V4       R# VP                  R4       R# )zQExplicitly shows or hides the search entry; can also update the placeholder text.N)get_header_barsearch_entryZset_custom_titleZset_placeholder_textget_search_entry_placeholderZset_tooltip_markup)r3   rT   placeholder_textZtooltip_markup
header_bars   &&&& r6   rS   Z,GameDialogCommon.set_search_entry_visibilitys   sz    ((*
4,,,''(9(9:223C3j3jtGhGhGjk00@''-r7   c                s    V P                   '       dC   V P                   P                  '       d'   \        R 4      V P                   P                  ,          # \        R4      # )zSearch %s optionsSearch options)r&   name_rA   rB   r6   rW   Z-GameDialogCommon.get_search_entry_placeholder}   s<    999()DIINN::!""r7   c                s    \        W P                  R 7      V n        V P                  V P                  4      pV P	                  V\        R4      4      pV P                  P                  V4       R# ))Zparent_widgetr&   z	Game infoN)r   r&   r#   r=   _add_notebook_tabr\   r(   r:   )r3   Zinfo_sw
page_indexs   &  r6   rH   Z GameDialogCommon._build_info_tab   sP    #$YYG,,T]];++GQ{^D
  $$Z0r7   c                sZ   V P                   '       d   V P                   P                  MR p\        RW R7      pVP                  '       d   VP                  V8X  d   R# \	        V P                   VP                  V R7      pVP                  RV P                  4       VP                  4        R# )Z z Select new location for the game)Zdefault_pathr   Nr   z
game-moved)r&   Z	directoryr   Zfolderr   r>   on_game_movedZmove)r3   _buttonZgame_directoryZnew_locationZmove_dialog   &&   r6   on_move_clickedZ GameDialogCommon.on_move_clicked   s    04			,,r&'IXft"""l&9&9^&K L,?,?ML$*<*<=r7   c                s   VP                   pV'       d   \        V P                  '       d   V P                  P                  MR4      V n        V P                  P                  V n        V P                  4        V P                  P                  '       d&   V P                  P                  P                  V4       \        RVP                  : RV: 24       R# \        RRVP                  ,          4       R# )z*Show a notification when the game is movedNzFinished moving gamez
 moved to zFailed to move gamezLutris could not move %s)new_directoryr   r&   Zidconfigr/   _rebuild_tabsr#   Zdirectory_entryZset_textr   )r3   Zdialogrd   rQ   r6   r`   ZGameDialogCommon.on_game_moved   s    ,,TYYYTYY\\DADI!%!1!1D }},,,--66}E4&++Wd6ef35ORXR]R]5]^r7   c                s8  a a R  pR pS P                   '       dw   S P                  '       de   S P                  S P                   n        S P                  \        R4      V 3R lV! S P                   4      V! S P                   4      R7      S n        R# S P                  '       dS   \        R4      oS P                  Sn        S P                  \        R4      VV 3R lV! S4      V! S4      R7      S n        R# S P                  S P                  \        R4      4       R# )c                 sn    V P                   ;'       d#    \        V P                  P                  4      ^8  # )i   )
has_runnerZlenrunnergame_options)r&   rB   r6   is_searchableZ7GameDialogCommon._build_game_tab.<locals>.is_searchable   s(    ??HHs4;;+C+C'Dq'HHr7   c                 s    V P                   '       d8   V P                  P                   F  pVP                  R 4      '       g   K   R# 	  R# )advancedTF)rg   rh   ri   rE   )r&   Zoptr<   r6   has_advancedZ6GameDialogCommon._build_game_tab.<locals>.has_advanced   s6    ;;33Cwwz**# 4 r7   zGame optionsc                  sZ   < \        S P                  S P                  S P                  4      # rD   )r	   r    r/   r&   rA      r6   <lambda>2GameDialogCommon._build_game_tab.<locals>.<lambda>   s     1 143E3EtyyQr7   )rk   
searchableNc                  sF   < \        SP                  SP                  S 4      # rD   )r	   r    r/   )r&   r3   s   r6   rn   ro      s     1 143E3EtLr7   )r&   r.   _build_options_tabr\   r,   r   _build_missing_options_tabno_runner_label)r3   rj   rl   r&   s   f  @r6   rI   Z GameDialogCommon._build_game_tab   s    	I	 999)))$($4$4DII! 33.!Q%dii0(3	 4 DM :D#//D 33.!L%d+(.	 4 DM ++D,@,@!NBSTr7   c                s   a  S P                   '       d'   S P                  \        R 4      V 3R l4      S n        R# S P	                  S P
                  \        R 4      4       R# )zRunner optionsc                  D   < \        S P                  S P                  4      # rD   )r
   r    r/   rA   rm   r6   rn   Z4GameDialogCommon._build_runner_tab.<locals>.<lambda>   s    Yt7H7H$J\J\-]r7   N)r.   rq   r\   r$   rr   rs   rA      fr6   rJ   Z"GameDialogCommon._build_runner_tab   sK    "55"#%]DO ++D,@,@!DTBUVr7   c                sP   a  S P                  \        R 4      V 3R l4      S n        R# )zSystem optionsc                  rt   rD   )r   r    r/   rA   rm   r6   rn   Z4GameDialogCommon._build_system_tab.<locals>.<lambda>   s    9J9JDL^L^)_r7   N)rq   r\   r-   rA   ru   r6   rK   Z"GameDialogCommon._build_system_tab   s!    11!_
r7   c                s   V P                   '       g   \        R 4      hV! 4       pV P                  V P                  V4      V4      pVP                  V P
                  V&   V^ 8X  d   VP                  4        MVP                  V P                  V&   V'       d   V P                  P                  V4       V'       d   V P                  P                  V4       V# )zLutris config not loaded yet)r/   ZRuntimeErrorr]   r=   Zupdate_widgetsr1   Zgenerate_widgetsr0   r(   r:   r)   )r3   notebook_labelZbox_factoryrk   rp   Z
config_boxr^   s   &&&&&  r6   rq   Z#GameDialogCommon._build_options_tab   s    !!!=>> ]
++D,F,Fz,RTbc
1;1J1J"":.?'')8B8S8SD))*5$$((4((,,Z8r7   c                s    \         P                  ! V P                  R 7      pV P                  W24      pV P                  P                  V4       R# )labelN)r   Labelrs   r]   r(   r:   )r3   Zmissing_labelrv   rx   r^   s   &&&  r6   rr   Z+GameDialogCommon._build_missing_options_tab   s:    		 4 45++EB
  $$Z0r7   c                sd    V P                   P                  V\        P                  ! VR 7      4      # )rw   )r"   Zappend_pager   ry   )r3   r;   rx   s   &&&r6   r]   Z"GameDialogCommon._add_notebook_tab   s"    }}((1GHHr7   c                s  a  \         P                  ! ^\        R4      R7      S n        S P                  P	                  RS P
                  4       S P                  P                  4        \         P                  ! \         P                  P                  ^RRR7      pVP                  \        R4      4       \         P                  ! \        R4      RRR7      p\         P                  ! RR\         P                  P                  R	7      pVP                  \         P"                  ! R
4      R8H  4       VP	                  RV 3R l4       VP%                  VRR^ 4       VP'                  VRR^ 4       S P)                  4       pVP'                  V4       W#.S n        S P,                  S P.                  V.S n        S P2                  '       d,   S P5                  S P2                  P7                  4       4       R# R# )i   rZ   )Zwidth_charsrX   zsearch-changedT)ZorientationZspacingno_show_allr9   zShow advanced optionsZAdvanced)rz   r9   )rz   r9   Zvalignshow_advanced_optionsZTruez	state-setc                 s8   < SP                  \        V4      4      # rD   ) on_show_advanced_options_toggledbool)Z_wZsr3   s   &&r6   rn   Z3GameDialogCommon.build_header_bar.<locals>.<lambda>   s    $2W2WX\]^X_2`r7   FN)r   ZSearchEntryr\   rV   r>   on_search_entry_changedshow_allZBoxZOrientationZ
HORIZONTALZset_tooltip_textry   ZSwitchZAlignZCENTERZ	set_stater   Zread_settingr@   Zpack_endrU   r*   Zcancel_buttonZsave_buttonr+   r"   rF   rL   )r3   Z
switch_boxZswitch_labelZswitchrY   s   f    r6   r2   Z!GameDialogCommon.build_header_bar   sv   OOQO_M`a!!"2D4P4PQ""$ WW)C)CQ\`jno
##A&=$>?yy:D$Od399CSCST../FG6QR{$`alE5!<FE5!4((*
J' )5'=$#'#5#5t7G7G"T===224==3Q3Q3ST r7   c                s    VP                  4       P                  4       P                  4       pV P                  V4       R# )z(Callback for the search input keypressesN)get_textZlowerZstrip_set_filter)r3   ZentryZtextrQ   r6   r~   Z(GameDialogCommon.on_search_entry_changed  s.    ~~%%'--/r7   c                sV    \         P                  ! R V4       V P                  V4       R# )r{   N)r   Zwrite_setting_set_advanced_options_visible)r3   Z	is_active   &&r6   r|   Z1GameDialogCommon.on_show_advanced_options_toggled	  s!    6	B**95r7   c                s    V P                   '       d   WP                   n        WP                  n        V P                  '       d   WP                  n        V P                  '       d   WP                  n        R# R# )z=Change visibility of advanced options across all config tabs.N)r#   Zadvanced_visibilityr-   r$   r,   r3   rP   r   r6   r   Z.GameDialogCommon._set_advanced_options_visible  sJ    ===05MM-.3+???27OO/===05MM- r7   c                s    V P                   '       d   WP                   n        V P                  '       d   WP                  n        V P                  '       d   WP                  n        R # R # rD   )r-   Zfilterr$   r,   r   r   r6   r   ZGameDialogCommon._set_filter  s@    ???%*OO"???%*OO"===#(MM  r7   c           
     s   VP                  4       pV P                  pVP                  '       d   W#P                  8w  d}   \        RV R\	        R4      R\	        R4      /4      pVP
                  \        P                  P                  8X  d   V P                  W4       R# VP                  VP                  4       R# V P                  W4       R# )z/Action called when runner drop down is changed.r   ZquestionzAre you sure you want to change the runner for this game ? This will reset the full configuration for this game and is not reversible.r4   zConfirm runner changeN)Z
get_activer#   runner_indexr   r\   Zresultr   ResponseTypeZYES_switch_runnerZ
set_active)r3   r;   new_runner_indexgame_info_boxZdlgrb   r6   on_runner_changedZ"GameDialogCommon.on_runner_changed   s    !,,.%%%*:>X>X*X d-!
 Q67
C zzS--111##F= !!-"<"<=9r7   c                s
   V P                   P                  4       pV P                  pW$n        V^ 8X  d&   \        P
                  ! R4       RV n        RV n        MVP                  4       V,          ^,          pWPP                  8X  d   \        P                  ! R4       R# \        P
                  ! RV4       WPn        \        V P                  RR7      V n        V P                  4        V P                   P                  V4       R# )z Rebuilds the UI on runner changez+No runner selected, resetting configurationNz+Runner unchanged, not creating a new configz)Creating new configuration with runner %sr&   )Zrunner_slugZlevel)r"   rL   r#   r   r   Zinfor.   r/   Z	get_modeldebugr   rf   Zset_current_page)r3   r;   r   Zcurrent_pager   r.   s   &&&   r6   r   ZGameDialogCommon._switch_runner9  s    }}557%5"q KKEF#D!%D **,-=>qAK...JKKKC[Q*!-$:J:JRX!YD&&|4r7   c                s   \        V P                  P                  4       ^R4       F%  pV P                  P                  V^,
          4       K'  	  V P                  P                  4        V P                  P                  4        V P                  4        V P                  4        V P                  4        V P                  4        R# )zRebuild notebook pagesNi)Zranger"   Zget_n_pagesZremove_pager(   Zclearr)   rI   rJ   rK   r   )r3   Zir<   r6   rf   ZGameDialogCommon._rebuild_tabsM  s    t}}002Ar:AMM%%a!e, ;  &&($$**,  r7   c                s   < V\         P                  P                  \         P                  P                  39   d-   V P                  '       d   V P                  P                  4        \        SV `  W4       R # rD   )r   r   ZCANCELZDELETE_EVENTr&   Zreload_configr   on_response)r3   Z_widgetZresponser5   s   &&&r6   r   ZGameDialogCommon.on_responseX  sN    ((//1A1A1N1NOOyyy		'')G.r7   c                s    < V ^8  d   QhRS[ /# )i   Zreturn)r}   )Zformat__classdict__s   "r6   Z__annotate__ZGameDialogCommon.__annotate___  s     % %$ %r7   c                s   V P                   pV P                  '       g   \        \        R 4      V R7       R# VP                  P                  4       '       g   \        \        R4      V R7       R# V P                  R8X  dD   V P                  P                  P                  R4      '       g   \        \        R4      V R7       R# VP                  P                  4       pV'       d9   V P                  '       d   W P                  P                  8w  d    \        V4       . p\        V P                  4      pV! 4       pR F  p\!        V P                  VR,           4      P#                  4        F[  w  rVP%                  VR	,           V4      p
V
f   K$  V
P                  R
4      pVf   K;   V! V	4      p\&        P(                  ! RW4       K]  	  K  	  V'       d/   \        \        R4      RP/                  V4      ,           V R7       R# R#   \         d   p\        Y0R7        Rp?R# Rp?ii ; i  \*         d%    TP-                  T
P                  R4      4        K  i ; i)zRunner not providedr_   FzPlease fill in the nameZsteamZappidzSteam AppID not providedNZ_configZ_options	validatorz%s validated successfully: %srx   z*The following fields have invalid values: z, T)r&   rh   )r#   r.   r   r\   
name_entryr   r/   Zgame_configrE   playtime_entryr&   formatted_playtimer   Z
ValueErrorr   r   ZgetattrZitemsZfind_optionr   r   Z	ExceptionZappendZjoin)r3   r   playtime_textZexZinvalid_fieldsZrunner_classZrunner_instancere   ZkZvZoptionr   Zress   &            r6   is_validZGameDialogCommon.is_valid_  s   /0>''002234TBw&t/A/A/M/M/Q/QRY/Z/Z45dC%44==?$)))}		@\@\/\}-
 $T%5%56&.(F 2 2FY4FGMMO(44Vj5H!L>"JJ{3	(C'l%DaM P ) FG$))TbJcclpq-  b." % C&--fjj.ABCs*   H 'H+H(H##H(++IIc                s   V P                  4       '       g"   \        P                  ! \        R4      4       R# V P                  pVP
                  P                  4       pVP                  P                  4       pVP                  '       g   \        V4      Vn        VP                  VP                  8w  d   \        \        RVP                  4       V P                  '       g   \        4       V n        RpVP                  P                  4       '       d$   \!        VP                  P                  4       4      pRpVP"                  P                  4       pV'       d&   WpP                  P$                  8w  d   \'        V4      pV P(                  P*                  '       g%   \-        VP                  4      V P(                  n        W0P                  n        W@P                  n        VP                  V P                  n        WPP                  n        V'       d   W`P                  n        RV P                  n        V P(                  V P                  n        \;        V P                  P8                  P*                  V P                  P                  4      ;p'       d   WP                  P8                  n        V P<                  V P                  n        RV P                  P>                  9  d0   V P                  P@                  PC                  VP                  4       V P                  PE                  4        V PG                  4        RV n$        R# )z"Save game info and destroy widget.z9Current configuration is not valid, ignoring save requestNTZicon)%r   r   Zwarningr\   r#   r   r   Zsortname_entryZslugr   Zinitial_slugr   r   r&   r   Z
year_entryZintr   r   r   r/   Zgame_config_idr   r[   sortnameyearplaytimeZis_installedre   r   r.   Zcustom_imagesrh   Zextract_iconZsaveZdestroyr'   )	r3   ra   r   r[   r   r   r   r   Znew_config_ids	   &&       r6   on_saveZGameDialogCommon.on_save  s.   }}NN1XYZ''002 //88:!!!!(M!;!;;+T=3E3EFyyyDI##,,..}//88:;D%44==?]ii.J.JJ%m4H!!0000CMDVDV0WD-		%		&++				!)II!%		--		 *$))*:*:*I*I499>>ZZ=Z.;II+ $ 0 0		000II))-*<*<=		
r7   )r*   r    r&   r,   r+   r#   r/   r"   r0   r1   r(   r$   r.   r'   rV   r)   r-   r%   rD   )NN)TT))__name__
__module____qualname____firstlineno____doc__r\   rs   r   Zstaticmethodr=   rC   r?   rN   rR   rF   rG   rS   rW   rH   rc   r`   rI   rJ   rK   rq   rr   r]   r2   r~   r|   r   r   r   r   rf   r   r   r   __static_attributes____classdictcell____classcell__r5   r      @@r6   r   r      s     '>?O 6  ;3@&0:.#1_U>W

&1
IU:
6
6):25(	/% %N1 1r7   r   c                   s2   a a ] tR tRt oV 3R ltRtVtV ;t# )RunnerMessageBoxi  c                s,   < \         SV `  ^^RR7       R# )i   zdialog-warning)Zmargin_leftZmargin_rightZ	icon_nameN)r   r   )r3   r5   s   &r6   r   ZRunnerMessageBox.__init__  s    RbDTUr7    )r   r   r   r   r   r   r   r   r   r   r6   r   r     s     V Vr7   r   N)1r   r    r\   Zgi.repositoryr   Zlutrisr   Zlutris.configr   r   r   Zlutris.gamer   Zlutris.gui.configr   r   Zlutris.gui.config.boxesr	   r
   r   Zlutris.gui.config.game_info_boxr   Z"lutris.gui.config.widget_generatorr   Zlutris.gui.dialogsr   r   r   r   r   Zlutris.gui.dialogs.delegatesr   Zlutris.gui.dialogs.move_gamer   Z lutris.gui.widgets.notificationsr   Zlutris.runnersr   Zlutris.services.lutrisr   Zlutris.util.jobsr   Zlutris.util.logr   Zlutris.util.stringsr   r   r   r   r   r7   r6   <module>r      sk      !   J J  9 G G 7 F q q @ 3 > ( 8 & " 7\,.E \~V. Vr7   