2023-11-21 01:29:46 -05:00
|
|
|
import App from 'resource:///com/github/Aylur/ags/app.js';
|
2023-10-31 08:32:40 -04:00
|
|
|
import Notifications from 'resource:///com/github/Aylur/ags/service/notifications.js';
|
2023-11-21 01:29:46 -05:00
|
|
|
|
2023-11-27 15:15:02 -05:00
|
|
|
import { Box, CenterBox, Icon, Label } from 'resource:///com/github/Aylur/ags/widget.js';
|
2023-09-05 15:10:25 -04:00
|
|
|
|
2024-01-13 23:38:31 -05:00
|
|
|
import CursorBox from '../../misc/cursorbox.ts';
|
|
|
|
import Separator from '../../misc/separator.ts';
|
2023-11-27 15:15:02 -05:00
|
|
|
|
|
|
|
const SPACING = 4;
|
2023-11-21 01:29:46 -05:00
|
|
|
|
2024-01-13 11:15:08 -05:00
|
|
|
// Types
|
2024-01-13 23:38:31 -05:00
|
|
|
import AgsWindow from 'types/widgets/window.ts';
|
2024-01-13 11:15:08 -05:00
|
|
|
|
2023-10-02 12:06:35 -04:00
|
|
|
|
2023-12-18 23:20:32 -05:00
|
|
|
export default () => CursorBox({
|
|
|
|
class_name: 'toggle-off',
|
2023-11-21 01:29:46 -05:00
|
|
|
|
2023-12-18 23:20:32 -05:00
|
|
|
on_primary_click_release: (self) => {
|
2024-01-13 11:15:08 -05:00
|
|
|
(App.getWindow('notification-center') as AgsWindow)
|
|
|
|
?.attribute.set_x_pos(
|
|
|
|
self.get_allocation(),
|
|
|
|
'right',
|
|
|
|
);
|
2023-12-12 11:21:27 -05:00
|
|
|
|
|
|
|
App.toggleWindow('notification-center');
|
|
|
|
},
|
2023-11-21 01:29:46 -05:00
|
|
|
|
2023-12-17 00:01:58 -05:00
|
|
|
setup: (self) => {
|
|
|
|
self.hook(App, (_, windowName, visible) => {
|
|
|
|
if (windowName === 'notification-center') {
|
|
|
|
self.toggleClassName('toggle-on', visible);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
2023-11-21 01:29:46 -05:00
|
|
|
|
2023-11-27 15:15:02 -05:00
|
|
|
child: CenterBox({
|
2023-12-18 18:00:30 -05:00
|
|
|
class_name: 'notif-panel',
|
2023-11-27 15:15:02 -05:00
|
|
|
|
|
|
|
center_widget: Box({
|
|
|
|
children: [
|
2023-12-18 18:00:30 -05:00
|
|
|
Icon().hook(Notifications, (self) => {
|
|
|
|
if (Notifications.dnd) {
|
|
|
|
self.icon = 'notification-disabled-symbolic';
|
|
|
|
}
|
|
|
|
else if (Notifications.notifications.length > 0) {
|
|
|
|
self.icon = 'notification-new-symbolic';
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
self.icon = 'notification-symbolic';
|
|
|
|
}
|
2023-11-27 15:15:02 -05:00
|
|
|
}),
|
|
|
|
|
|
|
|
Separator(SPACING),
|
|
|
|
|
|
|
|
Label({
|
2023-12-18 18:00:30 -05:00
|
|
|
label: Notifications.bind('notifications')
|
|
|
|
.transform((n) => String(n.length)),
|
2023-11-27 15:15:02 -05:00
|
|
|
}),
|
|
|
|
],
|
|
|
|
}),
|
2023-10-20 23:11:21 -04:00
|
|
|
}),
|
2023-09-05 15:10:25 -04:00
|
|
|
});
|