[gnome-sound-recorder/wip/cdavis/typescript] recorderWidget: Use AdwMessageDialog
- From: Christopher Davis <christopherdavis src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-sound-recorder/wip/cdavis/typescript] recorderWidget: Use AdwMessageDialog
- Date: Thu, 25 Aug 2022 10:03:23 +0000 (UTC)
commit 4452c81ea55ec1b470f37f7db192d600fbf53ea1
Author: Christopher Davis <christopherdavis gnome org>
Date: Thu Aug 25 06:02:06 2022 -0400
recorderWidget: Use AdwMessageDialog
src/recorderWidget.ts | 50 +++++++++++++++++++++-----------------------------
1 file changed, 21 insertions(+), 29 deletions(-)
---
diff --git a/src/recorderWidget.ts b/src/recorderWidget.ts
index f4eaac1..93e02cc 100644
--- a/src/recorderWidget.ts
+++ b/src/recorderWidget.ts
@@ -1,4 +1,5 @@
/* exported RecorderState RecorderWidget */
+import Adw from 'gi://Adw';
import Gio from 'gi://Gio';
import GObject from 'gi://GObject';
import Gtk from 'gi://Gtk?version=4.0';
@@ -107,41 +108,32 @@ export class RecorderWidget extends Gtk.Box {
private onCancel(): void {
this.onPause();
- const dialog = new Gtk.MessageDialog({
- modal: true,
- destroy_with_parent: true,
- buttons: Gtk.ButtonsType.NONE,
- message_type: Gtk.MessageType.QUESTION,
- text: _('Delete recording?'),
- secondary_text: _('This recording will not be saved.'),
+ const dialog = new Adw.MessageDialog({
+ heading: _('Delete Recording?'),
+ body: _('This recording will not be saved.'),
+ transient_for: this.root as Gtk.Window,
});
- dialog.set_default_response(Gtk.ResponseType.NO);
- dialog.add_button(_('Resume'), Gtk.ResponseType.NO);
- dialog.add_button(_('Delete'), Gtk.ResponseType.YES)
- .add_css_class('destructive-action');
-
- dialog.set_transient_for(this.root as Gtk.Window);
- dialog.connect('response', (_, response: number) => {
- switch (response) {
- case Gtk.ResponseType.YES: {
- const recording = this.recorder.stop();
- this.state = RecorderState.Stopped;
- if (recording) {
- recording.delete();
- }
- this.emit('canceled');
- break;
- }
- case Gtk.ResponseType.NO:
- this.onResume();
- break;
+ dialog.add_response('close', _('_Resume'));
+ dialog.add_response('delete', _('_Delete'));
+
+ dialog.set_response_appearance('delete', Adw.ResponseAppearance.DESTRUCTIVE);
+ dialog.set_default_response('close');
+
+ dialog.connect('response::delete', () => {
+ const recording = this.recorder.stop();
+ this.state = RecorderState.Stopped;
+ if (recording) {
+ recording.delete();
}
+ this.emit('canceled');
+ });
- dialog.close();
+ dialog.connect('response::close', () => {
+ this.onResume();
});
- dialog.show();
+ dialog.present();
}
private onStop(): void {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]