[five-or-more/arnaudb/wip/gtk4: 7/9] Adapt to Dialog API.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [five-or-more/arnaudb/wip/gtk4: 7/9] Adapt to Dialog API.
- Date: Wed, 5 Aug 2020 16:43:53 +0000 (UTC)
commit bac61cbb0868a853b58ab6091ed88c5f45eee080
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Tue Aug 4 17:13:23 2020 +0200
Adapt to Dialog API.
src/window.vala | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
---
diff --git a/src/window.vala b/src/window.vala
index e46e9d5..3da58f1 100644
--- a/src/window.vala
+++ b/src/window.vala
@@ -241,11 +241,12 @@ private class GameWindow : ApplicationWindow
if (!settings.set_string (FiveOrMoreApp.KEY_BACKGROUND_COLOR, color.to_string ()))
warning ("Failed to set color: %s", color.to_string ());
});
- var result = dialog.run ();
- dialog.destroy ();
- if (result == ResponseType.OK)
- return;
- settings.set_string (FiveOrMoreApp.KEY_BACKGROUND_COLOR, old_color_string);
+ dialog.response.connect ((_dialog, response) => {
+ _dialog.destroy ();
+ if (response != ResponseType.OK)
+ settings.set_string (FiveOrMoreApp.KEY_BACKGROUND_COLOR, old_color_string);
+ });
+ dialog.present ();
}
private inline void reset_background ()
@@ -299,10 +300,13 @@ private class GameWindow : ApplicationWindow
/* Translators: button of a dialog that appears when the user starts a new game while the score
is not null; the other answer is "_Cancel" */
_("_Restart"), ResponseType.OK);
- var result = restart_game_dialog.run ();
- restart_game_dialog.destroy ();
- if (result != ResponseType.OK)
- return;
+ restart_game_dialog.response.connect ((_restart_game_dialog, response) => {
+ _restart_game_dialog.destroy ();
+ if (response == ResponseType.OK)
+ game.new_game (size);
+ });
+ restart_game_dialog.present ();
+ return;
}
game.new_game (size);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]