+
    Ki(  c                   s    R t ^ RI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IHt ^ R	IHt ^ R
IHt  ! R R]P*                  4      tR# )z Widgets for the installer windowN)gettext)GObjectGtk)InstallerLabel)FileChooserEntry)InstallerFileCollection)SteamInstaller)system)logger)gtk_safec                   s  a a ] tR t^t oRtR]P                  RR3R]P                  RR3R]P                  RR3/tV 3R lt]	R 4       t
R tR	 tR
 tR tR tR tR tR tR tR tR tR tR tR tR tR tRR ltR tRtVtV ;t# )InstallerFileBoxz5Container for an installer file downloader / selectorfile-availableN
file-readyfile-unreadyc                sl  < \         SV `  4        Wn        V P                  P                  4       V n        R V n        RV n        RV n        RV n        V P                  ^4       V P                  ^4       V P                  P                  V n        RV n        V P                  V P                  4       4       R# )FN)Zsuper__init__installer_fileZuses_pga_cachecache_to_pgastarted
start_func	stop_funcstate_labelZset_margin_leftZset_margin_rightZdefault_providerproviderfile_provider_widgetaddget_widgets)selfr   	__class__s   &&B/usr/lib/python3.14/site-packages/lutris/gui/installer/file_box.pyr   ZInstallerFileBox.__init__   s    , //>>@R b!++<<$(!!!#$    c                sL    V P                   P                  V P                  4      # )zFWhether the file is ready to be downloaded / fetched from its provider)r   is_readyr   r      &r   r   ZInstallerFileBox.is_ready(   s     ""++DMM::r   c                s6   V P                   P                  4       pVP                  RV P                  4       VP                  RV P                  4       VP                  RV P
                  4       VP                  4        V P                   P                  4        V# )z/Return the widget for the download progress barZcompleteZcancelerror)r   Zcreate_download_progress_boxconnecton_download_completeon_download_cancelledon_download_errorshowZremove_previous)r   download_progress   & r   get_download_progressZ&InstallerFileBox.get_download_progress-   s}     //LLN!!*d.G.GH!!(D,F,FG!!'4+A+AB ++-  r   c                sn   \         P                  ! ^R7      pV P                  R8X  dI   V P                  4       pVP                  V n        VP                  V n        VP                  VRR^ 4       V# V P                  R8X  dC   \        RV P                  P                  4       ,          RR7      pVP                  VRR^4       V# V P                  R8X  d?   \        \        V P                  P                  4      4      pVP                  VRR^ 4       V# V P                  R8X  Edw   \        V P                  \        4      '       d   \!        R	4      h\#        V P                  P$                  V P                  P&                  4      pVP(                  P+                  V P,                  4       VP.                  P+                  V P0                  4       VP2                  V n        VP                  V n        \         P4                  ! ^R7      p\         P                  ! ^R7      p\        \7        R
4      P9                  VP:                  R7      4      pVP=                  V4       \        R4      V n        VP=                  V P>                  4       VP=                  V4       V# \A        RV P                  ,          4      h)z0Return the widget used to track progress of filespacingdownloadFpgazIn cache: %s)ZwrapusersteamzRInstaller file is type InstallerFileCollection and do not support 'steam' providerzSteam game <b>{appid}</b>)appidZ zInvalid provider %s)!r   VBoxr   r(   startr   Zon_cancel_clickedr   
pack_startr   r   	get_labelr	   	human_url
isinstancer   ZRuntimeErrorr   ZurlZidZgame_installedZregisteron_steam_game_installedZgame_state_changedon_steam_game_state_changedZinstall_steam_gameHBox_Zformatr/   r   r   Z
ValueError)	r   boxr&   Z	url_labelZ
user_labelZsteam_installerZ	steam_boxZinfo_boxZsteam_labels	   &        r   get_file_provider_widgetZ)InstallerFileBox.get_file_provider_widget7   s   hhq!==J& $ : : </55DO.@@DNNN,eUA>J==E!&~8K8K8U8U8W'W^cdINN9eUA6J==F"'1D1D1N1N(OPJNN:ueQ7J==G#$--/FGG"#wxx,T-@-@-D-DdFYFYF\F\]O**33D4P4PQ..778X8XY-@@DO,66DN+Ixx*H(+F)G)N)NUdUjUj)N)klKLL%-b1DLL))*MM(#.>??r   c                s<   \         P                  ! \        \        4      pRV P                  P                  9   d   VP                  R\        R4      .4       RV P                  P                  9   d   VP                  R\        R4      .4       RV P                  P                  9   d   VP                  R\        R4      .4       \        V P                  \        4      '       d   V P                  P                  R8X  g   VP                  R\        R	4      .4       V# )
z"Return the combobox's modelr+   ZDownloadr,   z	Use Cacher.   ZSteamZamazonr-   zSelect File)
r   Z	ListStoreZstrr   Z	providersZappendr9   r5   r   Zservice)r   modelr'   r   get_combobox_modelZ#InstallerFileBox.get_combobox_model\   s    c3',,666LL*a
m45D''111LL%;01d))333LL'1W:./4..0GHHTM`M`MhMhltMtLL&!M"234r   c                sd   \         P                  P                  V P                  4       4      pVP	                  ^ 4       \         P
                  ! 4       pVP                  VR4       VP                  VR^4       VP                  RV P                  4       VP                  V P                  4       V# )z0Return the combobox widget to select file sourceTZtextchanged)r   ZComboBoxZnew_with_modelr=   Zset_id_columnZCellRendererTextr2   Zadd_attributer!   on_source_changedZset_active_idr   )r   comboboxZrenderer_text   &  r   get_comboboxZInstallerFileBox.get_comboboxi   s    <<..t/F/F/HIq!,,.M40}fa8D$:$:;t}}-r   c                s   V P                   P                  4        V P                  4       ^ ,          pV P                  '       d>   V P	                  4       V n         VP                  4        F  pVP                  4        K  	  MV P                  4       V n         VP                  V P                   RR^ 4       VP                  V P                   ^ 4       VP                  4        R# )zLReplace the file provider label and the source button with the actual widgetTN)	r   ZdestroyZget_childrenr   r;   get_file_provider_labelr2   Zreorder_childZshow_all)r   Z
widget_boxZchildrA   r   replace_file_provider_widgetZ-InstallerFileBox.replace_file_provider_widgett   s    !!))+&&(+
<<<(,(E(E(GD%#002 3 )-(D(D(FD%d77tQG  !:!:A>r   c                s*   VP                  4       pVf   R# VP                  4       pW2,          ^ ,          pW@P                  8X  d   R# W@n        V P                  4        V P                  R8X  d   V P	                  R4       R# V P	                  R4       R# )z5Change the source to a new provider, emit a new stateNr-   r   r   )Zget_active_iterZ	get_modelr   rD   emit)r   r@   Z	tree_iterr<   Zsources   &&   r   r?   Z"InstallerFileBox.on_source_changed   sv    ,,.	""$!!$]]"))+==F"IIn%IIl#r   c                s*   V P                   R8X  Ed`   \        P                  ! ^R7      p\        V P                  P                  4       4      pRVP                  n        VP                  VRR^ 4       \        V P                  P                  \        P                  P                  4      pVP                  RV P                  4       VP                  4        VP                  VRR^ 4       V P                  P                   '       dk   \        P"                  ! \%        R4      4      pVP'                  V P(                  4       VP                  RV P*                  4       VP                  VRR^ 4       V# \        V P                  P                  4       4      # )z5Return the label displayed before the download startsr-   r)   TFr>   z#Cache file for future installationsZtoggled)r   r   r0   r   r   r3   propsZ	can_focusr2   r   r4   ZFileChooserActionZOPENr!   on_location_changedr%   Zis_user_pga_caching_allowedZCheckButtonr9   Z
set_activer   on_user_file_cached)r   r:   ZlabelZlocation_entryZcache_option   &    r   rC   Z(InstallerFileBox.get_file_provider_label   s,   ==F"((1%C"4#6#6#@#@#BCE$(EKK!NN5%2-d.A.A.K.KSMbMbMgMghN""9d.F.FG!NN>5%;"">>>"q1V/WX''(9(9:$$Y0H0HI|UE1=Jd11;;=>>r   c                sL   \         P                  ! ^^^R7      pV P                  4       V n        VP	                  V P                  RR^ 4       \         P                  ! 4       p\         P
                  P                  VP                  n        VP	                  VRR^ 4       V P                  P                  pV'       d   VP	                  \        V4      RR^ 4       VP	                  \        \        R4      4      RR^ 4       V P                  4       pVP	                  VRR^ 4       V# )zLReturn the widget with the source of the file and a way to change its source)r*   Z
margin_topZmargin_bottomTFzSource:)r   r8   rC   r   r2   ZAlignZSTARTrF   Zvalignr   Zauxiliary_infor   r9   rB   )r   r:   Z
source_boxZaux_infor@   rI   r   r   ZInstallerFileBox.get_widgets   s    hhraqA$($@$@$B!t00$a@XXZ
"%))//
z5%3&&55!!.":E5!LnQy\:E5!L$$&hua8
r   c                s   \         P                  P                  VP                  4       4      pV P                  P                  V4       \        P                  ! V4      '       d   V P                  R4       R# V P                  R4       R# )z4Open a file picker when the browse button is clickedr   r   N)	osZpathZ
expanduserZget_textr   Zoverride_dest_filer   Zpath_existsrE   )r   widgetZ	file_paths   && r   rG   Z$InstallerFileBox.on_location_changed   sZ    GG&&v'89	..y9i((IIl#IIn%r   c                s0    VP                  4       V n        R# )z0Enable or disable caching of user provided filesN)Z
get_activer   )r   Zcheckbutton   &&r   rH   Z$InstallerFileBox.on_user_file_cached   s    '224r   c                s<    V P                   P                  V4       R# z'Update the state label with a new stateN)r   set_text)r   Z_widgetstate   &&&r   on_state_changedZ!InstallerFileBox.on_state_changed   s    !!%(r   c                sP    V P                   P                  VP                  4       R# rM   )r   rN   rO   r   Z	installerrL   r   r7   Z,InstallerFileBox.on_steam_game_state_changed   s    !!)//2r   c                s8   RV n         V P                  P                  4        V P                  4        V P                  R9   d6   V P
                  '       d$   V P                  R4       V P                  4        R# V P                  '       d   V P                  4       # R# )zStarts the download of the fileTr   N)r,   r-   )	r   r   ZpreparerD   r   r   rE   
cache_filer   r   r   r   r1   ZInstallerFileBox.start   sp    ##%))+==O+II&'OO?????$$ r   c                sb    V P                   '       d   V P                  P                  4        R# R# )zCopy file to the PGA cacheN)r   r   Zsave_to_cacher   r   r   rS   ZInstallerFileBox.cache_file   s%    --/ r   c                sT    \         P                  ! RV4       VP                  4        R# )z!Handle cancellation of installerszDownload from %s cancelledNr   r    Zset_retry_button)r   
downloaderrL   r   r#   Z&InstallerFileBox.on_download_cancelled   s    1:>##%r   c                sT    \         P                  ! R W4       VP                  4        R# )zDownload from %s failed: %sNrT   )r   rU   r    rP   r   r$   Z"InstallerFileBox.on_download_error   s    2JF##%r   c                s   \         P                  ! R4       V P                  P                  4        \	        V\
        4      '       d!   VP                  4       V P                  n        MV P                  4        V P                  R4       R# )z&Action called on a completed download.zDownload completedr   N)
r   Zinfor   Z
check_hashr5   r   get_steam_data_path	dest_filerS   rE   )r   rK   Z_datarP   r   r"   Z%InstallerFileBox.on_download_complete   s\    ()&&(fn--,2,F,F,HD)OO		"#r   c                sf    VP                  4       V P                  n        V P                  R 4       R# )r   N)rV   r   rW   rE   rR   rL   r   r6   Z(InstallerFileBox.on_steam_game_installed   s&    (1(E(E(G%		"#r   )r   r   r   r   r   r   r   r    )N) Z__name__Z
__module__Z__qualname__Z__firstlineno____doc__r   ZSIGNAL_RUN_FIRSTZ__gsignals__r   Zpropertyr   r(   r;   r=   rB   rD   r?   rC   r   rG   rH   rQ   r7   r1   rS   r#   r$   r"   r6   Z__static_attributes__Z__classdictcell__Z__classcell__)r   Z__classdict__s   @@r   r
   r
      s     ? 	733T2>w//r:114<L% ; ;!#@J	$ ?&"&5)3
%0
&
&$$ $r   r
   )rY   rJ   r    r9   Zgi.repositoryr   r   Zlutris.gui.installer.widgetsr   Zlutris.gui.widgets.commonr   Z*lutris.installer.installer_file_collectionr   Z lutris.installer.steam_installerr   Zlutris.utilr   Zlutris.util.logr   Zlutris.util.stringsr	   r0   r
   rX   r   r   <module>rZ      s8    & 	   & 7 6 N ;  " (a$sxx a$r   