feat(ags notifs): add blocked apps list

This commit is contained in:
matt1432 2023-09-19 10:22:08 -04:00
parent bbf96b34c5
commit d5a9b24de1
3 changed files with 107 additions and 89 deletions

View file

@ -73,93 +73,104 @@ const NotificationIcon = ({ appEntry, appIcon, image }) => {
}); });
}; };
export default ({ id, summary, body, actions, urgency, time, command = i => {}, ...icon }) => Draggable({ export default ({ id, summary, body, actions, urgency, time, command = i => {}, ...icon }) => {
maxOffset: 200, const BlockedApps = [
command: () => command(id), 'Spotify',
properties: [ ];
['hovered', false],
['id', id], if (BlockedApps.find(app => app == Notifications.getNotification(id).appName)) {
], Notifications.close(id);
onHover: w => { return;
if (!w._hovered) { }
w._hovered = true;
} return Draggable({
}, maxOffset: 200,
onHoverLost: w => { command: () => command(id),
if (w._hovered) { properties: [
w._hovered = false; ['hovered', false],
} ['id', id],
}, ],
onHover: w => {
if (!w._hovered) {
w._hovered = true;
}
},
onHoverLost: w => {
if (w._hovered) {
w._hovered = false;
}
},
child: Box({
className: `notification ${urgency}`,
vexpand: false,
// Notification
child: Box({ child: Box({
vertical: true, className: `notification ${urgency}`,
children: [ vexpand: false,
// Content // Notification
Box({ child: Box({
children: [ vertical: true,
NotificationIcon(icon), children: [
Box({ // Content
hexpand: true, Box({
vertical: true, children: [
children: [ NotificationIcon(icon),
// Top of Content Box({
Box({ hexpand: true,
children: [ vertical: true,
Label({ children: [
className: 'title', // Top of Content
xalign: 0, Box({
justification: 'left', children: [
hexpand: true, Label({
maxWidthChars: 24, className: 'title',
truncate: 'end', xalign: 0,
wrap: true, justification: 'left',
label: summary, hexpand: true,
useMarkup: summary.startsWith('<'), maxWidthChars: 24,
}), truncate: 'end',
Label({ wrap: true,
className: 'time', label: summary,
valign: 'start', useMarkup: summary.startsWith('<'),
label: GLib.DateTime.new_from_unix_local(time).format('%H:%M'),
}),
EventBox({
reset: false,
child: Button({
className: 'close-button',
valign: 'start',
onClicked: () => Notifications.close(id),
child: Icon('window-close-symbolic'),
}), }),
}), Label({
], className: 'time',
}), valign: 'start',
Label({ label: GLib.DateTime.new_from_unix_local(time).format('%H:%M'),
className: 'description', }),
hexpand: true, EventBox({
useMarkup: true, reset: false,
xalign: 0, child: Button({
justification: 'left', className: 'close-button',
label: body, valign: 'start',
wrap: true, onClicked: () => Notifications.close(id),
}), child: Icon('window-close-symbolic'),
], }),
}), }),
], ],
}), }),
// Actions Label({
Box({ className: 'description',
className: 'actions', hexpand: true,
children: actions.map(action => Button({ useMarkup: true,
className: 'action-button', xalign: 0,
onClicked: () => Notifications.invoke(id, action.id), justification: 'left',
hexpand: true, label: body,
child: Label(action.label), wrap: true,
})), }),
}), ],
], }),
],
}),
// Actions
Box({
className: 'actions',
children: actions.map(action => Button({
className: 'action-button',
onClicked: () => Notifications.invoke(id, action.id),
hexpand: true,
child: Label(action.label),
})),
}),
],
}),
}), }),
}), });
}); };

View file

@ -61,11 +61,15 @@ const NotificationList = () => Box({
.map(n => Notification({ ...n, command: i => Notifications.close(i), })); .map(n => Notification({ ...n, command: i => Notifications.close(i), }));
} }
else if (id) { else if (id) {
box.add(Notification({ const NewNotif = Notification({
...Notifications.getNotification(id), ...Notifications.getNotification(id),
command: i => Notifications.close(i), command: i => Notifications.close(i),
})); });
box.show_all();
if (NewNotif) {
box.add(NewNotif);
box.show_all();
}
} }
}, 'notified'], }, 'notified'],

View file

@ -31,6 +31,9 @@ const Popups = () => Box({
if (!id || Notifications.dnd) if (!id || Notifications.dnd)
return; return;
if (! Notifications.getNotification(id))
return;
box._map.delete(id); box._map.delete(id);
box._map.set(id, Notification({ box._map.set(id, Notification({