Skip to content

Commit

Permalink
Merge branch 'main' into v7
Browse files Browse the repository at this point in the history
  • Loading branch information
jwahlstrand committed Aug 25, 2024
2 parents 62ebce0 + 0f65bbc commit d0cac18
Show file tree
Hide file tree
Showing 8 changed files with 122 additions and 14 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ Cairo = "1.0.0"
Cairo_jll = "1.16.0"
ColorTypes = "0.10, 0.11"
FixedPointNumbers = "0.5, 0.6, 0.7, 0.8"
GTK4_jll = "4.12.0"
GTK4_jll = "4.14.0"
Glib_jll = "2.78.0"
Graphene_jll = "1.10"
Graphics = "1"
JLLWrappers = "1.4.0"
Libdl = "1.10"
libpng_jll = "<1.6.42"
Librsvg_jll = "2.54"
Pango_jll = "1.51"
Pango_jll = "1.54"
Preferences = "1"
Reexport = "1.0"
Scratch = "1.1.0"
Expand Down
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,8 @@ Other registered packages extend the functionality of Gtk4.jl:
- [GtkObservables.jl](https://github.com/JuliaGizmos/GtkObservables.jl): provides integration with [Observables.jl](https://github.com/JuliaGizmos/Observables.jl). This package can simplify making interactive GUI's with Gtk4.jl.
- [Gtk4Makie.jl](https://github.com/JuliaGtk/Gtk4Makie.jl): provides integration with the popular plotting package [Makie.jl](https://github.com/MakieOrg/Makie.jl), specifically its interactive, high performance GLMakie backend.

A port of [ProfileView](https://github.com/timholy/ProfileView.jl) based on Gtk4 is available.
The registered version of ProfileView.jl uses Gtk.jl and thus cannot be used to profile Gtk4-based code.
To use the Gtk4 port, enter `add https://github.com/jwahlstrand/ProfileView.jl#gtk4` in Julia's package mode.

## Current status
For auto-generated code, Gtk4.jl relies on GObject introspection data generated on a Linux x86_64 machine, which may result in code that crashes on 32 bit computers. This seems to affect mostly obscure parts of GLib that are unlikely to be useful to Julia users, but 32 bit users should be aware of this.
For auto-generated code, Gtk4.jl relies on GObject introspection data generated on a Linux x86_64 machine, which may result in code that crashes on 32 bit computers. This mostly seems to affect obscure parts of GLib that are unlikely to be useful to Julia users, but 32 bit users should be aware of this.

Note that this package uses binaries for the GTK library and its dependencies that are built and packaged using [BinaryBuilder.jl](https://github.com/JuliaPackaging/BinaryBuilder.jl). On Linux it does **not** use the binaries that are packaged with your distribution. The build scripts for the binaries used by Gtk4.jl, including the library versions currently being used, can be found by perusing [Yggdrasil.jl](https://github.com/JuliaPackaging/Yggdrasil.jl).

Expand Down
2 changes: 2 additions & 0 deletions src/Gtk4.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ eval(include("gen/gsk4_structs"))
eval(include("gen/gtk4_consts"))
eval(include("gen/gtk4_structs"))

const ModifierType_NONE = ModifierType_NO_MODIFIER_MASK

module G_

using GTK4_jll, Glib_jll
Expand Down
8 changes: 4 additions & 4 deletions src/base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ end
Flag `w` to be displayed and return `w`.
Related GTK function: [`gtk_widget_show`()]($(gtkdoc_method_url("gtk4","Widget","show")))
Related GTK function: [`gtk_widget_set_visible`()]($(gtkdoc_method_url("gtk4","Widget","set_visible")))
"""
function show(w::GtkWidget)
G_.show(w)
G_.set_visible(w, true)
w
end

Expand All @@ -95,10 +95,10 @@ end
Flag `w` to be hidden and return `w`. This is the opposite of `show`.
Related GTK function: [`gtk_widget_hide`()]($(gtkdoc_method_url("gtk4","Widget","hide")))
Related GTK function: [`gtk_widget_set_visible`()]($(gtkdoc_method_url("gtk4","Widget","set_visible")))
"""
function hide(w::GtkWidget)
G_.hide(w)
G_.set_visible(w, false)
w
end

Expand Down
72 changes: 72 additions & 0 deletions src/gen/gsk4_structs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,78 @@ $(Expr(:toplevel, quote
end
const GskPathPointLike = GskPathPoint
end
mutable struct GskPath <: GBoxed
handle::Ptr{GskPath}
begin
(GLib.g_type(::Type{T}) where T <: GskPath) = begin
ccall(("gsk_path_get_type", libgtk4), GType, ())
end
function GskPath(ref::Ptr{T}, own::Bool = false) where T <: GBoxed
x = new(ref)
if own
finalizer(x) do x
GLib.delboxed(x)
end
end
x
end
push!(gboxed_types, GskPath)
end
end
mutable struct GskPathBuilder <: GBoxed
handle::Ptr{GskPathBuilder}
begin
(GLib.g_type(::Type{T}) where T <: GskPathBuilder) = begin
ccall(("gsk_path_builder_get_type", libgtk4), GType, ())
end
function GskPathBuilder(ref::Ptr{T}, own::Bool = false) where T <: GBoxed
x = new(ref)
if own
finalizer(x) do x
GLib.delboxed(x)
end
end
x
end
push!(gboxed_types, GskPathBuilder)
end
end
mutable struct GskPathMeasure <: GBoxed
handle::Ptr{GskPathMeasure}
begin
(GLib.g_type(::Type{T}) where T <: GskPathMeasure) = begin
ccall(("gsk_path_measure_get_type", libgtk4), GType, ())
end
function GskPathMeasure(ref::Ptr{T}, own::Bool = false) where T <: GBoxed
x = new(ref)
if own
finalizer(x) do x
GLib.delboxed(x)
end
end
x
end
push!(gboxed_types, GskPathMeasure)
end
end
mutable struct GskPathPoint <: GBoxed
handle::Ptr{GskPathPoint}
begin
(GLib.g_type(::Type{T}) where T <: GskPathPoint) = begin
ccall(("gsk_path_point_get_type", libgtk4), GType, ())
end
function GskPathPoint(ref::Ptr{T}, own::Bool = false) where T <: GBoxed
x = new(ref)
if own
finalizer(x) do x
GLib.delboxed(x)
end
end
x
end
push!(gboxed_types, GskPathPoint)
end
end
begin
mutable struct GskRoundedRect
handle::Ptr{GskRoundedRect}
Expand Down
18 changes: 18 additions & 0 deletions src/gen/gtk4_structs
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,24 @@ $(Expr(:toplevel, quote
end
const GtkPrintSetupLike = GtkPrintSetup
end
mutable struct GtkPrintSetup <: GBoxed
handle::Ptr{GtkPrintSetup}
begin
(GLib.g_type(::Type{T}) where T <: GtkPrintSetup) = begin
ccall(("gtk_print_setup_get_type", libgtk4), GType, ())
end
function GtkPrintSetup(ref::Ptr{T}, own::Bool = false) where T <: GBoxed
x = new(ref)
if own
finalizer(x) do x
GLib.delboxed(x)
end
end
x
end
push!(gboxed_types, GtkPrintSetup)
end
end
begin
struct _GtkRecentData
display_name::Cstring
Expand Down
13 changes: 13 additions & 0 deletions src/lists.jl
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,20 @@ GObject properties.
"""
GtkGridView(model=nothing; kwargs...) = GtkGridView(model, nothing; kwargs...)

function scroll_to(lv::Union{GtkListView,GtkGridView}, pos, flags = ListScrollFlags_NONE)
G_.scroll_to(lv, pos - 1, flags, nothing)
end

GtkColumnView(; kwargs...) = GtkColumnView(nothing; kwargs...)

function scroll_to(cv::GtkColumnView, pos, flags::ListScrollFlags = ListScrollFlags_NONE)
G_.scroll_to(lv, pos - 1, nothing, flags, nothing)
end

function scroll_to(cv::GtkColumnView, pos, column::GtkColumnViewColumn, flags::ListScrollFlags = ListScrollFlags_NONE)
G_.scroll_to(lv, pos - 1, column, flags, nothing)
end

GtkColumnViewColumn(title=""; kwargs...) = GtkColumnViewColumn(title, nothing; kwargs...)
push!(cv::GtkColumnView, cvc::GtkColumnViewColumn) = (G_.append_column(cv,cvc); cv)

Expand Down
13 changes: 10 additions & 3 deletions src/windows.jl
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,15 @@ Related GTK function: [`gtk_window_is_fullscreen`()]($(gtkdoc_method_url("gtk4",
"""
isfullscreen(win::GtkWindow) = G_.is_fullscreen(win)

"""
issuspended(win::GtkWindow)
Get whether `win` is in a state where it's invisible to the user.
Related GTK function: [`gtk_window_is_suspended`()]($(gtkdoc_method_url("gtk4","Window","is_suspended")))
"""
issuspended(win::GtkWindow) = G_.is_suspended(win)

"""
maximize(win::GtkWindow)
Expand All @@ -130,9 +139,7 @@ unmaximize(win::GtkWindow) = G_.unmaximize(win)
"""
present(win::GtkWindow [, timestamp])
Presents a window to the user. Usually means move it to the front. According to the GTK
docs, this function "should not be used" without including a timestamp for the user's
request. However, it's not clear from the GTK docs what the timestamp is exactly.
Presents a window to the user. Usually means move it to the front.
Related GTK function: [`gtk_window_present`()]($(gtkdoc_method_url("gtk4","Window","present")))
Related GTK function: [`gtk_window_present_with_time`()]($(gtkdoc_method_url("gtk4","Window","present_with_time")))
Expand Down

0 comments on commit d0cac18

Please sign in to comment.