summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAylur <[email protected]>2024-06-19 02:30:46 +0200
committerAylur <[email protected]>2024-06-19 02:30:46 +0200
commit976638c016eb21ade63779c9dade6110983dc75b (patch)
tree4c3d79d937ef147dab7223d575e514b65bfc6dab /src
parent049aeae084efd8616fbdcefc977f32dec9d0eb5a (diff)
add(box): implicit_destroy
this is a convinience property that is mostly useful in gjs and lua when binding children to a variable where these children set up connections themselves
Diffstat (limited to 'src')
-rw-r--r--src/widget/box.vala13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/widget/box.vala b/src/widget/box.vala
index 9993a38..d1c4a6b 100644
--- a/src/widget/box.vala
+++ b/src/widget/box.vala
@@ -6,6 +6,11 @@ public class Box : Gtk.Box {
set { orientation = value ? Gtk.Orientation.VERTICAL : Gtk.Orientation.HORIZONTAL; }
}
+ /**
+ * wether to implicity destroy previous children when setting them
+ */
+ public bool implicit_destroy { get; set; default = false; }
+
public List<weak Gtk.Widget> children {
set { _set_children(value); }
owned get { return get_children(); }
@@ -36,8 +41,12 @@ public class Box : Gtk.Box {
}
private void _set_children(List<weak Gtk.Widget> arr) {
- foreach(var child in get_children())
- remove(child);
+ foreach(var child in get_children()) {
+ if (implicit_destroy)
+ child.destroy();
+ else
+ remove(child);
+ }
foreach(var child in arr)
add(child);