summaryrefslogtreecommitdiff
path: root/src/widgets
diff options
context:
space:
mode:
author2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-03-29 18:13:21 +1100
committer2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-03-29 18:13:21 +1100
commit977a59afb32553c0990a3964404652e9606428dc (patch)
treed98dc8ba56cc107c73e45e492f485e53b7c108d1 /src/widgets
parentmonitors: fix ddc detection (diff)
downloadcaelestia-shell-977a59afb32553c0990a3964404652e9606428dc.tar.gz
caelestia-shell-977a59afb32553c0990a3964404652e9606428dc.tar.bz2
caelestia-shell-977a59afb32553c0990a3964404652e9606428dc.zip
sidebar: allow seeking
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/slider.tsx15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/widgets/slider.tsx b/src/widgets/slider.tsx
index fb219bd..c047d5f 100644
--- a/src/widgets/slider.tsx
+++ b/src/widgets/slider.tsx
@@ -1,8 +1,14 @@
import { bind, type Binding } from "astal";
-import { Gtk } from "astal/gtk3";
+import { Gdk, Gtk, type Widget } from "astal/gtk3";
import type cairo from "cairo";
-export default ({ value }: { value: Binding<number> }) => (
+export default ({
+ value,
+ onChange,
+}: {
+ value: Binding<number>;
+ onChange?: (self: Widget.DrawingArea, value: number) => void;
+}) => (
<drawingarea
hexpand
valign={Gtk.Align.CENTER}
@@ -48,6 +54,11 @@ export default ({ value }: { value: Binding<number> }) => (
cr.arc(radius, height - radius, radius, halfPi, Math.PI); // Bottom left
cr.fill();
});
+
+ self.add_events(Gdk.EventMask.BUTTON_PRESS_MASK);
+ self.connect("button-press-event", (_, event: Gdk.Event) =>
+ onChange?.(self, event.get_coords()[1] / self.get_allocated_width())
+ );
}}
/>
);