
    Eg                        d dl Z  e j                  dd        e j                  dd        e j                  dd       d dlmZmZmZmZ d dlZd dlZd dl	Z	d dl
Z
d dlZd dlZd dlZd dlZd dlmZmZ d d	lmZ  ej                  ej(                  ej*                          ej,                  d
d        G d dej.                        Zedk(  r* ej                  d
        e       Zej7                          yy)    NGtkz3.0GdkX11CScreensaverz1.0)r   Gdkr   Gio)utilssettings)ScreensaverServicezcinnamon-screensaverz/usr/share/localec                   <     e Zd ZdZ fdZd Zd ZddZd Z xZ	S )Mainz
    This is the main entry point to the program, and it shows up
    in the process list.  We do any theme preparation here as well.

    We start the ScreensaverService from here.
    c                 v    t         t        |   ddt        j                  j
                         t                y )Nzorg.cinnamon.ScreenSaveri0u  )application_idinactivity_timeoutflags)superr   __init__r   ApplicationFlags
IS_SERVICEr
   )self	__class__s    </usr/share/cinnamon-screensaver/cinnamon-screensaver-main.pyr   zMain.__init__    s5    dD"2L6;),)=)=)H)H 	# 	J
 	    c                      y N )r   s    r   do_activatezMain.do_activate(   s    r   c                 l   t        dd       t        j                  j                  |        t	        j
                  d      }|j                  dddd	
       |j                  dddd
       |j                  dddd
       |j                  dddd
       |j                  dddd
       |j                  dddd
       |j                         }t        j                         dk7  rt        dd       t                |j                  r&t        dt        j                  z         t                |j                   t        _        |j"                  t        _        |j&                  t        _        |j*                   t        _        | j/                          |j.                  s| j1                          t        j$                  rt        dd       |j                  rt        dd       dd l}t        j4                  j7                         j9                  d | j:                         | j=                          y )!NzStarting screensaver...TflushzCinnamon Screensaver)descriptionz--debugdebug
store_truez#Print out some extra debugging info)destactionhelpz--interactive-debuginteractivezPIf multiple monitors are in use, only cover one monitor, and launch GtkInspectorz--disable-lockinglock_disabledzDisable the lock screenz	--versionversionzDisplay the current versionz--holdholdzaKeep the process running.Normally cinnamon-screensaver will exit after being idle for 30 seconds.z--no-fallbackno_fallbackz6Don't spawn a fallback window when locking the screen. z:custom screensaver selected, exiting cinnamon-screensaver.zcinnamon-screensaver %szDebug mode activezLocking disabledr   znotify::gtk-theme-name)printr   Application
do_startupargparseArgumentParseradd_argument
parse_argsr	   get_custom_screensaverquitr(   configVERSIONr'   statusLockEnabledr!   Debugr&   InteractiveDebugr*   UseFallbackr)   release
singletonsSettingsget_defaultconnecton_theme_changeddo_style_overrides)r   parserargsr=   s       r   r.   zMain.do_startup+   s   't4""4(((5KLIGL!F 	 	H1l!s 	 	u/ol!: 	 	<Ki!> 	 	@H6,"l 	 	m 	O-!Y 	 	[  "**,2NVZ[F<<+fnn<=F!%!3!33zz"&"2"2!%!1!11 			yyLLN<<%T2$D1 	  "**+CTEZEZ[!r   c                 $    | j                          y r   )rB   )r   r	   pspecdatas       r   rA   zMain.on_theme_changed^   s    !r   c                    t         j                  j                         j                  d      }t         j                  j                  |      }|j                         }d|vr\t        dd       t        j                  j                  t        j                  d      }t        |d      }|j                         }|j                          d|v rnCd	|v r t        d
d       |j!                  dd      }nt        dd       |j!                  dd      }t        j                         }	 |j#                  |j%                                t         j&                  j)                  t*        j,                  j                         |d       t         j&                  j/                  t*        j,                  j                                yy# t0        $ r!}t        dt3        |      z         Y d}~yd}~ww xY w)a%  
        Here we try to check for theme support in the current system's gtk theme.

        We do this by retrieving a string of the current theme's final style sheet,
        then searching for the .csstage style class.  If it's found, we return, otherwise
        we add our own application-priority provider as a fallback.  While we have the
        theme string, we check for a variable name we can use for the fallback experience,
        and adjust it in our application stylesheet if necessary before adding it as a
        provider.
        zgtk-theme-namez.csstagezHCinnamon Screensaver support not found in current theme - adding some...Tr   zcinnamon-screensaver.cssrz%@define-color theme_selected_bg_colorz@define-color selected_bg_colorz8replacing theme_selected_bg_color with selected_bg_colorz@theme_selected_bg_colorz@selected_bg_colorz3replacing theme_selected_bg_color with Adwaita bluez#4a90d9iX  z Could not parse fallback css: %sN)r   r>   r?   get_propertyCssProvider	get_named	to_stringr,   ospathjoinr5   
pkgdatadiropenreadclosereplaceload_from_dataencodeStyleContextadd_provider_for_screenr   Screenreset_widgets	Exceptionstr)	r   
theme_nameprovidercssrO   ffallback_cssfallback_proves	            r   rB   zMain.do_style_overridesa   s    \\--/<<=MN
??,,Z8  "S \dhi77<< 1 13MNDT3A668LGGI6#=2c9PX\]+334NPdeKSWX+334H)TOO-MC,,\-@-@-BC  88#**:P:P:RTacfg  ..szz/E/E/GH/ !0  C83q6ABBCs   &BF? ?	G)G$$G)r   )
__name__
__module____qualname____doc__r   r   r.   rA   rB   __classcell__)r   s   @r   r   r      s#    1"f")Cr   r   __main__)girequire_versiongi.repositoryr   r   r   r   signalgettextr/   rN   setproctitlesysr5   r7   utilr   r	   servicer
   SIGINTSIG_DFLinstallr-   r   re   mainrunr   r   r   <module>ry      s    
   5%     8U #   >5 ) 5 5    	  
     & fmmV^^ , &(; <qC3?? qCf zL456DHHJ	 r   