Skip to content

Commit

Permalink
Make actions in the Console and Projects menu to call switch_to_plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
ccordoba12 committed Nov 12, 2018
1 parent 2e66269 commit 32496f7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion spyder/plugins/ipythonconsole.py
Original file line number Diff line number Diff line change
Expand Up @@ -1592,8 +1592,8 @@ def create_kernel_manager_and_kernel_client(self, connection_file,
def restart_kernel(self):
"""Restart kernel of current client."""
client = self.get_current_client()

if client is not None:
self.switch_to_plugin()
client.restart_kernel()

def connect_external_kernel(self, shellwidget):
Expand Down
16 changes: 14 additions & 2 deletions spyder/plugins/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def get_plugin_actions(self):
triggered=self.close_project)
self.delete_project_action = create_action(self,
_("Delete Project"),
triggered=self.delete_project)
triggered=self._delete_project)
self.clear_recent_projects_action =\
create_action(self, _("Clear this list"),
triggered=self.clear_recent_projects)
Expand Down Expand Up @@ -182,10 +182,13 @@ def setup_menu_actions(self):
for project in self.recent_projects:
if self.is_valid_project(project):
name = project.replace(get_home_dir(), '~')
def slot():
self.switch_to_plugin()
self.open_project(path=project)
action = create_action(self,
name,
icon = ima.icon('project'),
triggered=lambda v, path=project: self.open_project(path=path))
triggered=slot)
self.recent_projects_actions.append(action)
else:
self.recent_projects.remove(project)
Expand Down Expand Up @@ -225,6 +228,7 @@ def edit_project_preferences(self):
@Slot()
def create_new_project(self):
"""Create new project"""
self.switch_to_plugin()
active_project = self.current_active_project
dlg = ProjectDialog(self)
dlg.sig_project_creation_requested.connect(self._create_project)
Expand All @@ -245,6 +249,7 @@ def _create_project(self, path):
def open_project(self, path=None, restart_consoles=True,
save_previous_files=True):
"""Open the project located in `path`"""
self.switch_to_plugin()
if path is None:
basedir = get_home_dir()
path = getexistingdirectory(parent=self,
Expand Down Expand Up @@ -292,6 +297,7 @@ def close_project(self):
project
"""
if self.current_active_project:
self.switch_to_plugin()
path = self.current_active_project.root_path
self.current_active_project = None
self.set_option('current_project_path', None)
Expand All @@ -313,6 +319,12 @@ def close_project(self):
if self.editor is not None:
self.set_project_filenames(self.editor.get_open_filenames())

def _delete_project(self):
"""Delete current project."""
if self.current_active_project:
self.switch_to_plugin()
self.delete_project()

def clear_recent_projects(self):
"""Clear the list of recent projects"""
self.recent_projects = []
Expand Down

0 comments on commit 32496f7

Please sign in to comment.