
    Je)                         d Z ddlmZ ddlmZmZ ddlmZm	Z	m
Z
mZ ddlmZ ddlmZ ddlmZmZmZ ddlmZ  G d	 d
      Z G d d      Z G d de      Z G d de      Zd Zedk(  r e        yy)z
Explorer Main Widget.
    N)QtSignal)QHBoxLayoutQLabelQVBoxLayoutQWidget_)PluginMainWidget)DirViewActionsExplorerTreeWidgetExplorerTreeWidgetActions)getcwd_or_homec                       e Zd ZdZdZdZy)!ExplorerWidgetOptionsMenuSectionsfiles_sectionheader_sectioncommon_sectionN)__name__
__module____qualname__FilesHeaderCommon     M/usr/lib/python3/dist-packages/spyder/plugins/explorer/widgets/main_widget.pyr   r      s    EFFr   r   c                       e Zd ZdZy)!ExplorerWidgetMainToolbarSectionsmain_sectionN)r   r   r   Mainr   r   r   r   r   !   s    Dr   r   c                   (    e Zd ZdZ ee      Z	  ee      Z	  ee      Z	  ee      Z		  ee      Z
	  eee      Z	  ee      Z	  eee      Z	  ee      Z	  ee      Z	 d fd	Zd Zd Zd Zd ZddZd Zd	 Zd
 Zd Zd ZddZd Z xZS )ExplorerWidgetzExplorer widgetc                 (   t         |   |||       t        |       | _        | j                  j	                          | j                  t                      t               }|j                  | j                         | j                  |       | j                  j                  j                  | j                         | j                  j                  j                  | j                         | j                  j                  j                  | j                         | j                  j                  j                  | j                         | j                  j                  j                  | j                         | j                  j                   j                  | j                          | j                  j"                  j                  | j"                         | j                  j$                  j                  | j$                         | j                  j&                  j                  | j&                         | j                  j(                  j                  | j(                         | j                  j*                  j                  | j*                         y)a  
        Initialize the widget.

        Parameters
        ----------
        name: str
            Name of the container.
        plugin: SpyderDockablePlugin
            Plugin of the container
        parent: QWidget
            Parent of this widget
        )pluginparentr&   N)super__init__r   
treewidgetsetupchdirr   r   	addWidget	setLayoutsig_dir_openedconnectsig_file_createdsig_open_file_requestedsig_module_createdsig_open_interpreter_requestedsig_renamedsig_removedsig_run_requestedsig_tree_removedsig_tree_renamedsig_redirect_stdio_requested)selfnamer%   r&   layout	__class__s        r   r)   zExplorerWidget.__init__   s    	fV< -D9 	

>#$ )v 	&&..t/B/BC((001F1FG//77((	***2243J3JK66>>//	1##++D,<,<=##++D,<,<=))11$2H2HI((001F1FG((001F1FG44<<--	/r   c                     | j                   S )zDefine the widget to focus.)r*   r;   s    r   get_focus_widgetzExplorerWidget.get_focus_widget   s    r   c                     t        d      S )z#Return the title of the plugin tab.r   r	   r@   s    r   	get_titlezExplorerWidget.get_title   s    zr   c                    | j                         }| j                  t        j                        | j                  t        j                        fD ]$  }| j                  ||t        j                         & | j                  t        j                        | j                  t        j                        | j                  t        j                        fD ]$  }| j                  ||t        j                         & | j                  t        j                        }| j                  ||t        j                         | j                         }| j                  t        j                         | j                  t        j"                        | j                  t        j$                        | j                  t        j&                        fD ]$  }| j)                  ||t*        j,                         & y)z0Performs the setup of plugin's menu and actions.)menusection)toolbarrF   N)get_options_menu
get_actionr   ToggleHiddenFilesEditNameFiltersadd_item_to_menur   r   ToggleSizeColumnToggleTypeColumnToggleDateColumnr   ToggleSingleClickr   get_main_toolbarr   PreviousNextParentToggleFilteradd_item_to_toolbarr   r!   )r;   rE   itemsingle_click_actionrG   s        r   r+   zExplorerWidget.setup   s    $$&__^%E%EF__^%C%CDF 	BD!!49@@ " B	B __^%D%DE__^%D%DE__^%D%DEG 	BD !!49@@ " B	B #oon.N.NO@FF 	 	H
 '')__%>%G%GH__%>%C%CD__%>%E%EF__%>%K%KLN 	@D $$g9>> % @		@r   c                      y)z+Handle the update of actions of the plugin.Nr   r@   s    r   update_actionszExplorerWidget.update_actions   s    r   c                 >    | j                   j                  ||       y)z
        Set working directory.

        Parameters
        ----------
        directory: str
            Directory to set as working directory.
        emit: bool, optional
            Default is True.
        )emitN)r*   r,   )r;   	directoryr\   s      r   r,   zExplorerWidget.chdir   s     	id3r   c                 6    | j                   j                         S )z&Get current folder in the tree widget.)r*   get_current_folderr@   s    r   r_   z!ExplorerWidget.get_current_folder   s    1133r   c                 :    | j                   j                  |       y)z
        Set the current folder in the tree widget.

        Parameters
        ----------
        folder: str
            Folder path to set as current folder.
        N)r*   set_current_folder)r;   folders     r   ra   z!ExplorerWidget.set_current_folder  s     	**62r   c                 8    | j                   j                          y)zMove to parent directory.N)r*   go_to_parent_directoryr@   s    r   rd   z%ExplorerWidget.go_to_parent_directory  s    ..0r   c                 8    | j                   j                          y)z&Move to previous directory in history.N)r*   go_to_previous_directoryr@   s    r   rf   z'ExplorerWidget.go_to_previous_directory  s    002r   c                 8    | j                   j                          y)z"Move to next directory in history.N)r*   go_to_next_directoryr@   s    r   rh   z#ExplorerWidget.go_to_next_directory  s    ,,.r   c                 <    | j                   j                  ||       y)z
        Refresh history.

        Parameters
        ----------
        new_path: str, optional
            Path to add to history. Default is None.
        force_current: bool, optional
            Default is True.
        N)r*   refresh)r;   new_pathforce_currents      r   rj   zExplorerWidget.refresh  s     	-8r   c                 :    | j                   j                  |       y)z
        Update history with directory.

        Parameters
        ----------
        directory: str
            Path to add to history.
        N)r*   update_history)r;   r]   s     r   rn   zExplorerWidget.update_history%  s     	&&y1r   )N)T)NF)r   r   r   __doc__r   strr/   r3   r1   r2   r6   r5   r8   r9   r7   r4   r)   rA   rC   r+   rZ   r,   r_   ra   rd   rf   rh   rj   rn   __classcell__r>   s   @r   r#   r#   &   s     C[N   c{ %Sk +K c"K	 c{ c3'	 s &,C[")/Z@B44	313/9	2r   r#   c                   $     e Zd Zdi f fd	Z xZS )FileExplorerTestNc                     d _         t         	          || _        n1t	        j
                  t	        j                  t                     _        t        d         _	         j                  j                  d|        j                  j                           j                  j                          t        d       _        t        d       _        t                _         j                  j#                  t$        j&                         t                _        t        d       _        t                _         j                  j/                   j                          j                  j#                  t$        j&                          j*                  j#                  t$        j&                         t1               }|j3                   j                         |j3                   j                          t1               }|j3                   j                         |j3                   j(                         t1               }|j3                   j*                         |j3                   j,                         t5               }|j3                   j                         |j7                  |       |j7                  |       |j7                  |        j9                  |        j                  j:                  j=                   j(                  j>                          j                  j:                  j=                   fd        j                  j@                  j=                   j                   j>                         y )Nexplorerr'   file_associationsz<b>Open dir:</b>z<b>Open file:</b>z<b>Option changed:</b>c                  N     j                   j                  j                  d      S )Nz..)rv   r*   rj   r@   s   r   <lambda>z+FileExplorerTest.__init__.<locals>.<lambda>f  s    DMM,,44T: r   )!CONF_SECTIONr(   r)   r]   ospdirnameabspath__file__r#   rv   set_conf_setupr+   r   	label_dir
label_filelabel1setAlignmentr   
AlignRightlabel2label_optionlabel3ra   r   r-   r   	addLayoutr.   r/   r0   setTextr2   )r;   r]   rw   hlayout1hlayout2hlayout3vlayoutr>   s   `      r   r)   zFileExplorerTest.__init__5  sV   & &DN [[X)>?DN&z4E24EF 23 !45h##BMM2h"#;<h 	((8$$R]]3&&r}}5 =4??+4;;'=4>>*4;;'=4,,-4;;'-$--((#(#(#w 	$$,,T[[-@-@A$$,,:	<--55dkk6I6IJr   )r   r   r   r)   rq   rr   s   @r   rt   rt   4  s    !% 2K 2Kr   rt   c                      ddl m}   |        }t               }|j                  dd       |j	                          |j                          y )Nr   )qapplicationi  i  )spyder.utils.qthelpersr   rt   resizeshowexec_)r   apptests      r   r   r   j  s4    3
.CDKKSIIKIIKr   __main__)ro   os.pathpathr{   qtpy.QtCorer   r   qtpy.QtWidgetsr   r   r   r   spyder.api.translationsr
   spyder.api.widgets.main_widgetr   (spyder.plugins.explorer.widgets.explorerr   r   r   spyder.utils.miscr   r   r   r#   rt   r   r   r   r   r   <module>r      s}   
  # D D & ;C C ,  
H2% H2\3Kw 3Kl zF r   