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




commit a8beaf1312a212634b8a4a64473f65ffea389cf5
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 adcd5be..a55bb5a 100644
--- a/src/nibbles-view.vala
+++ b/src/nibbles-view.vala
@@ -63,6 +63,12 @@ private class NibblesView : Widget
 //            set_opacity (0);
 //            restore_easing_state ();
         }
+
+        internal void destroy ()
+        {
+            foreach (Widget widget in widgets)
+                widget.destroy ();
+        }
     }
 
     internal const uint8 WIDTH = 92;
@@ -178,17 +184,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]