diff options
-rw-r--r-- | gjs/src/astalify.ts | 3 | ||||
-rw-r--r-- | lua/astal/widget.lua | 10 | ||||
-rw-r--r-- | src/widget/centerbox.vala | 14 |
3 files changed, 21 insertions, 6 deletions
diff --git a/gjs/src/astalify.ts b/gjs/src/astalify.ts index ecd52d4..b97d730 100644 --- a/gjs/src/astalify.ts +++ b/gjs/src/astalify.ts @@ -156,7 +156,8 @@ function ctor(self: any, config: any = {}, children: any[] = []) { })) } else { - setChildren(self, children) + if (children.length > 0) + setChildren(self, children) } setup?.(self) diff --git a/lua/astal/widget.lua b/lua/astal/widget.lua index 7a88a1c..8cbb9b9 100644 --- a/lua/astal/widget.lua +++ b/lua/astal/widget.lua @@ -166,7 +166,11 @@ local function astalify(ctor) end -- construct, attach bindings, add children - local widget = ctor(props) + local widget = ctor() + + for prop, value in pairs(props) do + widget[prop] = value + end for prop, binding in pairs(bindings) do widget.on_destroy = binding:subscribe(function(v) @@ -180,7 +184,9 @@ local function astalify(ctor) set_children(widget, v) end) else - set_children(widget, children) + if #children > 0 then + set_children(widget, children) + end end if type(setup) == "function" then diff --git a/src/widget/centerbox.vala b/src/widget/centerbox.vala index eedee9b..0588828 100644 --- a/src/widget/centerbox.vala +++ b/src/widget/centerbox.vala @@ -23,7 +23,8 @@ public class CenterBox : Gtk.Box { if (_start_widget != null) remove(_start_widget); - pack_start(value, true, true, 0); + if (value != null) + pack_start(value, true, true, 0); } } @@ -34,13 +35,20 @@ public class CenterBox : Gtk.Box { if (_end_widget != null) remove(_end_widget); - pack_end(value, true, true, 0); + if (value != null) + pack_end(value, true, true, 0); } } public Gtk.Widget center_widget { get { return get_center_widget(); } - set { set_center_widget(value); } + set { + if (center_widget != null) + remove(center_widget); + + if (value != null) + set_center_widget(value); + } } } } |