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) {