summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAylur <[email protected]>2024-06-10 22:05:40 +0200
committerAylur <[email protected]>2024-06-10 22:05:40 +0200
commit183e68d68c3cbc264a9e94339af3ff7982acd3cc (patch)
treedae0a56c8c5cd2b375f62ddbf58bed9d553411f5 /src
parent27883173a9c540a17bc144af3c2dde710be03fc3 (diff)
fix overlay setters
setting overlays would remove its child
Diffstat (limited to 'src')
-rw-r--r--src/widget/overlay.vala31
1 files changed, 20 insertions, 11 deletions
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<weak Gtk.Widget> 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 {