
    Je<                     8    d Z ddlmZmZ ddlmZ  G d d      Zy)z3
Mixin to connect a plugin to the IPython console.
    )on_plugin_availableon_plugin_teardown)Pluginsc                       e Zd ZdZ eej                        d        Z eej                        d        Z	d Z
d Zd Zd Zy	)
ShellConnectMixinz
    Mixin to connect a plugin composed of stacked widgets to the shell
    widgets in the IPython console.

    It is assumed that self.get_widget() returns an instance of
    ShellConnectMainWidget
    )pluginc                 j   | j                  t        j                        }|j                  j	                  | j
                         |j                  j	                  | j                         |j                  j	                  | j                         |j                  j	                  | j                         y)zConnect to the IPython console.N)
get_pluginr   IPythonConsolesig_shellwidget_changedconnectset_shellwidgetsig_shellwidget_createdadd_shellwidgetsig_shellwidget_deletedremove_shellwidget$sig_external_spyder_kernel_connected'on_connection_to_external_spyder_kernelself
ipyconsoles     @/usr/lib/python3/dist-packages/spyder/api/shellconnect/mixins.pyon_ipython_console_availablez.ShellConnectMixin.on_ipython_console_available   s     __W%;%;<
**2243G3GH**2243G3GH**2243J3JK77??88	:    c                 j   | j                  t        j                        }|j                  j	                  | j
                         |j                  j	                  | j                         |j                  j	                  | j                         |j                  j	                  | j                         y)z$Disconnect from the IPython console.N)r
   r   r   r   
disconnectr   r   r   r   r   r   r   r   s     r   on_ipython_console_teardownz-ShellConnectMixin.on_ipython_console_teardown&   s     __W%;%;<
**55d6J6JK**55d6J6JK**55d6M6MN77BB88	:r   c                 B    | j                         j                  |       y)z
        Update the current shellwidget.

        Parameters
        ----------
        shellwidget: spyder.plugins.ipyconsole.widgets.shell.ShellWidget
            The shell widget.
        N)
get_widgetr   r   shellwidgets     r   r   z!ShellConnectMixin.set_shellwidget3   s     	))+6r   c                 B    | j                         j                  |       y)a-  
        Add a new shellwidget to be registered.

        This function registers a new widget to display content that
        comes from shellwidget.

        Parameters
        ----------
        shellwidget: spyder.plugins.ipyconsole.widgets.shell.ShellWidget
            The shell widget.
        N)r   r   r    s     r   r   z!ShellConnectMixin.add_shellwidget>   s     	))+6r   c                 B    | j                         j                  |       y)z
        Remove the registered shellwidget.

        Parameters
        ----------
        shellwidget: spyder.plugins.ipyconsole.widgets.shell.ShellWidget
            The shell widget.
        N)r   r   r    s     r   r   z$ShellConnectMixin.remove_shellwidgetL   s     	,,[9r   c                      y)a4  
        Actions to take when the IPython console connects to an
        external Spyder kernel.

        Parameters
        ----------
        shellwidget: spyder.plugins.ipyconsole.widgets.shell.ShellWidget
            The shell widget that was connected to the external Spyder
            kernel.
        N r    s     r   r   z9ShellConnectMixin.on_connection_to_external_spyder_kernelW   s     	r   N)__name__
__module____qualname____doc__r   r   r   r   r   r   r   r   r   r   r%   r   r   r   r      sY      6 67: 8: w556: 7:	77	:r   r   N)r)   )spyder.api.plugin_registration.decoratorsr   r   spyder.api.pluginsr   r   r%   r   r   <module>r,      s   - &R Rr   