awful.tag.attached_connect_signal: Simplify

Signals are emitted on individual objects and on the class for a while now. This
can be used to simplify this function a lot.

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2012-10-20 17:35:09 +02:00
parent 2ada67b730
commit 9c9b2b52b0
1 changed files with 5 additions and 11 deletions

View File

@ -479,15 +479,11 @@ function tag.withcurrent(c, startup)
end end
local function attached_connect_signal_screen(screen, sig, func) local function attached_connect_signal_screen(screen, sig, func)
capi.screen[screen]:connect_signal("tag::attach", function (s, _tag) capi.tag.connect_signal(sig, function(_tag, ...)
_tag:connect_signal(sig, func) if tag.getscreen(_tag) == screen then
end) func(_tag)
capi.screen[screen]:connect_signal("tag::detach", function (s, _tag)
_tag:disconnect_signal(sig, func)
end)
for _, _tag in ipairs(tag.gettags(screen)) do
_tag:connect_signal(sig, func)
end end
end)
end end
--- Add a signal to all attached tag and all tag that will be attached in the --- Add a signal to all attached tag and all tag that will be attached in the
@ -497,9 +493,7 @@ function tag.attached_connect_signal(screen, ...)
if screen then if screen then
attached_connect_signal_screen(screen, ...) attached_connect_signal_screen(screen, ...)
else else
for screen = 1, capi.screen.count() do capi.tag.connect_signal(...)
attached_connect_signal_screen(screen, ...)
end
end end
end end