diff --git a/Adwaita/src/gen/adw_consts b/Adwaita/src/gen/adw_consts index 3e36d5fc..438d8df1 100644 --- a/Adwaita/src/gen/adw_consts +++ b/Adwaita/src/gen/adw_consts @@ -3,9 +3,9 @@ $(Expr(:toplevel, quote begin const DURATION_INFINITE = 0xffffffff const MAJOR_VERSION = 1 - const MICRO_VERSION = 3 + const MICRO_VERSION = 4 const MINOR_VERSION = 5 - const VERSION_S = "1.5.3" + const VERSION_S = "1.5.4" begin @cenum AnimationState::Int32 AnimationState_IDLE = 0 AnimationState_PAUSED = 1 AnimationState_PLAYING = 2 AnimationState_FINISHED = 3 (GLib.g_type(::Type{T}) where T <: AnimationState) = begin diff --git a/Adwaita/src/gen/adw_methods b/Adwaita/src/gen/adw_methods index c7a27b8c..5cd05f27 100644 --- a/Adwaita/src/gen/adw_methods +++ b/Adwaita/src/gen/adw_methods @@ -5435,6 +5435,7 @@ $(Expr(:toplevel, quote get_buildable_id(GtkBuildable(instance)) end function SpringAnimation_new(_widget::GtkWidget, _from::Real, _to::Real, _spring_params::AdwSpringParams, _target::AdwAnimationTarget) + _spring_params = GLib.glib_ref(_spring_params) _target = GLib.glib_ref(_target) ret = ccall(("adw_spring_animation_new", libadwaita), Ptr{GObject}, (Ptr{GObject}, Float64, Float64, Ptr{AdwSpringParams}, Ptr{GObject}), _widget, _from, _to, _spring_params, _target) ret2 = AdwSpringAnimationLeaf(ret, false) diff --git a/GI/src/giimport.jl b/GI/src/giimport.jl index ed72f614..d3136a7b 100644 --- a/GI/src/giimport.jl +++ b/GI/src/giimport.jl @@ -844,6 +844,10 @@ function convert_to_c(name::Symbol, arginfo::GIArgInfo, typeinfo::TypeDesc{T}) w _convert_obj_to_c(name,arginfo,typeinfo) end +function convert_to_c(name::Symbol, arginfo::GIArgInfo, typeinfo::TypeDesc{T}) where {T<:Type{GBoxed}} + _convert_obj_to_c(name,arginfo,typeinfo) +end + function convert_from_c(name::Symbol, arginfo::ArgInfo, typeinfo::TypeDesc{T}, isconstructor=false) where {T <: Type{GObject}} owns = get_ownership_transfer(arginfo) != GITransfer.NOTHING object = get_container(arginfo) diff --git a/examples/word_counter.jl b/examples/word_counter.jl index 8e9458f5..f2791e1b 100644 --- a/examples/word_counter.jl +++ b/examples/word_counter.jl @@ -3,7 +3,7 @@ using Gtk4 win = GtkWindow("Word counter") b = GtkBox(:v) -tv = GtkTextView(; vexpand = true) +tv = GtkTextView(; vexpand = true, wrap_mode = Gtk4.WrapMode_WORD) l = GtkLabel("0 characters, 0 words, 0 lines") push!(b, tv) Gtk4.gutter(tv, :bottom, l) diff --git a/src/GLib/gtype.jl b/src/GLib/gtype.jl index 2896e628..519a8b71 100644 --- a/src/GLib/gtype.jl +++ b/src/GLib/gtype.jl @@ -128,6 +128,12 @@ function delboxed(x::GBoxed) ccall((:g_boxed_free, libgobject), Nothing, (GType, Ptr{GBoxed},), gtype, x.handle) end +function glib_ref(x::GBoxed) + T=typeof(x) + gtype = g_type(T) + ccall((:g_boxed_copy, libgobject), Ptr{GBoxed}, (GType, Ptr{GBoxed},), gtype, x.handle) +end + cconvert(::Type{Ptr{GObject}}, @nospecialize(x::GObject)) = x # All GObjects are expected to have a 'handle' field diff --git a/src/Graphene.jl b/src/Graphene.jl index f529a2d8..e5c90f7b 100644 --- a/src/Graphene.jl +++ b/src/Graphene.jl @@ -3,6 +3,8 @@ module Graphene using ..GLib using Graphene_jll +import Base: convert, length, getindex, iterate, unsafe_convert + import CEnum: @cenum, CEnum eval(include("gen/graphene_consts")) @@ -10,9 +12,18 @@ eval(include("gen/graphene_structs")) export _GrapheneRect, _GraphenePoint, _GrapheneMatrix, _GrapheneVec4, _GrapheneVec3, _GrapheneSize, _GraphenePoint3D -#eval(include("gen/graphene_methods")) +module G_ + +using Graphene_jll + +using ..GLib +using ..Graphene + +eval(include("gen/graphene_methods")) #eval(include("gen/graphene_functions")) +end + _GrapheneRect(x::Number,y::Number,w::Number,h::Number) = _GrapheneRect(_GraphenePoint(x,y),_GrapheneSize(w,h)) function __init__() diff --git a/src/gen/gtk4_methods b/src/gen/gtk4_methods index d39bc73e..79a45261 100644 --- a/src/gen/gtk4_methods +++ b/src/gen/gtk4_methods @@ -4428,7 +4428,12 @@ $(Expr(:toplevel, quote end function scroll_to(instance::GtkColumnView, _pos::Integer, _column::Maybe(GtkColumnViewColumn), _flags, _scroll::Maybe(GtkScrollInfo)) _column_maybe = nothing_to_null(_column) - _scroll_maybe = nothing_to_null(_scroll) + _scroll_maybe = begin + if _scroll !== nothing + GLib.glib_ref(_scroll) + end + nothing_to_null(_scroll) + end ret = ccall(("gtk_column_view_scroll_to", libgtk4), Nothing, (Ptr{GObject}, UInt32, Ptr{GObject}, UInt32, Ptr{GtkScrollInfo}), instance, _pos, _column_maybe, _flags, _scroll_maybe) nothing end @@ -5977,7 +5982,12 @@ $(Expr(:toplevel, quote nothing end function DropTargetAsync_new(_formats::Maybe(GdkContentFormats), _actions) - _formats_maybe = nothing_to_null(_formats) + _formats_maybe = begin + if _formats !== nothing + GLib.glib_ref(_formats) + end + nothing_to_null(_formats) + end ret = ccall(("gtk_drop_target_async_new", libgtk4), Ptr{GObject}, (Ptr{GdkContentFormats}, UInt32), _formats_maybe, _actions) ret2 = GtkDropTargetAsyncLeaf(ret, true) ret2 @@ -9845,7 +9855,12 @@ $(Expr(:toplevel, quote ret2 end function scroll_to(instance::GtkGridView, _pos::Integer, _flags, _scroll::Maybe(GtkScrollInfo)) - _scroll_maybe = nothing_to_null(_scroll) + _scroll_maybe = begin + if _scroll !== nothing + GLib.glib_ref(_scroll) + end + nothing_to_null(_scroll) + end ret = ccall(("gtk_grid_view_scroll_to", libgtk4), Nothing, (Ptr{GObject}, UInt32, UInt32, Ptr{GtkScrollInfo}), instance, _pos, _flags, _scroll_maybe) nothing end @@ -12498,7 +12513,12 @@ $(Expr(:toplevel, quote ret2 end function scroll_to(instance::GtkListView, _pos::Integer, _flags, _scroll::Maybe(GtkScrollInfo)) - _scroll_maybe = nothing_to_null(_scroll) + _scroll_maybe = begin + if _scroll !== nothing + GLib.glib_ref(_scroll) + end + nothing_to_null(_scroll) + end ret = ccall(("gtk_list_view_scroll_to", libgtk4), Nothing, (Ptr{GObject}, UInt32, UInt32, Ptr{GtkScrollInfo}), instance, _pos, _flags, _scroll_maybe) nothing end @@ -17467,6 +17487,7 @@ $(Expr(:toplevel, quote nothing end function push_gl_shader(instance::GtkSnapshot, _shader::GskGLShader, _bounds::GrapheneRectLike, _take_args::GBytes) + _take_args = GLib.glib_ref(_take_args) ret = ccall(("gtk_snapshot_push_gl_shader", libgtk4), Nothing, (Ptr{GObject}, Ptr{GObject}, Ptr{_GrapheneRect}, Ptr{GBytes}), instance, _shader, _bounds, _take_args) nothing end @@ -21905,7 +21926,12 @@ $(Expr(:toplevel, quote ret2 end function scroll_to(instance::GtkViewport, _descendant::GtkWidget, _scroll::Maybe(GtkScrollInfo)) - _scroll_maybe = nothing_to_null(_scroll) + _scroll_maybe = begin + if _scroll !== nothing + GLib.glib_ref(_scroll) + end + nothing_to_null(_scroll) + end ret = ccall(("gtk_viewport_scroll_to", libgtk4), Nothing, (Ptr{GObject}, Ptr{GObject}, Ptr{GtkScrollInfo}), instance, _descendant, _scroll_maybe) nothing end @@ -22100,7 +22126,12 @@ $(Expr(:toplevel, quote nothing end function allocate(instance::GtkWidget, _width::Integer, _height::Integer, _baseline::Integer, _transform::Maybe(GskTransform)) - _transform_maybe = nothing_to_null(_transform) + _transform_maybe = begin + if _transform !== nothing + GLib.glib_ref(_transform) + end + nothing_to_null(_transform) + end ret = ccall(("gtk_widget_allocate", libgtk4), Nothing, (Ptr{GObject}, Int32, Int32, Int32, Ptr{GskTransform}), instance, _width, _height, _baseline, _transform_maybe) nothing end diff --git a/src/gen/pango_methods b/src/gen/pango_methods index d47561cf..0a5432bc 100644 --- a/src/gen/pango_methods +++ b/src/gen/pango_methods @@ -48,6 +48,7 @@ $(Expr(:toplevel, quote ret2 end function change(instance::PangoAttrList, _attr::PangoAttributeLike) + _attr = GLib.glib_ref(_attr) ret = ccall(("pango_attr_list_change", libpango), Nothing, (Ptr{PangoAttrList}, Ptr{_PangoAttribute}), instance, _attr) nothing end @@ -72,10 +73,12 @@ $(Expr(:toplevel, quote ret2 end function insert(instance::PangoAttrList, _attr::PangoAttributeLike) + _attr = GLib.glib_ref(_attr) ret = ccall(("pango_attr_list_insert", libpango), Nothing, (Ptr{PangoAttrList}, Ptr{_PangoAttribute}), instance, _attr) nothing end function insert_before(instance::PangoAttrList, _attr::PangoAttributeLike) + _attr = GLib.glib_ref(_attr) ret = ccall(("pango_attr_list_insert_before", libpango), Nothing, (Ptr{PangoAttrList}, Ptr{_PangoAttribute}), instance, _attr) nothing end