From 8198d3f7dd3a07b878706ccb8ca1ca1194c7e32f Mon Sep 17 00:00:00 2001 From: Jared Wahlstrand Date: Sat, 17 Feb 2024 12:18:00 -0500 Subject: [PATCH] support GtkSizeGroup and add tests (#53) Add push! and delete! methods for GtkSizeGroup and tests for a method that returns a GList with transfer=none. Also put a limit on the version of libpng, which prevents tests from failing on Windows x86. I assume this is a bug in one of the libraries and will look into it further later. --- Project.toml | 4 +++- src/base.jl | 3 +++ test/gui/misc.jl | 20 +++++++++++++++++++- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index 1d25fb23..8b330617 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "Gtk4" uuid = "9db2cae5-386f-4011-9d63-a5602296539b" -version = "0.6.1" +version = "0.6.2" [deps] BitFlags = "d1d4a3ce-64b1-5f1a-9ba4-7e7e69966f35" @@ -14,6 +14,7 @@ Graphene_jll = "75302f13-0b7e-5bab-a6d1-23fa92e4c2ea" Graphics = "a2bd30eb-e257-5431-a919-1863eab51364" JLLWrappers = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210" Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb" +libpng_jll = "b53b4c65-9356-5827-b1ea-8c7a1a84506f" Librsvg_jll = "925c91fb-5dd6-59dd-8e8c-345e74382d89" Pango_jll = "36c8627f-9965-5494-a995-c6b170f724f3" Preferences = "21216c6a-2e73-6563-6e65-726566657250" @@ -36,6 +37,7 @@ Graphene_jll = "1.10" Graphics = "1" JLLWrappers = "1.4.0" Libdl = "1.6" +libpng_jll = "<1.6.42" Librsvg_jll = "2.54" Pango_jll = "1.50" Preferences = "1" diff --git a/src/base.jl b/src/base.jl index bd1bceb7..5474ffdc 100644 --- a/src/base.jl +++ b/src/base.jl @@ -136,6 +136,9 @@ Returns a GListModel of all toplevel widgets (i.e. windows) known to GTK4. """ toplevels() = G_.get_toplevels() +push!(sg::GtkSizeGroup, w::GtkWidget) = (G_.add_widget(sg, w); sg) +delete!(sg::GtkSizeGroup, w::GtkWidget) = (G_.remove_widget(sg, w); sg) + @doc """ display(w::GtkWidget) diff --git a/test/gui/misc.jl b/test/gui/misc.jl index 941113f7..790dc0e3 100644 --- a/test/gui/misc.jl +++ b/test/gui/misc.jl @@ -1,4 +1,4 @@ -using Test, Gtk4, Gtk4.G_ +using Test, Gtk4, Gtk4.G_, Gtk4.GLib @testset "get/set property and binding" begin w = GtkWindow("Window", 400, 300) @@ -52,6 +52,24 @@ using Test, Gtk4, Gtk4.G_ destroy(w2) end +@testset "SizeGroup" begin + sg = GtkSizeGroup(Gtk4.SizeGroupMode_BOTH) + b = GtkLabel("#1") + b2 = GtkLabel("#2") + push!(sg, b) + push!(sg, b2) + + widgets = Gtk4.widgets(sg) + @test length(widgets) == 2 + + @test Gtk4.size_request(b) == Gtk4.size_request(b2) + + delete!(sg, b2) + + widgets = Gtk4.widgets(sg) + @test length(widgets) == 1 +end + @testset "Iteration and toplevel" begin ## example of last in first covered ## Create this GUI, then shrink window with the mouse