im so close

This commit is contained in:
Erica Z 2024-11-03 19:27:22 +01:00
parent 9357c98521
commit 1b8a59bef5

View file

@ -14,8 +14,6 @@ mod imp {
song: RefCell<Option<crate::playbin::Song>>, song: RefCell<Option<crate::playbin::Song>>,
#[property(get, set)] #[property(get, set)]
playing_cover_art: RefCell<Option<gdk::Paintable>>, playing_cover_art: RefCell<Option<gdk::Paintable>>,
#[property(get, set)]
playbin: WeakRef<crate::Playbin>,
#[property(get, set, default = true)] #[property(get, set, default = true)]
show_cover_art: Cell<bool>, show_cover_art: Cell<bool>,
@ -76,20 +74,21 @@ mod imp {
#[template_callback] #[template_callback]
fn playbin_active(&self, state: crate::playbin::State) -> bool { fn playbin_active(&self, state: crate::playbin::State) -> bool {
state != crate::playbin::State::Stopped true // TODO
} }
#[template_callback] #[template_callback]
fn can_press_play(&self, state: crate::playbin::State, n_items: u32) -> bool { fn can_press_play(&self, state: crate::playbin::State, n_items: u32) -> bool {
!(state == crate::playbin::State::Stopped && n_items == 0) true // TODO
} }
#[template_callback] #[template_callback]
fn play_pause_icon_name(&self, state: crate::playbin::State) -> &'static str { fn play_pause_icon_name(&self, state: crate::playbin::State) -> &'static str {
/*
match state { match state {
crate::playbin::State::Playing => "media-playback-pause", crate::playbin::State::Playing => "media-playback-pause",
_ => "media-playback-start", _ => "media-playback-start",
} }*/todo!()
} }
#[template_callback] #[template_callback]
@ -108,56 +107,62 @@ mod imp {
value: f64, value: f64,
range: &gtk::Range, range: &gtk::Range,
) -> bool { ) -> bool {
/*
let playbin = self.playbin.upgrade().unwrap(); let playbin = self.playbin.upgrade().unwrap();
if range.adjustment().lower() < range.adjustment().upper() { if range.adjustment().lower() < range.adjustment().upper() {
playbin.seek(value); playbin.seek(value);
} }
false false*/todo!()
} }
#[template_callback] #[template_callback]
fn on_skip_forward_clicked(&self) { fn on_skip_forward_clicked(&self) {
/*
let playbin = self.playbin.upgrade().unwrap(); let playbin = self.playbin.upgrade().unwrap();
playbin.go_to_next_track(); playbin.go_to_next_track();*/todo!()
} }
#[template_callback] #[template_callback]
fn on_skip_backward_clicked(&self) { fn on_skip_backward_clicked(&self) {
/*
let playbin = self.playbin.upgrade().unwrap(); let playbin = self.playbin.upgrade().unwrap();
playbin.go_to_prev_track(); playbin.go_to_prev_track();*/todo!()
} }
#[template_callback] #[template_callback]
fn seek_backward(&self) { fn seek_backward(&self) {
/*
let playbin = self.playbin.upgrade().unwrap(); let playbin = self.playbin.upgrade().unwrap();
// 10 seconds // 10 seconds
let mut new_position = playbin.position() - 10.0; let mut new_position = playbin.position() - 10.0;
if new_position < 0.0 { if new_position < 0.0 {
new_position = 0.0; new_position = 0.0;
} }
playbin.seek(new_position); playbin.seek(new_position);*/todo!()
} }
#[template_callback] #[template_callback]
fn seek_forward(&self) { fn seek_forward(&self) {
/*
let playbin = self.playbin.upgrade().unwrap(); let playbin = self.playbin.upgrade().unwrap();
// 10 seconds // 10 seconds
let mut new_position = playbin.position() + 10.0; let mut new_position = playbin.position() + 10.0;
if new_position > playbin.duration() { if new_position > playbin.duration() {
new_position = playbin.duration(); new_position = playbin.duration();
} }
playbin.seek(new_position); playbin.seek(new_position);*/todo!()
} }
#[template_callback] #[template_callback]
fn on_play_pause_clicked(&self, _button: &gtk::Button) { fn on_play_pause_clicked(&self, _button: &gtk::Button) {
/*
let playbin = self.playbin.upgrade().unwrap(); let playbin = self.playbin.upgrade().unwrap();
if playbin.state() == crate::playbin::State::Playing { if playbin.state() == crate::playbin::State::Playing {
playbin.pause(); playbin.pause();
} else { } else {
playbin.play(); playbin.play();
} }*/todo!()
} }
#[template_callback] #[template_callback]