diff --git a/nixosModules/ags/v2/widgets/bar/fullscreen.tsx b/nixosModules/ags/v2/widgets/bar/fullscreen.tsx index 3b5f9cc1..45c28ebb 100644 --- a/nixosModules/ags/v2/widgets/bar/fullscreen.tsx +++ b/nixosModules/ags/v2/widgets/bar/fullscreen.tsx @@ -1,4 +1,4 @@ -import { Astal, Gdk, Gtk, Widget } from 'astal/gtk3'; +import { App, Astal, Gdk, Gtk, Widget } from 'astal/gtk3'; import { bind, Variable } from 'astal'; import AstalHyprland from 'gi://AstalHyprland?version=0.1'; @@ -150,9 +150,10 @@ export default ({ ); - return ( + const win = ( - ); + ) as Widget.Window; + + App.add_window(win); + + return win; }; diff --git a/nixosModules/ags/v2/widgets/notifs/center.tsx b/nixosModules/ags/v2/widgets/notifs/center.tsx index e69de29b..ad6d321a 100644 --- a/nixosModules/ags/v2/widgets/notifs/center.tsx +++ b/nixosModules/ags/v2/widgets/notifs/center.tsx @@ -0,0 +1,141 @@ +import { bind, timeout } from 'astal'; +import { App, Gtk, Widget } from 'astal/gtk3'; + +import AstalNotifd from 'gi://AstalNotifd?version=0.1'; +const Notifications = AstalNotifd.get_default(); + +import { Notification, HasNotifs } from './notification'; +import { NotifGestureWrapper } from './gesture'; + + +const addNotif = (box: Widget.Box, notifObj: AstalNotifd.Notification) => { + if (notifObj) { + const NewNotif = Notification({ + id: notifObj.id, + slide_in_from: 'Right', + }); + + if (NewNotif) { + box.pack_end(NewNotif, false, false, 0); + box.show_all(); + } + } +}; + +const NotificationList = () => ( + { + Notifications.get_notifications().forEach((n) => { + addNotif(self, n); + }); + + self + .hook(Notifications, 'notified', (_, id) => { + if (id) { + const notifObj = Notifications.get_notification(id); + + if (notifObj) { + addNotif(self, notifObj); + } + } + }) + .hook(Notifications, 'resolved', (_, id) => { + const notif = (self.get_children() as NotifGestureWrapper[]) + .find((ch) => ch.id === id); + + if (notif?.sensitive) { + notif.slideAway('Right'); + } + }); + }} + /> +); + +const ClearButton = () => ( + +); + +const Header = () => ( + + +); + +const Placeholder = () => ( + !v)} + > + + + + +); + +export default () => ( + +
+ + + + + + + + + + + +); diff --git a/nixosModules/ags/v2/widgets/notifs/gesture.tsx b/nixosModules/ags/v2/widgets/notifs/gesture.tsx index d9b9faeb..55cc0245 100644 --- a/nixosModules/ags/v2/widgets/notifs/gesture.tsx +++ b/nixosModules/ags/v2/widgets/notifs/gesture.tsx @@ -53,6 +53,8 @@ export class NotifGestureWrapper extends Widget.EventBox { readonly slide_in_from: 'Left' | 'Right'; + readonly is_popup: boolean; + private timer_object: AstalIO.Time | undefined; public popup_timer: number; @@ -108,7 +110,11 @@ export class NotifGestureWrapper extends Widget.EventBox { return false; } - public slideAway(side: 'Left' | 'Right', force = false) { + public slideAway(side: 'Left' | 'Right') { + if (!this.sensitive) { + return; + } + ((this.get_child() as Widget.Revealer).get_child() as Widget.Box) .css = side === 'Left' ? slideLeft : slideRight; @@ -120,16 +126,17 @@ export class NotifGestureWrapper extends Widget.EventBox { setTimeout(() => { // Kill notif if specified - if (force) { + if (!this.is_popup) { Notifications.get_notification(this.id)?.dismiss(); + + // Update HasNotifs + HasNotifs.set(Notifications.get_notifications().length > 0); + } + else { + // Make sure we cleanup any references to this instance + NotifGestureWrapper.popups.delete(this.id); + this.timer_object?.cancel(); } - - // Make sure we cleanup any references to this instance - this.timer_object?.cancel(); - NotifGestureWrapper.popups.delete(this.id); - - // Update HasNotifs - HasNotifs.set(Notifications.get_notifications().length > 0); // Get rid of disappeared widget this.destroy(); @@ -146,13 +153,12 @@ export class NotifGestureWrapper extends Widget.EventBox { }: NotifGestureWrapperProps) { super(); - setup_notif(this); - this.id = id; this.slide_in_from = slide_in_from; this.dragging = false; this.popup_timer = popup_timer; + this.is_popup = this.popup_timer !== 0; this.timer_update(this.popup_timer); // OnClick @@ -312,6 +318,8 @@ export class NotifGestureWrapper extends Widget.EventBox { /> , ); + + setup_notif(this); } } diff --git a/nixosModules/ags/v2/widgets/notifs/main.tsx b/nixosModules/ags/v2/widgets/notifs/main.tsx index 21247b52..61bd30a8 100644 --- a/nixosModules/ags/v2/widgets/notifs/main.tsx +++ b/nixosModules/ags/v2/widgets/notifs/main.tsx @@ -3,6 +3,7 @@ import { Astal } from 'astal/gtk3'; import PopupWindow from '../misc/popup-window'; import Popups from './popups'; +import Center from './center'; export const NotifPopups = () => ( @@ -21,6 +22,6 @@ export const NotifCenter = () => ( name="notif-center" anchor={Astal.WindowAnchor.TOP | Astal.WindowAnchor.RIGHT} > - +
); diff --git a/nixosModules/ags/v2/widgets/notifs/notification.tsx b/nixosModules/ags/v2/widgets/notifs/notification.tsx index f53f92d9..7a3b0a58 100644 --- a/nixosModules/ags/v2/widgets/notifs/notification.tsx +++ b/nixosModules/ags/v2/widgets/notifs/notification.tsx @@ -17,11 +17,9 @@ import SmoothProgress from '../misc/smooth-progress'; // to know when there are notifs or not export const HasNotifs = Variable(false); -const setTime = (time: number): string => { - return GLib.DateTime - .new_from_unix_local(time) - .format('%H:%M') ?? ''; -}; +const setTime = (time: number): string => GLib.DateTime + .new_from_unix_local(time) + .format('%H:%M') ?? ''; const NotifIcon = ({ notifObj }: { notifObj: AstalNotifd.Notification @@ -93,6 +91,7 @@ const BlockedApps = [ export const Notification = ({ id = 0, popup_timer = 0, + slide_in_from = 'Left' as 'Left' | 'Right', }): ReturnType | undefined => { const notifObj = Notifications.get_notification(id); @@ -114,10 +113,16 @@ export const Notification = ({ { - self.connect('timer-update', () => { - progress.fraction = self.popup_timer / 5; - }); + if (self.is_popup) { + self.connect('timer-update', () => { + progress.fraction = self.popup_timer / 5; + }); + } + else { + progress.destroy(); + } }} > diff --git a/nixosModules/ags/v2/widgets/notifs/style.scss b/nixosModules/ags/v2/widgets/notifs/style.scss index 0a8f88dc..c3a488a9 100644 --- a/nixosModules/ags/v2/widgets/notifs/style.scss +++ b/nixosModules/ags/v2/widgets/notifs/style.scss @@ -45,3 +45,88 @@ } } } + +.notification-center { + margin-top: 0; + + min-height: 700px; + min-width: 580px; + + * { + font-size: 16px; + } + + .header { + padding: 10px; + margin-bottom: 9px; + + label { + font-size: 22px; + } + } + + .notification-list-box { + padding: 0 12px; + border-radius: 30px; + border-top: 2px solid $accent-color; + + viewport { + all: unset; + } + + scrollbar { + all: unset; + border-radius: 8px; + border-top-left-radius: 0; + border-bottom-left-radius: 0; + + * { + all: unset; + } + + &:hover { + border-radius: 8px; + border-top-left-radius: 0; + border-bottom-left-radius: 0; + } + } + + scrollbar.vertical { + transition: 200ms; + background-color: rgba(23, 23, 23, 0.3); + + &:hover { + background-color: rgba(23, 23, 23, 0.7); + + slider { + background-color: rgba(238, 238, 238, 0.7); + min-width: .6em; + } + } + + slider { + background-color: rgba(238, 238, 238, 0.5); + border-radius: 9px; + min-width: .4em; + min-height: 2em; + transition: 200ms; + } + } + } + + .placeholder { + color: white; + + icon { + font-size: 7em; + text-shadow: 2px 2px 2px rgba(0, 0, 0, 0.6); + -gtk-icon-shadow: 2px 2px 2px rgba(0, 0, 0, 0.6); + } + + label { + font-size: 1.2em; + text-shadow: 2px 2px 2px rgba(0, 0, 0, 0.6); + -gtk-icon-shadow: 2px 2px 2px rgba(0, 0, 0, 0.6); + } + } +}