o
    =ßSbF  ã                
   @   s¼   d dl Z d dlmZ dZzd dlZe dd¡ e dd¡ d dlmZmZ d	ZW n e	e
fyC Z ze  d
e ¡ W Y dZ[ndZ[ww G dd„ deƒZG dd„ deƒZerZeZdS eZdS )é    N)ÚgettextFÚDbusmenuz0.4ÚUnityz7.0)r   r   Tzcan not import unity GI %sc                   @   s2   e Zd ZdZddd„Zdd„ Zdd„ Zd	d
„ ZdS )ÚIUnitySupportz interface for unity support Nc                 C   ó   d S ©N© )ÚselfÚparentr   r   ú</usr/lib/python3/dist-packages/UpdateManager/UnitySupport.pyÚ__init__(   ó   zIUnitySupport.__init__c                 C   r   r   r   ©r	   Úurgentr   r   r   Úset_urgency+   r   zIUnitySupport.set_urgencyc                 C   r   r   r   ©r	   Zvisibler   r   r   Úset_install_menuitem_visible.   r   z*IUnitySupport.set_install_menuitem_visiblec                 C   r   r   r   ©r	   Úprogressr   r   r   Úset_progress1   r   zIUnitySupport.set_progressr   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r   r   r   &   s    
r   c                   @   s:   e Zd ZdZddd„Zdd„ Zdd„ Zd	d
„ Zdd„ ZdS )ÚUnitySupportImplz9 implementation of unity support (if unity is available) Nc                 C   s(   t j d¡}|| _|r|  |¡ d S d S )Nzupdate-manager.desktop)r   ZLauncherEntryZget_for_desktop_idÚ_unityÚ_add_quicklist)r	   r
   Zum_launcher_entryr   r   r   r   8   s   ÿÿzUnitySupportImpl.__init__c                 C   sj   t j ¡ }t j ¡ | _| j t jtdƒ¡ | j t jd¡ | j 	d|j
d ¡ | | j¡ | j d|¡ d S )NzInstall All Available UpdatesTzitem-activatedÚ	quicklist)r   ZMenuitemÚnewÚinstall_dbusmenuitemZproperty_setZMENUITEM_PROP_LABELÚ_Úproperty_set_boolÚMENUITEM_PROP_VISIBLEZconnectZinstall_all_updatesZchild_appendr   Úset_property)r	   r
   r   r   r   r   r   @   s   
þÿÿzUnitySupportImpl._add_quicklistc                 C   sF   | j  d|d ¡ |dk s|dkr| j  dd¡ dS | j  dd¡ dS )	z set the progress [0,100] r   g      Y@r   éd   Zprogress_visibleFTN©r   r#   r   r   r   r   r   O   s   zUnitySupportImpl.set_progressc                 C   s   | j  d|¡ d S )Nr   r%   r   r   r   r   r   X   s   zUnitySupportImpl.set_urgencyc                 C   s   | j  tj|¡ d S r   )r   r!   r   r"   r   r   r   r   r   [   s   ÿz-UnitySupportImpl.set_install_menuitem_visibler   )	r   r   r   r   r   r   r   r   r   r   r   r   r   r   5   s    
	r   )Zloggingr   r    ZHAVE_UNITY_SUPPORTZgiZrequire_versionZgi.repositoryr   r   Ú
ValueErrorÚImportErrorÚeZwarningÚobjectr   r   ZUnitySupportr   r   r   r   Ú<module>   s$   €ÿ,