mirror of
https://github.com/johrpan/musicus.git
synced 2025-10-26 11:47:25 +01:00
player bar: hook up controls
This commit is contained in:
parent
25dc8e2779
commit
9489aaf2ee
3 changed files with 81 additions and 19 deletions
|
|
@ -16,6 +16,12 @@ mod imp {
|
|||
pub playlist: OnceCell<gio::ListStore>,
|
||||
#[property(get, set = Self::set_current_index)]
|
||||
pub current_index: Cell<u32>,
|
||||
#[property(get, set)]
|
||||
pub current_time: Cell<u32>,
|
||||
#[property(get, set)]
|
||||
pub remaining_time: Cell<u32>,
|
||||
#[property(get, set = Self::set_position)]
|
||||
pub position: Cell<f64>,
|
||||
}
|
||||
|
||||
impl MusicusPlayer {
|
||||
|
|
@ -36,6 +42,10 @@ mod imp {
|
|||
.set_is_playing(true);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_position(&self, position: f64) {
|
||||
self.position.set(position);
|
||||
}
|
||||
}
|
||||
|
||||
#[glib::object_subclass]
|
||||
|
|
@ -59,6 +69,9 @@ impl MusicusPlayer {
|
|||
.property("playing", false)
|
||||
.property("playlist", gio::ListStore::new::<PlaylistItem>())
|
||||
.property("current-index", 0u32)
|
||||
.property("current-time", 0u32)
|
||||
.property("remaining-time", 10000u32)
|
||||
.property("position", 0.0)
|
||||
.build()
|
||||
}
|
||||
|
||||
|
|
@ -88,6 +101,18 @@ impl MusicusPlayer {
|
|||
.item(imp.current_index.get())
|
||||
.and_downcast::<PlaylistItem>()
|
||||
}
|
||||
|
||||
pub fn next(&self) {
|
||||
if self.current_index() < self.playlist().n_items() - 1 {
|
||||
self.set_current_index(self.current_index() + 1);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn previous(&self) {
|
||||
if self.current_index() > 0 {
|
||||
self.set_current_index(self.current_index() - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for MusicusPlayer {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue