
    Eg	                     p    d dl mZmZ d dlmZmZ d dlmZ d dlm	Z	 d dl
mZ d dlZd dlZ G d de	e      Zy)	    )GioGtk)trackerssettings)
BaseWindow)Floating)FramedImageNc                   6     e Zd ZdZd fd	Zd Zd Zd Z xZS )AlbumArta6  
    AlbumArt

    It is a child of the Stage's GtkOverlay, and its placement is
    controlled by the overlay's child positioning function.

    When not Awake, it positions itself around all monitors
    using a timer which randomizes its halign and valign properties
    as well as its current monitor.
    c                    t         t        |   |       | j                         j	                  d       | j                  t        j                  j                         t        j                         sy t        j                  | _        | j                  j                         | _        d | _        t#        t$        j&                  j)                         d      | _        | j*                  j-                          | j*                  j/                  d       | j1                  | j*                         t3        j4                         j7                  | j*                  d| j8                         | j                  Ut3        j4                         j7                  | j                  d| j:                         | j;                  | j                         y y )NalbumartT)scale_up        zsurface-changedzmetadata-changed)superr   __init__get_style_context	add_class
set_halignr   AlignENDr   get_show_albumart
singletonsMediaPlayerWatcherwatcherget_best_playerplayercurrent_urlr	   statusscreenget_low_res_modeimageshowset_opacityaddr   con_tracker_getconnecton_surface_changedon_metadata_changed)selfaway_messageinitial_monitor	__class__s      +/usr/share/cinnamon-screensaver/albumArt.pyr   zAlbumArt.__init__   s9   h&7 **:6		&))+!44ll224 !?!?!ADQ




s#  "**4::+<+/+B+B	D ;;"$$&..t{{/A/3/G/GI $$T[[1	 #    c                 v    || j                   j                  d       y | j                   j                  d       y )Ng      ?r   )r!   r#   )r)   r!   surfaces      r-   r'   zAlbumArt.on_surface_changed4   s,    JJ""3'JJ""3'r.   c                 $    | j                          y )N)update_image)r)   r   s     r-   r(   zAlbumArt.on_metadata_changed:   s    r.   c                    | j                   j                         }| j                   j                         dk(  r|j                  dd      }|| j                  k(  ry || _        |dk(  r| j
                  j                          t        j                  j                  |      }|j                         dk(  r*| j
                  j                  |j                                y |j                         dk(  r| j
                  j                  |       y y )Nspotifyzopen.spotify.comz	i.scdn.co filehttp)r   get_albumart_urlget_identityreplacer   r!   clear_imager   Filenew_for_uriget_uri_schemeset_from_pathget_pathset_from_file)r)   urlfs      r-   r2   zAlbumArt.update_image=   s    kk**,;;##%2++0+>C$""""9JJ""$HH  %'JJ$$QZZ\26)JJ$$Q' *r.   )Nr   )	__name__
__module____qualname____doc__r   r'   r(   r2   __classcell__)r,   s   @r-   r   r      s    	28((r.   r   )gi.repositoryr   r   utilr   r   
baseWindowr   floatingr   widgets.framedImager	   r   r   r    r.   r-   <module>rO      s,    # # !  +  C(x C(r.   