mirror of
https://github.com/tuxdotrs/tpanel.git
synced 2025-12-15 20:00:05 +05:30
feat: add dnd toggle button
This commit is contained in:
@@ -0,0 +1 @@
|
||||
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path d="M8.35179 20.2418C9.19288 21.311 10.5142 22 12 22C13.4858 22 14.8071 21.311 15.6482 20.2418C13.2264 20.57 10.7736 20.57 8.35179 20.2418Z" fill="#000"></path> <path fill-rule="evenodd" clip-rule="evenodd" d="M18.7491 9V9.7041C18.7491 10.5491 18.9903 11.3752 19.4422 12.0782L20.5496 13.8012C21.5612 15.3749 20.789 17.5139 19.0296 18.0116C14.4273 19.3134 9.57274 19.3134 4.97036 18.0116C3.21105 17.5139 2.43882 15.3749 3.45036 13.8012L4.5578 12.0782C5.00972 11.3752 5.25087 10.5491 5.25087 9.7041V9C5.25087 5.13401 8.27256 2 12 2C15.7274 2 18.7491 5.13401 18.7491 9ZM10.0717 9.75C9.67233 9.75 9.34857 9.41421 9.34857 9C9.34857 8.58578 9.67233 8.25 10.0717 8.25H13.9283C14.2208 8.25 14.4845 8.43273 14.5964 8.71299C14.7083 8.99324 14.6465 9.31583 14.4397 9.53033L11.8175 12.25H13.9283C14.3277 12.25 14.6515 12.5858 14.6515 13C14.6515 13.4142 14.3277 13.75 13.9283 13.75H10.0717C9.77922 13.75 9.51554 13.5673 9.40362 13.287C9.29169 13.0068 9.35356 12.6842 9.56037 12.4697L12.1826 9.75H10.0717Z" fill="#000"></path> </g></svg>
|
||||
|
After Width: | Height: | Size: 1.2 KiB |
@@ -0,0 +1 @@
|
||||
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path d="M8.35179 20.2418C9.19288 21.311 10.5142 22 12 22C13.4858 22 14.8071 21.311 15.6482 20.2418C13.2264 20.57 10.7736 20.57 8.35179 20.2418Z" fill="#000"></path> <path fill-rule="evenodd" clip-rule="evenodd" d="M18.7491 9.7041V9C18.7491 5.13401 15.7274 2 12 2C8.27256 2 5.25087 5.13401 5.25087 9V9.7041C5.25087 10.5491 5.00972 11.3752 4.5578 12.0782L3.45036 13.8012C2.43882 15.3749 3.21105 17.5139 4.97036 18.0116C9.57274 19.3134 14.4273 19.3134 19.0296 18.0116C20.789 17.5139 21.5612 15.3749 20.5496 13.8012L19.4422 12.0782C18.9903 11.3752 18.7491 10.5491 18.7491 9.7041ZM12 5.25C12.4142 5.25 12.75 5.58579 12.75 6V10C12.75 10.4142 12.4142 10.75 12 10.75C11.5858 10.75 11.25 10.4142 11.25 10V6C11.25 5.58579 11.5858 5.25 12 5.25Z" fill="#000"></path> </g></svg>
|
||||
|
After Width: | Height: | Size: 996 B |
@@ -0,0 +1 @@
|
||||
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path d="M18.2211 19.6431C18.6981 18.7396 19.1627 17.7065 19.4613 16.6623C19.8722 15.2247 20.0207 13.8751 20.0629 12.8451L18.5105 11.2926L12.7073 5.48944L11.1549 3.93701C10.1248 3.97917 8.77531 4.12767 7.33767 4.53865C6.29348 4.83716 5.26037 5.30183 4.35693 5.77885C2.10098 6.96998 1.42721 9.71071 2.49716 11.8068L2.51021 11.8324L3.20923 12.9815C5.15002 16.1718 7.82804 18.8499 11.0184 20.7907L12.1675 21.4898L12.1931 21.5028C14.2892 22.5728 17.0299 21.899 18.2211 19.6431Z" fill="#000"></path> <path d="M21.7747 3.31343C22.0751 3.01296 22.0751 2.52581 21.7747 2.22535C21.4742 1.92488 20.987 1.92488 20.6866 2.22535L19.0118 3.90018C17.3118 2.66569 14.9941 2.66575 13.2942 3.9002L14.4027 5.00866L18.9915 9.59749L20.0999 10.7059C21.3344 9.00597 21.3343 6.68821 20.0998 4.98826L21.7747 3.31343Z" fill="#000"></path> </g></svg>
|
||||
|
After Width: | Height: | Size: 1.0 KiB |
@@ -61,6 +61,27 @@ window.control-center {
|
||||
}
|
||||
}
|
||||
|
||||
.notification-list {
|
||||
.focus {
|
||||
background: $accent;
|
||||
}
|
||||
|
||||
button {
|
||||
background-color: $inactive-color;
|
||||
border-radius: calc($rounded / 1.5);
|
||||
padding: 10px;
|
||||
transition: color 100ms;
|
||||
|
||||
&:hover {
|
||||
background-color: rgba($accent, 1);
|
||||
}
|
||||
|
||||
image {
|
||||
-gtk-icon-size: 1.2rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.footer {
|
||||
label {
|
||||
color: $accent;
|
||||
|
||||
@@ -1,11 +1,53 @@
|
||||
import { Gtk } from "ags/gtk4";
|
||||
import { Gdk, Gtk } from "ags/gtk4";
|
||||
import Notifd from "gi://AstalNotifd";
|
||||
import { createComputed, createBinding } from "ags";
|
||||
|
||||
export const NotificationList = () => {
|
||||
const { VERTICAL } = Gtk.Orientation;
|
||||
|
||||
const notifd = Notifd.get_default();
|
||||
const isDndMode = createBinding(notifd, "dont-disturb");
|
||||
|
||||
const toggleDndMode = () => {
|
||||
const currentDnd = notifd.get_dont_disturb();
|
||||
notifd.set_dont_disturb(!currentDnd);
|
||||
};
|
||||
|
||||
const notificationIcon = createComputed([isDndMode], (dndMode) => {
|
||||
if (dndMode) {
|
||||
return "fa-bell-off-symbolic";
|
||||
}
|
||||
|
||||
return "fa-bell-symbolic";
|
||||
});
|
||||
|
||||
return (
|
||||
<box vexpand orientation={VERTICAL} spacing={20}>
|
||||
<label label="Notifications" />
|
||||
<box
|
||||
vexpand
|
||||
hexpand
|
||||
orientation={VERTICAL}
|
||||
spacing={20}
|
||||
cssClasses={["notification-list"]}
|
||||
>
|
||||
<box hexpand>
|
||||
<label label="Notifications" />
|
||||
<box hexpand halign={Gtk.Align.END} spacing={10}>
|
||||
<button
|
||||
onClicked={toggleDndMode}
|
||||
tooltipText={isDndMode((dnd) =>
|
||||
dnd ? "Disable Do Not Disturb" : "Enable Do Not Disturb",
|
||||
)}
|
||||
cursor={Gdk.Cursor.new_from_name("pointer", null)}
|
||||
class={isDndMode((dnd) => (dnd ? "focus" : ""))}
|
||||
>
|
||||
<image iconName={notificationIcon} />
|
||||
</button>
|
||||
|
||||
<button cursor={Gdk.Cursor.new_from_name("pointer", null)}>
|
||||
<image iconName="fa-broom-symbolic" />
|
||||
</button>
|
||||
</box>
|
||||
</box>
|
||||
<box vexpand cssClasses={["pill"]}></box>
|
||||
</box>
|
||||
);
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
import { For, createState, onCleanup } from "ags";
|
||||
import {
|
||||
For,
|
||||
createBinding,
|
||||
createComputed,
|
||||
createState,
|
||||
onCleanup,
|
||||
} from "ags";
|
||||
import { Astal, Gdk, Gtk } from "ags/gtk4";
|
||||
import AstalNotifd from "gi://AstalNotifd";
|
||||
import { Notification } from "./notification";
|
||||
@@ -7,6 +13,7 @@ export const WINDOW_NAME = "notifications";
|
||||
|
||||
export const Notifications = (gdkmonitor: Gdk.Monitor) => {
|
||||
const notifd = AstalNotifd.get_default();
|
||||
const isDndMode = createBinding(notifd, "dont-disturb");
|
||||
|
||||
const { TOP, RIGHT } = Astal.WindowAnchor;
|
||||
|
||||
@@ -33,13 +40,20 @@ export const Notifications = (gdkmonitor: Gdk.Monitor) => {
|
||||
notifd.disconnect(resolvedHandler);
|
||||
});
|
||||
|
||||
const shouldShowWindow = createComputed(
|
||||
[notifications, isDndMode],
|
||||
(notifs, dndEnabled) => {
|
||||
return !dndEnabled && notifs.length > 0;
|
||||
},
|
||||
);
|
||||
|
||||
return (
|
||||
<window
|
||||
$={(self) => onCleanup(() => self.destroy())}
|
||||
name={WINDOW_NAME}
|
||||
cssClasses={["notifications"]}
|
||||
gdkmonitor={gdkmonitor}
|
||||
visible={notifications((ns) => ns.length > 0)}
|
||||
visible={shouldShowWindow}
|
||||
anchor={TOP | RIGHT}
|
||||
>
|
||||
<box orientation={Gtk.Orientation.VERTICAL} spacing={10}>
|
||||
|
||||
Reference in New Issue
Block a user