Show confirmation dialog on quit when unsaved changes exist
This commit is contained in:
@@ -102,6 +102,14 @@ class MainWindow(Gtk.Window):
|
||||
def mb_save_lib(self, menu_item):
|
||||
util.save_library()
|
||||
|
||||
def do_delete_event(self, event):
|
||||
if util.unsaved_changes:
|
||||
response = util.show_question_dialog("Unsaved Changes", "You have unsaved changes in your library. "
|
||||
"Save before exiting?")
|
||||
if response == Gtk.ResponseType.YES:
|
||||
util.save_library()
|
||||
|
||||
|
||||
win = MainWindow()
|
||||
win.connect('delete-event', Gtk.main_quit)
|
||||
GObject.threads_init()
|
||||
|
||||
@@ -99,6 +99,14 @@ def push_status(msg):
|
||||
status_bar.push(0, msg)
|
||||
|
||||
|
||||
def show_question_dialog(title, message):
|
||||
dialog = Gtk.MessageDialog(window, 0, Gtk.MessageType.QUESTION,
|
||||
Gtk.ButtonsType.YES_NO, title)
|
||||
dialog.format_secondary_text(message)
|
||||
response = dialog.run()
|
||||
dialog.destroy
|
||||
return response
|
||||
|
||||
def show_message(title, message):
|
||||
dialog = Gtk.MessageDialog(window, 0, Gtk.MessageType.INFO,
|
||||
Gtk.ButtonsType.OK, title)
|
||||
|
||||
Reference in New Issue
Block a user