diff --git a/src/GLib/signals.jl b/src/GLib/signals.jl index 4e308868..06cafd19 100644 --- a/src/GLib/signals.jl +++ b/src/GLib/signals.jl @@ -412,13 +412,12 @@ end waitforsignal(obj::GObject, signal) Returns when a GObject's signal is emitted. Can be used to wait for a window to -be closed. +be closed. This function should only be used for signals that return nothing, with one exception: the "close-request" signal of GtkWindow. """ function waitforsignal(obj::GObject,signal) c = Condition() signal_connect(obj, signal) do w notify(c) - return false end wait(c) end diff --git a/src/windows.jl b/src/windows.jl index 6bd83631..9f4d7b77 100644 --- a/src/windows.jl +++ b/src/windows.jl @@ -153,6 +153,20 @@ 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) + if signal === :close_request || signal == "close-request" + c = Condition() + signal_connect(obj, signal) do w + notify(c) + return false + end + wait(c) + else + invoke(GLib.waitforsignal, Tuple{GObject,Any}, obj, signal) + end +end + function push!(wg::GtkWindowGroup, w::GtkWindow) G_.add_window(wg,w) wg