Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "close all but this" and "close all to the right" entries to the Editor context menu #2519

Merged
merged 5 commits into from
Jan 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion spyderlib/widgets/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,16 @@ def __init__(self, parent, actions):
icon=ima.icon('editcopy'),
triggered=lambda:
QApplication.clipboard().setText(self.get_current_filename()))

close_right = create_action(self, _("Close all to the right"),
icon=ima.icon('filelist'),
triggered=self.close_all_right)
close_all_but_this = create_action(self, _("Close all but this"),
icon=ima.icon('filelist'),
triggered=self.close_all_but_this)

self.menu_actions = actions + [None, fileswitcher_action,
copy_to_cb_action]
copy_to_cb_action, None, close_right, close_all_but_this]
self.outlineexplorer = None
self.inspector = None
self.unregister_callback = None
Expand Down Expand Up @@ -1131,6 +1139,18 @@ def close_all_files(self):
while self.close_file():
pass

def close_all_right(self):
""" Close all files opened to the right """
num = self.get_stack_index()
n = self.get_stack_count()
for i in range(num, n-1):
self.close_file(num+1)

def close_all_but_this(self):
"""Close all files but the current one"""
self.close_all_right()
for i in range(0, self.get_stack_count()-1 ):
self.close_file(0)

#------ Save
def save_if_changed(self, cancelable=False, index=None):
Expand Down
1 change: 1 addition & 0 deletions spyderlib/widgets/tabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ def add_corner_widgets(self, widgets, corner=Qt.TopRightCorner):

def contextMenuEvent(self, event):
"""Override Qt method"""
self.setCurrentIndex(self.tabBar().tabAt(event.pos()))
if self.menu:
self.menu.popup(event.globalPos())

Expand Down