diff --git a/spyderlib/widgets/editor.py b/spyderlib/widgets/editor.py index d5621b74e91..7310a24ef5c 100644 --- a/spyderlib/widgets/editor.py +++ b/spyderlib/widgets/editor.py @@ -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 @@ -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): diff --git a/spyderlib/widgets/tabs.py b/spyderlib/widgets/tabs.py index 1fd770ded6e..aec14e4d6a7 100644 --- a/spyderlib/widgets/tabs.py +++ b/spyderlib/widgets/tabs.py @@ -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())