fix(ags): make close button work in noti center

This commit is contained in:
matt1432 2023-09-15 12:32:30 -04:00
parent bb7a001eb8
commit 9488310721
2 changed files with 32 additions and 16 deletions

View file

@ -54,7 +54,10 @@ 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 }) => Draggable({
maxOffset: 200, maxOffset: 200,
command: () => command(id), command: () => command(id),
properties: [['hovered', false]], properties: [
['hovered', false],
['id', id],
],
onHover: w => { onHover: w => {
if (!w._hovered) { if (!w._hovered) {
w._hovered = true; w._hovered = true;

View file

@ -1,5 +1,6 @@
const { Notifications } = ags.Service; const { Notifications } = ags.Service;
const { Button, Label, Box, Icon, Scrollable, Window, Revealer } = ags.Widget; const { Button, Label, Box, Icon, Scrollable, Window, Revealer } = ags.Widget;
const { timeout } = ags.Utils;
import Notification from './base.js'; import Notification from './base.js';
import { EventBox } from '../misc/cursorbox.js' import { EventBox } from '../misc/cursorbox.js'
@ -33,22 +34,34 @@ const Header = () => Box({
const NotificationList = () => Box({ const NotificationList = () => Box({
vertical: true, vertical: true,
vexpand: true, vexpand: true,
connections: [[Notifications, (box, id) => { connections: [
if (box.children.length == 0) { [Notifications, (box, id) => {
box.children = Notifications.notifications if (box.children.length == 0) {
.reverse() box.children = Notifications.notifications
.map(n => Notification({ ...n, command: i => Notifications.close(i), })); .reverse()
} .map(n => Notification({ ...n, command: i => Notifications.close(i), }));
else if (id) { }
box.add(Notification({ else if (id) {
...Notifications.getNotification(id), box.add(Notification({
command: i => Notifications.close(i), ...Notifications.getNotification(id),
})); command: i => Notifications.close(i),
box.show_all(); }));
} box.show_all();
}
box.visible = Notifications.notifications.length > 0; box.visible = Notifications.notifications.length > 0;
}, 'notified']], }, 'notified'],
[Notifications, (box, id) => {
for (const ch of box.children) {
if (ch._id == id) {
ch.child.setStyle(ch.child._rightAnim);
timeout(500, () => box.remove(ch));
return;
}
}
}, 'closed'],
],
}); });
const Placeholder = () => Revealer({ const Placeholder = () => Revealer({