This commit is contained in:
sankalp committed 2024-07-13 22:39:45 +05:45
1 parent de1e763b0c
commit de01178f8f
5 files changed
+83 -7

No files matched your search

+2
View File
@@ -229,6 +229,8 @@ function SysTray() {
const items = systemtray.items;
// @ts-expect-error
self.children = items.map((item) => {
if (!item.id)
return undefined;
if (item.id.trim() != "nm-applet" && item.id.trim() != "blueman") {
return Widget.Button({
child: Widget.Icon({ icon: item.bind("icon") }),
@@ -0,0 +1,45 @@
import App from "resource:///com/github/Aylur/ags/app.js";
import Widget from "resource:///com/github/Aylur/ags/widget.js";
import { WindowProps, Window } from "types/widgets/window";
import Gtk from "gi://Gtk?version=3.0";
type _WindowProps = WindowProps<any, unknown, Window<any, unknown>> | undefined[];
type Type = {
name: string;
child: any;
showClassName?: string;
hideClassName?: string;
};
export default <T extends Type>({
name,
child,
showClassName = "",
hideClassName = "",
...props
}: T & Omit<_WindowProps, keyof Type>) => {
return Widget.Window({
name,
visible: false,
type: Gtk.WindowType.POPUP,
layer: "overlay",
resizable: true,
...props,
setup: (self) => {
self.keybind("Escape", () => App.closeWindow(name));
self.on("button-press-event", () => App.closeWindow(name)); // Close on mouse click
if (showClassName !== "" && hideClassName !== "") {
self.hook(App, (self, currentName, visible) => {
if (currentName === name) {
self.toggleClassName(hideClassName, !visible);
}
});
self.class_name = `${showClassName} ${hideClassName}`;
}
},
child: child
});
};
+30 -3
View File
@@ -154,6 +154,7 @@ const NotificationReveal = (notification: NotificationType, visible = false, dis
destroyWithAnims: any;
count: number;
id: number;
app: string;
};
let box: Box<any, BoxAttrs>;
@@ -173,7 +174,8 @@ const NotificationReveal = (notification: NotificationType, visible = false, dis
attribute: {
destroyWithAnims: destroyWithAnims,
count: 0,
id: notification.id
id: notification.id,
app: notification.app_name
},
children: [firstRevealer]
});
@@ -197,6 +199,29 @@ export function NotificationPopups(
children: notifications.popups.map((id) => revealer(id, false, dismiss))
});
function onChange() {
for (let i = 0; i < list.children.length; i++) {
const current = list.children[i];
const next = list.children[i + 1];
const prev = list.children[i - 1];
let is_last = true;
let is_first = true;
if (next) {
if (next.attribute.app === current.attribute.app) {
is_last = false;
}
}
if (prev) {
if (prev.attribute.app === current.attribute.app) {
is_first = false;
}
}
current.toggleClassName("last", is_last);
current.toggleClassName("first", is_first);
current.toggleClassName("middle", !is_first && !is_last);
}
}
function onNotified(_: any, id: number) {
const n = notifications.getNotification(id);
if (notifications.dnd || !n) return;
@@ -221,15 +246,17 @@ export function NotificationPopups(
onDismissed(_, id);
}
});
onChange();
}
function onDismissed(_: any, id: number) {
const original = list.children.find((n) => n.attribute.id === id);
if (!original) return;
original.attribute.count--;
if (original?.attribute.count <= 0) {
original?.attribute.destroyWithAnims();
if (original.attribute.count <= 0) {
original.attribute.destroyWithAnims();
}
original.connect("destroy", () => onChange())
}
list.hook(notifications, onNotified, "notified").hook(notifications, onDismissed, dismiss ? "dismissed" : "closed");
@@ -38,6 +38,7 @@ const NotificationReveal = (notification: NotificationType, visible = false, dis
destroyWithAnims: any;
count: number;
id: number;
app: string;
};
let box: Box<any, BoxAttrs>;
@@ -56,7 +57,8 @@ const NotificationReveal = (notification: NotificationType, visible = false, dis
attribute: {
destroyWithAnims: destroyWithAnims,
count: 0,
id: notification.id
id: notification.id,
app: notification.app_name
},
children: [firstRevealer]
});
+3 -3
View File
@@ -533,16 +533,16 @@ window.notification-popups box.notifications {
transition: all 0.2s ease-in-out, border-radius 0.1s ease-in-out;
}
.notifications_sidebar_scrollable viewport > box > :first-child .notification {
.notifications_sidebar_scrollable viewport > box > .first .notification{
border-radius: 14px 14px 6px 6px;
}
.notifications_sidebar_scrollable viewport > box > :last-child .notification {
.notifications_sidebar_scrollable viewport > box > .last .notification {
border-radius: 6px 6px 14px 14px;
margin-bottom: 10px;
}
.notifications_sidebar_scrollable viewport > box > :last-child:first-child .notification {
.notifications_sidebar_scrollable viewport > box > .first.last .notification {
border-radius: 14px;
}