refactor(wim ags): make main file for notif widgets

This commit is contained in:
matt1432 2023-11-27 15:01:54 -05:00
parent 369fd32e54
commit f85df15e93
5 changed files with 50 additions and 52 deletions

View file

@ -1,22 +1,22 @@
import App from 'resource:///com/github/Aylur/ags/app.js';
import App from 'resource:///com/github/Aylur/ags/app.js';
import { exec } from 'resource:///com/github/Aylur/ags/utils.js';
import Setup from './js/setup.js';
import Setup from './js/setup.js';
import AppLauncher from './js/applauncher/main.js';
import Bar from './js/bar/main.js';
import BgFade from './js/misc/background-fade.js';
import Calendar from './js/date.js';
import Corners from './js/corners/main.js';
import NotifCenter from './js/notifications/center.js';
import NotifPopups from './js/notifications/popup.js';
import OSD from './js/osd/main.js';
import OSK from './js/on-screen-keyboard/main.js';
import Overview from './js/overview/main.js';
import Powermenu from './js/powermenu.js';
import QSettings from './js/quick-settings/main.js';
import Bar from './js/bar/main.js';
import BgFade from './js/misc/background-fade.js';
import Calendar from './js/date.js';
import Corners from './js/corners/main.js';
import { NotifPopups, NotifCenter } from './js/notifications/main.js';
import OSD from './js/osd/main.js';
import OSK from './js/on-screen-keyboard/main.js';
import Overview from './js/overview/main.js';
import Powermenu from './js/powermenu.js';
import QSettings from './js/quick-settings/main.js';
const scss = `${App.configDir }/scss/main.scss`;
const css = `${App.configDir }/style.css`;
const scss = App.configDir + '/scss/main.scss';
const css = App.configDir + '/style.css';
exec(`sassc ${scss} ${css}`);
Setup();

View file

@ -3,12 +3,8 @@ import Notifications from 'resource:///com/github/Aylur/ags/service/notification
import { Box, Icon, Label } from 'resource:///com/github/Aylur/ags/widget.js';
import Separator from '../../misc/separator.js';
import EventBox from '../../misc/cursorbox.js';
const L_PADDING = 28;
const R_PADDING = 8;
export default () => EventBox({
className: 'toggle-off',
@ -26,9 +22,8 @@ export default () => EventBox({
vertical: false,
children: [
Separator(L_PADDING),
Icon({
hpack: 'center',
connections: [[Notifications, (self) => {
if (Notifications.dnd) {
self.icon = 'notification-disabled-symbolic';
@ -41,9 +36,6 @@ export default () => EventBox({
}
}]],
}),
Separator(R_PADDING),
Label({
binds: [['label', Notifications, 'notifications',
(n) => String(n.length)]],

View file

@ -3,7 +3,6 @@ import Notifications from 'resource:///com/github/Aylur/ags/service/notification
import { Button, Label, Box, Icon, Scrollable, Revealer } from 'resource:///com/github/Aylur/ags/widget.js';
import { Notification, HasNotifs } from './base.js';
import PopupWindow from '../misc/popup.js';
import EventBox from '../misc/cursorbox.js';
@ -100,7 +99,7 @@ const Placeholder = () => Revealer({
}),
});
const NotificationCenterWidget = () => Box({
export default () => Box({
className: 'notification-center',
vertical: true,
children: [
@ -124,13 +123,3 @@ const NotificationCenterWidget = () => Box({
}),
],
});
const TOP_MARGIN = 6;
const RIGHT_MARGIN = 60;
export default () => PopupWindow({
name: 'notification-center',
anchor: ['top', 'right'],
margins: [TOP_MARGIN, RIGHT_MARGIN, 0, 0],
child: NotificationCenterWidget(),
});

View file

@ -0,0 +1,26 @@
import PopUpsWidget from './popup.js';
import NotifCenterWidget from './center.js';
import PopupWindow from '../misc/popup.js';
export const NotifPopups = () => PopupWindow({
name: 'notifications',
anchor: ['top', 'left'],
visible: true,
transition: 'none',
closeOnUnfocus: 'stay',
child: PopUpsWidget(),
});
const TOP_MARGIN = 6;
const RIGHT_MARGIN = 60;
export const NotifCenter = () => PopupWindow({
name: 'notification-center',
anchor: ['top', 'right'],
margins: [TOP_MARGIN, RIGHT_MARGIN, 0, 0],
child: NotifCenterWidget(),
});

View file

@ -6,7 +6,6 @@ import { interval } from 'resource:///com/github/Aylur/ags/utils.js';
import GLib from 'gi://GLib';
import { Notification } from './base.js';
import PopupWindow from '../misc/popup.js';
const DELAY = 2000;
@ -55,20 +54,12 @@ const handleDismiss = (box, id, force = false) => {
}
};
export default () => PopupWindow({
name: 'notifications',
anchor: ['top', 'left'],
visible: true,
transition: 'none',
closeOnUnfocus: 'stay',
export default () => Box({
vertical: true,
child: Box({
vertical: true,
connections: [
[Notifications, (s, id) => addPopup(s, id), 'notified'],
[Notifications, (s, id) => handleDismiss(s, id), 'dismissed'],
[Notifications, (s, id) => handleDismiss(s, id, true), 'closed'],
],
}),
connections: [
[Notifications, (s, id) => addPopup(s, id), 'notified'],
[Notifications, (s, id) => handleDismiss(s, id), 'dismissed'],
[Notifications, (s, id) => handleDismiss(s, id, true), 'closed'],
],
});