+
    Ki-  c                   s    ^ 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HtHtHtHtHt ^ RIHt ^ RIHt ^ R	IHt  ! R
 R]P0                  4      tR# )i    )datetime)gettext)GtkPango)runnersservices)get_game_for_service)GAME_INSTALLED
GAME_STARTGAME_STARTEDGAME_STOPPEDGAME_UPDATEDGame)get_game_actions)update_action_widget_visibility)gtk_safec                   s   a a ] tR t^t oV 3R ltR tR t]RR l4       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R tV3R lR ltRtVtV ;t# )GameBarc           
     s  < \         SV `  \        P                  P                  R^^^^^R7       W n        W0n        \        P                  ! V P                  4      V n
        \        P                  ! V P                  4      V n        \        P                  ! V P                  4      V n        \        P                  ! V P                  4      V n        \"        P                  ! V P                  4      V n        V P'                  RV P(                  4       V P+                  ^4       Wn        RV n        VP1                  R4      '       d*    \2        P4                  VR,          ,          ! 4       V n        RpRV9   d   VR,          V n        VR,          pM[V P.                  '       dJ   VR,          V n        \;        V P.                  P<                  V P8                  4      pV'       d
   VR,          pV'       d   VP?                  V4      V n         M%\B        PD                  ! WP.                  4      V n         V PG                  4        R#   \6         d     Li ; i)	z'Create the game bar with a database rowT)orientationvisibleZ
margin_topZmargin_leftZmargin_bottomZmargin_rightspacingdestroyNserviceZ
service_ididappid)$Zsuper__init__r   OrientationVERTICALapplicationwindowr   Zregisteron_game_state_changedgame_start_registrationr	   game_started_registrationr
   game_stopped_registrationr   game_updated_registrationr   game_installed_registrationconnect
on_destroyZset_margin_bottomdb_gamer   getr   ZSERVICESZKeyErrorr   r   r   Zget_game_by_idgamer   Zcreate_empty_service_gameupdate_view)selfr%   r   r   Zgame_idr'   	__class__s   &&&&  @/usr/lib/python3.14/site-packages/lutris/gui/widgets/game_bar.pyr   ZGameBar.__init__   s   00 	 	
 ''1':':4;U;U'V$)5)>)>t?Y?Y)Z&)5)>)>t?Y?Y)Z&)5)>)>t?Y?Y)Z&+9+B+B4C]C]+^(Y0r";;y!!'001CDF 7" .DJdmG\\\ )DJ'DDt*#227;DI66wMDI!  s   (I IIc                s
   V P                   P                  4        V P                  P                  4        V P                  P                  4        V P                  P                  4        V P
                  P                  4        R # )T)r   Z
unregisterr   r    r!   r"   )r)   Zwidget   &&r+   r$   ZGameBar.on_destroy=   s_    $$//1&&113&&113&&113((335    c                s   \        V P                  .V P                  V P                  R7      pV P	                  4       pVP                  \        P                  P                  4       V P                  VRR^ 4       \        P                  ! \        P                  P                  ^R7      pV P                  VRR^ 4       V P                  V4      V n        VP                  V P                  RR^ 4       VP                  V P                  4       RR^ 4       VP                  V P!                  4       RR^ 4       V P                  P"                  '       d#   VP                  V P%                  4       RR^ 4       V P                  P&                  '       d#   VP                  V P)                  4       RR^ 4       VP+                  4        R# )zPopulate the view with widgets)r   r   F)r   N)r   r'   r   r   get_game_name_labelZ
set_halignr   ZAlignZSTART
pack_startBoxr   
HORIZONTALget_play_buttonplay_buttonget_runner_buttonget_platform_label
lastplayedget_last_played_labelZplaytimeget_playtime_labelZshow_all)r)   game_actionsZ
game_labelZhboxs   &   r+   r(   ZGameBar.update_viewE   sC   'DKKUYUeUef--/
ciioo.
E5!4wws111=eUA.//=((%:..0%B//15%C99OOD668%J99OOD335ueQGr-   c                s  aa V3R lp\         P                  ! RR7      pVP                  4       pVP                  R4       VP	                  V RR^ 4       S'       d   \         P
                  ! \         P                  P                  RR7      oSP                  ^ ^ 4       V! S4      pSP                  V4       VP	                  SRR^ 4       V'       d   V P                  RV3R l4       V# )	a:  Creates a box that contains a primary button and a second button that
opens a popover with the popover_buttons in it; these have a linked
style so this looks like a single button.

If primary_opens_popover is true, this method also handled the 'clicked' signal
of the primary button to trigger the popover as well.c                 s  < \         P                  ! 4       p\         P                  ! \         P                  P                  R R7      pVP                  ^	4       VP                  ^4       S F  pVP                  VRR^ 4       K  	  VP                  V4       VP                  \         P                  P                  4       VP                  \         P                  P                  4       VP                  V 4       V# )Tr   r   F)r   ZPopoverr0   r   r   Zset_border_widthZset_spacingZpack_endZaddZset_positionZPositionTypeZTOPZset_constrain_toZPopoverConstraintZNONEZset_relative_to)ZparentZpopZvboxbuttonpopover_buttonss   &   r+   get_popoverZ,GameBar.get_popover_box.<locals>.get_popoverd   s    ++-C77s'?'?ND!!!$Q)feUA6 * GGDMS--112  !6!6!;!;<'Jr-   Tr   ZlinkedF)Z	directionr   clickedc                 s&   < SP                  R 4      # )r?   )Zemit)Z_xpopover_button   &r+   <lambda>Z)GameBar.get_popover_box.<locals>.<lambda>   s    ^=P=PQZ=[r-   )r   ZHBoxZget_style_contextZ	add_classr/   Z
MenuButtonZ	ArrowTypeZUPset_size_requestZset_popoverr#   )Zprimary_buttonr<   primary_opens_popoverr=   boxZstyle_contextpopoverr@   s   &f&    @r+   get_popover_boxZGameBar.get_popover_box[   s    	  hht$--/)~ueQ7 ^^cmm6F6FPTUN++B3!.1G&&w/NN>5%;$&&y2[\
r-   c                s    VR8X  d1   \         P                  ! \         P                  P                  RR7      # \         P                  ! VRRR7      pV'       d   VP                  RV P                  V4       V# )z_Return a suitable button for a menu popover; this must be
a ModelButton to be styled correctly.Z-Tr:   g        )r   Zxalignr?   )r   Z	Separatorr   r1   ZModelButtonr#   on_link_button_clicked)r)   Ztextcallbackr;      &&& r+   get_link_buttonZGameBar.get_link_button   sW     3;==S__-G-GQUVVtC@NN9d&A&A8Lr-   c                s    \         P                  ! RR7      pVP                  \        P                  P
                  4       VP                  R\        V P                  P                  4      ,          4       V# )z&Return the label with the game's titleTr>   z%<span font_desc='16'><b>%s</b></span>)
r   LabelZset_ellipsizer   EllipsizeModeEND
set_markupr   r'   name)r)   Ztitle_label   & r+   r.   ZGameBar.get_game_name_label   sV    ii-!!%"5"5"9"9:FRVR[R[R`R`Iaabr-   c                s   V P                   P                  '       g   \        P                  ! 4       # V P                   P                  P
                  R ,           p\        P                  P                  V\        P                  P                  4      pV P                  4       pV'       d0   \        P                  ! VRR7      p\        P                  WCRR7      # VP                  ^14       VP                  ^4       V# )z	-symbolicT)Zimager   )rD   )r'   
has_runnerr   r0   runnerrP   ZImageZnew_from_icon_nameZIconSizeZMENUget_runner_buttonsButtonr   rG   Zset_margin_leftZset_margin_right)r)   Z	icon_nameZrunner_iconZrunner_popover_buttonsZrunner_buttons   &    r+   r4   ZGameBar.get_runner_button   s    yy###779II$$))K7	ii229cll>O>OP!%!8!8!:!JJ[$GM**=hl*mm##B'$$Q'r-   c                s   \         P                  ! R R7      pV P                  P                  '       g   V# VP	                  ^xR4       VP                  ^ R4       \        V P                  P                  4      pVP                  V4       VP                  \        R4      V,          4       VP                  R\        P                  P                  4       V# )Tr>         ?zPlatform:
<b>%s</b>Z	ellipsize)r   rL   r'   platformrC   set_alignmentr   Zset_tooltip_markuprO   _Zset_propertyr   rM   rN   )r)   Zplatform_labelrX      &  r+   r5   ZGameBar.get_platform_label   s    40yy!!!!!''R0$$Q,DII../))(3!!!$:";h"FG##K1D1D1H1HIr-   c                s    \         P                  ! RR7      pVP                  ^xR4       VP                  ^ R4       VP	                  \        R4      V P                  P                  ,          4       V# )z-Return the label containing the playtime infoTr>   rV   zTime played:
<b>%s</b>rW   )r   rL   rC   rY   rO   rZ   r'   Zformatted_playtime)r)   Zplaytime_labelrQ   r+   r8   ZGameBar.get_playtime_label   sY    40''R0$$Q,!!!$=">A]A]"]^r-   c                s0   \         P                  ! RR7      pVP                  ^xR4       VP                  ^ R4       \        P
                  ! V P                  P                  4      pVP                  \        R4      VP                  R4      ,          4       V# )z0Return the label containing the last played infoTr>   rV   zLast played:
<b>%s</b>z	%b %-d %YrW   )r   rL   rC   rY   r    Zfromtimestampr'   r6   rO   rZ   Zstrftime)r)   Zlast_played_labelr6   r[   r+   r7   ZGameBar.get_last_played_label   sv    IId3**33''3/++DII,@,@A
$$Q'@%AJDWDWXcDd%de  r-   c                sr    V P                  \        R4      4      pVP                  RVP                  4       V# )z-Return a button to locate an existing installzLocate installed gamer?   )rK   rZ   r#   Zon_locate_installed_game)r)   r9   r;      && r+    get_locate_installed_game_buttonZ(GameBar.get_locate_installed_game_button   s1    %%a(?&@Ay,"G"GHr-   c                s   \         P                  ! RR7      pVP                  ^x^ 4       RpV P                  P                  '       EdB   V P                  V4      pV P                  P                  V P                  P                  8X  dT   VP                  \        R4      4       VP                  RVP                  4       VP                  VP                  4       EMuV P                  P                  V P                  P                  8X  d.   VP                  \        R4      4       VP                  R4       EMVP                  \        R4      4       VP                  RVP                  4       VP                  VP                   4       MVP                  \        R	4      4       VP                  RVP"                  4       VP                  VP$                  4       V P&                  '       de   V P&                  P(                  '       d   VP                  \        R4      4       V P&                  P*                  '       d   V P-                  V4      .pV'       d*   VP                  ^T^ 4       \.        P1                  W#4      pV# V# )
z7Return the widget for install/play/stop and game configTr>   NZPlayr?   Z	LaunchingFZStopZInstall)r   rU   rC   r'   is_installedget_game_buttonsZstateZSTATE_STOPPEDZ	set_labelrZ   r#   Zon_game_launchZset_sensitiveZis_game_launchableZSTATE_LAUNCHINGZon_game_stopZis_game_runningon_install_clickedZis_installabler   ZlocalZdrm_freer]   r   rG   )r)   r9   r;   Zgame_buttonsrE   s   &&   r+   r2   ZGameBar.get_play_button   s   D)R(99!!!00>Lyy$))"9"99  6+y,*E*EF$$\%D%DEDII$=$==  ;0$$U+  6+y,*C*CD$$\%A%ABQy\*NN9l&E&EF  !<!<=|||<<%%%$$QvY/<<((($($I$I,$W#XL##B+))&?CJr-   c                s  a VP                  4       p. p/ oVP                  4        FN  w  rEpVR9   d   K  V P                  WV4      pV'       d   VP                  VR4      SV&   VP	                  V4       KP  	  \        VV3R l4       V# )z,Return a list of buttons to use in the panelTc                 s(   < SP                  V R 4      # N)r&   )Zwbutton_visibilityrA   r+   rB   Z*GameBar.get_game_buttons.<locals>.<lambda>   s    ;L;P;PQRTX;Yr-   )ZplayZstopinstall)Zget_displayed_entriesr   rK   r&   appendr   )	r)   r9   Z	displayedbuttonsZ	action_idlabelrI   r;   rb   s	   &&      @r+   r_   ZGameBar.get_game_buttons   s     668	*6*G*G*I&Ih77))%:F,5MM)T,J!&)NN6" +J 	(1YZr-   c                sr   . pV P                   P                  '       d   V P                   P                  '       d}   \        P                  ! V P                   P
                  4      ! V P                   P                  4      pVP                   F(  w  r4pV P                  WE4      pVP                  V4       K*  	  V# ra   )
r'   rR   r^   r   Zimport_runnerZrunner_nameZconfigZcontext_menu_entriesrK   rd   )r)   re   rS   Z_namerf   rI   r;   s   &      r+   rT   ZGameBar.get_runner_buttons   s    99DII$:$:$:**499+@+@A$))BRBRSF*0*E*E&h--e>v& +F r-   c                sr    VP                  4       P                  4       pVP                  4        V! V4       R# )zICallback for link buttons. Closes the popover then runs the actual actionN)Z
get_parentZpopdown)r)   r;   rI   rF   rJ   r+   rH   ZGameBar.on_link_button_clicked  s+    ##%002r-   c                sP    V P                   P                  V P                  4       R# )z$Handler for installing service gamesN)r   rc   r%   )r)   r;   r,   r+   r`   ZGameBar.on_install_clicked  s    T\\*r-   c                s$   < V ^8  d   QhRS[ RR/# )i   r'   ZreturnN)r   )Zformat__classdict__s   "r+   Z__annotate__ZGameBar.__annotate__  s     	 	$ 	4 	r-   c                s   V P                   P                  '       d&   VP                  V P                   P                  8X  g.   V P                  '       d#   VP                  V P                  8X  d   Wn         MV P                   V8w  d   R# V P	                  4        F  pVP                  4        K  	  V P                  4        R# )z.Handler called when the game has changed stateN)r'   Zis_db_storedr   r   Zget_childrenr   r(   )r)   r'   Zchildr\   r+   r   ZGameBar.on_game_state_changed  s~    II"""tww$)),,'>DJJJSWS]S]aeakakSkIYY$&&(EMMO )r-   )r   r   r%   r'   r"   r   r   r    r!   r3   r   r   )Fra   )Z__name__Z
__module__Z__qualname__Z__firstlineno__r   r$   r(   ZstaticmethodrG   rK   r.   r4   r5   r8   r7   r]   r2   r_   rT   rH   r`   r   Z__static_attributes__Z__classdictcell__Z__classcell__)r*   rg   s   @@r+   r   r      sv     ,\, ( (T	
!"H +	 	 	r-   r   N)r    r   rZ   Zgi.repositoryr   r   Zlutrisr   r   Zlutris.database.gamesr   Zlutris.gamer   r   r	   r
   r   r   Zlutris.game_actionsr   Z"lutris.gui.widgets.contextual_menur   Zlutris.util.stringsr   r0   r   ) r-   r+   <module>rh      s5       $ $ 6 b b 0 N (Kcgg Kr-   