Merge pull request #2093 from necauqua/master
Add call_now argument to gears.timer
This commit is contained in:
commit
579c8cae10
|
@ -30,6 +30,7 @@
|
||||||
--
|
--
|
||||||
-- gears.timer {
|
-- gears.timer {
|
||||||
-- timeout = 10,
|
-- timeout = 10,
|
||||||
|
-- call_now = true,
|
||||||
-- autostart = true,
|
-- autostart = true,
|
||||||
-- callback = function()
|
-- callback = function()
|
||||||
-- -- You should read it from `/sys/class/power_supply/` (on Linux)
|
-- -- You should read it from `/sys/class/power_supply/` (on Linux)
|
||||||
|
@ -147,6 +148,7 @@ local timer_instance_mt = {
|
||||||
-- @tparam table args Arguments.
|
-- @tparam table args Arguments.
|
||||||
-- @tparam number args.timeout Timeout in seconds (e.g. 1.5).
|
-- @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.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
|
-- @tparam[opt=nil] function args.callback Callback function to connect to the
|
||||||
-- "timeout" signal.
|
-- "timeout" signal.
|
||||||
-- @tparam[opt=false] boolean args.single_shot Run only once then stop.
|
-- @tparam[opt=false] boolean args.single_shot Run only once then stop.
|
||||||
|
@ -168,6 +170,9 @@ function timer.new(args)
|
||||||
end
|
end
|
||||||
|
|
||||||
if args.callback then
|
if args.callback then
|
||||||
|
if args.call_now then
|
||||||
|
args.callback()
|
||||||
|
end
|
||||||
ret:connect_signal("timeout", args.callback)
|
ret:connect_signal("timeout", args.callback)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue