
    G@dx                          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dS )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/dS )Explorerz)File and Directories Explorer DockWidget.explorerFc                       t          d          S )zReturn widget titleFilesr        >lib/python3.11/site-packages/spyder/plugins/explorer/plugin.pyget_namezExplorer.get_name   s     zz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CCr   c                 ,    |                      d          S )zReturn the explorer icon.outline_explorer)create_iconr   s    r   get_iconzExplorer.get_icon   s      2333r   c                    |                                  }|j                            | j                   |j                            | j                   |j                            | j                   |j                            | j                   |j                            | j                   |j                            | j                   |j	                            | j
                   |j                            | j                   |j                            | j                   |j                            | j                   d S 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:::''(=>>>&..t/KLLL-55/	1 	1 	1!))$*ABBB""4#8999""4#8999 (()?@@@''(?@@@''(?@@@@@r   )pluginc                 2   |                      t          j                  j                            | j                   | j                            fd           | j                            j                   | j	                            j
                   | j                            j                   | j                            j                   | j                            j                   | j                            j                   d S )Nc                 0                         |           S )N)text)new)teditors    r   <lambda>z.Explorer.on_editor_available.<locals>.<lambda>   s    


0B0B 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0%%dj111%%&B&B&B&BCCC%%fn555%%fn555''(;<<<''(;<<<''
333$,,V[99999r   c                 n    |                      t          j                  }|                    |            d S r   )r9   r   Preferencesregister_plugin_preferencesr   preferencess     r   on_preferences_availablez!Explorer.on_preferences_available   s2     oog&9:://55555r   c                     |                      t          j                  | j                            j                   | j                            fd           d S )Nc                 Z                         | 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>   s6    !![''$ $	 "   r   )r9   r   IPythonConsoler$   r!   create_client_from_pathr*   r   rS   s    @r   on_ipython_console_availablez%Explorer.on_ipython_console_available   sq    __W%;<<
+33.	0 	0 	0&&   	
 	
 	
 	
 	
r   c                 (   |                      t          j                  }|j                            | j                   | j                                         | j                            |j                   | j	                            |j
                   | j                            |j                   | j                            |j                   | j                            |j                   | j                            |j                   d S 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0((444((***((888((888**6+>???**6+>???**6:666$//<<<<<r   c                 n    |                      t          j                  }|                    |            d S r   )r9   r   rD   deregister_plugin_preferencesrF   s     r   on_preferences_teardownz Explorer.on_preferences_teardown   s0    oog&9::11$77777r   c                     |                      t          j                  }| j                            |j                   | j                                         d S r   )r9   r   rT   r$   rY   rU   r*   rV   s     r   on_ipython_console_teardownz$Explorer.on_ipython_console_teardown   sR    __W%;<<
+66.	0 	0 	0))+++++r   Tc                 X    |                                                      ||           dS )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-     		55555r   c                 N    |                                                                  S )z#Get folder displayed at the moment.)r   get_current_folderr   s    r   rd   zExplorer.get_current_folder  s      33555r   Nc                     |                                  }|                    |           |                    ||           dS )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  sC     ""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3D#$H&7H%F!LL*I"' VC[[N vc{{ vc{{ vc3''	 %fSkk    S))	 &,VC[["   s   \D D D4 4 4
A A A  ///
: 
: 0/
:  34446 6 546
  6777
 
 87
 w~...
= 
= /.
= w23338 8 438 w5666, , 76,6 6 6 66 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      s    , +             & % % % % % < < < < < < < <- - - - - - - - F F F F F F ? ? ? ? ? ?x> x> x> x> x># x> x> x> x> x>r   