make notifications hide on click

This commit is contained in:
gnat 2024-12-15 19:06:37 -08:00
parent 2a8070cc08
commit 4763fc0624
2 changed files with 55 additions and 51 deletions

View File

@ -21,56 +21,60 @@ local notification_icon = function(n)
end end
local make_notification = function(n) local make_notification = function(n)
print(n:get_urgency()) local layout = Widget.Button({
local layout = Widget.Box({ on_clicked = function(self)
children = { self:get_parent():set_reveal_child(false)
Widget.Box({ end,
vertical = true, child = Widget.Box({
css = 'min-width: 200px; min-height: 50px;', children = {
children = { Widget.Box({
Widget.Box({ vertical = true,
children = { css = 'min-width: 200px; min-height: 50px;',
notification_icon(n), children = {
Widget.Box({ Widget.Box({
vertical = true, children = {
children = { notification_icon(n),
Widget.Label({ Widget.Box({
class_name = 'title', vertical = true,
label = n.summary, children = {
xalign = 0, Widget.Label({
justify = 0, class_name = 'title',
ellipsize = pango.EllipsizeMode.END, label = n.summary,
}), xalign = 0,
Widget.Label({ justify = 0,
class_name = 'body', ellipsize = pango.EllipsizeMode.END,
label = n.body, }),
xalign = 0, Widget.Label({
justify = 0, class_name = 'body',
wrap = true, label = n.body,
wrap_mode = pango.WrapMode.WORD_CHAR, xalign = 0,
use_markup = true justify = 0,
}) wrap = true,
} wrap_mode = pango.WrapMode.WORD_CHAR,
}), use_markup = true
} })
}), }
Widget.ProgressBar({ }),
class_name = 'timeout-bar', }
hexpand = true, }),
valign = 2, Widget.ProgressBar({
fraction = bind(Variable(1):poll(((n.expire_timeout > 0 and n.expire_timeout or popup_timeout_seconds) * 1000 + 250) // 100, function(prev) class_name = 'timeout-bar',
if prev > .01 then hexpand = true,
return prev - .01 valign = 2,
end fraction = bind(Variable(1):poll(((n.expire_timeout > 0 and n.expire_timeout or popup_timeout_seconds) * 1000 + 250) // 100, function(prev)
return 0 if prev > .01 then
end)), return prev - .01
}) end
} return 0
}), end)),
Widget.Box({ })
class_name = 'urgency-indicator ' .. n.urgency }
}) }),
} Widget.Box({
class_name = 'urgency-indicator ' .. n.urgency
})
}
})
}) })
return Widget.Revealer({ return Widget.Revealer({

View File

@ -1,6 +1,6 @@
.notifications { .notifications {
> * { > * {
> box { > button > box {
margin: 10px 15px; margin: 10px 15px;
border: 1px solid $fg; border: 1px solid $fg;
background: $bg; background: $bg;