textclock: Load GLib.DateTime only once
I doubt that this makes much of a difference since lgi surely caches things, but this still seems nicer to me. Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
fe0a96d7f1
commit
31fcc11272
|
@ -11,6 +11,7 @@ local setmetatable = setmetatable
|
||||||
local os = os
|
local os = os
|
||||||
local textbox = require("wibox.widget.textbox")
|
local textbox = require("wibox.widget.textbox")
|
||||||
local timer = require("gears.timer")
|
local timer = require("gears.timer")
|
||||||
|
local DateTime = require("lgi").GLib.DateTime
|
||||||
|
|
||||||
local textclock = { mt = {} }
|
local textclock = { mt = {} }
|
||||||
|
|
||||||
|
@ -32,7 +33,7 @@ function textclock.new(format, timeout)
|
||||||
local w = textbox()
|
local w = textbox()
|
||||||
local t = timer { timeout = timeout }
|
local t = timer { timeout = timeout }
|
||||||
t:connect_signal("timeout", function()
|
t:connect_signal("timeout", function()
|
||||||
w:set_markup(require("lgi").GLib.DateTime.new_now_local():format(format))
|
w:set_markup(DateTime.new_now_local():format(format))
|
||||||
t.timeout = calc_timeout(timeout)
|
t.timeout = calc_timeout(timeout)
|
||||||
t:again()
|
t:again()
|
||||||
end)
|
end)
|
||||||
|
|
Loading…
Reference in New Issue