[five-or-more/arnaudb/wip/gtk4: 76/80] Adapt to Dialog API.




commit 79019df9c2b38b39de49f1088d0949b6bd5c7adb
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 10a318a..4c2d5ac 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]