o
    Q`s                     @   s^   d dl Z d dlZedd d dlmZ d dlmZ d dlmZ d dl	m
Z
 G dd	 d	ZdS )
    NGtkz3.0)r   )gettext)SourceEntry)setup_uic                   @   s$   e Zd Zdd Zdd Zdd ZdS )	DialogAddc                 C   s   || _ || _|| _t| tj|dddd | j| _| j	| j | j
| _| j| _| jd| j |rEd|j|jj|j|jjd jf }nd}td	d
|  }| j| dS )z]
    Initialize the dialog that allows to add a new source entering the
    raw apt line
    Z
gtkbuilderzdialog-add.uizsoftware-properties)domainZchangedz%s %s %s %sr   z$deb http://ftp.debian.org sarge mainz[The APT line includes the type, location and components of a repository, for example  '%s'.z	<i>%s</i>N)sourceslistparentdatadirr   ospathjoinZdialog_add_customdialogZset_transient_forZentry_source_lineentryZbutton_add_source
button_addZconnect
check_lineZbinary_typeZsource_templateZbase_uriZcodenameZ
componentsname_Zlabel_example_lineZ	set_label)selfr	   r   r
   ZdistroZexamplemsg r   B/usr/lib/python3/dist-packages/softwareproperties/gtk/DialogAdd.py__init__'   s(   zDialogAdd.__init__c                 C   s:   | j  }| j   |tjjkr| j d }|S d }|S )N
)r   runZhider   ZResponseTypeZOKr   get_text)r   resliner   r   r   r   D   s   

zDialogAdd.runc                 G   sd   | j  d }|dr| jd dS t|}|jdks"|jdkr*| jd dS | jd dS )zb
    Check for a valid apt line and set the sensitiveness of the
    button 'add' accordingly
    r   zppa:TNF)r   r   
startswithr   Zset_sensitiver   ZinvalidZdisabled)r   argsr   Zsource_entryr   r   r   r   M   s   
zDialogAdd.check_lineN)__name__
__module____qualname__r   r   r   r   r   r   r   r   &   s    	r   )r   ZgiZrequire_versionZgi.repositoryr   r   r   Zaptsources.sourceslistr   Zsoftwareproperties.gtk.utilsr   r   r   r   r   r   <module>   s   