From 4d17f100fcc4e8990eab64d0cdde99c8565a16bb Mon Sep 17 00:00:00 2001 From: Marcus Lundblad Date: Sat, 25 Mar 2023 16:34:50 +0100 Subject: mapView: Use Adw.MessageDialog for shape layer confirmation Replace the usage of a Gtk.MessageDialog with an Adw.MessageDialog for the confirmation dialog when loading large shape layers. --- src/mapView.js | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/mapView.js b/src/mapView.js index d7f91e5f..537373a7 100644 --- a/src/mapView.js +++ b/src/mapView.js @@ -19,6 +19,7 @@ * Author: Zeeshan Ali (Khattak) */ +import Adw from 'gi://Adw'; import GObject from 'gi://GObject'; import Gdk from 'gi://Gdk'; import GeocodeGlib from 'gi://GeocodeGlib'; @@ -514,19 +515,25 @@ export class MapView extends Gtk.Overlay { if (result.confirmLoad) { let totalFileSizeMB = result.totalFileSizeMB; - let dialog = new Gtk.MessageDialog ({ + let dialog = new Adw.MessageDialog ({ transient_for: this._mainWindow, modal: true, - buttons: Gtk.ButtonsType.OK_CANCEL, - text: _("Do you want to continue?"), - secondary_text: _("You are about to open files with a total " + - "size of %s MB. This could take some time to" + - " load").format(totalFileSizeMB.toLocaleString(undefined, - { maximumFractionDigits: 1 })) + heading: _("Do you want to continue?"), + body: _("You are about to open files with a total " + + "size of %s MB. This could take some time to" + + " load").format(totalFileSizeMB.toLocaleString(undefined, + { maximumFractionDigits: 1 })) }); + dialog.add_response('cancel', _("Cancel")); + dialog.add_response('continue', _("Continue")); + dialog.set_response_appearance('continue', + Adw.ResponseAppearance.SUGGESTED); + dialog.set_default_response('cancel'); + dialog.set_close_response('cancel'); + dialog.connect('response', (widget, responseId) => { - if (responseId === Gtk.ResponseType.OK) { + if (responseId === 'continue') { this._loadShapeLayers(files); } dialog.destroy(); -- cgit v1.2.1