diff --git a/src/GLib/GLib.jl b/src/GLib/GLib.jl index 699f8006..9b79a052 100644 --- a/src/GLib/GLib.jl +++ b/src/GLib/GLib.jl @@ -23,6 +23,7 @@ export signal_connect, signal_emit, signal_handler_disconnect export signal_handler_block, signal_handler_unblock export setproperty!, getproperty export GConnectFlags +export @sigatom module CompatGLib export @assign_if_unassigned diff --git a/src/GLib/signals.jl b/src/GLib/signals.jl index 0d7b8e9f..2ca5f994 100644 --- a/src/GLib/signals.jl +++ b/src/GLib/signals.jl @@ -155,7 +155,7 @@ g_stack = nothing # need to call g_loop_run from only one stack const g_yielded = Ref(false) # when true, use the `g_doatomic` queue to run sigatom functions const g_doatomic = [] # (work, notification) scheduler queue const g_sigatom_flag = Ref(false) # keep track of Base sigatomic state -function g_sigatom(f::Base.Callable) # calls f, where f never throws (but this function may throw) +function g_sigatom(f::ANY) # calls f, where f never throws (but this function may throw) global g_sigatom_flag, g_stack, g_doatomic prev = g_sigatom_flag[] stk = g_stack @@ -199,6 +199,13 @@ function g_sigatom(f::Base.Callable) # calls f, where f never throws (but this f end return ret end +macro sigatom(f) + return quote + g_sigatom() do + $(esc(f)) + end + end +end function g_siginterruptible(f::Base.Callable, cb) # calls f (which may throw), but this function never throws global g_sigatom_flag, g_stack diff --git a/src/base.jl b/src/base.jl index 45ac7188..91ca960f 100644 --- a/src/base.jl +++ b/src/base.jl @@ -1,6 +1,6 @@ unsafe_convert(::Type{Ptr{GObject}},w::AbstractStringLike) = unsafe_convert(Ptr{GObject},GtkLabelLeaf(w)) -destroy(w::GtkWidget) = ccall((:gtk_widget_destroy,libgtk), Void, (Ptr{GObject},), w) +destroy(w::GtkWidget) = @sigatom ccall((:gtk_widget_destroy,libgtk), Void, (Ptr{GObject},), w) parent(w::GtkWidget) = convert(GtkWidget, ccall((:gtk_widget_get_parent,libgtk), Ptr{GObject}, (Ptr{GObject},), w)) hasparent(w::GtkWidget) = ccall((:gtk_widget_get_parent,libgtk), Ptr{Void}, (Ptr{GObject},), w) != C_NULL function toplevel(w::GtkWidget) @@ -29,9 +29,9 @@ end ### Functions and methods common to all GtkWidget objects visible(w::GtkWidget) = bool(ccall((:gtk_widget_get_visible,libgtk),Cint,(Ptr{GObject},),w)) -visible(w::GtkWidget, state::Bool) = ccall((:gtk_widget_set_visible,libgtk),Void,(Ptr{GObject},Cint),w,state) -show(w::GtkWidget) = (ccall((:gtk_widget_show,libgtk),Void,(Ptr{GObject},),w); w) -showall(w::GtkWidget) = (ccall((:gtk_widget_show_all,libgtk),Void,(Ptr{GObject},),w); w) +visible(w::GtkWidget, state::Bool) = @sigatom ccall((:gtk_widget_set_visible,libgtk),Void,(Ptr{GObject},Cint),w,state) +show(w::GtkWidget) = (@sigatom ccall((:gtk_widget_show,libgtk),Void,(Ptr{GObject},),w); w) +showall(w::GtkWidget) = (@sigatom ccall((:gtk_widget_show_all,libgtk),Void,(Ptr{GObject},),w); w) # TODO Use Pango type PangoFontDescription once it is wrapped modifyfont(w::GtkWidget, font_desc::Ptr{Void}) = diff --git a/src/gio.jl b/src/gio.jl index d1ce5c5a..b077dd36 100644 --- a/src/gio.jl +++ b/src/gio.jl @@ -1,7 +1,7 @@ if gtk_version == 3 -run(app::GApplication) = GLib.g_sigatom() do - ccall((:g_application_run,libgio),Cint, (Ptr{GObject},Cint, Ptr{Ptr{UInt8}}), app, 0, C_NULL) -end +run(app::GApplication) = + (@sigatom ccall((:g_application_run,libgio), Cint, + (Ptr{GObject},Cint, Ptr{Ptr{UInt8}}), app, 0, C_NULL))::Cint function register(app::GApplication) GError() do error_check