Merge pull request #2093 from necauqua/master

Add call_now argument to gears.timer
This commit is contained in:
Emmanuel Lepage Vallée 2017-10-31 19:17:15 +01:00 committed by GitHub
commit 579c8cae10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions

View File

@ -30,6 +30,7 @@
--
-- gears.timer {
-- timeout = 10,
-- call_now = true,
-- autostart = true,
-- callback = function()
-- -- You should read it from `/sys/class/power_supply/` (on Linux)
@ -147,6 +148,7 @@ local timer_instance_mt = {
-- @tparam table args Arguments.
-- @tparam number args.timeout Timeout in seconds (e.g. 1.5).
-- @tparam[opt=false] boolean args.autostart Automatically start the timer.
-- @tparam[opt=false] boolean args.call_now Call the callback at timer creation.
-- @tparam[opt=nil] function args.callback Callback function to connect to the
-- "timeout" signal.
-- @tparam[opt=false] boolean args.single_shot Run only once then stop.
@ -168,6 +170,9 @@ function timer.new(args)
end
if args.callback then
if args.call_now then
args.callback()
end
ret:connect_signal("timeout", args.callback)
end