naughty: cleanup of some code repetitions

Signed-off-by: koniu <gkusnierz@gmail.com>
This commit is contained in:
koniu 2008-11-05 02:18:01 +00:00
parent 390b218526
commit 0d98ed7f5a
1 changed files with 8 additions and 8 deletions

View File

@ -218,21 +218,21 @@ function notify(args)
idx = idx idx = idx
} }
local timer = function () destroy(notification) end local die = function () destroy(notification) end
hooks.timer.register(timeout, timer) hooks.timer.register(timeout, die)
notification.timer = timer notification.die = die
local run = args.run or function () destroy(notification) end local run = args.run or die
local hover_destroy = function () local hover_destroy = function ()
if config.hover_timeout == 0 then destroy(notification) if config.hover_timeout == 0 then die()
else hooks.timer.register(config.hover_timeout, timer) end else hooks.timer.register(config.hover_timeout, die) end
end end
-- populate the wibox with widgets -- populate the wibox with widgets
local textbox = widget({ type = "textbox", name = "text", align = "flex" }) local textbox = widget({ type = "textbox", name = "text", align = "flex" })
textbox:buttons({ button({ }, 1, run), textbox:buttons({ button({ }, 1, run),
button({ }, 3, function () destroy(notification) end) }) button({ }, 3, die) })
textbox.text = string.format('<span font_desc="%s"><b>%s</b> %s</span>', textbox.text = string.format('<span font_desc="%s"><b>%s</b> %s</span>',
config.font, title, text) config.font, title, text)
if config.hover_timeout then textbox.mouse_enter = hover_destroy end if config.hover_timeout then textbox.mouse_enter = hover_destroy end
@ -241,7 +241,7 @@ function notify(args)
if icon then if icon then
iconbox = widget({ type = "imagebox", name = "icon", align = "left" }) iconbox = widget({ type = "imagebox", name = "icon", align = "left" })
iconbox:buttons({ button({ }, 1, run), iconbox:buttons({ button({ }, 1, run),
button({ }, 3, function () destroy(notification) end) }) button({ }, 3, die) })
local img = image(icon) local img = image(icon)
if icon_size then if icon_size then
img = img:crop_and_scale(0,0,img.height,img.width,icon_size,icon_size) img = img:crop_and_scale(0,0,img.height,img.width,icon_size,icon_size)