Skip to content

Commit

Permalink
Refactor the toolbar handling on main widgets
Browse files Browse the repository at this point in the history
  • Loading branch information
goanpeca committed Aug 22, 2020
1 parent 3bf9253 commit ead54c0
Show file tree
Hide file tree
Showing 8 changed files with 180 additions and 176 deletions.
19 changes: 12 additions & 7 deletions spyder/api/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
# Standard library imports
from collections import OrderedDict
import inspect
import logging
import os

# Third party imports
Expand Down Expand Up @@ -51,6 +52,7 @@

# Localization
_ = get_translation('spyder')
logger = logging.getLogger(__name__)


# =============================================================================
Expand Down Expand Up @@ -815,9 +817,12 @@ def __init__(self, parent, configuration=None):
# Widget setup
# ----------------------------------------------------------------
try:
container._setup(options=options)
except AttributeError:
pass
_setup = getattr(container, "_setup", None)
if _setup:
_setup(options=options)
except AttributeError as error:
logger.debug(
"Running `_setup` on {0}: {1}".format(self, error))

if isinstance(container, SpyderWidgetMixin):
container.setup(options=options)
Expand Down Expand Up @@ -1606,10 +1611,10 @@ def __init__(self, parent, configuration):
# Render all toolbars as a final separate step on the main window
# in case some plugins want to extend a toolbar. Since the rendering
# can only be done once!
widget.get_main_toolbar()._render()
for __, toolbars in widget._aux_toolbars.items():
for toolbar in toolbars:
toolbar._render()
widget._main_toolbar._render()
widget._corner_toolbar._render()
for __, toolbar in widget._auxiliary_toolbars.items():
toolbar._render()

# Default Signals
# --------------------------------------------------------------------
Expand Down
Loading

0 comments on commit ead54c0

Please sign in to comment.