[gnome-klotski] Do not use 'as' keyword.



commit 6bfd1832c7015b714210423f5d600d434e920e09
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Sun Feb 9 01:55:46 2020 +0100

    Do not use 'as' keyword.

 src/klotski-window.vala | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)
---
diff --git a/src/klotski-window.vala b/src/klotski-window.vala
index 5a16590..a2fe684 100644
--- a/src/klotski-window.vala
+++ b/src/klotski-window.vala
@@ -525,11 +525,11 @@ private class KlotskiWindow : ApplicationWindow
             maximize ();
 
         add_action_entries (win_actions, this);
-        prev_pack = lookup_action ("prev-pack") as SimpleAction;
-        next_pack = lookup_action ("next-pack") as SimpleAction;
-        prev_puzzle = lookup_action ("prev-puzzle") as SimpleAction;
-        next_puzzle = lookup_action ("next-puzzle") as SimpleAction;
-        start_game = lookup_action ("start-game") as SimpleAction;
+        lookup_non_nullable_action ("prev-pack",    out prev_pack);
+        lookup_non_nullable_action ("next-pack",    out next_pack);
+        lookup_non_nullable_action ("prev-puzzle",  out prev_puzzle);
+        lookup_non_nullable_action ("next-puzzle",  out next_puzzle);
+        lookup_non_nullable_action ("start-game",   out start_game);
 
         scores_context = new Games.Scores.Context.with_importer (
             "gnome-klotski",
@@ -601,6 +601,14 @@ private class KlotskiWindow : ApplicationWindow
         start_puzzle ();
     }
 
+    private void lookup_non_nullable_action (string name, out SimpleAction action)
+    {
+        GLib.Action? nullable_action = lookup_action (name);
+        if (nullable_action == null)
+            assert_not_reached ();
+        action = (SimpleAction) (!) nullable_action;
+    }
+
     /*\
     * * Window management callbacks
     \*/


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]