summaryrefslogtreecommitdiff
path: root/lib/astal/gtk4/src/widget/box.vala
diff options
context:
space:
mode:
authorAylur <[email protected]>2024-12-25 02:38:27 +0100
committerGitHub <[email protected]>2024-12-25 02:38:27 +0100
commit37f0d24178a1516eb45eb639640e07c5dc3b8e81 (patch)
tree28ff8d1030be1919c00152e99b4ab9c229b0f01b /lib/astal/gtk4/src/widget/box.vala
parent553b2186db47fb34602d4e949c1e40a018238d7a (diff)
parent0f2fefd2053203e1bfe4d66eb4e37dea07369890 (diff)
Merge pull request #196 from Aylur/feat/jsx-gtk4
Add jsx support for gtk4
Diffstat (limited to 'lib/astal/gtk4/src/widget/box.vala')
-rw-r--r--lib/astal/gtk4/src/widget/box.vala50
1 files changed, 50 insertions, 0 deletions
diff --git a/lib/astal/gtk4/src/widget/box.vala b/lib/astal/gtk4/src/widget/box.vala
new file mode 100644
index 0000000..28f2b00
--- /dev/null
+++ b/lib/astal/gtk4/src/widget/box.vala
@@ -0,0 +1,50 @@
+public class Astal.Box : Gtk.Box {
+ /**
+ * Corresponds to [[email protected] :orientation].
+ */
+ [CCode (notify = false)]
+ public bool vertical {
+ get { return orientation == Gtk.Orientation.VERTICAL; }
+ set { orientation = value ? Gtk.Orientation.VERTICAL : Gtk.Orientation.HORIZONTAL; }
+ }
+
+ construct {
+ notify["orientation"].connect(() => {
+ notify_property("vertical");
+ });
+ }
+
+ public List<weak Gtk.Widget> children {
+ set {
+ foreach (var child in children) {
+ remove(child);
+ }
+ foreach (var child in value) {
+ append(child);
+ }
+ }
+ owned get {
+ var list = new List<weak Gtk.Widget>();
+ var child = get_first_child();
+ while (child != null) {
+ list.append(child);
+ child = child.get_next_sibling();
+ }
+ return list;
+ }
+ }
+
+ public Gtk.Widget? child {
+ owned get {
+ foreach (var child in children) {
+ return child;
+ }
+ return null;
+ }
+ set {
+ var list = new List<weak Gtk.Widget>();
+ list.append(child);
+ this.children = children;
+ }
+ }
+}