Add notification timeout
This commit is contained in:
parent
77825859ec
commit
1a2bef6b9b
|
@ -71,7 +71,7 @@ function Date({ format = "%Y-%m-%d" }): JSX.Element {
|
||||||
}
|
}
|
||||||
|
|
||||||
function Time({ format = "%H:%M:%S" }): JSX.Element {
|
function Time({ format = "%H:%M:%S" }): JSX.Element {
|
||||||
const time = createPoll<string>("", 10000, () => GLib.DateTime.new_now_local().format(format)!)
|
const time = createPoll<string>("", 1000, () => GLib.DateTime.new_now_local().format(format)!)
|
||||||
return <label
|
return <label
|
||||||
class="item blue"
|
class="item blue"
|
||||||
label={time}
|
label={time}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import Adw from "gi://Adw"
|
||||||
import GLib from "gi://GLib"
|
import GLib from "gi://GLib"
|
||||||
import AstalNotifd from "gi://AstalNotifd"
|
import AstalNotifd from "gi://AstalNotifd"
|
||||||
import Pango from "gi://Pango"
|
import Pango from "gi://Pango"
|
||||||
|
import { timeout } from "ags/time"
|
||||||
|
|
||||||
function isIcon(icon?: string | null) {
|
function isIcon(icon?: string | null) {
|
||||||
const iconTheme = Gtk.IconTheme.get_for_display(Gdk.Display.get_default()!)
|
const iconTheme = Gtk.IconTheme.get_for_display(Gdk.Display.get_default()!)
|
||||||
|
@ -38,6 +39,9 @@ export default function Notification({
|
||||||
notification: AstalNotifd.Notification
|
notification: AstalNotifd.Notification
|
||||||
onHoverLost: () => void
|
onHoverLost: () => void
|
||||||
}) {
|
}) {
|
||||||
|
const timer = timeout(3000, () => {
|
||||||
|
onHoverLost()
|
||||||
|
})
|
||||||
return (
|
return (
|
||||||
<Adw.Clamp maximumSize={400}>
|
<Adw.Clamp maximumSize={400}>
|
||||||
<box
|
<box
|
||||||
|
@ -45,7 +49,7 @@ export default function Notification({
|
||||||
class={`Notification ${urgency(n)}`}
|
class={`Notification ${urgency(n)}`}
|
||||||
orientation={Gtk.Orientation.VERTICAL}
|
orientation={Gtk.Orientation.VERTICAL}
|
||||||
>
|
>
|
||||||
<Gtk.EventControllerMotion onLeave={onHoverLost} />
|
<Gtk.EventControllerMotion onEnter={() => timer.cancel()} onLeave={onHoverLost} />
|
||||||
<box class="header">
|
<box class="header">
|
||||||
{(n.appIcon || isIcon(n.desktopEntry)) && (
|
{(n.appIcon || isIcon(n.desktopEntry)) && (
|
||||||
<image
|
<image
|
||||||
|
|
Loading…
Reference in New Issue