+
    Kif  c                   sR   R t ^ RIt^ RIt^ RIt^ RIHt ^ RIHt ^ RIH	t	H
t
 ^ RIt^ RIHtHtH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Ht ^ RI H!t! ^ RI"H#t#H$t$H%t%H&t& ^ RI'H(t( ^ RI)H*t* ^ RI+H,t, Rt-Rt.Rt/ ! R R]4      t0 ! R R]Pb                  4      t2R# )zGame Info Panel implementationN)gettext)Path)AnyOptional)	GdkPixbufGtkPango)settings)Game)AdvancedSettingsBox)LabelNumberEntry	SlugEntry)ScaledImage)MEDIA_CACHE_INVALIDATEDget_image_file_extensionopen_uri)get_installed)LutrisBannerLutrisCoverart
LutrisIcondownload_lutris_media)resolve_media_path)	AsyncCall)loggerZcoverart_bigZbannerZiconc                   sF  a a ] tR t^$t oRtV3R lV 3R ll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 t]R 4       tR tR tR tR tV3R lR l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$V3R% lR& lt%R' t&R*R( lt'R)t(Vt)V ;t*# )+GameInfoBoxz&Generate a vbox for the Game Info tab.c                s:   < V ^8  d   QhRS[ RS[S[,          RR/# )   parent_widgetgamereturnN)r   r   r   Zformat__classdict__   "D/usr/lib/python3.14/site-packages/lutris/gui/config/game_info_box.py__annotate__GameInfoBox.__annotate__'   s&     4 4c 4$ 4d 4    c                s  < \         SV `  ! R/ VB  Wn        W n        V'       d   VP                  MR V n        V'       d   VP                  MR V n        R V n        R V n        R V n        R V n	        R V n
        R V n        R V n        R V n        R V n        \        \!        4       \"        \%        4       \&        \)        4       /V n        / V n        / V n        / V n        R V n        V P                  '       d^   \4        P6                  ! 4       pV P9                  4       pVP;                  VRR^ 4       V P;                  VRR^ 4       V P=                  4        V P;                  V P?                  4       RR^4       V P;                  V PA                  4       RR^4       V P;                  V PC                  4       RR^4       V P;                  V PE                  4       RR^4       V P;                  V PG                  4       RR^4       V P                  '       d   V P;                  V PI                  4       RR^4       V P;                  V PK                  4       RR^4       V P;                  V PM                  4       RR^4       V PO                  4       V n        V P;                  V P2                  RR^4       \P        PR                  ! R4      R8H  V n*        V PW                  4        R # )NTFZshow_advanced_optionsZTrue ),super__init__r   r   sluginitial_slug
name_entrysortname_entryrunner_dropdownrunner_index
slug_entryslug_change_buttondirectory_entry
year_entryplaytime_entryICON_KEYr   
BANNER_KEYr   COVERART_KEYr   service_mediasimage_buttonsimage_path_entriesimage_path_open_button_game_config_location_entryr   HBox_get_banner_box
pack_start_get_banner_entries_get_name_box_get_sortname_box_get_runner_box_get_year_box_get_playtime_box_get_slug_box_get_directory_box_get_launch_config_box_get_game_config_location_boxr   Zread_settingadvanced_visibilityupdate_widgets)selfr   r   ZkwargsZcentering_container
banner_box	__class__s   &&&,  r!   r'   ZGameInfoBox.__init__'   sH   "6"*	!%DII4	)-DII4"# "&#"'z<>S_aoaqr"$&(#+/(999"%((*--/J**:tUAFOO/qA$$&**,eUA>..0%B,,.ua@**,eUA>..0%B999OOD..0%BOOD335ueQGOOD7795%K/3/Q/Q/SD,OOD<<eUAN $,#8#89P#QU[#[ r$   c                s   V P                   '       d   V P                  P                  V P                  4       V P                  P	                  V P                  '       * 4       V P
                  P                  V P                  4       V P
                  P	                  V P                  '       * 4       V P                  P                  V P                  4       V P                  P	                  V P                  '       * 4       V P                  '       dR   V P                  P                  V P                  4       V P                  P	                  V P                  '       * 4       R # R # N)r   _cover_entryZset_visibleZ_advanced_visibilityZset_no_show_all_banner_entry_icon_entryr:   rJ      &r!   rI   ZGameInfoBox.update_widgets]   s    999))$*C*CD--$2K2K.KL**4+D+DE..43L3L/LM(()B)BC,,1J1J-JK+++,,889R9RS,,<<AZAZ=Z[ ,r$   c                s   \         P                  ! ^^^R7      p\        \        R4      4      pVP	                  VRR^ 4       \         P
                  ! 4       V n        V P                  P                  ^4       V P                  '       d0   V P                  P                  V P                  P                  4       VP	                  V P                  RR^ 4       V# )   spacingmargin_rightmargin_leftZNameFT)r   Boxr
   _r=   Entryr*   set_max_lengthr   set_textnamerJ   boxlabel   &  r!   r?   ZGameInfoBox._get_name_boxj   s    ggbrrBai ueUA.))+&&s+999OO$$TYY^^4tdA6
r$   c                sF   \         P                  ! ^^^R7      p\        \        R4      4      pVP	                  VRR^ 4       \         P
                  ! 4       V n        V P                  P                  ^4       V P                  '       d{   V P                  P                  V P                  P                  4       V P                  P                  '       d0   V P                  P                  V P                  P                  4       VP	                  V P                  RR^ 4       V# )rS   rT   z	Sort nameFT)r   rX   r
   rY   r=   rZ   r+   r[   r   set_placeholder_textr]   Zsortnamer\   r^   ra   r!   r@   ZGameInfoBox._get_sortname_boxu   s    ggbrrBan%ueUA.!iik**3/99944TYY^^Dyy!!!##,,TYY-?-?@t**D$:
r$   c                s   \         P                  ! ^^^R7      p\        \        R4      4      pVP	                  VRR^ 4       \        4       V n        V P                  P                  ^
4       V P                  '       dC   V P                  P                  \        V P                  P                  ;'       g    R4      4       VP	                  V P                  RR^ 4       V# )rS   rT   zRelease yearF T)r   rX   r
   rY   r=   r   r1   r[   r   r\   strZyearr^   ra   r!   rB   ZGameInfoBox._get_year_box   s    ggbrrBa'(ueUA.%-&&r*999OO$$S)=)=2%>?tdA6
r$   c                sz   \         P                  ! ^^^R7      p\        \        R4      4      pVP	                  VRR^ 4       \         P
                  ! 4       V n        V P                  '       d0   V P                  P                  V P                  P                  4       VP	                  V P                  RR^ 4       V# )rS   rT   ZPlaytimeFT)
r   rX   r
   rY   r=   rZ   r2   r   r\   Zformatted_playtimer^   ra   r!   rC   ZGameInfoBox._get_playtime_box   s    ggbrrBa
m$ueUA.!iik999(()E)EFt**D$:
r$   c                s   \         P                  ! ^^^R7      p\         P                  ! ^^ ^ R7      p\        4       pTP	                  \        RV P                  '       d   V P                  P                  MR R24      4       VP                  VRR^ 4       \        4       V n
        V P                  '       d0   V P                  P                  V P                  P                  4       V P                  P                  R4       V P                  P                  RV P                  4       VP                  V P                  RR^ 4       \         P                   ! \        R4      4      V n        V P"                  P                  R	V P$                  4       VP                  V P"                  RR^ 4       VP                  VRR^ 4       V# )
rS   rT   z.Identifier
<span size='x-small'>(Internal ID: z""z)</span>FZactivateTChangeclicked)r   VBoxrX   r
   Z
set_markuprY   r   Zidr=   r   r.   r\   r(   set_sensitiveconnecton_slug_entry_activateButtonr/   on_slug_change_clicked)rJ   Zslug_boxZslug_entry_boxZ
slug_label   &   r!   rD   ZGameInfoBox._get_slug_box   sP   88BRRH!KW
ARVR[R[R[$)),,aeAffnqr	
 	!!*eUA>#+999OO$$TYY^^4%%e,
D,G,GH!!$//4qA"%**Qx["9''	43N3NO!!$"9"95%KND$:r$   c                sl   \         P                  ! ^^^RR7      p\        \        R4      4      pVP	                  VRR^ 4       \         P
                  ! RR7      V n        V P                  '       d0   V P                  P                  V P                  P                  4       V P                  P                  R4       VP	                  V P                  RR^ 4       \         P                  ! \        R4      RR7      pVP                  RV P                  P                  4       VP	                  VRR^ 4       V# )zIReturn widget displaying the location of the game and allowing to move itTrU   rV   rW   visibleZ	DirectoryFro   ZMoverf   )r   rX   r
   rY   r=   rZ   r0   r   r\   Z	directoryrh   rk   ri   r   Zon_move_clicked)rJ   r_   r`   Zmove_buttonrm   r!   rE   ZGameInfoBox._get_directory_box   s    ggbrr4Pan%ueUA."yy6999  ))$))*=*=>**51t++T4;jj6D9It'9'9'I'IJ{E5!4
r$   c                s^   \         P                  ! ^^^RR7      pV P                  '       dN   V P                  P                  '       d2   V P                  P                  P                  P                  R/ 4      pM/ pVP                  R4      pV'       Ed   \         P                  ! 4       pVP                  ^R4       VP                  VRR^ 4       V\        P                  8X  d   \        R4      pM\        R4      V,          p\         P                  ! V4      pVP                  R4       VP                  \         P                  P                  4       VP!                  R4       VP#                  \         P                  P$                  4       VP                  VRR^ 4       \         P&                  ! \        R	4      4      pVP)                  R
V P*                  V4       VP#                  \         P                  P$                  4       VP                  VRR^ 4       V# VP-                  4        V# )rS   Trn   r   preferred_launch_config_nameFz4The default launch option will be used for this gamez1The '%s' launch option will be used for this gameg        ZResetrf   i)r   rX   r   config
game_levelgetZset_size_requestr=   r   ZPRIMARY_LAUNCH_CONFIG_NAMErY   r
   Zset_line_wrapZ
set_halignAlignZSTARTZ
set_xalign
set_valignCENTERrk   ri   (on_reset_preferred_launch_config_clickedhide)rJ   r_   game_configZpreferred_nameZspacertextr`   Zbuttons   &       r!   rF   Z"GameInfoBox._get_launch_config_box   s   ggbrr4P999)))))**5599&"EKK$)GH>WWYF##C,NN65%3!@!@@OPLMP^^IIdOE%SYY__-S!SYY--.NN5$a0ZZ'
+FNN9d&S&SUXYcii../NN65%3 
 HHJ
r$   c                s   \         P                  ! ^^^RR7      pRpV P                  '       dq   V P                  P                  '       dU   \	        V P                  P                  P
                  \        4      '       d!   V P                  P                  P
                  p\        \        R4      4      pVP                  VRR^ 4       \         P                  ! RR7      pVP                  V4       VP                  \        R4      4       VP                  R4       VP                  VRR^ 4       \         P                  P                  R\         P                   P"                  4      pVP%                  4        VP                  \        R	4      4       VP'                  4       P)                  R
4       R pVP+                  RW`4       VP                  VRR^ 4       V# )rS   Trn   rc   zGame ConfigFrp   z'Path to the game config file (readonly)folder-symbolicOpen in file browsercircularc                 sd   VP                   '       d   VP                   P                  '       d   \        VP                   P                  P                  \        4      '       dJ   \        VP                   P                  P                  4      P                  p\        \	        V4      4       R # R # R # R # rM   )r   rr   
isinstancegame_config_pathrd   r   parentr   )_widgetZgame_info_boxZgame_config_dirs   && r!   open_in_file_browserZGGameInfoBox._get_game_config_location_box.<locals>.open_in_file_browser   s~    """!&&---}1188II3OO"&}'9'9'@'@'Q'Q"R"Y"Y_-. P . #r$   rf   )r   rX   r   rr   r   r   rd   r
   rY   r=   rZ   r\   set_tooltip_textrh   rk   new_from_icon_nameIconSizeBUTTONshowget_style_context	add_classri   )rJ   r_   r   r`   
path_entryZopen_dir_buttonr   s   &      r!   rG   Z)GameInfoBox._get_game_config_location_box   sb   ggbrr4P999)))j9I9I9Z9Z\_.`.`#yy//@@a&'ueUA. YYt,
,-##A&O$PQ  'z4q1**778I3<<K^K^_((+A)BC))+55jA	/ 		+?Fua8
r$   c                s.   V P                   '       dM   V P                   P                  '       d1   V P                   P                  P                  P                  R / 4      M/ pVP	                  RR4       VP	                  RR4       VP                  4        R# )r   rq   NZpreferred_launch_config_index)r   rr   rs   rt   Zpopry   )rJ   Z_buttonZlaunch_config_boxrz      &&& r!   rx   Z4GameInfoBox.on_reset_preferred_launch_config_clicked  sk    EIYYYSWS\S\ScScScdii&&1155fbAik6=7> r$   c                s    \         P                  ! ^^^R7      p\        \        R4      4      pVP	                  VRR^ 4       V P                  4       V n        VP	                  V P                  RR^ 4       V# )rS   rT   ZRunnerFT)r   rX   r
   rY   r=   _get_runner_dropdownr,   )rJ   Z
runner_boxZrunner_labelra   r!   rA   ZGameInfoBox._get_runner_box  sg    WWRbbI
Qx[)lE5!<#88:d22D$Br$   c           	     s   \         P                  ! 4       pVP                  ^4       VP                  ^4       VP	                  ^4       V P                  V\        \        R4      \        R4      \        R4      4       V P                  V\        \        R4      \        R4      \        R4      4       V P                  V\        \        R4      \        R4      \        R	4      4       V# )
rS   zSet custom cover artzRemove custom cover artzDownload custom cover artzSet custom bannerzRemove custom bannerzDownload custom bannerzSet custom iconzRemove custom iconzDownload custom icon)
r   ZGridZset_margin_topZset_column_spacingZset_row_spacing_create_image_buttonr5   rY   r4   r3   )rJ   rK      & r!   r<   ZGameInfoBox._get_banner_box  s    XXZ
!!"%%%b)""1%!!$%'()*	
 	!!
A&9$:A>T<UWXYqWr	
 	!!!$5"6:N8OQRSiQj	
 r$   c                s   V P                  \        \        R 4      \        R4      4      V n        V P	                  V P                  RR^4       V P                  \
        \        R4      \        R4      4      V n        V P	                  V P                  RR^4       V P                  \        \        R4      \        R4      4      V n        V P	                  V P                  RR^4       R# )ZCoverzLocation of custom cover artFZBannerzLocation of custom bannerZIconzLocation of custom iconN)	_create_image_entryr5   rY   rN   r=   r4   rO   r3   rP   rQ   rR   r!   r>   ZGameInfoBox._get_banner_entries.  s     44\1W:qQoOpq))5%;!55j!H+qQlOmn**E5!<33HaiKdIef((%:r$   c                s  a a \         P                  ! ^^^RR7      p\        V4      pVP                  VRR^ 4       \         P                  ! RR7      pVP                  V4       VP                  R4       VP                  VRR^ 4       \         P                  P                  R\         P                  P                  4      pVP                  4        VP                  \        R4      4       VP                  4       P                  R4       VP                  RS P                   S4       VS P"                  S&   VP                  R	VV 3R
 l4       VP                  VRR^ 4       VS P$                  S&   S P'                  S4       V# )zKReturn widget displaying the location of the coverart, banner or icon imageTrn   Frp   r|   r}   r~   rf   changedc                 s&   < SP                  S4      # rM   )refresh_image_path_entry)rY   
image_typerJ   s   &r!   Z<lambda>Z1GameInfoBox._create_image_entry.<locals>.<lambda>L  s    0M0Mj0Yr$   )r   rX   r
   r=   rZ   r   rh   rk   r   r   r   r   rY   r   r   ri   .on_open_image_location_in_file_browser_clickedr9   r8   r   )rJ   r   Zimage_labelZimage_entry_tooltipr_   r`   r   Zopen_buttons   ff&&    r!   r   ZGameInfoBox._create_image_entry8  s9   ggbrr4Pk"ueUA. YYt,
##$78  'z4q1jj334Es||GZGZ[$$Q'=%>?%%'11*=It'Z'Z\fg2=##J/9&YZ{E5!4.8
+%%j1
r$   c                sB   \         P                  ! 4       p\         P                  ! 4       p\         P                  ! 4       pV P	                  W(4       VP                  \         P                  P                  4       VP                  V4       VP                  RV P                  V4       VP                  VRR^ 4       \         P                  P                  R\         P                  P                  4      p	V	P                  \         P                   P"                  4       V	P                  V4       V	P                  RV P$                  V4       V	P                  \         P                  P                  4       VP                  V	RR^ 4       \         P                  P                  R\         P                  P                  4      p
V
P                  \         P                   P"                  4       V
P                  V4       V
P                  RV P&                  V4       V
P                  \         P                  P                  4       VP)                  V
RR^ 4       VP+                  V4       VP-                  Wv\         P.                  P0                  ^^4       WP2                  V&   R# )zThis adds an image button and its reset button to the box given,
and adds the image button to self.image_buttons for future reference.rf   Tzedit-undo-symbolicFzweb-browser-symbolicN)r   rg   r;   rk   
_set_imagerv   ru   rw   r   ri   on_custom_image_selectr=   r   r   ZMENUZ
set_reliefZReliefStyleZNONEon_custom_image_reset_clicked on_custom_image_download_clickedZpack_endaddZattach_next_toZPositionTypeZBOTTOMr7   )rJ   rK   r   Zimage_tooltipZreset_tooltipZdownload_tooltipZimage_button_containerZbutton_containerimage_buttonZreset_buttonZdownload_buttons   &&&&&&     r!   r   Z GameInfoBox._create_image_buttonU  s    "%88:zz|
1		 0 01%%m4Y(C(CZP)),dAFzz445I3<<K\K\] 4 45%%m4Y(J(JJW		 0 01##L$qA**778NPSP\P\PaPab""3??#7#78(()9:	4+P+PR\]""399#3#34!!/4B-.!!"2CL\L\LcLcefhij)5:&r$   c                s   V P                  4       pV P                  V,          pV P                  ;'       g+    V P                  '       d   V P                  P                  MR p\	        VP                  V4      4      P                  p \        P                  ! WdP                  V4      pVP                  V4       R#   \         d#   p\        P                  ! RY4        Rp?R# Rp?ii ; i)rc   zUnable to load media '%s': %sN)get_scale_factorr6   r(   r   r   get_possible_media_pathspathr   Znew_from_media_pathZconfig_ui_sizeZ	set_imageZ	Exceptionr   Z	exception)	rJ   Zimage_formatr   scale_factorservice_media	game_slug
media_pathZimageZex	   &&&      r!   r   ZGameInfoBox._set_imagev  s    ,,.++L9IIFFDIII$))..2	'(N(Ny(YZ__
	P33J@\@\^jkE""5) 	P <lOO	Ps   2B; ;C(C##C(c                s   V P                  4       p\        P                  P                  V4      pVP	                  ^4       ^ pV P
                  P                  '       d@   V F9  pV P
                  P                  \        V^,          4      8X  d    MV^,          pK;  	  W0n        VP                  V P                  4       VP                  RV P
                  P                  4       \        P                  ! 4       p\        P                  P                  VP                   n        VP%                  VR4       VP'                  VR^ 4       V# )i   r   Tr{   )_get_runner_liststorer   ZComboBoxZnew_with_modelZset_id_columnr   Zrunner_namerd   r-   Z
set_activeri   Zon_runner_changedZCellRendererTextr   ZEllipsizeModeZENDZpropsZ	ellipsizer=   Zadd_attribute)rJ   runner_liststorer,   r-   runnerZcells   &     r!   r   Z GameInfoBox._get_runner_dropdown  s   557,,556FG%%a()))*%%11S^C! + )""4#4#45	4+=+=+O+OP##%$2266

""4.%%dFA6r$   c                 s   \         P                  ! \        \        4      p V P                  \	        R4      R34       \        4        F>  pVP                  pV P                  VP                  : RV: R2VP                  34       K@  	  V # )z)Build a ListStore with available runners.zSelect a runner from the listrc   z (Z))	r   Z	ListStorerd   ZappendrY   r   descriptionZ
human_namer]   )r   r   r   s      r!   r   Z!GameInfoBox._get_runner_liststore  sr     ==c2#B!CR HI#oF ,,K##&2C2C[%QSYS^S^$_` &  r$   c                s    V P                   '       g   R # V P                   P                  4       RJ d8   VP                  \        R4      4       V P                   P	                  R4       R # V P                  4        R # )NFZApplyT)r.   Zget_sensitive	set_labelrY   rh   change_game_slug)rJ   Zwidget   &&r!   rl   Z"GameInfoBox.on_slug_change_clicked  sS    ??((*e3QwZ(OO))$/!!#r$   c                s&    V P                  4        R # rM   )r   )rJ   r   r   r!   rj   Z"GameInfoBox.on_slug_entry_activate  s    r$   c                sZ   V P                   '       g   R # V P                   P                  4       pWn        V P                   P                  R4       V P                  '       d%   V P                  P                  \        R4      4       \        \        V P                  V P                  4       R # )NFre   )
r.   get_textr(   rh   r/   r   rY   r   r   refresh_all_images_cb)rJ   r(   r   r!   r   ZGameInfoBox.change_game_slug  sr    '')	%%e,"""##--ak:')C)CTYYOr$   c                sn    V P                   P                  4        F  w  r4V P                  W44       K  	  R # rM   )r7   Zitemsr   )rJ   _result_errorr   r   s   &&&  r!   r   Z!GameInfoBox.refresh_all_images_cb  s+    (,(:(:(@(@(B$JOOJ5 )Cr$   c                s0   < V ^8  d   QhRS[ S[,          /# )r   r   )r   r   r   r    r!   r"   r#     s      HTN r$   c                sR   WP                   9  d   R# V P                   V,          pV P                  ;'       g+    V P                  '       d   V P                  P                  MRp\        VP	                  V4      4      pRpVP
                  '       d   \        VP                  4      pV# )zGet the path of the image fileNrc   )r6   r(   r   r   r   Zexistsr   r   )rJ   r   r   r   r   
image_paths   &&    r!   get_image_pathZGameInfoBox.get_image_path  s~    000++J7IIFFDIII$))..2	'(N(Ny(YZ

joo.Jr$   c                sx    V P                  V4      ;p'       d!   \        \        VP                  4      4       R # R # rM   )r   r   rd   r   )rJ   r   r   r   r   r!   r   Z:GameInfoBox.on_open_image_location_in_file_browser_clicked  s.    &&z2242S%& 3r$   c                s   \        V P                  V4      ;'       g    R 4      pV P                  P                  V4      ;p'       d?   VP	                  V4       V P
                  V,          P                  \        V4      4       R# R# rc   N)rd   r   r8   rt   r\   r9   rh   Zbool)rJ   r   r   Zimage_path_entrys   &&  r!   r   Z$GameInfoBox.refresh_image_path_entry  sn    ,,Z8>>B?
#66:::FFF%%j1''
3AA$zBRS Gr$   c                s   \         P                  P                  \        R 4      V P                  \         P
                  P                  RR4      p\         P                  ! 4       pVP                  \        R4      4       VP                  4        VP                  V4       VP                  4       pV\         P                  P                  8X  d"   VP                  4       pV P                  W&4       VP!                  4        R# )zPlease choose a custom imageNZImages)r   ZFileChooserNativeZnewrY   r   ZFileChooserActionZOPENZ
FileFilterZset_nameZadd_pixbuf_formatsZ
add_filterrunResponseTypeZACCEPTZget_filenamesave_custom_mediadestroy)rJ   r   r   dialogZimage_filterresponser   s   &&&    r!   r   Z"GameInfoBox.on_custom_image_select  s    &&**,-!!&&
 ~~'ak*''),'::<s''...,,.J""::r$   c                s(    V P                  V4       R # rM   )refresh_image)rJ   r   r   s   &&&r!   r   Z)GameInfoBox.on_custom_image_reset_clicked  s    :&r$   c                s  a aaa	 \        S P                  4      pVP                  4       pV\        P                  P
                  8w  d   VP                  4        R # VP                  4       o	VP                  4        \        P                  ! 4       p\        P                  P                  \        P                  RV R24      o\        P                   ! RS	 RS R24       VV VV	3R lpR p\#        Wg4       R # )Nz	download-.tmpzDownloading custom image from `z` to `Z`c            	      s  < \         P                  ! SR R7      ;_uu_ 4       p V P                  '       g3   \        P                  ! RS RV P
                   R24        RRR4       R# \        SR4      ;_uu_ 4       pV P                  RR7       F  pV'       g   K  VP                  V4       K   	  RRR4       RRR4       SP                  SS4       R#   + '       g   i     L,; i  + '       g   i     L7; i)	T)Zstreamz>Request returned a status code that didn't indicate success: `z` (`z`)NZwbi   )Z
chunk_size)
requestsrt   Zokr   errorZstatus_codeZopenZiter_contentZwriter   )ZrZfpZchunkr   rJ   tmp_fileurls      r!   downloadZ>GameInfoBox.on_custom_image_download_clicked.<locals>.download  s    c$//1tttLLXY\X]]abcboboapprs  0/ (D))R!"4!@ 5HHUO "A * 0 "":x8 *) 0/s/   ;C''C';C	C	0C'C$C''C7	c                     V'       d   VhR # rM   r%   r   r   r   r!   download_cbZAGameInfoBox.on_custom_image_download_clicked.<locals>.download_cb       r$   )	UrlDialogr   r   r   r   OKr   get_urluuidZuuid4osr   Zjoinr   ZTMP_DIRr   Zinfor   )
rJ   r   r   r   r   Zfile_idr   r   r   r   s
   f&f     @@r!   r   Z,GameInfoBox.on_custom_image_download_clicked  s    4--.::<s''***NNnn**,77<< 0 0IgYd2KL5cU&
!LM	9 	9	 	((r$   c                s*   < V ^8  d   QhRS[ RS[ RR/# )r   r   r   r   Nrd   r   r    r!   r"   r#     s'     R RC RS RT Rr$   c                s`   V P                   ;'       g+    V P                  '       d   V P                  P                   MR pV P                  V,          pV P                  '       d&   V P                  P                  P	                  V4       VP                  V4       Uu. uF  qUP                  NK  	  ppW&9  dr   \        V4      pV'       dD   V F=  pVP                  4       P                  V4      '       g   K*  V P                  WV4        R# 	  V P                  V^ ,          W4       R# R# u upi r   )r(   r   r6   custom_imagesr   r   r   r   ZcasefoldZendswith_save_copied_media_to_save_transcoded_media_to)	rJ   r   r   r(   r   ZmpZ
dest_pathsextZ	candidater   r!   r   ZGameInfoBox.save_custom_media  s    yyAAtyyyTYY^^b++J7999II##''
3(5(N(Nt(TU(T"gg(T
U'*:6C!+I ))+44S99229*U ",
 **:a=*Q ( Vs   D+c                0   < V ^8  d   QhRS[ RS[ RS[ RR/# r   	dest_pathr   r   r   Nr   r   r    r!   r"   r#     s1     H Hs H HQT HY] Hr$   c                s   a aaaa S P                   ;'       g+    S P                  '       d   S P                  P                   MRpS P                  S,          pVV 3R lpVVV3R loVP                  WFR7       R# )zCopies a media file to the dest_path, but trashes the existing media
for the game first. When complete, this updates the button indicated by
image_type as well.rc   c                  4   < \        S SP                  4       R # rM   r   image_refreshed_cb)
copy_imagerJ      r!   
on_trashedZ5GameInfoBox._save_copied_media_to.<locals>.on_trashed$  s    j$"9"9:r$   c                  sd   < \         P                  ! SS R R7       \        P                  ! 4        S# )T)Zfollow_symlinks)shutilZcopyr   fire)r   r   r   s   r!   r   Z5GameInfoBox._save_copied_media_to.<locals>.copy_image'  s%    KK
ItD#((*r$   Zcompletion_functionN)r(   r   r6   trash_media)rJ   r   r   r   r(   r   r   r   s   ffff   @r!   r   Z!GameInfoBox._save_copied_media_to  sU     yyAAtyyyTYY^^b++J7	;	
 	!!$!Gr$   c                r   r   r   r   r    r!   r"   r#   .  s+     #+ #+3 #+C #+UX #+]a #+r$   c                s  a aaaaa	a
aaaa S P                   ;'       g+    S P                  '       d   S P                  P                   MRoS P                  S,          o\        S4      ;'       g    RpRRRR/V,          oS P	                  4       pSP
                  w  oo	SV,          oS	V,          o	SR,           oVV	VV
VVVV3R lpR pVVV V3R	 lo
\        Wg4       R
# )zTranscode an image, copying it to a new path and selecting the file type
based on the file extension of dest_path. Trashes all media for the current
game too. Runs in the background, and when complete updates the button indicated
by image_type.rc   z.pngz.jpgZjpegZpngr   c                  s   < \         P                  P                  SSS4      p V P                  SSR .R.4       SP	                  SSR7       R# )ZqualityZ100r   N)r   ZPixbufZnew_from_file_at_sizeZsavevr   )	Zpixbuffile_formatheightr   r   r   r(   	temp_filewidths	    r!   	transcodeZ8GameInfoBox._save_transcoded_media_to.<locals>.transcodeA  sH    %%;;JvVF LLK)ugF%%d
%Kr$   c                 r   rM   r%   r   r   r!   transcode_cbZ;GameInfoBox._save_transcoded_media_to.<locals>.transcode_cbH  r   r$   c                  s   < \         P                  ! SS 4       \        P                  ! 4        SP	                  S4       R # rM   )r   Zrenamer   r   r   )r   r   rJ   r   s   r!   r   Z9GameInfoBox._save_transcoded_media_to.<locals>.on_trashedL  s+    IIi+#((*##J/r$   N)r(   r   r6   r   r   Zcustom_media_storage_sizer   )rJ   r   r   r   r   r   r   r   r   r   r   r   r(   r   r   s   ffff    @@@@@@@r!   r   Z%GameInfoBox._save_transcoded_media_to.  s    
 yyAAtyyyTYY^^b++J7&y1;;Vvvu5c:
 ,,.%??v$,&&		L 	L		0 	0
 	)*r$   c                s`  a aaa S P                   ;'       g+    S P                  '       d   S P                  P                   MR oS P                  S,          pS P                  '       d&   S P                  P                  P	                  S4       VV 3R lpVV3R loVP                  SVR7       R# )rc   c                  r   rM   r   )r   rJ   r   r!   r   Z-GameInfoBox.refresh_image.<locals>.on_trashedY  s    h 7 78r$   c                  s   < \        S4       S # rM   )r   )r   r(   r   r!   r   Z+GameInfoBox.refresh_image.<locals>.download\  s    !$'r$   r   N)r(   r   r6   r   Zdiscardr   )rJ   r   r   r   r   r(   s   ff  @@r!   r   ZGameInfoBox.refresh_imageS  sv    yyAAtyyyTYY^^b++J7999II##++J7	9	 	!!$J!Gr$   c                s    V'       dY   V P                  WP                  V,          4       V P                  V,          pVP                  4        V P	                  V4       R # R # rM   )r   r7   r6   Zrun_system_update_desktop_iconsr   )rJ   r   r   r   r   r!   r   ZGameInfoBox.image_refreshed_cbb  sM    OOJ(:(::(FG //
;M99; ))*5 r$   )rO   rN   r:   rP   rH   r0   r   r7   r8   r9   r)   r*   r   r2   r,   r-   r6   r(   r/   r.   r+   r1   rM   )+__name__
__module____qualname____firstlineno____doc__r'   rI   r?   r@   rB   rC   rD   rE   rF   rG   rx   rA   r<   r>   r   r   r   r   Zstaticmethodr   rl   rj   r   r   r   r   r   r   r   r   r   r   r   r   r   __static_attributes____classdictcell____classcell__rL   r      @@r!   r   r   $   s     04 4l\	2@!F!	,;:6BP&    $ P6 'T&'!)FR R$H H"#+ #+JH6 6r$   r   c                   s8   a a ] tR tRt oV 3R ltR tRtVtV ;t# )r   il  c                s  < \         SV `  \        R 4      V^ R7       V P                  \        P
                  \        P                  P                  \        P                  \        P                  P                  4       V P                  R^d4       V P                  4       p\        P                  ! 4       V n        V P                  P                  R4       VP                  V P                  4       V P!                  4        R# )z	Enter URL)ZtitleZtransient_forZflagsi,  zhttps://example.com/image.pngN)r&   r'   rY   Zadd_buttonsr   ZSTOCK_CANCELr   ZCANCELZSTOCK_OKr   Zset_default_sizeZget_content_arearZ   entryrb   r   Zshow_all)rJ   r   r_   rL   s   && r!   r'   ZUrlDialog.__init__m  s    q~V1M))3+;+;+B+BCLLRURbRbReRefc3'##%YY[


''(GH

r$   c                s6    V P                   P                  4       # rM   )r   r   rQ   rR   r!   r   ZUrlDialog.get_urlz  s    zz""$$r$   )r   )	r   r   r   r   r'   r   r   r   r   r   r   r!   r   r   l  s     % %r$   r   )3r   r   r   r   r    rY   Zpathlibr   Ztypingr   r   r   Zgi.repositoryr   r   r   Zlutrisr   Zlutris.gamer   Zlutris.gui.config.boxesr	   Zlutris.gui.widgets.commonr
   r   r   Zlutris.gui.widgets.scaled_imager   Zlutris.gui.widgets.utilsr   r   r   Zlutris.runnersr   Zlutris.services.lutrisr   r   r   r   Zlutris.services.service_mediar   Zlutris.util.jobsr   Zlutris.util.logr   r5   r4   r3   r   ZDialogr   r%   r$   r!   <module>r      s    $ 	   !     0 /   7 C C 7 ` ` ( b b < & "
E	6% E	6P%

 %r$   