Made the mailbox widget update properly

This commit is contained in:
Yessiest 2022-03-21 12:56:53 +00:00
parent db4839b716
commit 5a78139515
2 changed files with 19 additions and 52 deletions

View File

@ -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,30 +14,24 @@ 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",
widget = wibox.widget.textbox
},
notifications_list,
layout = wibox.layout.fixed.vertical,
forced_width = style.mailbox_container_width
},{
visible = false,
ontop = true,
}
))
end
-- Initialize the popup
local notification_popup = gen_popup()
text = "Notifications: ",
widget = wibox.widget.textbox
},
notifications_list,
layout = wibox.layout.fixed.vertical,
forced_width = style.mailbox_container_width
},{
visible = false,
ontop = true,
}
))
-- 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 })

View File

@ -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