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:
Uli Schlachter 2015-06-12 10:57:42 +02:00
parent fe0a96d7f1
commit 31fcc11272
1 changed files with 2 additions and 1 deletions

View File

@ -11,6 +11,7 @@ local setmetatable = setmetatable
local os = os
local textbox = require("wibox.widget.textbox")
local timer = require("gears.timer")
local DateTime = require("lgi").GLib.DateTime
local textclock = { mt = {} }
@ -32,7 +33,7 @@ function textclock.new(format, timeout)
local w = textbox()
local t = timer { timeout = timeout }
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:again()
end)