From 6d5805e66204caa599a8a2996238adf7931cb95b Mon Sep 17 00:00:00 2001
From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>
Date: Thu, 16 Jan 2025 23:20:39 +1100
Subject: refactor: move popdowns to own folder
And group them like osds
---
app.tsx | 6 +--
src/modules/notifications.tsx | 65 -------------------------
src/modules/popdowns/index.tsx | 9 ++++
src/modules/popdowns/notifications.tsx | 65 +++++++++++++++++++++++++
src/modules/popdowns/updates.tsx | 88 ++++++++++++++++++++++++++++++++++
src/modules/updates.tsx | 88 ----------------------------------
6 files changed, 164 insertions(+), 157 deletions(-)
delete mode 100644 src/modules/notifications.tsx
create mode 100644 src/modules/popdowns/index.tsx
create mode 100644 src/modules/popdowns/notifications.tsx
create mode 100644 src/modules/popdowns/updates.tsx
delete mode 100644 src/modules/updates.tsx
diff --git a/app.tsx b/app.tsx
index 9743792..66cc1ca 100644
--- a/app.tsx
+++ b/app.tsx
@@ -2,10 +2,9 @@ import { execAsync, GLib, writeFileAsync } from "astal";
import { App } from "astal/gtk3";
import Bar from "./src/modules/bar";
import Launcher from "./src/modules/launcher";
-import Notifications from "./src/modules/notifications";
import NotifPopups from "./src/modules/notifpopups";
import Osds from "./src/modules/osds";
-import Updates from "./src/modules/updates";
+import Popdowns from "./src/modules/popdowns";
import Monitors from "./src/services/monitors";
import Players from "./src/services/players";
@@ -26,8 +25,7 @@ App.start({
;
;
Monitors.get_default().forEach(m => );
- ;
- ;
+ ;
console.log("Caelestia started");
},
diff --git a/src/modules/notifications.tsx b/src/modules/notifications.tsx
deleted file mode 100644
index 85747ce..0000000
--- a/src/modules/notifications.tsx
+++ /dev/null
@@ -1,65 +0,0 @@
-import { bind } from "astal";
-import { Astal, Gtk } from "astal/gtk3";
-import AstalNotifd from "gi://AstalNotifd";
-import Notification from "../widgets/notification";
-import PopdownWindow from "../widgets/popdownwindow";
-
-const List = () => (
- {
- const notifd = AstalNotifd.get_default();
- const map = new Map();
-
- const addNotification = (notification: AstalNotifd.Notification) => {
- const notif = () as Notification;
- notif.connect("destroy", () => map.get(notification.id) === notif && map.delete(notification.id));
- map.get(notification.id)?.destroyWithAnims();
- map.set(notification.id, notif);
-
- self.pack_end(
- event.button === Astal.MouseButton.MIDDLE && notification.dismiss()}
- >
- {notif}
- ,
- false,
- false,
- 0
- );
- };
-
- notifd
- .get_notifications()
- .sort((a, b) => a.time - b.time)
- .forEach(addNotification);
-
- self.hook(notifd, "notified", (_, id) => addNotification(notifd.get_notification(id)));
- self.hook(notifd, "resolved", (_, id) => map.get(id)?.destroyWithAnims());
- }}
- />
-);
-
-export default () => (
- n.length)}
- headerButtons={[
- {
- label: "Silence",
- onClicked: () => (AstalNotifd.get_default().dontDisturb = !AstalNotifd.get_default().dontDisturb),
- className: bind(AstalNotifd.get_default(), "dontDisturb").as(d => (d ? "enabled" : "")),
- },
- {
- label: "Clear",
- onClicked: () => AstalNotifd.get_default().notifications.forEach(n => n.dismiss()),
- },
- ]}
- emptyIcon="notifications_active"
- emptyLabel="All caught up!"
- list={
}
- />
-);
diff --git a/src/modules/popdowns/index.tsx b/src/modules/popdowns/index.tsx
new file mode 100644
index 0000000..db3245b
--- /dev/null
+++ b/src/modules/popdowns/index.tsx
@@ -0,0 +1,9 @@
+import Notifications from "./notifications";
+import Updates from "./updates";
+
+export default () => {
+ ;
+ ;
+
+ return null;
+};
diff --git a/src/modules/popdowns/notifications.tsx b/src/modules/popdowns/notifications.tsx
new file mode 100644
index 0000000..bb08c13
--- /dev/null
+++ b/src/modules/popdowns/notifications.tsx
@@ -0,0 +1,65 @@
+import { bind } from "astal";
+import { Astal, Gtk } from "astal/gtk3";
+import AstalNotifd from "gi://AstalNotifd";
+import Notification from "../../widgets/notification";
+import PopdownWindow from "../../widgets/popdownwindow";
+
+const List = () => (
+ {
+ const notifd = AstalNotifd.get_default();
+ const map = new Map();
+
+ const addNotification = (notification: AstalNotifd.Notification) => {
+ const notif = () as Notification;
+ notif.connect("destroy", () => map.get(notification.id) === notif && map.delete(notification.id));
+ map.get(notification.id)?.destroyWithAnims();
+ map.set(notification.id, notif);
+
+ self.pack_end(
+ event.button === Astal.MouseButton.MIDDLE && notification.dismiss()}
+ >
+ {notif}
+ ,
+ false,
+ false,
+ 0
+ );
+ };
+
+ notifd
+ .get_notifications()
+ .sort((a, b) => a.time - b.time)
+ .forEach(addNotification);
+
+ self.hook(notifd, "notified", (_, id) => addNotification(notifd.get_notification(id)));
+ self.hook(notifd, "resolved", (_, id) => map.get(id)?.destroyWithAnims());
+ }}
+ />
+);
+
+export default () => (
+ n.length)}
+ headerButtons={[
+ {
+ label: "Silence",
+ onClicked: () => (AstalNotifd.get_default().dontDisturb = !AstalNotifd.get_default().dontDisturb),
+ className: bind(AstalNotifd.get_default(), "dontDisturb").as(d => (d ? "enabled" : "")),
+ },
+ {
+ label: "Clear",
+ onClicked: () => AstalNotifd.get_default().notifications.forEach(n => n.dismiss()),
+ },
+ ]}
+ emptyIcon="notifications_active"
+ emptyLabel="All caught up!"
+ list={
}
+ />
+);
diff --git a/src/modules/popdowns/updates.tsx b/src/modules/popdowns/updates.tsx
new file mode 100644
index 0000000..359fe81
--- /dev/null
+++ b/src/modules/popdowns/updates.tsx
@@ -0,0 +1,88 @@
+import { bind, execAsync, Variable } from "astal";
+import { App, Astal, Gtk } from "astal/gtk3";
+import Updates, { Repo as IRepo, Update as IUpdate } from "../../services/updates";
+import { MenuItem } from "../../utils/widgets";
+import PopdownWindow from "../../widgets/popdownwindow";
+
+const constructItem = (label: string, exec: string, quiet = true) =>
+ new MenuItem({
+ label,
+ onActivate() {
+ App.get_window("updates")?.hide();
+ execAsync(exec).catch(e => !quiet && console.error(e));
+ },
+ });
+
+const Update = (update: IUpdate) => {
+ const menu = new Gtk.Menu();
+ menu.append(constructItem("Open info in browser", `xdg-open '${update.url}'`, false));
+ menu.append(constructItem("Open info in terminal", `uwsm app -- foot -H pacman -Qi ${update.name}`));
+ menu.append(constructItem("Reinstall", `uwsm app -T -- yay -S ${update.name}`));
+ menu.append(constructItem("Remove with dependencies", `uwsm app -T -- yay -Rns ${update.name}`));
+
+ return (
+
+ );
+};
+
+const Repo = (repo: IRepo) => {
+ const expanded = Variable(false);
+
+ return (
+
+
+
+
+ {repo.updates.map(Update)}
+
+
+
+ );
+};
+
+const List = () => (
+
+ {bind(Updates.get_default(), "updateData").as(d => d.repos.map(Repo))}
+
+);
+
+export default () => (
+
+ execAsync("uwsm app -T -- yay")
+ .then(() => Updates.get_default().getUpdates())
+ // Ignore errors
+ .catch(() => {}),
+ },
+ { label: "Reload", onClicked: () => Updates.get_default().getUpdates() },
+ ]}
+ emptyIcon="deployed_code_history"
+ emptyLabel="All packages up to date!"
+ list={
}
+ />
+);
diff --git a/src/modules/updates.tsx b/src/modules/updates.tsx
deleted file mode 100644
index feaa3cd..0000000
--- a/src/modules/updates.tsx
+++ /dev/null
@@ -1,88 +0,0 @@
-import { bind, execAsync, Variable } from "astal";
-import { App, Astal, Gtk } from "astal/gtk3";
-import Updates, { Repo as IRepo, Update as IUpdate } from "../services/updates";
-import { MenuItem } from "../utils/widgets";
-import PopdownWindow from "../widgets/popdownwindow";
-
-const constructItem = (label: string, exec: string, quiet = true) =>
- new MenuItem({
- label,
- onActivate() {
- App.get_window("updates")?.hide();
- execAsync(exec).catch(e => !quiet && console.error(e));
- },
- });
-
-const Update = (update: IUpdate) => {
- const menu = new Gtk.Menu();
- menu.append(constructItem("Open info in browser", `xdg-open '${update.url}'`, false));
- menu.append(constructItem("Open info in terminal", `uwsm app -- foot -H pacman -Qi ${update.name}`));
- menu.append(constructItem("Reinstall", `uwsm app -T -- yay -S ${update.name}`));
- menu.append(constructItem("Remove with dependencies", `uwsm app -T -- yay -Rns ${update.name}`));
-
- return (
-
- );
-};
-
-const Repo = (repo: IRepo) => {
- const expanded = Variable(false);
-
- return (
-
-
-
-
- {repo.updates.map(Update)}
-
-
-
- );
-};
-
-const List = () => (
-
- {bind(Updates.get_default(), "updateData").as(d => d.repos.map(Repo))}
-
-);
-
-export default () => (
-
- execAsync("uwsm app -T -- yay")
- .then(() => Updates.get_default().getUpdates())
- // Ignore errors
- .catch(() => {}),
- },
- { label: "Reload", onClicked: () => Updates.get_default().getUpdates() },
- ]}
- emptyIcon="deployed_code_history"
- emptyLabel="All packages up to date!"
- list={
}
- />
-);
--
cgit v1.2.3-freya