Add cancel option when exiting with unsaved changes.

This commit is contained in:
luxick
2017-07-02 15:57:47 +02:00
parent f5cd7d5d1c
commit bd8ec22dc0
2 changed files with 10 additions and 6 deletions

View File

@@ -178,7 +178,10 @@ class Application:
def show_question_dialog(self, title, message):
dialog = Gtk.MessageDialog(self.ui.get_object("mainWindow"), 0, Gtk.MessageType.WARNING,
Gtk.ButtonsType.YES_NO, title)
Gtk.ButtonsType.NONE, title)
dialog.add_buttons(Gtk.STOCK_YES, Gtk.ResponseType.YES,
Gtk.STOCK_NO, Gtk.ResponseType.NO,
Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)
dialog.format_secondary_text(message)
response = dialog.run()
dialog.destroy()
@@ -346,6 +349,7 @@ class Application:
def remove_card_from_want_list(self, card: mtgsdk.Card, list: str):
l = self.wants[list]
l.remove(card)
self.unsaved_changes = True
util.log("Removed '{}' from wants list '{}'".format(card.name, list), util.LogLevel.Info)
def get_mana_icons(self, mana_string):

View File

@@ -1,4 +1,5 @@
import gi
gi.require_version('Gtk', '3.0')
import datetime
import os
@@ -81,6 +82,9 @@ class Handlers:
"Save before exiting?")
if response == Gtk.ResponseType.YES:
self.app.save_library()
return False
elif response == Gtk.ResponseType.CANCEL:
return True
# ---------------------------------Search----------------------------------------------
@@ -213,7 +217,6 @@ class Handlers:
self.app.ui.get_object("typeCombo").set_active(0)
self.app.ui.get_object("setEntry").set_text("")
def do_show_card_details(self, menu_item):
tree = self.app.ui.get_object("searchResults").get_child()
cards = tree.get_selected_cards()
@@ -287,7 +290,6 @@ class Handlers:
self.app.rename_tag(tag, new_name)
self.app.current_page.emit('show')
def do_tag_list_delete(self, tree):
(model, pathlist) = tree.get_selection().get_selected_rows()
for path in pathlist:
@@ -521,5 +523,3 @@ class Handlers:
self.app.ui.get_object("wants_cardListPopup").emit('show')
self.app.ui.get_object("wants_cardListPopup").popup(None, None, None, None, 0, event.time)
return True