awful.widget.textclock: Port to new widget system
Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
0cb3569e3e
commit
b55dc20319
|
@ -6,27 +6,25 @@
|
||||||
|
|
||||||
local setmetatable = setmetatable
|
local setmetatable = setmetatable
|
||||||
local os = os
|
local os = os
|
||||||
local capi = { widget = widget,
|
local textbox = require("wibox.widget.textbox")
|
||||||
timer = timer }
|
local capi = { timer = timer }
|
||||||
|
|
||||||
--- Text clock widget.
|
--- Text clock widget.
|
||||||
module("awful.widget.textclock")
|
module("awful.widget.textclock")
|
||||||
|
|
||||||
--- Create a textclock widget. It draws the time it is in a textbox.
|
--- Create a textclock widget. It draws the time it is in a textbox.
|
||||||
-- @param args Standard arguments for textbox widget.
|
|
||||||
-- @param format The time format. Default is " %a %b %d, %H:%M ".
|
-- @param format The time format. Default is " %a %b %d, %H:%M ".
|
||||||
-- @param timeout How often update the time. Default is 60.
|
-- @param timeout How often update the time. Default is 60.
|
||||||
-- @return A textbox widget.
|
-- @return A textbox widget.
|
||||||
function new(args, format, timeout)
|
function new(format, timeout)
|
||||||
local args = args or {}
|
|
||||||
local format = format or " %a %b %d, %H:%M "
|
local format = format or " %a %b %d, %H:%M "
|
||||||
local timeout = timeout or 60
|
local timeout = timeout or 60
|
||||||
args.type = "textbox"
|
|
||||||
local w = capi.widget(args)
|
local w = textbox()
|
||||||
local timer = capi.timer { timeout = timeout }
|
local timer = capi.timer { timeout = timeout }
|
||||||
w.text = os.date(format)
|
timer:connect_signal("timeout", function() w:set_markup(os.date(format)) end)
|
||||||
timer:connect_signal("timeout", function() w.text = os.date(format) end)
|
|
||||||
timer:start()
|
timer:start()
|
||||||
|
timer:emit_signal("timeout")
|
||||||
return w
|
return w
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue