Moved two MessageDialogs to AlertDialog helper classes
The helper classes ensure that alert dialogs are properly formed and deal with other issues, like destroying the dialogs when completed.
This commit is contained in:
parent
86757cdb11
commit
b010e8c532
2 changed files with 5 additions and 15 deletions
|
|
@ -473,16 +473,9 @@ public class ComposerWindow : Gtk.Window {
|
|||
public bool should_close() {
|
||||
// TODO: Check if the message was (automatically) saved
|
||||
if (editor.can_undo()) {
|
||||
var dialog = new Gtk.MessageDialog(this, 0,
|
||||
Gtk.MessageType.WARNING, Gtk.ButtonsType.NONE,
|
||||
_("Do you want to discard the unsaved message?"));
|
||||
dialog.add_buttons(Gtk.Stock.CANCEL, Gtk.ResponseType.CANCEL,
|
||||
Gtk.Stock.DISCARD, Gtk.ResponseType.OK);
|
||||
dialog.set_default_response(Gtk.ResponseType.CANCEL);
|
||||
int response = dialog.run();
|
||||
dialog.destroy();
|
||||
|
||||
if (response != Gtk.ResponseType.OK)
|
||||
ConfirmationDialog dialog = new ConfirmationDialog(this,
|
||||
_("Do you want to discard the unsaved message?"), null, Gtk.Stock.DISCARD);
|
||||
if (dialog.run() != Gtk.ResponseType.OK)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -1463,12 +1463,9 @@ public class MessageViewer : Object {
|
|||
string temporary_uri = Filename.to_uri(temporary_filename, null);
|
||||
Gtk.show_uri(web_view.get_screen(), temporary_uri, Gdk.CURRENT_TIME);
|
||||
} catch (Error error) {
|
||||
var dialog = new Gtk.MessageDialog(null, 0,
|
||||
Gtk.MessageType.ERROR, Gtk.ButtonsType.OK,
|
||||
"%s", _("Failed to open default text editor."));
|
||||
dialog.format_secondary_text(error.message);
|
||||
ErrorDialog dialog = new ErrorDialog(GearyApplication.instance.get_main_window(),
|
||||
_("Failed to open default text editor."), error.message);
|
||||
dialog.run();
|
||||
dialog.destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue