Sindbad~EG File Manager

Current Path : /usr/share/hplip/ui5/__pycache__/
Upload File :
Current File : //usr/share/hplip/ui5/__pycache__/filetable.cpython-310.pyc

o

�/�a�=�@s�ddlZddlZddlZddlZddlTddlmZmZddlm	Z	ddl
TddlTddlm
Z
mZmZddlTddlTddlTddlmZdZdZGdd	�d	e�ZdS)
�N)�*)�utils�magic)�cups�)�
to_unicode�to_string_utf8�from_unicode_to_str)�MimeTypesDialogc@s�eZdZe�Ze�Ze�Zdd�Zdd�Zdd�Z	dd�Z
d	d
�Zdd�Zd
d�Z
dd�Zd7dd�Zdd�Zdd�Zdd�Zd8dd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd9d5d6�Zd4S):�	FileTablecCsft�||�||_|��g|_t|_d|_d|_t	�
�|_t�|_
|j
��|j
��|j
j|_dS�N)�QWidget�__init__�parent�initUi�	file_list�FILETABLE_TYPE_PRINT�typ�selected_filename�fax_add_callbackr�getAllowableMIMETypes�allowable_mime_types�UserSettings�
user_settings�load�debug�working_dir)�selfr�r�!/usr/share/hplip/ui5/filetable.pyr8s


zFileTable.__init__cCs�t|�|_|j�d�t|�|_|j�d�|j�|jdddd�t|�|_|j�d�|j�|jdddd�t|�|_|j�d�|j�|jdddd�t|�|_	|j	�d�|j�|j	dd	dd�t|�|_
|j
�d
�|j�|j
dddd�tdd
tj
tj�}|j�|dddd�t|�|_|j�d�|j�|jdddd�|j�|�d��|j�ttdd���|jj�|j�|j�ttdd���|j�|�d��|jj�|j�|j	�|�d��|j	�ttdd���|j	j�|j�|j
�|�d��|j
�ttdd���|j
j�|j�|j�|�d��|j�ttdd���|jj�|j�|j�tj�|jj d�|j!�|�d�|�d�|�d�g|_"|j�#d �|jj$�|j%�dS)!N�
gridlayoutrrr��
AddFileButton�RemoveFileButton�MoveFileUpButton��MoveFileDownButton��[���ShowTypesButton�zAdd...�list_add�16x16�list_remove�RemovezMove Up�upz	Move Down�downzShow Valid Types...�	mimetypeszconst QPoint &�Name�TypezFolder/PathF)&�QGridLayoutr �
setObjectName�QTableWidgetr�	addWidget�QPushButtonr"r#r$r&�QSpacerItem�QSizePolicy�	Expanding�Minimum�addItemr+�setText�_FileTable__tr�setIcon�QIcon�load_pixmap�clicked�connect�AddFileButton_clicked�RemoveFileButton_clicked�MoveFileUpButton_clicked�MoveFileDownButton_clicked�ShowTypesButton_clicked�setContextMenuPolicy�Qt�CustomContextMenu�customContextMenuRequested�$FileTable_customContextMenuRequested�headers�setSortingEnabled�itemSelectionChanged�FileTable_itemSelectionChanged)r�
spacerItemrrrrKsT






zFileTable.initUicCstj�|�r||_dSdSr)�os�path�existsr)r�drrr�
setWorkingDir{s
�zFileTable.setWorkingDircCs8|jrtj�|jdd�|_|j|j_|j��|jS�Nr)rrVrW�pathnamerr�save�rrrr�
getWorkingDir�s


zFileTable.getWorkingDircCsT||_|jtkr&|�d�|�d�|�d�g|_t��r(|j�|�d��dSdSdS)Nr4r5�Pages�File)r�FILETABLE_TYPE_FAXrArQ�log�is_debug�append)r�trrr�setType�s
�zFileTable.setTypecCs
||_dSr)r)r�callbackrrr�setFaxCallback��
zFileTable.setFaxCallbackcCs
t|j�Sr)�lenrr^rrr�
isNotEmpty�rjzFileTable.isNotEmptycCs|��|_|��dSr)�currentFilenamer�setUpDownButtonsr^rrrrT�s
z(FileTable.FileTable_itemSelectionChangedTc
Cs�|j��|j�t|j��|j�d�|j�rK|j��t�	t
tj���zd}|j�t|j
��|j�|j
�tjtjB}t|j�D]�\}}|\}}}}	}
d}|jtkrf|	r]t|	�}nttj�|��}nttj�|��}|�tjt|��|�|�|jdur�|j|kr�|}|j�|||�|d7}t|�}|�|�|j�|||�|d7}|jtkr�ttj�|��}|�|�|j�|||�|d7}|jtk�r|
dkr�t|� d��}ntt|
��}|�|�|j�|||�|d7}|jtk�rt!�"��rt|�}|�|�|j�|||�qD|j�#�|du�r|j�$dd�}|�%d�|j�&|�Wt�'�nt�'�w|j(�)d�|j(�*t+t,dd���|�-�dS|j.��|j(�)d�|�-�|�re|j/j0��dSdS)Nrrz	(unknown)Tr/r.F)1r�clear�setRowCountrkr�setColumnCount�	isNotEmpt�emit�QApplication�setOverrideCursor�QCursorrM�
WaitCursorrQ�setHorizontalHeaderLabels�ItemIsSelectable�
ItemIsEnabled�	enumeraterrb�QTableWidgetItemrVrW�basename�setData�UserRoler�setFlagsr�setItemr�dirnamerArcrd�resizeColumnsToContents�item�setSelected�setCurrentItem�restoreOverrideCursorr#�
setEnabledrBrCrDrn�isEmptyr"rE)
r�show_add_file_if_empty�selected�flags�row�f�filename�	mime_type�mime_type_desc�title�	num_pages�col�irrr�updateUi�s|











�



�zFileTable.updateUicCs�|jr@|j��}t|j�dkr|t|j�dkr|j�d�n|j�d�t|j�dkr8|dkr8|j�d�dS|j�d�dS|j�d�|j�d�dS)NrTFr)rr�
currentRowrkr&r�r$�rr�rrrrn�s
 zFileTable.setUpDownButtonscCs�|jtkr|�d�}n.d}ztjdtjtjd�}|��\}}t|�}Wnty,Ynt	�
�Y|�d�}t�|||j
|�d��}dd�|d	D�}|ra|�|�|jtkrc|�d
�dSdSdS)NzSelect File(s) to Print��
getenforce)�stdout�stderrzSelect File(s) to Sendz
All files (*)cSsg|]}t|��qSr)r)�.0r�rrr�
<listcomp>&sz3FileTable.AddFileButton_clicked.<locals>.<listcomp>rF)rrrA�
subprocess�Popen�PIPE�communicater�OSErrorrc�	exception�QFileDialog�getOpenFileNamesr�addFileListr�)r�s�stat�p�err�filesrrrrGs(




�zFileTable.AddFileButton_clickedcCs|D]}|�|�qdSr)�
addFileFromUI)rrr�rrrr�/s�zFileTable.addFileListr�rc	Cstj�tj�|��}t�d|�tj�|�ryt�|tj�ryt	�
|�}|}t�d||f�zt|d}Wn+tya|j
tkrOt||�d�|�d��nt||�d�|�d��YdSYdSw|j
tkrr|�|||||�dS|�|�dSt||�d|�|�d��dS)NzTrying to add file: %szFile type of file %s: %sra(<b>You are trying to add a file  that cannot be directly printed with this utility.</b><p>To print this file, use the print command in the application that created it.<p>Note: Click <i>Show Valid Types...</i> to view a list of compatible file types that can be directly printed from this utility.zHP Device Managera]<b>You are trying to add a file  that cannot be directly faxed with this utility.</b><p>To fax this file, use the print command in the application that created it (using the appropriate fax print queue).<p>Note: Click <i>Show Valid Types...</i> to view a list of compatible file types that can be directly added to the fax file list in this utility.z~<b>Unable to add file '%s' to file list (file not found or insufficient permissions).</b><p>Check the file name and try again.)rVrW�abspath�
expanduserrcrrX�access�R_OKrr��MIME_TYPES_DESC�KeyErrorrr�	FailureUIrA�addFiler)rr�r�r�r�r�rrrr�4s0

�
���
�zFileTable.addFileFromUIcCsDt�d|||||f�|j�|||||f�|��|j��dS)NzAdding file %s (%s,%s,%s,%d))rcrrrer��fileListChangedrs)rr�r�r�r�r�rrrr�NszFileTable.addFilecCs0|j�|j��d�}|durdSt|�tj��Sr[)rr�r��	value_str�datarMrr�rrrrmVszFileTable.currentFilenamecCs|��}|dur
dS|�|�Sr)rm�
removeFile�rr�rrrrH^s
z"FileTable.RemoveFileButton_clickedc	Cs`|jdd�}d}|D]"\}}}}}|t|�kr)|j|=|j��|�d�dS|d7}qdS�NrFr)rrr�rsr�)	rr��temp�indexr�r�r�r�r�rrrr�fs


�zFileTable.removeFilec	Cs\|jdd�}d}|D] \}}}}}||kr'|j|=|j��|�d�dS|d7}qdSr�)rr�rsr�)	rr�r�r�r��mr�r�r�rrr�removeFileByMIMETypess


�zFileTable.removeFileByMIMETypecCs(|jD]\}}}}}||krdSqdS)NTF)r)rr�r�r�r�r�r�rrr�isMIMETypeInList�s
�zFileTable.isMIMETypeInListcCs6i}|jD]
}t�|d�||<qt||�}|��dS)N)�Unknownzn/a)rr��getr
�exec_)r�x�a�dlgrrrrK�s


z!FileTable.ShowTypesButton_clickedcC�2|��}|dur
dSt�|j||j�|��dSr)rmr�list_move_upr�_FileTable__compareFilenamesr�r�rrrrI��
z"FileTable.MoveFileUpButton_clickedcCr�r)rmr�list_move_downrr�r�r�rrrrJ�r�z$FileTable.MoveFileDownButton_clickedcCs|d|kSr[r)rr��brrr�__compareFilenames��zFileTable.__compareFilenamescCst|�dSr)�print)rr�rrrrP�r�z.FileTable.FileTable_customContextMenuRequestedNcCst�d||�S)Nr)�qApp�	translate)rr��crrr�__tr�szFileTable.__tr)T)r�rr) �__name__�
__module__�__qualname__�
pyqtSignalr�r�rrrrrZr_rgrirlrTr�rnrGr�r�r�rmrHr�r�r�rKrIrJr�rPrArrrrr2s:0

^


			r)�sys�os.pathrVr��base.g�baserr�prntr�
base.codes�ui_utils�base.sixextrrr	�PyQt5.QtCore�PyQt5.QtGui�PyQt5.QtWidgets�mimetypesdialogr
rrbr
rrrrr�<module>s"

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists