[gnome-games/wip/exalm/dialogs: 1/3] display-view: Split run_dialog_async() into a separate file
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/exalm/dialogs: 1/3] display-view: Split run_dialog_async() into a separate file
- Date: Wed, 24 Mar 2021 18:00:35 +0000 (UTC)
commit eb8c878ebeb8aa4f6a00ffa13a27a8c3cc4d91ce
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Wed Mar 24 20:25:24 2021 +0500
display-view: Split run_dialog_async() into a separate file
It will be useful in other places too. Add a native dialog variant as well.
src/meson.build | 1 +
src/ui/display-view.vala | 24 ++++--------------------
src/utils/dialog-utils.vala | 35 +++++++++++++++++++++++++++++++++++
3 files changed, 40 insertions(+), 20 deletions(-)
---
diff --git a/src/meson.build b/src/meson.build
index f3479bd6..bb4da609 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -174,6 +174,7 @@ vala_sources = [
'utils/cue-sheet/cue-sheet-file-node.vala',
'utils/cue-sheet/cue-sheet-track-mode.vala',
'utils/cue-sheet/cue-sheet-track-node.vala',
+ 'utils/dialog-utils.vala',
'utils/directory.vala',
'utils/file-operations.vala',
'utils/filename-title.vala',
diff --git a/src/ui/display-view.vala b/src/ui/display-view.vala
index b334acd0..0ce88061 100644
--- a/src/ui/display-view.vala
+++ b/src/ui/display-view.vala
@@ -458,7 +458,7 @@ private class Games.DisplayView : Gtk.Box, UiView {
resume_dialog = null;
});
- var response = yield run_dialog_async (resume_dialog);
+ var response = yield DialogUtils.run_async (resume_dialog);
// The null check is necessary because the dialog could already
// be canceled by this point
@@ -506,7 +506,7 @@ private class Games.DisplayView : Gtk.Box, UiView {
resume_failed_dialog = null;
});
- var response = yield run_dialog_async (resume_failed_dialog);
+ var response = yield DialogUtils.run_async (resume_failed_dialog);
resume_failed_dialog.destroy ();
resume_failed_dialog = null;
@@ -591,7 +591,7 @@ private class Games.DisplayView : Gtk.Box, UiView {
quit_dialog = null;
});
- var response = yield run_dialog_async (quit_dialog);
+ var response = yield DialogUtils.run_async (quit_dialog);
// The null check is necessary because the dialog could already
// be canceled by this point
@@ -713,7 +713,7 @@ private class Games.DisplayView : Gtk.Box, UiView {
var button = restart_dialog.add_button (_("Restart"), Gtk.ResponseType.ACCEPT);
button.get_style_context ().add_class ("destructive-action");
- var response = yield run_dialog_async (restart_dialog);
+ var response = yield DialogUtils.run_async (restart_dialog);
restart_dialog.destroy ();
restart_dialog = null;
@@ -827,20 +827,4 @@ private class Games.DisplayView : Gtk.Box, UiView {
return false;
}
}
-
- private async Gtk.ResponseType run_dialog_async (Gtk.Dialog dialog) {
- var response = Gtk.ResponseType.CANCEL;
-
- dialog.response.connect (r => {
- response = (Gtk.ResponseType) r;
-
- run_dialog_async.callback ();
- });
-
- dialog.present ();
-
- yield;
-
- return response;
- }
}
diff --git a/src/utils/dialog-utils.vala b/src/utils/dialog-utils.vala
new file mode 100644
index 00000000..85da22fd
--- /dev/null
+++ b/src/utils/dialog-utils.vala
@@ -0,0 +1,35 @@
+// This file is part of GNOME Games. License: GPL-3.0+.
+
+namespace Games.DialogUtils {
+ public async Gtk.ResponseType run_async (Gtk.Dialog dialog) {
+ var response = Gtk.ResponseType.CANCEL;
+
+ dialog.response.connect (r => {
+ response = (Gtk.ResponseType) r;
+
+ run_async.callback ();
+ });
+
+ dialog.present ();
+
+ yield;
+
+ return response;
+ }
+
+ public async Gtk.ResponseType run_native_async (Gtk.NativeDialog dialog) {
+ var response = Gtk.ResponseType.CANCEL;
+
+ dialog.response.connect (r => {
+ response = (Gtk.ResponseType) r;
+
+ run_native_async.callback ();
+ });
+
+ dialog.show ();
+
+ yield;
+
+ return response;
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]