
    G@d                         d 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 ddlmZ dd	lmZ dd
lmZ  G d d          Z G d de          ZdS )z
Status bar plugin.
    )Slot)SpyderAPIError)PluginsSpyderPluginV2)on_plugin_availableon_plugin_teardown_)StatusBarWidget)running_under_pytest)StatusBarConfigPage)StatusBarContainerc                       e Zd ZdZdZdS )StatusBarWidgetPositionr   N)__name__
__module____qualname__LeftRight     ?lib/python3.11/site-packages/spyder/plugins/statusbar/plugin.pyr   r      s        DEEEr   r   c                      e Zd ZdZdZej        gZeZ	eZ
dZeZi Zi Zi Zi Zh dZed             Zd Zd Zd Zd	 Z eej        
          d             Z eej        
          d             Zd Zej        fdZ d Z!d Z"d Z#d Z$ e%e&          d             Z'e(d             Z)e(d             Z*e(d             Z+e(d             Z,d Z-d Z.dS )	StatusBarzStatus bar plugin.	statusbarF>   
cpu_status
eol_status
lsp_status
vcs_statuskite_statusclock_statusmemory_statusencoding_statuscompletion_statusread_write_statusinterpreter_statuscursor_position_statusapplication_update_statusc                       t          d          S )Nz
Status barr	   r   r   r   get_namezStatusBar.get_name4   s    r   c                 ,    |                      d          S )Nr   )create_iconselfs    r   get_iconzStatusBar.get_icon8   s    ,,,r   c                      t          d          S )Nz&Provide Core user interface managementr	   r.   s    r   get_descriptionzStatusBar.get_description;   s    9:::r   c                     |                      | j        t          j                   |                      | j        t          j                   |                      | j        t          j                   d S N)add_status_widget
mem_statusr   r   r   r"   r.   s    r   on_initializezStatusBar.on_initialize>   sh    t0G0MNNNt0G0MNNN6<	> 	> 	> 	> 	>r   c                 :    | j                             d           d S )NF
_statusbar
setVisible)r/   _unuseds     r   on_closezStatusBar.on_closeE   s    ""5)))))r   )pluginc                 n    |                      t          j                  }|                    |            d S r4   )
get_pluginr   Preferencesregister_plugin_preferencesr/   preferencess     r   on_preferences_availablez"StatusBar.on_preferences_availableH   s0    oog&9:://55555r   c                 n    |                      t          j                  }|                    |            d S r4   )r@   r   rA   deregister_plugin_preferencesrC   s     r   on_preferences_teardownz!StatusBar.on_preferences_teardownM   s0    oog&9::11$77777r   c                 l    |                                  }|j                            | j                   d S r4   )get_containersig_show_status_bar_requestedconnectshow_status_bar)r/   	containers     r   after_container_creationz"StatusBar.after_container_creationR   s>    &&((	/77 	
 	
 	
 	
 	
r   c                    t          |t                    st          d          |j        }| t          dt	          |           d          || j        v r!t                      st          d| d          || j        v r|| j        |<   n%|t          j
        k    r|| j        |<   n
|| j        |<   || j        |<   | j                            d           |t          j
        k    r| j                            |           n%| j                            t          j        |           | j                                                            dddd           | j                                                            d           dS )aI  
        Add status widget to main application status bar.

        Parameters
        ----------
        widget: StatusBarWidget
            Widget to be added to the status bar.
        position: int
            Position where the widget will be added given the members of the
            StatusBarWidgetPosition enum.
        z0Any status widget must subclass StatusBarWidget!NzStatus widget `z` doesn't have an identifier!z` already added!z QStatusBar::item {border: None;}r   )
isinstancer   r   IDreprSTATUS_WIDGETSr   INTERNAL_WIDGETS_IDSINTERNAL_WIDGETSr   r   EXTERNAL_RIGHT_WIDGETSEXTERNAL_LEFT_WIDGETSr:   setStyleSheetaddPermanentWidgetinsertPermanentWidgetr   layoutsetContentsMargins
setSpacing)r/   widgetpositionid_s       r   r5   zStatusBar.add_status_widgetY   s    &/22 	 B  
 i; M$v,,MMM  
 $%%%.B.D.D% !H3!H!H!HIII$+++)/D!#&&0666/5D',,.4D&s+#)C %%&HIII.444O..v6666O11',f6 6 6  33Aq!Q???  ++A.....r   c                     	 |                      |          }| j                            |           | j                            |           dS # t
          $ r Y dS w xY w)z
        Remove widget from status bar.

        Parameters
        ----------
        id_: str
            String identifier for the widget.
        N)get_status_widgetrT   popr:   removeWidgetRuntimeError)r/   ra   r_   s      r   remove_status_widgetzStatusBar.remove_status_widget   sq    	++C00F##C(((O((00000 	 	 	 DD	s   A	A 
AAc                 T    || j         v r| j         |         S t          d| d          )z
        Return an application status widget by name.

        Parameters
        ----------
        id_: str
            String identifier for the widget.
        zStatus widget "z" not found!)rT   r   )r/   ra   s     r   rc   zStatusBar.get_status_widget   s:     $%%%&s++ !D3!D!D!DEEEr   c                 N    t          | j                                                  S )zReturn all status widgets.)listrT   keysr.   s    r   get_status_widgetszStatusBar.get_status_widgets   s    D',,..///r   c                 ^    |                                  D ]}|                     |           dS )zRemove all status widgets.N)rl   rg   )r/   ws     r   remove_status_widgetszStatusBar.remove_status_widgets   s>    ((** 	) 	)A%%a((((	) 	)r   c                 :    | j                             |           dS )z
        Show/hide status bar.

        Parameters
        ----------
        value: bool
            Decide whether to show or hide the status bar.
        Nr9   )r/   values     r   rM   zStatusBar.show_status_bar   s      	""5)))))r   c                 4    |                                  j        S r4   )rJ   r6   r.   s    r   r6   zStatusBar.mem_status       !!##..r   c                 4    |                                  j        S r4   )rJ   r   r.   s    r   r   zStatusBar.cpu_status   rs   r   c                 4    |                                  j        S r4   )rJ   r"   r.   s    r   r"   zStatusBar.clock_status   s    !!##00r   c                 4    | j                                         S )z$Reference to main window status bar.)_main	statusBarr.   s    r   r:   zStatusBar._statusbar   s     z##%%%r   c                 |   g d}t          | j                                                  }| j        D ]'}| j                            | j        |                    (| j        D ]'}| j                            | j        |                    (|D ][}|| j        v rP| j                            t          j        | j        |                    | j        |         	                    d           \|D ]R}| j                            t          j        | j        |                    | j        |         	                    d           SdS )zQ
        Organize the status bar widgets once the application is loaded.
        )r"   r   r#   r&   r   r$   r(   r    r   r!   r%   r'   r)   TN)
rj   rX   rk   rV   r:   re   r[   r   r   r;   )r/   internal_layoutexternal_leftra   s       r   _organize_status_widgetsz"StatusBar._organize_status_widgets   sm   
? ? ?
 T7<<>>?? ( 	E 	ECO(()>s)CDDDD- 	J 	JCO(()CC)HIIII # 	< 	<Cd+++55+0$2G2LN N N%c*55d;;; ! 	= 	=CO11',d.H.MO O O&s+66t<<<<	= 	=r   c                 b    | j                             d           |                                  dS )z0Perform actions before the mainwindow is visibleFN)r:   r;   r|   r.   s    r   before_mainwindow_visiblez#StatusBar.before_mainwindow_visible   s2     	""5)))%%'''''r   N)/r   r   r   __doc__NAMEr   rA   REQUIRESr   CONTAINER_CLASSCONF_SECTION	CONF_FILEr   CONF_WIDGET_CLASSrT   rW   rX   rV   rU   staticmethodr+   r0   r2   r7   r=   r   rE   r   rH   rO   r   r   r5   rg   rc   rl   ro   r   boolrM   propertyr6   r   r"   r:   r|   r~   r   r   r   r   r      s3       D#$H(OLI+N; ; ;   \- - -; ; ;> > >* * *  34446 6 546 w23338 8 438
 
 
 2I1M -/ -/ -/ -/^  $F F F0 0 0) ) )
 
T$ZZ	* 	* Z	* / / X/ / / X/ 1 1 X1 & & X&= = =B( ( ( ( (r   r   N)r   qtpy.QtCorer   spyder.api.exceptionsr   spyder.api.pluginsr   r   )spyder.api.plugin_registration.decoratorsr   r   spyder.api.translationsr
   spyder.api.widgets.statusr   spyder.config.baser   !spyder.plugins.statusbar.confpager   "spyder.plugins.statusbar.containerr   r   r   r   r   r   <module>r      s7   
       1 0 0 0 0 0 6 6 6 6 6 6 6 6- - - - - - - - % % % % % % 5 5 5 5 5 5 3 3 3 3 3 3 A A A A A A A A A A A A       
V( V( V( V( V( V( V( V( V( V(r   