From fb8704bb7d25ae1ae401c28e3fb7b3c6650740da Mon Sep 17 00:00:00 2001 From: PhiCross5 <56079747+PhiCross5@users.noreply.github.com> Date: Wed, 16 Aug 2023 18:16:51 -0300 Subject: [PATCH 1/2] Make Gtk Box call append() for array part --- lgi/override/Gtk.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lgi/override/Gtk.lua b/lgi/override/Gtk.lua index 96a76d5a..1d930a21 100644 --- a/lgi/override/Gtk.lua +++ b/lgi/override/Gtk.lua @@ -219,6 +219,9 @@ if Gtk.Container then end end +-------------------------------- Gtk.Box overrides. +Gtk.Box._container_add = Gtk.Box.append + -------------------------------- Gtk.Builder overrides. Gtk.Builder._attribute = {} From 9020ed2121229ec9ebcdef8e5094d5fa822003eb Mon Sep 17 00:00:00 2001 From: Phicross5 Date: Fri, 18 Aug 2023 23:56:49 -0300 Subject: [PATCH 2/2] wrap the gtk Box override around a gtk4 version check --- lgi/override/Gtk.lua | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/lgi/override/Gtk.lua b/lgi/override/Gtk.lua index 1d930a21..1812a6fb 100644 --- a/lgi/override/Gtk.lua +++ b/lgi/override/Gtk.lua @@ -219,8 +219,6 @@ if Gtk.Container then end end --------------------------------- Gtk.Box overrides. -Gtk.Box._container_add = Gtk.Box.append -------------------------------- Gtk.Builder overrides. Gtk.Builder._attribute = {} @@ -634,6 +632,25 @@ Gtk._constant.PRINT_OUTPUT_URI = 'output-uri' -- Gtk-cairo integration helpers. cairo.Context._method.should_draw_window = Gtk.cairo_should_draw_window +-------------------------------- Gtk-4 overrides + + +if Gtk._version == '4.0' then + + --- CONTAINER CLASSES + --- GTK4 Has removed the Container abstract class. + --- This means Boxes, Grids and other layout widgets + --- Must now add children using their own specific methods. + + --- Gtk.Box overrides + + --- widgets on a the array part of the constructor of a Box + --- will be `append()`-ed + --- in order of appearance. + Gtk.Box._container_add = Gtk.Box.append + +end + --------------------------------- Gtk-2 workarounds if Gtk._version == '2.0' then -- Get rid of Gtk.Bin internal 'child' field, which gets in the way