From 9fab13452a26ed55c01047d4225f699f43bba20d Mon Sep 17 00:00:00 2001 From: Aylur Date: Mon, 14 Oct 2024 16:45:03 +0000 Subject: feat: Astal3 --- lib/astal/gtk3/src/widget/overlay.vala | 57 ++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 lib/astal/gtk3/src/widget/overlay.vala (limited to 'lib/astal/gtk3/src/widget/overlay.vala') diff --git a/lib/astal/gtk3/src/widget/overlay.vala b/lib/astal/gtk3/src/widget/overlay.vala new file mode 100644 index 0000000..603ee66 --- /dev/null +++ b/lib/astal/gtk3/src/widget/overlay.vala @@ -0,0 +1,57 @@ +public class Astal.Overlay : Gtk.Overlay { + public bool pass_through { get; set; } + + public Gtk.Widget? overlay { + get { return overlays.nth_data(0); } + set { + foreach (var ch in get_children()) { + if (ch != child) + remove(ch); + } + + if (value != null) + add_overlay(value); + } + } + + public List overlays { + owned get { return get_children(); } + set { + foreach (var ch in get_children()) { + if (ch != child) + remove(ch); + } + + foreach (var ch in value) + add_overlay(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); + } + } + + construct { + notify["pass-through"].connect(() => { + update_pass_through(); + }); + } + + private void update_pass_through() { + foreach (var child in get_children()) + set_overlay_pass_through(child, pass_through); + } + + public new void add_overlay(Gtk.Widget widget) { + base.add_overlay(widget); + set_overlay_pass_through(widget, pass_through); + } +} -- cgit v1.2.3 From 306e64998c1bf1fb997c1098ae92d6edfef31cd2 Mon Sep 17 00:00:00 2001 From: Aylur Date: Wed, 23 Oct 2024 20:37:32 +0000 Subject: docs: astal3 and io comments --- lib/astal/gtk3/src/widget/overlay.vala | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib/astal/gtk3/src/widget/overlay.vala') diff --git a/lib/astal/gtk3/src/widget/overlay.vala b/lib/astal/gtk3/src/widget/overlay.vala index 603ee66..ed5f03b 100644 --- a/lib/astal/gtk3/src/widget/overlay.vala +++ b/lib/astal/gtk3/src/widget/overlay.vala @@ -1,6 +1,11 @@ public class Astal.Overlay : Gtk.Overlay { public bool pass_through { get; set; } + /** + * First [property@Astal.Overlay:overlays] element. + * + * WARNING: setting this value will remove every overlay but the first. + */ public Gtk.Widget? overlay { get { return overlays.nth_data(0); } set { @@ -14,6 +19,9 @@ public class Astal.Overlay : Gtk.Overlay { } } + /** + * Sets the overlays of this Overlay. [method@Gtk.Overlay.add_overlay]. + */ public List overlays { owned get { return get_children(); } set { -- cgit v1.2.3