Skip to content

Commit

Permalink
Show single warning when closing tab
Browse files Browse the repository at this point in the history
  • Loading branch information
astrofrog committed May 27, 2015
1 parent 33b70a1 commit d9b093b
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions glue/qt/glue_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from __future__ import absolute_import, division, print_function

import os
import sys
import webbrowser

Expand Down Expand Up @@ -274,11 +275,30 @@ def new_tab(self):

def close_tab(self, index):
""" Close a tab window and all associated data viewers """

# do not delete the last tab
if self.tab_widget.count() == 1:
return

if not os.environ.get('GLUE_TESTING'):
buttons = QMessageBox.Ok | QMessageBox.Cancel
dialog = QMessageBox.warning(self, "Confirm Close",
"Are you sure you want to close this tab? "
"This will close all data viewers in the tab.",
buttons=buttons,
defaultButton=QMessageBox.Cancel)
if not dialog == QMessageBox.Ok:
return

w = self.tab_widget.widget(index)

for window in w.subWindowList():
widget = window.widget()
if isinstance(widget, DataViewer):
widget.close(warn=False)

w.close()

self.tab_widget.removeTab(index)

def add_widget(self, new_widget, label=None, tab=None,
Expand Down

0 comments on commit d9b093b

Please sign in to comment.