telak: use timer

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2009-06-30 13:56:08 +02:00
parent e899ca7696
commit f554060ffe
1 changed files with 5 additions and 4 deletions

View File

@ -11,9 +11,9 @@ local http = require("socket.http")
local ltn12 = require("ltn12")
local setmetatable = setmetatable
local util = require("awful.util")
local hooks = require("awful.hooks")
local capi =
{
timer = timer,
wibox = wibox,
widget = widget,
image = image
@ -55,8 +55,9 @@ local function new(_, args)
local wimg = capi.widget({ type = "imagebox" })
w.widgets = wimg
data[w].cb = function () update(w) end
hooks.timer.register(args.timer or 300, data[w].cb)
data[w].timer = capi.timer { timeout = args.timer or 300 }
data[w].timer:add_signal("timeout", function update(w) end)
data[w].timer:start()
update(w)
@ -67,7 +68,7 @@ end
-- @param w The wibox.
function delete(w)
if data[w] then
hooks.timer.unregister(data[w].cb)
data[w].timer:stop()
data[w] = nil
end
end