diff --git a/GI/src/GLibBase/GLibBase.jl b/GI/src/GLibBase/GLibBase.jl index 3d6e293e..e8498439 100644 --- a/GI/src/GLibBase/GLibBase.jl +++ b/GI/src/GLibBase/GLibBase.jl @@ -15,16 +15,6 @@ export GInterface, GType, GObject, GBoxed, GTypeInstance export GEnum, GError, GValue, g_type export GHashTable, GByteArray, GArray, GPtrArray export GList, _GSList, _GList -export cfunction_ - - -cfunction_(@nospecialize(f), r, a::Tuple) = cfunction_(f, r, Tuple{a...}) - -@generated function cfunction_(f, R::Type{rt}, A::Type{at}) where {rt, at<:Tuple} - quote - @cfunction($(Expr(:$,:f)), $rt, ($(at.parameters...),)) - end -end # local function, handles Symbol and makes UTF8-strings easier const AbstractStringLike = Union{AbstractString, Symbol} @@ -33,7 +23,6 @@ bytestring(s::Symbol) = s bytestring(s::Ptr{UInt8}) = s == C_NULL ? nothing : unsafe_string(s) # bytestring(s::Ptr{UInt8}, own::Bool=false) = unsafe_string(s) -g_malloc(s::Integer) = ccall((:g_malloc, libglib), Ptr{Nothing}, (Csize_t,), s) g_free(p::Ptr) = ccall((:g_free, libglib), Nothing, (Ptr{Nothing},), p) gtkdoc_const_url(ns,name)="https://docs.gtk.org/$(ns)/const.$(name).html" diff --git a/GI/src/GLibBase/gtype.jl b/GI/src/GLibBase/gtype.jl index bdeea0f6..4461e1e7 100644 --- a/GI/src/GLibBase/gtype.jl +++ b/GI/src/GLibBase/gtype.jl @@ -57,7 +57,6 @@ end g_isa(gtyp::GType, is_a_type::GType) = ccall((:g_type_is_a, libgobject), Cint, (GType, GType), gtyp, is_a_type) != 0 g_type_name(g_type::GType) = Symbol(bytestring(ccall((:g_type_name, libgobject), Ptr{UInt8}, (GType,), g_type))) -g_type_test_flags(g_type::GType, flag) = ccall((:g_type_test_flags, libgobject), Bool, (GType, GEnum), g_type, flag) const G_TYPE_FLAG_CLASSED = 1 << 0 const G_TYPE_FLAG_INSTANTIATABLE = 1 << 1 const G_TYPE_FLAG_DERIVABLE = 1 << 2 diff --git a/GI/src/girepo.jl b/GI/src/girepo.jl index efffe907..28ad398b 100644 --- a/GI/src/girepo.jl +++ b/GI/src/girepo.jl @@ -26,7 +26,6 @@ function info_unref(info::GIInfo) info.handle = C_NULL end -convert(::Type{Ptr{GIBaseInfo}},w::GIInfo) = w.handle unsafe_convert(::Type{Ptr{GIBaseInfo}},w::GIInfo) = w.handle const GIInfoTypesShortNames = (:Invalid, :Function, :Callback, :Struct, :Boxed, :Enum, @@ -115,13 +114,7 @@ struct GINamespace new(namespace) end end -convert(::Type{Symbol}, ns::GINamespace) = ns.name convert(::Type{Cstring}, ns::GINamespace) = ns.name -convert(::Type{Ptr{UInt8}}, ns::GINamespace) = convert(Ptr{UInt8}, ns.name) -unsafe_convert(::Type{Symbol}, ns::GINamespace) = ns.name -unsafe_convert(::Type{Ptr{UInt8}}, ns::GINamespace) = convert(Ptr{UInt8}, ns.name) - -Base.:(==)(a::GINamespace, b::GINamespace) = (a.name === b.name) function gi_require(namespace::Symbol, version = nothing) if isnothing(version) diff --git a/src/buttons.jl b/src/buttons.jl index 05d6b74d..5fb90db8 100644 --- a/src/buttons.jl +++ b/src/buttons.jl @@ -94,4 +94,3 @@ end GtkPopoverMenuBar(model::GMenu) = G_.PopoverMenuBar_new_from_model(model) menu_model(b::Union{GtkMenuButton,GtkPopoverMenu, GtkPopoverMenuBar}, model) = G_.set_menu_model(b, GMenuModel(model)) -menu_model(b::Union{GtkMenuButton,GtkPopoverMenu, GtkPopoverMenuBar}) = G_.get_menu_model(b) diff --git a/src/cairo.jl b/src/cairo.jl index e531e66f..1e3682fd 100644 --- a/src/cairo.jl +++ b/src/cairo.jl @@ -22,7 +22,7 @@ end function _canvas_on_resize(::Ptr, width, height, canvas) canvas.is_sized = true - if G_.get_realized(canvas) + if isrealized(canvas) _init_canvas!(canvas, width, height) if isa(canvas.resize, Function) diff --git a/src/gen/gdkpixbuf_consts b/src/gen/gdkpixbuf_consts index 7cd92348..702a785a 100644 --- a/src/gen/gdkpixbuf_consts +++ b/src/gen/gdkpixbuf_consts @@ -2,9 +2,9 @@ quote $(Expr(:toplevel, quote begin const PIXBUF_MAJOR = 2 - const PIXBUF_MICRO = 8 + const PIXBUF_MICRO = 10 const PIXBUF_MINOR = 42 - const PIXBUF_VERSION = "2.42.8" + const PIXBUF_VERSION = "2.42.10" begin @cenum Colorspace::Int32 Colorspace_RGB = 0 (GLib.g_type(::Type{T}) where T <: Colorspace) = begin diff --git a/test/gdkpixbuf.jl b/test/gdkpixbuf.jl index f0a712f2..5faf6183 100644 --- a/test/gdkpixbuf.jl +++ b/test/gdkpixbuf.jl @@ -9,6 +9,8 @@ using Test, Gtk4, Gtk4.GdkPixbufLib, Colors, TestImages t2 = GdkMemoryTexture(img,false) @test size(t2) == size(img) + arr = Gtk4.toarray(t2) + @test size(arr) == size(img) end @testset "pixbuf" begin diff --git a/test/gui/canvas.jl b/test/gui/canvas.jl index bee5572b..8b2748be 100644 --- a/test/gui/canvas.jl +++ b/test/gui/canvas.jl @@ -10,7 +10,8 @@ gs = GtkEventControllerScroll(Gtk4.EventControllerScrollFlags_VERTICAL,c) gk = GtkEventControllerKey(c) ggc = GtkGestureClick(c) ggd = GtkGestureDrag(c) -gsc = GtkShortcutController(c) + gsc = GtkShortcutController(c) + Gtk4.add_action_shortcut(gsc,"S","win.copy") ggz = GtkGestureZoom(c) t = Gtk4.find_controller(c,GtkEventControllerMotion) @test t==gm diff --git a/test/gui/examples.jl b/test/gui/examples.jl index 7ac20f34..1c6716e2 100644 --- a/test/gui/examples.jl +++ b/test/gui/examples.jl @@ -66,4 +66,13 @@ end destroy(main_window) end + @testset "Show Image" begin + include(joinpath(@__DIR__, "..", "..", "examples", "show_image.jl")) + destroy(win) + end + + @testset "CSS Style" begin + include(joinpath(@__DIR__, "..", "..", "examples", "css-style.jl")) + end + end diff --git a/test/gui/layout.jl b/test/gui/layout.jl index 3b2fce42..861915e4 100644 --- a/test/gui/layout.jl +++ b/test/gui/layout.jl @@ -86,6 +86,8 @@ end push!(nb, four, "tab _four") @test pagenumber(nb, four) == 4 @test length(nb) == 4 + deleteat!(nb, 3) + @test length(nb) == 3 empty!(nb) @test length(nb) == 0 destroy(w) diff --git a/test/gui/misc.jl b/test/gui/misc.jl index dbe30bcb..28b479c8 100644 --- a/test/gui/misc.jl +++ b/test/gui/misc.jl @@ -1,5 +1,9 @@ using Test, Gtk4, Gtk4.G_, Gtk4.GLib +@testset "Initialization" begin + @test Gtk4.isinitialized() +end + @testset "get/set property and binding" begin w = GtkWindow("Window", 400, 300) @test w.title == "Window" @@ -125,6 +129,9 @@ Gtk4.child(w,f) l = GtkLabel("label"); push!(f,l) b = GtkButton("button"); push!(f,b) +add_css_class(b,"error") +remove_css_class(b,"error") + counter = 0 id = signal_connect(b, "activate") do widget counter::Int += 1 @@ -151,7 +158,7 @@ destroy(w) end @testset "Builder" begin -b=GtkBuilder("test.ui") +b=GtkBuilder(joinpath(dirname(@__FILE__), "test.ui")) widgets = [w for w in b] @test length(widgets)==length(b) @test length(b)==6 @@ -165,7 +172,9 @@ destroy(a_window) @test button == b["a_button"] -s = open("test.ui","r") do f +testui = joinpath(dirname(@__FILE__), "test.ui") + +s = open(testui,"r") do f read(f,String) end b3 = GtkBuilder(s,-1) @@ -173,7 +182,7 @@ win = b3["a_window"] destroy(win) b4 = GtkBuilder() -push!(b4; filename="test.ui") +push!(b4; filename=testui) win = b4["a_window"] destroy(win) @@ -206,7 +215,7 @@ end w = GtkWindow(l) show(w) - ### add css tests here + delete!(sc, provider) destroy(w) end @@ -215,9 +224,15 @@ end @test keyval("H") == Gtk4.KEY_H end -@testset "IconTheme" begin - i = GtkIconTheme(GdkDisplay()) +@testset "IconTheme and CSS for GdkDisplay" begin + d = GdkDisplay() + i = GtkIconTheme(d) Gtk4.icon_theme_add_search_path(i, ".") + + css = "GtkLabel { color: blue; }" + provider = GtkCssProvider(css) + push!(d, provider, 500) + delete!(d, provider) end @testset "Menus" begin @@ -239,6 +254,7 @@ push!(filemenu, quit) GLib.submenu(menubar,"File",filemenu) mb = GtkPopoverMenuBar(menubar) +@test Gtk4.menu_model(mb) == menubar b = GtkBox(:h) push!(b,mb) win = GtkWindow(b, "Menus", 200, 40) diff --git a/test/test.ui b/test/gui/test.ui similarity index 100% rename from test/test.ui rename to test/gui/test.ui diff --git a/test/runtests.jl b/test/runtests.jl index 7c2efbbc..ef8a5eed 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -40,8 +40,8 @@ include("gui/input.jl") include("gui/layout.jl") include("gui/window.jl") include("gui/listviews.jl") -#include("gui/examples.jl") -#include("gui/application.jl") # needs to be last because it messes with the main loop +include("gui/examples.jl") +include("gui/application.jl") # needs to be last because it messes with the main loop end GC.gc()