finally make volume slider bidirectional

This commit is contained in:
Erica Z 2024-11-01 17:57:06 +01:00
parent 472770013e
commit 83e627d3d2
2 changed files with 4 additions and 16 deletions

View file

@ -19,8 +19,8 @@ mod imp {
#[property(get, set, default = true)]
show_cover_art: Cell<bool>,
#[property(type = i32, get = Self::volume, set = Self::set_volume)]
_volume: (),
#[property(get, set)]
volume: Cell<i32>,
}
#[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);
}
}
}

View file

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