summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcus Lundblad <ml@dfupdate.se>2023-03-25 15:38:32 +0100
committerMarcus Lundblad <ml@dfupdate.se>2023-03-26 22:50:52 +0200
commit13798c112adf1a68ad142e8bdd9e419fd9f3658b (patch)
tree0c884b440941b3fc563a748a344359f92f565a69
parentee83a98694da8c1bc5aea01dab3aa39fdeb0e06f (diff)
downloadgnome-maps-13798c112adf1a68ad142e8bdd9e419fd9f3658b.tar.gz
exportViewDialog: Replace MessageDialog with a toast
Replace the Gtk.MessageDialog on error with an Adw.Toast. Also actually check the success return code from the texture.save_to_png() call.
-rw-r--r--src/exportViewDialog.js33
1 files changed, 6 insertions, 27 deletions
diff --git a/src/exportViewDialog.js b/src/exportViewDialog.js
index be060f52..ce91a0b6 100644
--- a/src/exportViewDialog.js
+++ b/src/exportViewDialog.js
@@ -145,34 +145,13 @@ export class ExportViewDialog extends Gtk.Dialog {
let texture = renderer.render_texture(node, rect);
let path = GLib.build_filenamev([this._folder, this._fileName]);
- try {
- texture.save_to_png(path);
+ let success = texture.save_to_png(path);
+
+ if (success) {
this.response(ExportViewDialog.Response.SUCCESS);
- } catch(e) {
- Utils.debug('failed to export view: ' + e.message);
- let details = null;
-
- if (e.matches(GLib.FileError, GLib.FileError.ROFS))
- details = _("Filesystem is read only");
- else if (e.matches(GLib.FileError, GLib.FileError.ACCES))
- details = _("You do not have permission to save there");
- else if (e.matches(GLib.FileError, GLib.FileError.NOENT))
- details = _("The directory does not exist");
- else if (e.matches(GLib.FileError, GLib.FileError.ISDIR))
- details = _("No filename specified");
-
- let dialog = new Gtk.MessageDialog({
- transient_for: this,
- destroy_with_parent: true,
- message_type: Gtk.MessageType.ERROR,
- buttons: Gtk.ButtonsType.OK,
- modal: true,
- text: _("Unable to export view"),
- secondary_text: details
- });
-
- dialog.connect('response', () => dialog.destroy());
- dialog.present();
+ } else {
+ this.transient_for.showToast(_("Unable to export view"));
+ this.response(ExportViewDialog.Response.CANCEL);
}
}
}