From 183e68d68c3cbc264a9e94339af3ff7982acd3cc Mon Sep 17 00:00:00 2001 From: Aylur Date: Mon, 10 Jun 2024 22:05:40 +0200 Subject: fix overlay setters setting overlays would remove its child --- src/widget/overlay.vala | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/widget/overlay.vala b/src/widget/overlay.vala index 4833180..207aaa7 100644 --- a/src/widget/overlay.vala +++ b/src/widget/overlay.vala @@ -2,33 +2,42 @@ namespace Astal { public class Overlay : Gtk.Overlay { public bool pass_through { get; set; } - public Gtk.Widget overlay { + public Gtk.Widget? overlay { get { return overlays.nth_data(0); } set { - foreach (var ch in get_children()) - remove(ch); + foreach (var ch in get_children()) { + if (ch != child) + remove(ch); + } - add_overlay(value); + if (value != null) + add_overlay(value); } } public List overlays { owned get { return get_children(); } set { - foreach (var ch in get_children()) - remove(ch); + foreach (var ch in get_children()) { + if (ch != child) + remove(ch); + } foreach (var ch in value) add_overlay(ch); } } - public void set_child(Gtk.Widget widget) { - var ch = get_child(); - if (ch != null) { - remove(ch); + public new Gtk.Widget? child { + get { return get_child(); } + set { + var ch = get_child(); + if (ch != null) + remove(ch); + + if (value != null) + add(value); } - add(widget); } construct { -- cgit v1.2.3