Made the mailbox widget update properly
This commit is contained in:
parent
db4839b716
commit
5a78139515
|
@ -6,8 +6,7 @@ local wibox = require("wibox")
|
|||
local naughty = require("naughty")
|
||||
local awmtk_status,awmtk = pcall(require,"awmtk")
|
||||
local dbus_config = require("naughty.dbus")
|
||||
local widget = {}
|
||||
local function worker(args)
|
||||
return function(args)
|
||||
local args = args or {}
|
||||
-- Set up style variables
|
||||
style = awmtk.style(awmtk.defaults,args.style or {},"mailbox_")
|
||||
|
@ -15,16 +14,14 @@ local function worker(args)
|
|||
style.mailbox_button_height = style.mailbox_button_heihgt or 40
|
||||
args.mail_limit = args.mail_limit or 8
|
||||
-- Create a notifications list
|
||||
notifications_list = {
|
||||
local notifications_list = wibox.widget {
|
||||
spacing = style.mailbox_container_spacing_vertical,
|
||||
layout = wibox.layout.fixed.vertical,
|
||||
}
|
||||
-- Function to regenerate the popup
|
||||
local gen_popup = function()
|
||||
return awful.popup(style.container(
|
||||
local notification_popup = awful.popup(style.container(
|
||||
{
|
||||
{
|
||||
text = "This widget will store your notification",
|
||||
text = "Notifications: ",
|
||||
widget = wibox.widget.textbox
|
||||
},
|
||||
notifications_list,
|
||||
|
@ -35,10 +32,6 @@ local function worker(args)
|
|||
ontop = true,
|
||||
}
|
||||
))
|
||||
end
|
||||
|
||||
-- Initialize the popup
|
||||
local notification_popup = gen_popup()
|
||||
|
||||
-- Create a mailbox button
|
||||
args.screen.notify_widget = style.icon (
|
||||
|
@ -60,10 +53,8 @@ local function worker(args)
|
|||
end
|
||||
}
|
||||
)
|
||||
local notify_widget = args.screen.notify_widget
|
||||
local update_notifications = function(update_args)
|
||||
if notification_popup.visible then notification_popup.visible = false end
|
||||
table.insert(notifications_list,1,style.button(
|
||||
naughty.config.notify_callback = function(update_args)
|
||||
notifications_list:add(style.button(
|
||||
{
|
||||
(update_args.icon and {
|
||||
image = update_args.icon,
|
||||
|
@ -93,21 +84,10 @@ local function worker(args)
|
|||
end
|
||||
}
|
||||
))
|
||||
if #notifications_list >= args.mail_limit then
|
||||
table.remove(notifications_list,args.mail_limit)
|
||||
end
|
||||
notification_popup = gen_popup()
|
||||
for s in screen do
|
||||
s.notify_widget:emit_signal("notification::arrived")
|
||||
s.notify_widget.bg = style.mailbox_button_bg_focus
|
||||
end
|
||||
return update_args
|
||||
end
|
||||
args.screen.notify_widget:connect_signal("notification::arrived",function()
|
||||
args.screen.notify_widget.bg = style.mailbox_button_bg_focus
|
||||
end)
|
||||
naughty.config.notify_callback = update_notifications
|
||||
widget = notify_widget
|
||||
return notify_widget
|
||||
return args.screen.notify_widget
|
||||
end
|
||||
|
||||
return setmetatable(widget, { __call = function(_, ...) return worker(...) end })
|
||||
|
|
|
@ -96,25 +96,12 @@ local function worker(args)
|
|||
},{},{
|
||||
function()
|
||||
if popup.visible then
|
||||
--rows = nil
|
||||
popup.visible = not popup.visible
|
||||
else
|
||||
--init_popup()
|
||||
popup:move_next_to(mouse.current_widget_geometry)
|
||||
end
|
||||
end
|
||||
})
|
||||
widget = clip_widget
|
||||
root.keys(gears.table.join(
|
||||
root.keys(),
|
||||
awful.key({global.modkey,"Control"},"b",function()
|
||||
pager:next()
|
||||
end),
|
||||
awful.key({global.modkey,"Control"},"v",function()
|
||||
pager:prev()
|
||||
end)
|
||||
))
|
||||
|
||||
return clip_widget
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue