naughty: hover_timeout can now be used in notify()

Signed-off-by: koniu <gkusnierz@gmail.com>
This commit is contained in:
koniu 2008-11-25 00:14:29 +00:00 committed by Julien Danjou
parent fd0e1022bb
commit 5603d93da6
1 changed files with 6 additions and 4 deletions

View File

@ -205,6 +205,7 @@ end
-- @param ontop Target screen for the notification
-- @param run Function to run on left click
-- @param width The popup width
-- @field hover_timeout Delay in seconds after which hovered popup disappears.
-- @param replaces_id Replace the notification with the given ID
-- @usage naughty.notify({ title = 'Achtung!', text = 'You\'re idling', timeout = 0 })
-- @return The notification object
@ -217,6 +218,7 @@ function notify(args)
local screen = args.screen or config.screen
local ontop = args.ontop or config.ontop
local width = args.width or config.width
local hover_timeout = args.hover_timeout or config.hover_timeout
-- beautiful
local beautiful = bt.get()
@ -260,8 +262,8 @@ function notify(args)
local run = args.run or die
local hover_destroy = function ()
if config.hover_timeout == 0 then die()
else hooks.timer.register(config.hover_timeout, die) end
if hover_timeout == 0 then die()
else hooks.timer.register(hover_timeout, die) end
end
-- create textbox
@ -269,7 +271,7 @@ function notify(args)
textbox:buttons({ button({ }, 1, run),
button({ }, 3, die) })
textbox.text = string.format('<margin right="'..config.margin..'" left="'..config.margin..'"/><span font_desc="%s"><b>%s</b>%s</span>', font, title, text)
if config.hover_timeout then textbox.mouse_enter = hover_destroy end
if hover_timeout then textbox.mouse_enter = hover_destroy end
-- create iconbox
local iconbox = nil
@ -287,7 +289,7 @@ function notify(args)
end
iconbox.resize = false
iconbox.image = img
if config.hover_timeout then iconbox.mouse_enter = hover_destroy end
if hover_timeout then iconbox.mouse_enter = hover_destroy end
end
end