
    Jex                      z    d Z ddlmZ ddlmZ ddlmZ ddlm	Z	m
Z
 ddlmZmZ ddlmZ ddlmZ  G d	 d
e	      Zy)z%Files and Directories Explorer Plugin    N)Signal_)SpyderDockablePluginPlugins)on_plugin_availableon_plugin_teardown)ExplorerWidget)ExplorerConfigPagec                      e Zd ZdZdZej                  gZej                  ej                  gZ
ej                  ZeZeZeZdZdZ ee      Z	  ee      Z	  ee      Z	  eee      Z	  ee      Z	  ee      Z	  eee      Z	  ee      Z	  ee      Z	  ee      Z	 e d        Z!d Z"d Z#d Z$ e%ej                        d	        Z& e%ej                        d
        Z' e%ej                        d        Z( e)ej                        d        Z* e)ej                        d        Z+ e)ej                        d        Z,ddZ-d Z.ddZ/y)Explorerz)File and Directories Explorer DockWidget.explorerFc                      t        d      S )zReturn widget titleFilesr        @/usr/lib/python3/dist-packages/spyder/plugins/explorer/plugin.pyget_namezExplorer.get_name   s     zr   c                     t        d      S )z.Return the description of the explorer widget.z/Explore files in the computer with a tree view.r   selfs    r   get_descriptionzExplorer.get_description   s    BCCr   c                 $    | j                  d      S )zReturn the explorer icon.outline_explorer)create_iconr   s    r   get_iconzExplorer.get_icon   s      233r   c                    | 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 N)
get_widgetsig_dir_openedconnectsig_file_createdsig_open_file_requestedsig_open_interpreter_requestedsig_module_createdsig_removedsig_file_removedsig_renamedsig_file_renamedsig_run_requestedsig_tree_removedsig_folder_removedsig_tree_renamedsig_folder_renamed)r   widgets     r   on_initializezExplorer.on_initialize   s   " 	%%d&9&9:''(=(=>&&..t/K/KL--55//	1!!))$*A*AB""4#8#89""4#8#89  (()?)?@''(?(?@''(?(?@r   )pluginc                    | j                  t        j                        j                  j	                  | j
                         | j                  j	                  fd       | j                  j	                  j                         | j                  j	                  j                         | j                  j	                  j                         | j                  j	                  j                         | j                  j	                  j                          | j"                  j	                  j$                         y )Nc                 (    j                  |       S )N)text)new)teditors    r   <lambda>z.Explorer.on_editor_available.<locals>.<lambda>   s    


0B r   )
get_pluginr   Editorr    r!   chdirr"   r'   removedr)   renamedr,   removed_treer.   renamed_treer%   r5   r#   loadr   r7   s    @r   on_editor_availablezExplorer.on_editor_available   s    0%%djj1%%&BC%%fnn5%%fnn5''(;(;<''(;(;<''

3$$,,V[[9r   c                 d    | j                  t        j                        }|j                  |        y r   )r9   r   Preferencesregister_plugin_preferencesr   preferencess     r   on_preferences_availablez!Explorer.on_preferences_available   s&     oog&9&9://5r   c                     | j                  t        j                        | j                  j	                  j
                         | j                  j	                  fd       y )Nc                 T    j                  | t        j                  |       dd      S )NFT)filenamewdircurrent_clientclear_variables)
run_scriptospdirname)fname
ipyconsoles    r   r8   z7Explorer.on_ipython_console_available.<locals>.<lambda>   s0    !![['$ $	 "  r   )r9   r   IPythonConsoler$   r!   create_client_from_pathr*   r   rS   s    @r   on_ipython_console_availablez%Explorer.on_ipython_console_available   sM    __W%;%;<
++33..	0&&	
r   c                 |   | j                  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$                         y r   )r9   r   r:   r    
disconnectr;   r"   r'   r<   r)   r=   r,   r>   r.   r?   r%   r5   r#   r@   rA   s     r   on_editor_teardownzExplorer.on_editor_teardown   s    0((4((*((8((8**6+>+>?**6+>+>?**6::6$$//<r   c                 d    | j                  t        j                        }|j                  |        y r   )r9   r   rD   deregister_plugin_preferencesrF   s     r   on_preferences_teardownz Explorer.on_preferences_teardown   s$    oog&9&9:11$7r   c                     | j                  t        j                        }| j                  j	                  |j
                         | j                  j	                          y r   )r9   r   rT   r$   rY   rU   r*   rV   s     r   on_ipython_console_teardownz$Explorer.on_ipython_console_teardown   sE    __W%;%;<
++66..	0))+r   c                 F    | j                         j                  ||       y)a  
        Set working directory.

        Parameters
        ----------
        directory: str
            The new working directory path.
        emit: bool, optional
            Emit a signal to indicate the working directory has changed.
            Default is True.
        )emitN)r   r;   )r   	directoryra   s      r   r;   zExplorer.chdir   s     		5r   c                 >    | j                         j                         S )z#Get folder displayed at the moment.)r   get_current_folderr   s    r   rd   zExplorer.get_current_folder  s     3355r   Nc                 l    | j                         }|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.
        )force_currentN)r   update_historyrefresh)r   new_pathrf   r/   s       r   rh   zExplorer.refresh  s.     "h'x}=r   )T)NT)0__name__
__module____qualname____doc__NAMEr   rD   REQUIRESrT   r:   OPTIONALVariableExplorerTABIFYr
   WIDGET_CLASSCONF_SECTIONr   CONF_WIDGET_CLASS	CONF_FILEDISABLE_ACTIONS_WHEN_HIDDENr   strr    r"   r'   r)   r#   r,   r.   r$   r%   r*   staticmethodr   r   r   r0   r   rB   rH   rW   r	   rZ   r]   r_   r;   rd   rh   r   r   r   r   r      s   3D##$H&&7H%%F!LL*I"' C[N c{ c{ c3'	 %Sk    S)	 &,C["   s  D4
A  /
: 0
:  3 346 56
  6 67
 8
 w~~.
= /
= w2238 48 w556, 7,66>r   r   )rm   os.pathpathrP   qtpy.QtCorer   spyder.api.translationsr   spyder.api.pluginsr   r   )spyder.api.plugin_registration.decoratorsr   r	   +spyder.plugins.explorer.widgets.main_widgetr
    spyder.plugins.explorer.confpager   r   r   r   r   <module>r      s6    ,   & <- F ?x># x>r   