
    G@d                     h   d Z ddlZddlZddlZddlmZmZmZm	Z	m
Z
 ddlmZmZ ddlmZ ddlmZmZ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m Z  ddl!m"Z"m#Z#m$Z$ ddl%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+ ddl,m-Z- ddl.m/Z/m0Z0 ddl1m2Z2  ej3        e4          Z5 ee&          Z6dZ7 G d de          Z8dS )z
Layout Plugin.
    N)Qt
QByteArrayQSizeQPointSlot)QApplicationQDesktopWidget)SpyderAPIError)PluginsDockablePluginsSpyderDockablePluginSpyderPluginV2)on_plugin_availableon_plugin_teardown)PLUGIN_REGISTRY_)get_class_values)ApplicationMenusViewMenuSections)LayoutContainerLayoutContainerActionsLayoutPluginMenus)DefaultLayoutsHorizontalSplitLayoutMatlabLayoutRLayoutSpyderLayoutVerticalSplitLayout)PreferencesActions)ApplicationToolbarsMainToolbarSections)qbytearray_to_str   c                   |   e Zd ZdZdZdZej        gZdZ	e
Zd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d Zd Zd Zd Zd Zd Zd Z d Z!d Z"d Z#d Z$d2dZ%d Z&d Z'd3dZ(d Z)d Z*	 	 d4d Z+ e,            d!             Z-e.d"             Z/d2d#Z0d$ Z1d% Z2d5d'Z3 e,            d(             Z4e.d)             Z5d* Z6e.d+             Z7d5d,Z8d- Z9d. Z:d/ Z;d5d0Z<d1 Z=d&S )6Layoutz 
    Layout manager plugin.
    layoutquick_layoutsFc                       t          d          S )Nr&   r        <lib/python3.11/site-packages/spyder/plugins/layout/plugin.pyget_namezLayout.get_nameO   s    {{r+   c                      t          d          S )NzLayout managerr   selfs    r,   get_descriptionzLayout.get_descriptionS   s    !"""r+   c                 ,    |                      d          S )Nhistory)create_iconr/   s    r,   get_iconzLayout.get_iconV   s    	***r+   c                    d | _         d| _        d | _        d | _        d | _        d | _        |                     dd          | _        |                     | t                     |                     | t                     |                     | t                     |                     | t                     |                     | t                     |                                  d S )NFpanes_lockedmainsection)_last_plugin_first_spyder_run_fullscreen_flag_maximized_flag_saved_normal_geometry_state_before_maximizingget_conf_interface_lockedregister_layoutr   r   r   r   r   _update_fullscreen_actionr/   s    r,   on_initializezLayout.on_initializeY   s     !& $  $ '+#(,%!%~v!N!N 	T<000T7+++T<000T#8999T#6777&&(((((r+   )pluginc                    |                      t          j                  }|                                 }|j        |j        |j        |j        g}|D ]9}|                    |t          j
        t          j        t          j                   :|j        |j        |j        g}|D ]9}|                    |t          j
        t          j        t          j                   :|                    |j        t          j
        t          j                   d S )N)menu_idr:   before_section)rH   r:   )
get_pluginr   MainMenuget_container_plugins_menu_lock_interface_action_close_dockwidget_action_maximize_dockwidget_actionadd_item_to_application_menur   Viewr   PaneToolbar_layouts_menu_toggle_next_layout_action_toggle_previous_layout_actionr&   Bottom_fullscreen_action)r0   mainmenu	containerpanes_items
panes_itemlayout_itemslayout_items          r,   on_main_menu_availablezLayout.on_main_menu_availableo   s.   ??7#344&&((	 #,.1	3
 & 	9 	9J11(-(-/7	 2 9 9 9 9 #046 ( 	8 	8K11(-(//6	 2 8 8 8 8 	--($)$+ 	. 	- 	- 	- 	- 	-r+   c                     |                                  }|                     t          j                  }|                    |j        t          j        t          j	        t          j                   d S )N)
toolbar_idr:   before)rL   rJ   r   rT   add_item_to_application_toolbarrP   r!   Mainr"   ApplicationSectionr    Show)r0   r[   toolbarss      r,   on_toolbar_availablezLayout.on_toolbar_available   se    &&((	??7?33001*/':%*	 	1 	
 	
 	
 	
 	
r+   c                    |                      t          j                  }t          j        t
          j        t
          j        t
          j        g}|D ]#}|	                    |t          j                   $t          j        t
          j        t
          j        g}|D ]#}|	                    |t          j                   $|	                    t
          j        t          j                   d S )N)rH   )rJ   r   rK   r   PluginsMenur   LockDockwidgetsAndToolbarsCloseCurrentDockwidgetMaximizeCurrentDockwidget!remove_item_from_application_menur   rR   LayoutsMenu
NextLayoutPreviousLayout
Fullscreen)r0   rZ   r\   r]   r^   r_   s         r,   on_main_menu_teardownzLayout.on_main_menu_teardown   s    ??7#344 )"="9"<	>
 & 	/ 	/J66(- 7 / / / /
 )"-"13 ( 	/ 	/K66(- 7 / / / / 	22"-$) 	3 	+ 	+ 	+ 	+ 	+r+   c                     |                      t          j                  }|                    t          j        t          j                   d S )N)rb   )rJ   r   rT   $remove_item_from_application_toolbarr   rn   r!   re   )r0   rh   s     r,   on_toolbar_teardownzLayout.on_toolbar_teardown   sJ    ??7?33 	55"<*/ 	6 	
 	
 	
 	
 	
r+   c                 Z    |                                   |                     d           d S )NFdefault)update_layout_menu_actionssetup_layoutr/   s    r,   before_mainwindow_visiblez Layout.before_mainwindow_visible   s1    '')))%(((((r+   c                     |                                   |                                  |                     | j                   d S N)create_plugins_menurestore_visible_pluginstoggle_lockrB   r/   s    r,   on_mainwindow_visiblezLayout.on_mainwindow_visible   sI     	  """ 	$$&&& 	/00000r+   c                 *    t          t                    S )z)Get the list of internal dockable plugins)r   r   r/   s    r,   _get_internal_dockable_pluginsz%Layout._get_internal_dockable_plugins   s    000r+   c                     | j         r|                     d          }n|                     d          }|                                 j                            |           d S )Nwindow_nofullscreenwindow_fullscreen)r=   r4   rL   rY   setIcon)r0   icons     r,   rD   z Layout._update_fullscreen_action   s`      	9##$9::DD##$788D/77=====r+   c                    | j         r%|                     d          }t          d          }n$|                     d          }t          d          }| j                            |           | j                            |           dS )z
        Helper method to update the locking of panes/dockwidgets and toolbars.

        Returns
        -------
        None.
        drag_dock_widgetzUnlock panes and toolbarslockzLock panes and toolbarsN)rB   r4   r   lock_interface_actionr   setText)r0   r   texts      r,   _update_lock_interface_actionz$Layout._update_lock_interface_action   s     ! 	0##$677D011DD##F++D.//D"**4000"**400000r+   c                     | j         S )z
        Return the last focused dockable plugin.

        Returns
        -------
        SpyderDockablePlugin
            The last focused dockable plugin.
        )r;   r/   s    r,   get_last_pluginzLayout.get_last_plugin   s       r+   c                     | j         S )z
        Give access to the fullscreen flag.

        The flag shows if the mainwindow is in fullscreen mode or not.

        Returns
        -------
        bool
            True is the mainwindow is in fullscreen. False otherwise.
        )r=   r/   s    r,   get_fullscreen_flagzLayout.get_fullscreen_flag  s     $$r+   c                 V    |                                                      ||           dS )a  
        Register a new layout type.

        Parameters
        ----------
        parent_plugin: spyder.api.plugins.SpyderPluginV2
            Plugin registering the layout type.
        layout_type: spyder.plugins.layout.api.BaseGridLayoutType
            Layout to register.
        N)rL   rC   )r0   parent_pluginlayout_types      r,   rC   zLayout.register_layout  s,     	,,]KHHHHHr+   c                 0   t           j        D ]}|                     |          }t          |d          rat	          |j        t                    r!|j        D ]}|                     | |           bt          	                    d| d|j         d           dS )z5Register custom layouts provided by external plugins.CUSTOM_LAYOUTSz)Unable to load custom layouts for plugin z-. Expecting a list of layout classes but got .N)
r   external_pluginsrJ   hasattr
isinstancer   listrC   loggerinfo)r0   plugin_nameplugin_instancecustom_layouts       r,   register_custom_layoutszLayout.register_custom_layouts  s    *; 	 	K"ook::O(899 	o<dCC )8)G B B,,T=AAAAB KKE&E E#2#AE E E  	 	r+   c                 P    |                                                      |          S )a  
        Get a registered layout by his ID.

        Parameters
        ----------
        layout_id : string
            The ID of the layout.

        Returns
        -------
        Instance of a spyder.plugins.layout.api.BaseGridLayoutType subclass
            Layout.
        )rL   
get_layout)r0   	layout_ids     r,   r   zLayout.get_layout,  s$     !!##..y999r+   c                 R    |                                                                   d S r   )rL   r{   r/   s    r,   r{   z!Layout.update_layout_menu_actions<  s&    7799999r+   c                    d}|                      ||          }|d         }d| _        |7| j                            t          j                   d| _        |                     t          j        |           d}|r| j	        n| j
        } |d|          }|r\|                     d	||           |                     d||           |                     d
||           |                     d||           t          |          D ]2\  }}	d                    |          }|                     ||d           3d}d}|                     ||d           t          j        | _         | j        |  dS )zInitialize mainwindow layout.zwindow/r   FNTr(   orderr9   activenamesui_nameszlayout_{0}/)
none_statezlayout_default/)load_window_settingsr<   r8   setWindowStater   WindowMaximizedsetup_default_layoutsr   r   get_conf_defaultrA   set_conf	enumerateformatsave_current_window_settings_current_quick_layoutset_window_settings)
r0   rz   prefixsettingshexstater:   get_funcr   index_names
             r,   r|   zLayout.setup_layout?  s   ,,VW==A;!&I$$R%7888%)D"&&~'BHMMM &G07Jt,,T]HHWg666E  :hw777gug666gug666j%999!*5!1!1 C Cu&--e4411&'=A 2 C C C C 'F%G--fg$-OOO)7)DD&  (++++r+   c                    | j         }|                    d           t          | j                  }|r | j        |  n| j        r"| j        j        r|                     d           |                                s| j	        s|
                                 |                                }|                                }|                                }|                    |           |                     |          }|                    | j         |                                            |rd| _        nm| j                             |           | j                             |           | j                                         s | j	        s| j         
                                 | j                             d           | j         j                            |           |S )z2Setup default layouts when run for the first time.FTrestore)r8   setUpdatesEnabledboolr<   r   r;   _ismaximizedmaximize_dockwidgetisMaximizedr>   showMaximizedminimumWidthmaximumWidthwidthsetFixedWidthr   set_main_window_layoutget_dockable_pluginssetMinimumWidthsetMaximumWidthsig_layout_setup_readyemit)	r0   r   r   r8   first_spyder_run	min_width	max_width
base_widthr'   s	            r,   r   zLayout.setup_default_layoutsh  s   yu%%% 677 	+$D$h///  ;$1 ;,,T,:::$$&& %$*> %""$$$))++I))++IJz*** ++ 	%%di1J1J1L1LMMM 	*%*D""I%%i000I%%i000I))++ *t/C *	'')))	##D)))	(--f555r+   c           	         d}|                                  }	 |                     d                    |          |          }|\  }}}}}	}
|R|t          vr2|                    t          d          t          d                     dS |                     ||           n
 | j        |  n# t          j	        $ r 	 | 
                    |          }|                    | j        |                                            | j        j                            |           nP# t           $ rC |                    t          d          t          d          t#          |          z             Y nw xY wY nw xY w|                                 D ]N}	 |j        }n# t&          $ r
 |j        }Y nw xY w|                    |j                                                   O|S )z
        Switch to quick layout.

        Using a number *index* or a registered layout id *layout_id*.

        Parameters
        ----------
        index_or_layout_id: int or str
        r(   z
layout_{}/r9   NWarningzError opening the custom layout.  Please close Spyder and try again.  If the issue persists, then you must use 'Reset to Spyder default' from the layout menu.z1Quick switch layout #%s has not yet been defined.)rL   r   r   DEFAULT_LAYOUTScritical_messager   r   r   cpNoOptionErrorr   r   r8   r   r   r   r
   strtoggle_view_actionAttributeError_toggle_view_action
setChecked
dockwidget	isVisible)r0   index_or_layout_idr:   r[   r   r   window_sizeprefs_dialog_sizeposis_maximizedis_fullscreenr'   rF   actions                 r,   quick_layout_switchzLayout.quick_layout_switch  sY    "&&((	"	B00##$677 1 J JH 'X{$5sL
  &_<<..) 2 3 34 4 4 F**+=xHHHH(((33 
	B 
	B 
	B	B);<<--It88::< < <	055f====! B B B**iLL & ' '),-?)@)@AB B B B BB
	B //11 	= 	=F42! 4 4 434 f/99;;<<<<!!sP   A.B* !B* *E/:A!DE/A
E)&E/(E))E/.E/	FF%$F%r8   c                 (   |r| j         n| j        } ||dz   |          } ||dz   |          }|rd}n$	  ||dz   |          }n# t          $ r d}Y nw xY w ||dz   |          }|d         }	|d         }
t          j                                                    }|                                }|                                }||	k     s||
k     r|                      |dz   |          } ||d	z   |          } ||d
z   |          }||||||fS )z
        Load window layout settings from userconfig-based configuration with
        *prefix*, under *section*.

        Parameters
        ----------
        default: bool
            if True, do not restore inner layout.
        sizer9   r   Nstatepositionr      r   r   )r   rA   	Exceptionr   desktopgeometryr   height)r0   r   rz   r:   r   r   r   r   r   r   r   screen_shapecurrent_widthcurrent_heightr   r   s                   r,   r   zLayout.load_window_settings  s    -4F4((hv@@@$H(('; ; ;  	 HH #8FW$4gFFF        hv
*G<<< AQ#+--6688$**,,%,,..5  NV$;$;''(;WEECx 7III /!97KKK+'8#| 	s   A AAc                    | j                                         | j                                         f}| j                                        }|r| j        }n| j                                        }| j                                        | j        	                                f}| j
                                        | j
                                        f}t          | j                            t                              }||||||fS )zh
        Return current window settings.

        Symetric to the 'set_window_settings' setter.
        version)r   r   r   r8   isFullScreenr>   r   window_positionxyr   r#   	saveStateWINDOW_STATE_VERSION)r0   r   r   r   r   r   r   s          r,   get_window_settingszLayout.get_window_settings  s     '--//1A1H1H1J1JK	..00 	3/LL90022L#%%'')=)?)?)A)AB!399;;!3::<<> %I(<==
 
 +'8#| 	r+   c                    | j         }|                    d           t          |d         |d                   | _        |                    | j                   t          |d         |d                   | _        t          |d         |d                   | _        |                    t          j
                   |                    | j                   |                    | j                   |r| j                             t                                          t!          |                              d                    t$                    }|s2| j                             d           |                     d           dS |r$| j                             t          j                   |r|| _        n&|r$| j                             t          j                   | j                             d           dS )	zU
        Set window settings Symetric to the 'get_window_settings' accessor.
        Fr   r   zutf-8r   Try   N)r8   r   r   r   set_prefs_sizer   r   r   r   r   WindowNoStateresizemoverestoreStater   fromHexr   encoder  r|   WindowFullScreenr>   r   )	r0   r   r   r   r   r   r   r8   hexstate_valids	            r,   r   zLayout.set_window_settings  s   
 yu%%%!&'8';'8';"= "=D2333 Q!,Q1 1%c!fc!f55B,---D$%%%		$&'''  	!Y33$$S]]%9%9'%B%BCC, 4  N " 	++D111!!$!///  	:I$$R%8999  	9#/D   	9I$$R%7888	##D)))))r+   c                 H   | j                                         }| j                                         }| j        }|                     |dz   |                                |                                f|           |                     |dz   |                                |                                f|           |                     |dz   | j                                         |           |                     |dz   | j                                         |           |                     |dz   |	                                |
                                f|           |                     d           |r|                     |d	z   d
|           nH| j                             t                    }|                     |d	z   t          |          |           |                     |dz   | j                                                                          |           d
S )z
        Save current window settings.

        It saves config with *prefix* in the userconfig-based,
        configuration under *section*.
        r   r9   r   r   r   r   Tr   r   Nr   	statusbar)r8   r   r   r   r   r   r   r   r   r   r   r   r   r  r#   	statusBarisHidden)r0   r   r:   r   win_sizer   
prefs_sizeqbas           r,   r   z#Layout.save_current_window_settings=  sU    9>>##immoo+
VO^^x001 	 	
 	
 	

 	((!2!2!4!45 	 	
 	
 	

 	^#I!!## 	 	
 	
 	

 	_$I""$$ 	 	
 	
 	

 	ZUUWWceegg 	 	
 	
 	
 	   ... 	MM       )%%.B%CCCMM !#&&     	[ 	##%%..000 	 	
 	
 	
 	
 	
r+   c                 j   t          j                    }|                                 D ]}	 |                                                    |          r|j                            d            dS H# t          $ r6 |                    |          r|j                            d           Y  dS Y w xY wdS )z5Search for the currently focused plugin and close it.FN)	r   focusWidgetr   
get_widgetisAncestorOfr   r   r   r   )r0   widgetrF   s      r,   close_current_dockwidgetzLayout.close_current_dockwidget}  s     )++//11 	 	F	$$&&33F;; -88???EE "   &&v.. .99%@@@EEE 	 	s   AA009B0/B0c                 4    |                                  j        S )z*Expose maximize current dockwidget action.)rL   rP   r/   s    r,   maximize_actionzLayout.maximize_action  s     !!##??r+   c                    | j         |rdS | j                            t                    | _         t	          j                    }|                                 D ]v}|j                                         	 |	                                
                    |          r|| _        K# t          $ r |
                    |          r|| _        Y sw xY w| j        $|                     t          j                  | _        | j        j                                                            d           	 | j                            | j        	                                           | j        	                                                    d           n;# t(          $ r. | j                            | j                   d| j        _        Y nw xY w	 | j        	                                                                 | j                            d           nC# t(          $ r6 | j                                         | j                            d           Y nw xY w| j        | j        j        u rd|                     t          j                  }| j                            t8          j        |j                   |j                                         dS dS 	 | j        j                            | j        	                                           n4# t(          $ r' | j        j                            | j                   Y nw xY w| j        j                                                            d           | j                            d           	 | j        	                                                    d           n# t(          $ r d| j        _        Y nw xY w| j                             | j         t                     d| _         	 | j        	                                !                                "                                 dS # t(          $ r/ | j        !                                "                                 Y dS w xY w)z
        Maximize current dockwidget.

        Shortcut: Ctrl+Alt+Shift+M
        First call: maximize current dockwidget
        Second call (or restore=True): restore original window layout
        Nr   TF)#r@   r8   r   r  r   r  r   r   hider  r  r;   r   rJ   r   EditortoggleViewActionsetDisabledsetCentralWidgetset_maximized_stater   r   showchange_visibility_visibility_changededitorOutlineExploreraddDockWidgetr   RightDockWidgetArea	setWidget
setEnabledr  get_focus_widgetsetFocus)r0   r   focus_widgetrF   outline_explorers        r,   r   zLayout.maximize_dockwidget  s    (0  -1I,?,?, -@ - -D) (355L3355 
3 
3!&&(((3((**77EE 3,2)  3 3 3**<88 3,2)3  ($(OOGN$C$C! (99;;GGMMM6	**4+<+G+G+I+IJJJ!,,..BB4HHHH! 6 6 6	**4+<===15!...6<!,,..33555!33D9999! < < <!&&(((!55d;;;;;<
  DI$444#'??73J#K#K 	''*$/1 1 1 !+0022222 54J!,66%00224 4 4 4! J J J!,66t7HIIIIIJ (99;;FFtLLLI&&t,,,7!,,..BB5IIII! 7 7 716!...7 I""-7K #    -1D)@!,,..??AAJJLLLLL! @ @ @!2244==??????@sn   5.B$$&CC-AF 5GGAH =II
6L .L21L2,N. .OO8=P7 75Q0/Q0c                 p    | j                                         r| j                             d           dS dS )zUnmaximize any dockable plugin.FN)r  	isCheckedr   r/   s    r,   unmaximize_dockwidgetzLayout.unmaximize_dockwidget  s@    ))++ 	3 ++E22222	3 	3r+   c                     |                                  }d}|?	 |                                                                }n# t          $ r
 |j        }Y nw xY w||r||ur|                                  dS dS dS dS )zV
        Unmaximize the currently maximized plugin, if not `plugin_instance`.
        FN)r   r  get_maximized_stater   r   r2  )r0   r   last_pluginr   s       r,   unmaximize_other_dockwidgetz"Layout.unmaximize_other_dockwidget  s     **,,"8  **,,@@BB  " 8 8 8*78
 # $?22&&(((((	 $###22s   &A AANc                    |                                  }	 |x|                                                                rR||urN| j                                        r| j                            d           n| j                            d           nk# t          $ r^ |Y|j        rR||urN| j                                        r| j                            d           n| j                            d           Y nw xY w	 |j                                        s3|j                            d           d|                                _	        nO# t          $ rB |j
                                        s&|j
                            d           d|j        _        Y nw xY w	 |                    d|           dS # t          $ r |                    d           Y dS w xY w)z
        Switch to `plugin`.

        Notes
        -----
        This operation unmaximizes the current plugin (if any), raises
        this plugin to view (if it's hidden) and gives it focus (if
        possible).
        NFT)force_focus)r   r  r4  r  r1  r   r   r   r   
is_visibler   _widget_is_visibler$  r%  )r0   rF   r8  r5  s       r,   switch_to_pluginzLayout.switch_to_plugin  s    **,,	: '**,,@@BB (v--'1133 :(33E::::(33D999 
	: 
	: 
	: ', (v--'1133 :(33E::::(33D999
	:		3,6688 7)44T:::16!!##. 	3 	3 	3-7799 3*55d;;;-2*		3	-$$T{$CCCCC 	- 	- 	-&&t,,,,,,	-s9   A:B A%C98C9=AE
 
A	FFF3 3GGc                 n   | j         }| j        rd| _        t          j        dk    r[|                    |                                t          j        t          j        z  z             |	                    | j
                   |                                 | j        r|                                 no|                                | _        d| _        |                                | _
        t          j        dk    r|                    |                                t          j        z  t          j        z             t!                                          |          }|dk     rd}t%          j                                        |          }|	                    |                                dz
  |                                dz
  |                                dz   |                                dz              |                                 n|                                 |                                  dS )zQ
        Toggle option to show the mainwindow in fullscreen or windowed.
        FntTr   r      N)r8   r=   osnamesetWindowFlagswindowFlagsr   FramelessWindowHintWindowStaysOnTopHintsetGeometryr?   
showNormalr>   r   r   normalGeometryr	   screenNumberr   r   screenGeometrylefttopr   r   showFullScreenrD   )r0   r8   screen_numberrs       r,   toggle_fullscreenzLayout.toggle_fullscreenJ  s   
 y   	&$)D!w$##$$&&-0GGIJ J J   !<===OO# %""$$$#'#3#3#5#5D $(D!*.*=*=*?*?D'w$
 ##D$4$4$6$6&(&<%=&(&=%> ? ? ? !/ 0 0 = =d C C 1$$$%M (**99-HH  FFHHqL!%%''A+qwwyy1}ahhjj1nN N N!!!!##%%%&&(((((r+   c                 4    |                                  j        S )z#Expose plugins toggle actions menu.)rL   rM   r/   s    r,   plugins_menuzLayout.plugins_menus  s     !!##11r+   c                 2   g d}|                                  D ]}	 |j        }n&# t          $ r |j        }d|j         |_        Y nw xY w|r,|                    |j                                                   	 |j        }|	                    |          }n# t          $ r d}Y nw xY w||||<   |                    |           |dd         }|D ]D}t          |          t          ur,|                                 j                            |           EdS )zV
        Populate panes menu with the toggle view action of each base plugin.
        )r&  ipython_consolevariable_explorerhelpplotsNexplorerr/  project_explorerfind_in_filesN
historylogprofilerbreakpointspylintN
onlinehelpinternal_consoleNz
switch to N)r   r   r   r   CONF_SECTION	action_idr   r   r   r   
ValueErrorappendtyper   rL   rM   
add_action)r0   r   rF   r   rA  r   actionss          r,   r   zLayout.create_plugins_menux  sx   9 9 9 //11 	% 	%FF2! F F F3#E0C#E#E   F
  A!!&"3"="="?"?@@@*kk$''    #c

V$$$$( 	F 	FFF||3&&""$$2==fEEE	F 	Fs!   $ AA9BB%$B%c                 4    |                                  j        S r   )rL   rN   r/   s    r,   r   zLayout.lock_interface_action  s    !!##::r+   c                    || j          n|| _         |                     d| j         d           |                                  |                                 D ]o}| j         rM|j                                        r|j                            d           |j                                         V|j                                         p| 	                    t          j                  }|r|                    | j                    dS dS )z%Lock/Unlock dockwidgets and toolbars.Nr7   r8   F)value)rB   r   r   r   r   
isFloatingsetFloatingremove_title_barset_title_barrJ   r   rT   r   )r0   rj  rF   toolbars       r,   r   zLayout.toggle_lock  s    +0-&&&U 	nd&<fEEE**,,,//11 	2 	2F% 2$//11 9%11%888!224444!//1111 //'/22 	>d&<=====	> 	>r+   c                 R   t                               d           |                     dg           }|s#t          j        t          j        t          j        g}|D ]M}|                     |d          }|r2|j        	                                r|j        
                                 NdS )zY
        Restore dockable plugins that were visible during the previous session.
        z3Restoring visible plugins from the previous sessionlast_visible_pluginsry   FerrorN)r   r   rA   r   IPythonConsoleHelpr  rJ   r   r   raise_)r0   visible_pluginsrF   plugin_classs       r,   r   zLayout.restore_visible_plugins  s     	IJJJ--(>-KK  	/&5w|&~/O & 	1 	1F??6???L 1 7 A A C C 1'..000	1 	1r+   c                 b   t                               d           g }|                                 D ]g}	 |                                j        r|                    |j                   7# t          $ r$ |j        r|                    |j                   Y dw xY w| 	                    d|           dS )zSave visible plugins.z'Saving visible plugins to config systemrq  N)
r   debugr   r  r9  rd  NAMEr   
_isvisibler   )r0   rw  rF   s      r,   save_visible_pluginszLayout.save_visible_plugins  s    >???//11 	8 	8F8$$&&1 8#**6;777! 8 8 8$ 8#**6;7778
 	,o>>>>>s   3A((+BBc                 P    | j                             |j        |j                   dS )zTabify plugin dockwigdets.N)r8   tabifyDockWidgetr   )r0   firstseconds      r,   tabify_pluginszLayout.tabify_plugins  s&    	""5#3V5FGGGGGr+   c                       fd}t          |d|g          }t          |t                    s|g}n|}|dgg fv rdS  fd|D             }|                    dd          rt          |t                    r|j        t          j        k    rkt          	                    d|j         d	|             |||           |j        t          j        v r'|                                                    d           |                    d
d           |                    dd           n[t           j                            |j                            s/t          	                    d|j         d            |||           dS )z
        Tabify `plugin` using the list of possible TABIFY options.

        Only do this if the dockwidget does not have more dockwidgets
        in the same position and if the plugin is using the New API.
        c                     |D ]L}	                      ||             d S # t          $ r$}t                              |           Y d }~Ed }~ww xY wd S r   )r  r
   r   rs  )rF   next_to_pluginsnext_to_pluginerrr0   s       r,   tabify_helperz+Layout.tabify_plugin.<locals>.tabify_helper  s~    "1 & &&''???EE% & & &LL%%%%%%%%&	& &s    
AA		ATABIFYNFc                 :    g | ]}                     |          S r*   )rJ   ).0pr0   s     r,   
<listcomp>z(Layout.tabify_plugin.<locals>.<listcomp>  s%    GGG!4??1--GGGr+   
first_timeTz
Tabifying z# plugin for the first time next to enablez plugin)getattrr   r   rA   r   r{  r   Consoler   r   r   r   r  toggle_viewr   r   r8   tabifiedDockWidgetsr   )r0   rF   rz   r  tabifyr  s   `     r,   tabify_pluginzLayout.tabify_plugin  s   	& 	& 	& 	& 	& G955&$'' 	%%hOO$O tfb\!!5 HGGGGGG??<.. 	7
 6#788:K7?22, , ,), ,   fo666 ;/"BBB%%''33D999OOHd+++OOL%0000 	55f6GHHII 7====>>>fo666tr+   c                    |                                  D ]H}|j        t          j        v r3|j        |                                 vrt          d|j         d          I| j        r*|                     d|                                            dS t          	                    d           | 
                    d|                                           }|                                 D ]?}||vr9|                     |d          }|r |                     |t          j                   @|                                  D ]K}|j        t          j        v r6|
                    d	d
          r |                     |t          j                   LdS )aW  
        Tabify new dockable plugins, i.e. plugins that were not part of the
        interface in the last session.

        Notes
        -----
        This is only necessary the first time a plugin is loaded. Afterwards,
        the plugin's placement is recorded in the window hexstate, which is
        loaded in the next session.
        zPlugin zs is a new dockable plugin but it hasn't been added to the DockablePlugins enum. Please do that to avoid this error.internal_dockable_pluginsNzTabifying new pluginsry   Frr  r  T)r   r{  r   internal_pluginsr   r
   r<   r   r   rz  rA   rJ   r  r   r  r   )r0   rF   last_internal_dockable_pluginsr   s       r,   tabify_new_pluginszLayout.tabify_new_plugins   s    //11 		 		F???Kt'J'J'L'LLL$4fk 4 4 4   ! 	 MM+3355   F,--- *.'7799 *7 *
 *
&  >>@@ 	@ 	@K"@@@EBB @&&vw??? //11 	< 	<F???OOL$77 @ ""67?;;;	< 	<r+   )F)Fr8   )r8   Fr   )>__name__
__module____qualname____doc__r{  ra  r   AllREQUIRES	CONF_FILEr   CONTAINER_CLASSCAN_BE_DISABLEDstaticmethodr-   r1   r5   rE   r   rK   r`   rT   ri   r   rt   rw   r}   r   r   rD   r   r   r   rC   r   r   r{   r|   r   r   r   r  r   r   r   r  propertyr  r   r2  r6  r<  rP  rR  r   r   r   r   r}  r  r  r  r*   r+   r,   r&   r&   B   s         D"L}HI%OO   \# # #+ + +) ) ),  0111- - 21-@ 000	
 	
 10	
 w/000+ + 10+4 w///
 
 0/
) ) )1 1 1"1 1 1> > >1 1 1&	! 	! 	!% % %I I I  : : : : : :', ', ', ',R( ( (T:" :" :"x& & & &P  2,* ,* ,*\ <B05<
 <
 <
 <
@ 
TVV  V  @ @ X@a@ a@ a@ a@F3 3 3
) ) )03- 3- 3- 3-n 
TVV&) &) V&)P 2 2 X2$F $F $FL ; ; X;> > > >.1 1 1$? ? ?&H H H< < < <|:< :< :< :< :<r+   r&   )9r  configparserr   loggingr@  qtpy.QtCorer   r   r   r   r   qtpy.QtWidgetsr   r	   spyder.api.exceptionsr
   spyder.api.pluginsr   r   r   r   )spyder.api.plugin_registration.decoratorsr   r   'spyder.api.plugin_registration.registryr   spyder.api.translationsr   spyder.api.utilsr   spyder.plugins.mainmenu.apir   r   spyder.plugins.layout.containerr   r   r   spyder.plugins.layout.layoutsr   r   r   r   r   r   ,spyder.plugins.preferences.widgets.containerr    spyder.plugins.toolbar.apir!   r"   spyder.py3compatr#   	getLoggerr  r   r   r  r&   r*   r+   r,   <module>r     s         				 < ; ; ; ; ; ; ; ; ; ; ; ; ; 7 7 7 7 7 7 7 7 1 0 0 0 0 0D D D D D D D D D D D D- - - - - - - - C C C C C C % % % % % % - - - - - - J J J J J J J J@ @ @ @ @ @ @ @ @ @N N N N N N N N N N N N N N N N L K K K K K. . . . . . . . . . . . . . 
	8	$	$ #">22$  X< X< X< X< X<^ X< X< X< X< X<r+   