diff --git a/Project.toml b/Project.toml index daff7794..2d72cd06 100644 --- a/Project.toml +++ b/Project.toml @@ -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" diff --git a/src/Gtk4.jl b/src/Gtk4.jl index fe06b5f9..9097ff34 100644 --- a/src/Gtk4.jl +++ b/src/Gtk4.jl @@ -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") diff --git a/src/base.jl b/src/base.jl index d1b5691a..8e7e1acd 100644 --- a/src/base.jl +++ b/src/base.jl @@ -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 diff --git a/src/buttons.jl b/src/buttons.jl index 5fb90db8..0be4c47e 100644 --- a/src/buttons.jl +++ b/src/buttons.jl @@ -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 @@ -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 diff --git a/src/layout.jl b/src/layout.jl index aaa66b29..6a986cd0 100644 --- a/src/layout.jl +++ b/src/layout.jl @@ -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}) @@ -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) @@ -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) diff --git a/src/lists.jl b/src/lists.jl index 0bfc9dbb..15ef63d0 100644 --- a/src/lists.jl +++ b/src/lists.jl @@ -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() diff --git a/src/windows.jl b/src/windows.jl index 2d0ac043..29c61fcf 100644 --- a/src/windows.jl +++ b/src/windows.jl @@ -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) @@ -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)