+
    KicG  c                   s   R t ^ RIt^ RIt^ RIt^ RIHt ^ RIHt ^ RI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HtHt ^ R
I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 t$R t%R t& ! R R]4      t' ! R R]4      t(R# )z+Dialog used to install versions of a runnerN)defaultdict)gettext)Gtk)apisettings)format_runner_versionparse_version_architecture)get_games_by_runner)Game)ErrorDialogModelessDialogdisplay_error)has_stock_icon)jobssystem)
Downloaderextract_archive)schedule_repeating_at_idle)loggerc                s`    RVRV/p\         P                  P                  V \        V4      4      # )z;Return the local path where the runner is/will be installedversionarchitecture)ospathjoinr   )runner_directoryr   archZinfos   &&& F/usr/lib/python3.14/site-packages/lutris/gui/dialogs/runner_install.pyget_runner_pathr      s,    w5D77<<(*?*EFF    c                s    \         P                  P                  V 4      '       g   \        4       # \         P                  ! V 4       Uu0 uF  p\        V4      kK  	  up# u upi )zList versions available locally)r   r   existsZsetZlistdirr   )r   ps   & r   get_installed_versionsr       sG    77>>*++u35::>N3OP3Oa&q)3OPPPs   Ac                s   \        V 4      p\        \        4      pV Fa  pVR,          '       g   K  \        VR,          4      pVP                  P
                  R,          pW%,          P                  VR,          4       Kc  	  V# )z!Return the usage for each version	installedidr   )r   r    Zlistr   configrunner_configappend)runner_namerunner_gamesversion_usagedb_gamegamer   s   &     r   get_usage_statsr+   &   sm    &{3L%M{##GDM"++++I6%%gdm4   r   c                   s>   a a ] tR t^3t oV 3R ltR tR tRtVtV ;t	# )ShowAppsDialogc                s  < \         SV `  W^
R7       W0n        W@n        V P	                  \
        P                  \
        P                  P                  4       V P                  RR4       . V n
        \
        P                  P                  \        R4      V,          4      pV P                  P                  V4       \
        P                   ! 4       p\
        P"                  ! 4       V n        V P$                  P'                  \
        P(                  P*                  4       VP-                  \
        P.                  P0                  \
        P.                  P0                  4       VP3                  \
        P4                  P6                  4       VP                  V P$                  4       V P                  P9                  VRR^4       V P;                  4        \<        P>                  ! V P@                  V PB                  4       R# )i
   Zborder_widthiX  i  zShowing games using %sTN)"super__init__r&   runner_versionadd_default_buttonr   STOCK_OKResponseTypeOKset_default_sizeappsLabelnew_vboxaddScrolledWindowListBoxlistboxset_selection_modeSelectionModeNONE
set_policy
PolicyType	AUTOMATICset_shadow_type
ShadowType
ETCHED_OUT
pack_startshow_allr   	AsyncCall	load_appson_apps_loaded)selftitleparentr&   r0   labelscrolled_listbox	__class__s   &&&&&  r   r/   ZShowAppsDialog.__init__4   sG   R8&,c.>.>.A.ABc3'			a 89NJK		e--/{{}''(9(9(>(>?##CNN$<$<cnn>V>VW(()B)BCT\\*		-tT2>t~~t':':;r   c                s   \        V P                  4      pV Fp  pVR ,          '       g   K  \        VR,          4      pVP                  P                  R,          pW@P
                  8w  d   KU  V P                  P                  V4       Kr  	  R# )r!   r"   r   N)r   r&   r   r#   r$   r0   r6   r%   )rM   r'   r)   r*   r      &    r   rK   ZShowAppsDialog.load_appsG   sm    *4+;+;<#G;''&Dkk//	:G---IIT" $r   c                s   V P                    F  p\        P                  ! R R7      p\        P                  ! R \        P                  P
                  R7      p\        P                  ! VP                  R R7      pVP                  \        P                  P                  4       VP                  VR R ^4       VP                  V4       V P                  P                  V4       K  	  R# )Tvisible)rU   orientationN)r6   r   
ListBoxRowBoxOrientation
HORIZONTALr7   name
set_halignAlignSTARTrH   r;   r>   )rM   Z_resultZ_errorZapprowhboxZlbl_game   &&&    r   rL   ZShowAppsDialog.on_apps_loadedR   s    99C...C774S__5O5OPDyy48H		0OOHdD!4GGDMLLS! r   )r6   r>   r&   r0   )
__name__
__module____qualname____firstlineno__r/   rK   rL   __static_attributes____classdictcell____classcell__rR   __classdict__   @@r   r,   r,   3   s     <&	#" "r   r,   c                   s  a a ] tR t^]t oRt^ t^t^t^t^t	^t
V 3R lt]R 4       t]R 4       tR tR tR tR t]R	 4       tR
 tR tR tR tR tR tR tV3R lR ltV3R lR ltR t]R 4       tR tV3R lV 3R llt Rt!Vt"V ;t## )RunnerInstallDialogz=Dialog displaying available runner version and downloads themc                s6  < \         SV `  W^ ^
R7       V P                  \        P                  \        P
                  P                  4      V n        VP                  V n	        VP                  V n        / V n        . V n        / V n        V P                  RR4       . V n        RV n        \        P$                  P'                  \)        R4      \*        P,                  ,          4      pV P.                  P1                  VRR^4       \        P2                  ! RR7      pVP5                  4        V P.                  P1                  VRR^4       V P7                  4        \8        P:                  ! V P<                  V P>                  V P                  V P                  4       R# )	i    r-   i  i  NzWaiting for response from %sFTrT   ) r.   r/   r1   r   r2   r3   r4   	ok_buttonr[   r&   Z	directoryr   runner_inforunner_store
installingr5   runnersr>   r7   r8   r9   r   ZSITE_URLr:   rH   ZSpinnerstartrI   r   rJ   fetch_runner_versionsrunner_fetch_cb)rM   rN   rO   runnerrP   ZspinnerrR   s   &&&&  r   r/   ZRunnerInstallDialog.__init__g   s(   ;00s?O?O?R?RS!;; & 0 0c3'		a >?(BSBSST		UE5"5++d+		WeUB7t1143G3GIYIY[_[p[pqr   c           	     sP   \         P                  ! V 4      pWR &   WR&   VR,           Uu0 uF  q3R,          VR,          3kK  	  pp\        V4      pWT,
           F/  pVR,          P                  RV^ ,          RV^,          RR/4       K1  	  V\        P                  V4      3# u upi )r&   r   versionsr   r   url )r   Zget_runnersr    r%   rl   fetch_runner_store)r&   r   rn   ZvZremote_versionsZlocal_versionsZlocal_version   &&     r   rs   Z)RunnerInstallDialog.fetch_runner_versions~   s    ook2%0M"*:&'FQR\F]^F]iL!N*;<F]^/0@A+==M
#**}Q/"M!$42 > /BB;OOO _s   B#c                s   . pV R,          pV R,          p\        V4      p\        V R,          \        P                  R7      p\	        V4       F  p\
        P                  P                  \        W6R,          VR,          4      4      pVP                  RV,          4      pTP                  RVR,          RVR,          RVR,          R	TR
^ RV'       d   \        V4      M^ /4       K  	  V# )z0Return a list populated with the runner versionsr&   r   rv   )Zkeyr   r   z%(version)s-%(architecture)srw   is_installedprogress
game_count)r+   Zsortedrl   get_version_sort_keyZreversedr   r   r   r   Zgetr%   Zlen)	rn   ro   r&   r   r(   ZorderedZversion_infor{   Zgames_usings	   &        r   ry   Z&RunnerInstallDialog.fetch_runner_store   s     !-0&'9:'4Z06I6^6^_$W-L77>> 0y2I<XfKghL (++,J\,YZK|I6"L$@<."L k#k"2q	 . r   c                s   V P                   f   R# V'       d6   \        P                  ! V4       \        \	        R4      V,          V R7       R# Vw  V n        V n        V P
                  '       g   \        \	        R4      V R7       R# V P                   P                  4        F*  pVP                  4       R9  g   K  VP                  4        K,  	  \        P                  P                  \	        R4      V P
                  R,          ,          4      pV P                   P                  V4       / V n        \        P                  ! 4       p\        P                   ! 4       V n        V P"                  P%                  \        P&                  P(                  4       VP+                  \        P,                  P.                  \        P,                  P.                  4       VP1                  \        P2                  P4                  4       VP                  V P"                  4       V P                   P7                  VRR^4       V P9                  4        V P;                  4        R# )	z3Clear the box and display versions from runner_infoNz!Unable to get runner versions: %srO   z-Unable to get runner versions from lutris.netZGtkBoxz%s version managementr[   T)r:   r   errorr	   r9   rn   ro   Zget_childrenZget_nameZdestroyr   r7   r8   r;   rp   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   rH   rI   populate_listboxrows)rM   Zresultr   Zchild_widgetrP   rQ      &&&   r   rt   Z#RunnerInstallDialog.runner_fetch_cb   s   99LL=>FtT.4+$+IJSWX II224L$$&h6$$& 5 		a 784;K;KF;SST		e--/{{}''(9(9(>(>?##CNN$<$<cnn>V>VW(()B)BCT\\*		-tT2>!!#r   c                sd   \        R 4      '       d   R MRpV P                   EF  p\        P                  ! 4       pW#n        \        P
                  ! \        P                  P                  R7      pWCn        \        P                  P                  V\        P                  P                  4      pVP                  VR,          4       \        P
                  ! 4       pVP                  ^^4       VP                  VRR^ 4       VP                  VRR^ 4       WSn        \        P"                  ! VR,          4      pVP%                  ^4       VP'                  R^4       VP)                  \        P*                  P,                  4       VP                  VRR^4       \        P"                  ! VR,          4      pVP%                  ^4       VP)                  \        P*                  P,                  4       VP                  VRR^4       \        P.                  ! 4       p	V	P1                  R4       VP3                  V	RR^4       Wn        VR,          '       d   VR	,          ;'       g    ^ p
V
^ 8  d   \6        P8                  ! R
RV
4      V
,          p\        P:                  P=                  V4      pVP?                  \        P*                  P@                  4       VPC                  RV PD                  V4       VP3                  VRR^4       \        PF                  ! 4       pVP                  ^dR4       VP3                  VRR^ 4       VPI                  V^ 4       Wn%        RVn&        VPO                  V4       V PP                  PO                  V4       VPS                  4        V PU                  V4       EK  	  R# )zsoftware-installed-symboliczwine-symbolic)rV   r{   FTr   zwidth-charsr   r}   zView %d gamezView %d gamesclickedNi)+r   ro   r   rW   ru   rX   rY   rZ   r`   ZImageZnew_from_icon_nameZIconSizeZMENUset_visibleZset_size_requestrH   iconr7   Zset_max_width_charsZset_propertyr\   r]   r^   ZProgressBarZset_show_textZpack_endinstall_progressr   ZngettextZ
LinkButtonZnew_with_labelZ
set_valignZCENTERconnecton_show_apps_usageZButtonZreorder_childinstall_uninstall_cancel_button
handler_idr;   r>   rI   update_listboxrow)rM   Z	icon_nameru   r_   r`   r   Zicon_containerZlbl_versionZ
arch_labelr   Z	app_countZusage_button_textZusage_buttonbuttons   &             r   r   Z(RunnerInstallDialog.populate_listboxrows   s   5CDa5b5b1hw	''F.."CJ77s'A'ABDH99//	3<<;L;LMDVN34 WWYN++B3%%dE5!<OONE4;H))F9$56K++B/$$]B7""399??3OOKq96.#9:J**1-!!#))//2OOJtQ7"0**40MM*D$:#3 n%%"<055A	q=(/(8(8Zc(dgp(p%#&>>#@#@AR#SL ++CII,<,<= ((D4K4KSQMM,tQ?ZZ\F##C,MM&%q1vq)28/!CNGGDMLLS!LLN""3'i (r   c                s`   VP                   P                  R 4       V P                  P                  V P                  '       * 4       VP
                  pVP                  pVP                  VR,          4       VP                  pVP                  4       pVP                  e#   VP                  VP                  4       RVn	        VR,          V P                  9   dJ   VP                  R4       VP                  \        R4      4       VP                  RV P                  V4      pMVR,          '       dJ   VP!                  R4       VP                  \        R4      4       VP                  RV P"                  V4      pMVR,          '       g@   VP                  R4       VP                  \        R	4      4       VP                  R 4       RpMYVP                  R4       VP                  \        R
4      4       VP                  R4       VP                  RV P$                  V4      pWAn        Wan	        R# )Fr{   Nr   zdestructive-actionZCancelr   Z	Uninstallrw   ZUnavailableZInstallT)r   r   rm   Zset_sensitiverp   ru   r   r   Zget_style_contextr   Z
disconnectZremove_classZ	set_labelr9   r   on_cancel_installZ	add_classon_uninstall_runneron_install_runner)rM   r_   ru   r   r   Zstyle_contextr   rz   r   r   Z%RunnerInstallDialog.update_listboxrow  s   ((/$$%89xx/044002>>%cnn-!CN)/&&';<Qx[)	43I3I3OJn%%''(<=  ;0#^^It7O7OQTU
E]]**+?@  =!12$$U+!
**+?@  9.$$T*#^^It7M7MsS
.4+#r   c                s    VP                   pVR,          : RVR,          : 2p\        \        R4      V P                  4       V P                  V4      pVP                  4        R# )z2Return grid with games that uses this wine versionr   -r   zWine version usageN)ru   r,   r9   Zget_toplevelr&   Zrun)rM   Z_buttonr_   ru   r0   dialogr   r   r   Z&RunnerInstallDialog.on_show_apps_usage)  sQ    $*9$5$5vn7MN"6 79J9J9LdN^N^`no

r   c                s*   V R,          p\         P                  ! RV4      pV'       d]   VP                  ^4      P                  RR4      P	                  R4       Uu. uF  q3'       g   K  \        V4      NK  	  ppWAV R,          3# . WR,          3# u upi )zGenerate a sorting key that sorts first on the version number part of the version,
and which breaks the version number into its components, which are parsed as integersr   z^(.*?)\-?(\d[.\-\d]*)$r   Z.r   )reZsearchZgroupZreplaceZsplitZint)r   Zraw_versionZmatchr   Zversion_partsrS   r   r~   Z(RunnerInstallDialog.get_version_sort_key0  s     i( 		3[A-2[[^-C-CC-M-S-STW-X^-X\]VSV-XM^ w~/FFF ; 777	 _s   	B)Bc                s    \         P                  P                  \        P                  \         P                  P                  VR,          4      4      # )z?Return temporary path where the runners should be downloaded torw   )r   r   r   r   Z	CACHE_DIRZbasename)rM   ru   s   &&r   get_dest_pathZ!RunnerInstallDialog.get_dest_path@  s0    ww||H..0@0@0OPPr   c                (    V P                  V4       R # N)cancel_installrM   Zwidgetr_      &&&r   r   Z%RunnerInstallDialog.on_cancel_installD      C r   c                s    VP                   pV P                  VR,          ,          P                  4        V P                  V4       ^ VR&   V P                  P	                  VR,          4       V P                  V4       R# )z+Cancel the installation of a runner versionr   r|   N)ru   rp   Zcanceluninstall_runnerpopr   rM   r_   ru      && r   r   Z"RunnerInstallDialog.cancel_installG  sb    y)*113c"zF9-.s#r   c                r   r   )r   r   r   r   r   Z'RunnerInstallDialog.on_uninstall_runnerP  s    c"r   c                s   a aaa SP                   oSR,          oSR,          p\        S P                  SV4      pVVV 3R lpV V3R lp\        P                  ! W4VR7       R# )zUninstall a runner versionr   r   c                  s   < R SR&   SP                   R8X  d$   \        P                  ! R4       ^ RIHp  V ! 4        SP                  S4       R# )Fr{   wineClearing wine version cacheclear_wine_version_cacheN)r&   r   debuglutris.util.wine.winer   r   )r   r_   ru   rM   s    r   on_completeZ9RunnerInstallDialog.uninstall_runner.<locals>.on_completeZ  s?    %*F>"6):;J(*""3'r   c                 sh   < \         P                  ! R SP                  SV 4       \        V SR7       R# )z%Runner '%s (%s)' uninstall failed: %sr   N)r   Z	exceptionr&   r   )r   rM   r   s   &r   on_errorZ6RunnerInstallDialog.uninstall_runner.<locals>.on_errorc  s*    DdFVFVX_afg%-r   )Zcompletion_functionZerror_functionN)ru   r   r   r   Zremove_folder)rM   r_   r   Zrunner_pathr   r   ru   r   s   ff    @@r   r   Z$RunnerInstallDialog.uninstall_runnerS  sQ    #n%%d&;&;WdK	(	. 	[Zbcr   c                r   r   )install_runner)rM   Z_widgetr_   r   r   r   Z%RunnerInstallDialog.on_install_runneri  r   r   c                s   VP                   pVP                  P                  R4       V P                  V4      pVR,          pVR,          pV'       g    \	        \        R4      V,          V R7       R# \        WCRR7      p\        V P                  WaR	R
7       W`P                  V&   VP                  4        V P                  V4       R# )z%Download and install a runner version        rw   r   z!Version %s is no longer availabler   NT)Z	overwrite皙?Zinterval_seconds)ru   r   set_fractionr   r	   r9   r   r   get_progressrp   rr   r   )rM   r_   ru   Z	dest_pathrw   r   
downloaderrz   r   r   Z"RunnerInstallDialog.install_runnerl  s    ))#.&&v.	Um#=>HQUV$?
"4#4#4jX[\#- s#r   c                    < V ^8  d   QhRS[ /#    returnZboolZformatrj      "r   __annotate__ RunnerInstallDialog.__annotate__|  s      t r   c                s   VP                   pVP                  VP                  8X  d   R# VP                  VP                  8X  d   V P	                  V4       R# VP
                  P                  4        VP                  4        VP                  pV^8  d(   WCR&   VP
                  P                  V^d,          4       M9^VR&   VP
                  P                  4        \        R4      VP
                  n        VP                  VP                  8X  d3   ^cVR&   \        R4      VP
                  n        V P                  V4       R# R# )z*Update progress bar with download progressFr|   u   Downloading…u   Extracting…T)ru   ZstateZ	CANCELLEDZERRORr   r   ZshowZcheck_progressZprogress_percentager   pulser9   set_textZ	COMPLETEDon_runner_downloaded)rM   r   r_   ru   Zpercent_downloadeds   &&&  r   r   Z RunnerInstallDialog.get_progress|  s   z333z///$!!#!!#';;"!3:  --.@3.FG!"F:  &&(,-.>,?C  )z333!#F:,-o,>C  )%%c*r   c                r   r   r   r   r   r   r   r     s     * *T *r   c                sj    VP                   pVP                  P                  4        VR ,          '       * # )r{   )ru   r   r   r   r   r   progress_pulseZ"RunnerInstallDialog.progress_pulse  s+    ""$.)))r   c                sH   VP                   pVR,          pVR,          p\        P                  ! RW44       V P                  V4      p\	        V P
                  W44      p\        V P                  VRR7       \        P                  ! V P                  V P                  WVV4       R# )z2Handler called when a runner version is downloadedr   r   z)Runner %s for %s has finished downloadingr   r   N)ru   r   r   r   r   r   r   r   r   rJ   extracton_extracted)rM   r_   ru   r   r   srcdstrz   r   r   Z(RunnerInstallDialog.on_runner_downloaded  s~    #n-@'X  (d33WK"4#6#6cRt||T%6%6#Fr   c                s    \        W4       W3# )z)Extract a runner archive to a destinationr   )r   r   r_   r   r   r   ZRunnerInstallDialog.extract  s     	!xr   c                s   V'       g	   V'       g   \        \        R4      V R7       R# Vw  r4VP                  p\        P                  ! V4       ^ VR&   RVR&   V P
                  P                  VR,          4       RVP                  n        VP                  P                  R	4       VP                  P                  4        V P                  V4       V P                  R
8X  d&   \        P                  ! R4       ^ RIHp V! 4        R# R# )z)Called when a runner archive is extractedz%Failed to retrieve the runner archiver   Nr|   Tr{   r   rx   r   r   r   r   )r	   r9   ru   r   Zremoverp   r   r   r   r   Zhider   r&   r   r   r   r   )rM   Zrow_infor   r   r_   ru   r   ra   r   r   Z RunnerInstallDialog.on_extracted  s    AB4P
		#z!%~F9-.(*%))#.!!#s#v%LL67F$&	 &r   c                s8   < V ^8  d   QhRS[ P                  RR/# )r   responser   N)r   r3   r   r   r   r   r     s!     . .C,<,< . .r   c                sN   < V P                   '       d   R # \        SV `	  W4       R # r   )rp   r.   on_response)rM   r   r   rR   s   &&&r   r   ZRunnerInstallDialog.on_response  s    ???F-r   )rp   r>   rm   r   rn   r&   ro   rq   )$rb   rc   rd   re   __doc__ZCOL_VERZCOL_ARCHZCOL_URLZCOL_INSTALLEDZCOL_PROGRESSZ	COL_USAGEr/   Zstaticmethodrs   ry   rt   r   r   r   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   rf   rg   rh   ri   rk   r   rl   rl   ]   s     GGHGMLIr. P P"  0 $D7(r#$J 8 8Q!$#d,!$  2* *
	G  
'*. . .r   rl   ))r   r   r   r   Zcollectionsr    r9   Zgi.repositoryr   Zlutrisr   r   Z
lutris.apir   r   Zlutris.database.gamesr   Zlutris.gamer   Zlutris.gui.dialogsr	   r
   r   Zlutris.gui.widgets.utilsr   Zlutris.utilr   r   Zlutris.util.downloaderr   Zlutris.util.extractr   Zlutris.util.jobsr   Zlutris.util.logr   r   r    r+   r,   rl   ) r   r   <module>r      sl    1  	 	 #      H 5  I I 3 $ - / 7 "GQ
'"^ '"Tf.. f.r   