Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getindex/setindex! for get/set child #82

Merged
merged 3 commits into from
Jan 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 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.7.3"
version = "0.7.4"

[deps]
BitFlags = "d1d4a3ce-64b1-5f1a-9ba4-7e7e69966f35"
Expand Down
11 changes: 11 additions & 0 deletions src/Gtk4.jl
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,17 @@ let skiplist = [:selected_rows, :selected, :selection_bounds, # handwritten meth
end
end

let havechild = [:GtkButton,:GtkCheckButton,:GtkMenuButton,:GtkFrame,:GtkAspectFrame,
:GtkExpander,:GtkOverlay,:GtkPopover,:GtkRevealer,:GtkViewport,
:GtkSearchBar,:GtkComboBox,:GtkWindow,:GtkScrolledWindow]
for haschild in havechild
@eval begin
getindex(w::$haschild) = G_.get_child(w)
setindex!(w::$haschild, c::Union{Nothing,GtkWidget}) = G_.set_child(w,c)
end
end
end

include("Gdk4.jl")
include("base.jl")
include("builder.jl")
Expand Down
2 changes: 1 addition & 1 deletion src/base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ Create a `GtkApplication` with DBus id `id` and flags.

Related GTK function: [`gtk_application_new`()]($(gtkdoc_method_url("gtk4","Application","new")))
"""
GtkApplication(id = nothing, flags = GLib.ApplicationFlags_FLAGS_NONE) = G_.Application_new(id,flags)
GtkApplication(id = nothing, flags = GLib.ApplicationFlags_FLAGS_NONE; kwargs...) = GtkApplication(id,flags; kwargs...)
function push!(app::GtkApplication, win::GtkWindow)
G_.add_window(app, win)
app
Expand Down
4 changes: 1 addition & 3 deletions src/buttons.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ function GtkButton(s::Symbol,str::AbstractString)
end
end

setindex!(f::GtkButton, w::Union{Nothing,GtkWidget}) = G_.set_child(f,w)
getindex(f::GtkButton) = G_.get_child(f)

function on_signal_clicked(@nospecialize(clicked_cb::Function), widget::GtkButton, vargs...)
signal_connect(clicked_cb, widget, "clicked", Nothing, (), vargs...)
end
Expand Down Expand Up @@ -82,6 +79,7 @@ function GtkVolumeButton(value::Real; kwargs...) # 0 <= value <= 1
end

popup(b::GtkMenuButton) = G_.popup(b)
popdown(b::GtkMenuButton) = G_.popdown(b)

function GtkPopoverMenu(model::GMenu, nested::Bool = false)
if nested
Expand Down
18 changes: 0 additions & 18 deletions src/layout.jl
Original file line number Diff line number Diff line change
Expand Up @@ -221,19 +221,6 @@ function GtkFrame(w::GtkWidget, label=nothing; kwargs...)
f
end

setindex!(f::GtkFrame, w::Union{Nothing,GtkWidget}) = G_.set_child(f,w)
getindex(f::GtkFrame) = G_.get_child(f)

## GtkAspectFrame - A widget that preserves the aspect ratio of its child

setindex!(f::GtkAspectFrame, w::Union{Nothing,GtkWidget}) = G_.set_child(f,w)
getindex(f::GtkAspectFrame) = G_.get_child(f)

## GtkExpander

setindex!(f::GtkExpander, w::Union{Nothing,GtkWidget}) = G_.set_child(f,w)
getindex(f::GtkExpander) = G_.get_child(f)

## GtkNotebook

function insert!(w::GtkNotebook, position::Integer, x::GtkWidget, label::Union{GtkWidget, AbstractString})
Expand Down Expand Up @@ -296,9 +283,6 @@ function GtkOverlay(w::GtkWidget; kwargs...)
o
end

setindex!(f::GtkOverlay, w::Union{Nothing,GtkWidget}) = G_.set_child(f,w)
getindex(f::GtkOverlay) = G_.get_child(f)

function add_overlay(f::GtkOverlay, x::GtkWidget, clip_overlay=false, measure_overlay=false)
G_.add_overlay(f,x)
clip_overlay && G_.set_clip_overlay(f,x,true)
Expand Down Expand Up @@ -326,7 +310,5 @@ end

## GtkPopover

getindex(w::GtkPopover) = G_.get_child(w)
setindex!(w::GtkPopover, c::GtkWidget) = G_.set_child(w,c)
popup(m::GtkPopover) = G_.popup(m)

3 changes: 0 additions & 3 deletions src/lists.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
## GtkComboBox

setindex!(f::GtkComboBox, w::Union{Nothing,GtkWidget}) = G_.set_child(f,w)
getindex(f::GtkComboBox) = G_.get_child(f)

GtkComboBoxText(with_entry::Bool) =
if with_entry
G_.ComboBoxText_new_with_entry()
Expand Down
5 changes: 0 additions & 5 deletions src/windows.jl
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,6 @@ present(win::GtkWindow) = G_.present(win)
present(win::GtkWindow, timestamp) = G_.present_with_time(win, timestamp)

push!(w::GtkWindow, widget::GtkWidget) = (G_.set_child(w, widget); w)
setindex!(w::GtkWindow, widget::Union{Nothing,GtkWidget}) = G_.set_child(w, widget)
getindex(w::GtkWindow) = G_.get_child(w)

# totally ugly hack to salvage this Gtk.jl legacy function for its original purpose
function GLib.waitforsignal(obj::GtkWindow,signal)
Expand Down Expand Up @@ -188,9 +186,6 @@ function GtkApplicationWindow(app::GtkApplication, title::AbstractString; kwargs
win
end

setindex!(w::GtkScrolledWindow, widg::Union{Nothing,GtkWidget}) = G_.set_child(w,widg)
getindex(w::GtkScrolledWindow) = G_.get_child(w)

## GtkHeaderBar

push!(hb::GtkHeaderBar, w::GtkWidget) = (G_.pack_end(hb, w); hb)
Expand Down
Loading