Skip to content

Commit

Permalink
support GtkSizeGroup and add tests (#53)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jwahlstrand authored Feb 17, 2024
1 parent d94555e commit 8198d3f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
4 changes: 3 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions src/base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
20 changes: 19 additions & 1 deletion test/gui/misc.jl
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 8198d3f

Please sign in to comment.