From 83e627d3d2fdf26cd13f561af28edfcc282ad826 Mon Sep 17 00:00:00 2001 From: Erica Z Date: Fri, 1 Nov 2024 17:57:06 +0100 Subject: [PATCH] finally make volume slider bidirectional --- src/ui/playbar.rs | 18 ++---------------- src/ui/window.vala | 2 ++ 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/src/ui/playbar.rs b/src/ui/playbar.rs index 4c1864d..2c08166 100644 --- a/src/ui/playbar.rs +++ b/src/ui/playbar.rs @@ -19,8 +19,8 @@ mod imp { #[property(get, set, default = true)] show_cover_art: Cell, - #[property(type = i32, get = Self::volume, set = Self::set_volume)] - _volume: (), + #[property(get, set)] + volume: Cell, } #[glib::object_subclass] @@ -159,20 +159,6 @@ mod imp { let playbin = self.playbin.upgrade().unwrap(); playbin.set_mute(!playbin.mute()); } - - fn volume(&self) -> i32 { - let playbin = self.playbin.upgrade(); - - match playbin { - None => 100, - Some(playbin) => playbin.volume(), - } - } - - fn set_volume(&self, value: i32) { - let playbin = self.playbin.upgrade().unwrap(); - playbin.set_volume(value); - } } } diff --git a/src/ui/window.vala b/src/ui/window.vala index e9408c5..78b57b3 100644 --- a/src/ui/window.vala +++ b/src/ui/window.vala @@ -27,6 +27,8 @@ public class Audrey.Ui.Window : Adw.ApplicationWindow { public Window (Gtk.Application app) { Object (application: app); + + this.playbin.bind_property("volume", this.playbar, "volume", BindingFlags.BIDIRECTIONAL | BindingFlags.SYNC_CREATE); } private void now_playing (PlaybinSong song) {