2024-10-16 22:33:15 -04:00
|
|
|
import { bind } from 'astal';
|
|
|
|
import { App } from 'astal/gtk3';
|
|
|
|
|
2024-10-22 13:09:39 -04:00
|
|
|
import AstalNotifd from 'gi://AstalNotifd';
|
2024-10-16 22:33:15 -04:00
|
|
|
|
|
|
|
import Separator from '../../misc/separator';
|
|
|
|
|
|
|
|
const SPACING = 4;
|
|
|
|
|
|
|
|
// Types
|
2024-10-30 18:53:15 -04:00
|
|
|
import PopupWindow from '../../misc/popup-window';
|
2024-10-16 22:33:15 -04:00
|
|
|
|
|
|
|
|
2024-11-20 23:38:41 -05:00
|
|
|
export default () => {
|
|
|
|
const notifications = AstalNotifd.get_default();
|
|
|
|
|
|
|
|
return (
|
|
|
|
<button
|
|
|
|
className="bar-item"
|
|
|
|
cursor="pointer"
|
2024-10-16 22:33:15 -04:00
|
|
|
|
2024-11-20 23:38:41 -05:00
|
|
|
onButtonReleaseEvent={(self) => {
|
|
|
|
const win = App.get_window('win-notif-center') as PopupWindow;
|
2024-10-16 22:33:15 -04:00
|
|
|
|
2024-11-20 23:38:41 -05:00
|
|
|
win.set_x_pos(
|
|
|
|
self.get_allocation(),
|
|
|
|
'right',
|
|
|
|
);
|
|
|
|
|
|
|
|
win.visible = !win.visible;
|
|
|
|
}}
|
|
|
|
|
|
|
|
setup={(self) => {
|
|
|
|
App.connect('window-toggled', (_, win) => {
|
|
|
|
if (win.name === 'win-notif-center') {
|
|
|
|
self.toggleClassName('toggle-on', win.visible);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<box>
|
|
|
|
<icon
|
|
|
|
icon={bind(notifications, 'notifications').as((notifs) => {
|
|
|
|
if (notifications.dontDisturb) {
|
|
|
|
return 'notification-disabled-symbolic';
|
|
|
|
}
|
|
|
|
else if (notifs.length > 0) {
|
|
|
|
return 'notification-new-symbolic';
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return 'notification-symbolic';
|
|
|
|
}
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
|
|
|
|
<Separator size={SPACING} />
|
|
|
|
|
|
|
|
<label label={bind(notifications, 'notifications').as((n) => String(n.length))} />
|
|
|
|
</box>
|
|
|
|
</button>
|
|
|
|
);
|
|
|
|
};
|