[gnome-nibbles/arnaudb/wip/gtk4: 36/40] Clean walls after each level.



commit 67edc49139cf4bae65a3ef1fc508488f487b4479
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Tue Jun 16 17:31:48 2020 +0200

    Clean walls after each level.
    
    Else it is more complicated.

 src/nibbles-view.vala | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
---
diff --git a/src/nibbles-view.vala b/src/nibbles-view.vala
index f1d29d8..a8e6fcc 100644
--- a/src/nibbles-view.vala
+++ b/src/nibbles-view.vala
@@ -61,6 +61,12 @@ private class WormView : Object
 //        set_opacity (0);
 //        restore_easing_state ();
     }
+
+    internal void destroy ()
+    {
+        foreach (Widget widget in widgets)
+            widget.destroy ();
+    }
 }
 
 private class NibblesView : Widget
@@ -174,17 +180,38 @@ private class NibblesView : Widget
             error ("Nibbles couldn't find pixmap file: %s", filename);
 
         foreach (var actor in worm_actors.values)
+        {
+            actor.hide ();
             actor.unparent ();
+            actor.destroy ();
+        }
         worm_actors.clear ();
 
         foreach (var actor in bonus_actors.values)
+        {
+            actor.hide ();
             actor.unparent ();
+            actor.destroy ();
+        }
         bonus_actors.clear ();
 
         foreach (var actor in warp_actors)
+        {
+            actor.hide ();
             actor.unparent ();
+            actor.destroy ();
+        }
         warp_actors.clear ();
 
+        Widget? widget = get_first_child ();
+        while (widget != null)
+        {
+            widget.hide ();
+            widget.unparent ();
+            widget.destroy ();
+            widget = get_first_child ();
+        }
+
 //        if (level != null)
 //        {
 //            level.remove_all_children ();


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