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




commit bb95874dbee230705800271e7b994390eeb24757
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 be7f4d3..ea661dc 100644
--- a/src/window.vala
+++ b/src/window.vala
@@ -242,11 +242,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 ()
@@ -300,10 +301,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]