Skip to content

Commit

Permalink
improved error message when a compound widgets toplevel does not have…
Browse files Browse the repository at this point in the history
… a signal with given name
  • Loading branch information
Clemapfel committed Feb 8, 2024
1 parent 6a7a882 commit 4f16e9f
Showing 1 changed file with 31 additions and 6 deletions.
37 changes: 31 additions & 6 deletions src/Mousetrap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5543,45 +5543,70 @@ end # else MOUSETRAP_ENABLE_OPENGL_COMPONENT
connect_signal_name = :connect_signal_ * signal * :!
push!(out.args, esc(:(
function Mousetrap.$connect_signal_name(f, x::Widget)
$connect_signal_name(f, Mousetrap.get_top_level_widget(x))
if Mousetrap.is_native_widget(x)
log_critical(Mousetrap.MOUSETRAP_DOMAIN, "In " * $(string(connect_signal_name)) * ": object of type `$(typeof(x))` has no signal with ID `" * $(string(signal)) * "`")
else
$connect_signal_name(f, Mousetrap.get_top_level_widget(x))
end
end
)))

push!(out.args, esc(:(
function Mousetrap.$connect_signal_name(f, x::Widget, data::Data_t) where Data_t
$connect_signal_name(f, Mousetrap.get_top_level_widget(x), data)
if Mousetrap.is_native_widget(x)
log_critical(Mousetrap.MOUSETRAP_DOMAIN, "In " * $(string(connect_signal_name)) * ": object of type `$(typeof(x))` has no signal with ID `" * $(string(signal)) * "`")
else
$connect_signal_name(f, Mousetrap.get_top_level_widget(x), data)
end
end
)))

emit_signal_name = :emit_signal_ * signal

push!(out.args, esc(:(
function $emit_signal_name(x::Widget, args...)
$emit_signal_name(Mousetrap.get_top_level_widget(x), args)
if Mousetrap.is_native_widget(x)
log_critical(Mousetrap.MOUSETRAP_DOMAIN, "In " * $(string(emit_signal_name)) * ": object of type `$(typeof(x))` has no signal with ID `" * $(string(signal)) * "`")
else
$emit_signal_name(Mousetrap.get_top_level_widget(x), args)
end
end
)))

disconnect_signal_name = :disconnect_signal_ * signal * :!

push!(out.args, esc(:(
function $disconnect_signal_name(x::Widget)
$disconnect_signal_name(Mousetrap.get_top_level_widget(x))
if Mousetrap.is_native_widget(x)
log_critical(Mousetrap.MOUSETRAP_DOMAIN, "In " * $(string(disconnect_signal_name)) * ": object of type `$(typeof(x))` has no signal with ID `" * $(string(signal)) * "`")
else
$disconnect_signal_name(Mousetrap.get_top_level_widget(x))
end
end
)))

set_signal_blocked_name = :set_signal_ * signal * :_blocked * :!

push!(out.args, esc(:(
function $set_signal_blocked_name(x::Widget, b)
$set_signal_blocked_name(Mousetrap.get_top_level_widget(x), b)
if Mousetrap.is_native_widget(x)
log_critical(Mousetrap.MOUSETRAP_DOMAIN, "In " * $(string(set_signal_blocked_name)) * ": object of type `$(typeof(x))` has no signal with ID `" * $(string(signal)) * "`")
else
$set_signal_blocked_name(Mousetrap.get_top_level_widget(x), b)
end
end
)))

get_signal_blocked_name = :get_signal_ * signal * :_blocked

push!(out.args, esc(:(
function $get_signal_blocked_name(x::Widget)
return $get_signal_blocked_name(Mousetrap.get_top_level_widget(x))
if Mousetrap.is_native_widget(x)
log_critical(Mousetrap.MOUSETRAP_DOMAIN, "In " * $(string(get_signal_blocked_name)) * ": object of type `$(typeof(x))` has no signal with ID `" * $(string(signal)) * "`")
return false
else
return $get_signal_blocked_name(Mousetrap.get_top_level_widget(x))
end
end
)))
end
Expand Down

0 comments on commit 4f16e9f

Please sign in to comment.