finally make volume slider bidirectional
This commit is contained in:
parent
472770013e
commit
83e627d3d2
2 changed files with 4 additions and 16 deletions
|
@ -19,8 +19,8 @@ mod imp {
|
||||||
#[property(get, set, default = true)]
|
#[property(get, set, default = true)]
|
||||||
show_cover_art: Cell<bool>,
|
show_cover_art: Cell<bool>,
|
||||||
|
|
||||||
#[property(type = i32, get = Self::volume, set = Self::set_volume)]
|
#[property(get, set)]
|
||||||
_volume: (),
|
volume: Cell<i32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[glib::object_subclass]
|
#[glib::object_subclass]
|
||||||
|
@ -159,20 +159,6 @@ mod imp {
|
||||||
let playbin = self.playbin.upgrade().unwrap();
|
let playbin = self.playbin.upgrade().unwrap();
|
||||||
playbin.set_mute(!playbin.mute());
|
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,8 @@ public class Audrey.Ui.Window : Adw.ApplicationWindow {
|
||||||
|
|
||||||
public Window (Gtk.Application app) {
|
public Window (Gtk.Application app) {
|
||||||
Object (application: app);
|
Object (application: app);
|
||||||
|
|
||||||
|
this.playbin.bind_property("volume", this.playbar, "volume", BindingFlags.BIDIRECTIONAL | BindingFlags.SYNC_CREATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void now_playing (PlaybinSong song) {
|
private void now_playing (PlaybinSong song) {
|
||||||
|
|
Loading…
Reference in a new issue