Skip to content

Commit

Permalink
Breakpoints: Update calls to add_item_to_application_menu
Browse files Browse the repository at this point in the history
  • Loading branch information
andfoy committed Aug 11, 2021
1 parent a8715db commit 8248e15
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
9 changes: 8 additions & 1 deletion spyder/api/widgets/main_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,9 +353,16 @@ def _setup(self):
)

bottom_section = OptionsMenuSections.Bottom
for item in [self.undock_action, self.close_action, self.dock_action]:
actions = [
(self.undock_action, PluginMainWidgetActions.UndockPane),
(self.close_action, PluginMainWidgetActions.ClosePane),
(self.dock_action, PluginMainWidgetActions.DockPane)
]

for item, _id in actions:
self.add_item_to_menu(
item,
_id,
self._options_menu,
section=bottom_section,
)
Expand Down
7 changes: 4 additions & 3 deletions spyder/api/widgets/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,15 +226,16 @@ class SpyderMenuMixin:
sections in a simple way.
"""

def add_item_to_menu(self, action_or_menu, menu, section=None,
before=None):
def add_item_to_menu(self, action_or_menu, action_menu_id, menu,
section=None, before=None):
"""
Add a SpyderAction or a QWidget to the menu.
"""
if not isinstance(menu, SpyderMenu):
raise SpyderAPIError('Menu must be an instance of SpyderMenu!')

menu.add_action(action_or_menu, section=section, before=before)
menu.add_action(action_or_menu, action_menu_id, section=section,
before=before)

def create_menu(self, name, text=None, icon=None):
"""
Expand Down
5 changes: 3 additions & 2 deletions spyder/plugins/breakpoints/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,9 @@ def on_editor_available(self):
def on_main_menu_available(self):
mainmenu = self.get_plugin(Plugins.MainMenu)
list_action = self.get_action(BreakpointsActions.ListBreakpoints)
debug_menu = mainmenu.get_application_menu(ApplicationMenus.Debug)
mainmenu.add_item_to_application_menu(list_action, debug_menu)
mainmenu.add_item_to_application_menu(
list_action, BreakpointsActions.ListBreakpoints,
menu_id=ApplicationMenus.Debug)

# --- Private API
# ------------------------------------------------------------------------
Expand Down
9 changes: 7 additions & 2 deletions spyder/plugins/breakpoints/widgets/main_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,13 @@ def setup(self):
)

self.popup_menu = self.create_menu(PluginMainWidgetMenus.Context)
for item in [clear_all_action, clear_action, edit_action]:
self.add_item_to_menu(item, menu=self.popup_menu)
actions = [
(clear_all_action, BreakpointTableViewActions.ClearAllBreakpoints),
(clear_action, BreakpointTableViewActions.ClearBreakpoint),
(edit_action, BreakpointTableViewActions.EditBreakpoint)
]
for item, _id in actions:
self.add_item_to_menu(item, _id, menu=self.popup_menu)

# --- Qt overrides
# ------------------------------------------------------------------------
Expand Down

0 comments on commit 8248e15

Please sign in to comment.