mirror of
https://github.com/johrpan/musicus.git
synced 2025-10-26 19:57:25 +01:00
Fix some player screen lifetime issues
This commit is contained in:
parent
88e1c97143
commit
b49272b8ac
1 changed files with 26 additions and 26 deletions
|
|
@ -67,6 +67,9 @@ impl Screen<(), ()> for PlayerScreen {
|
||||||
let list = List::new();
|
let list = List::new();
|
||||||
frame.set_child(Some(&list.widget));
|
frame.set_child(Some(&list.widget));
|
||||||
|
|
||||||
|
let position_controller = gtk::GestureClick::new();
|
||||||
|
position_scale.add_controller(&position_controller);
|
||||||
|
|
||||||
let this = Rc::new(Self {
|
let this = Rc::new(Self {
|
||||||
handle,
|
handle,
|
||||||
widget,
|
widget,
|
||||||
|
|
@ -90,12 +93,16 @@ impl Screen<(), ()> for PlayerScreen {
|
||||||
|
|
||||||
let player = &this.handle.backend.pl();
|
let player = &this.handle.backend.pl();
|
||||||
|
|
||||||
player.add_playlist_cb(clone!(@weak this => move |playlist| {
|
player.add_playlist_cb(clone!(@weak this => @default-return (), move |playlist| {
|
||||||
|
if playlist.is_empty() {
|
||||||
|
this.handle.pop(None);
|
||||||
|
}
|
||||||
|
|
||||||
this.playlist.replace(playlist);
|
this.playlist.replace(playlist);
|
||||||
this.show_playlist();
|
this.show_playlist();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
player.add_track_cb(clone!(@weak this, @weak player => move |current_item, current_track| {
|
player.add_track_cb(clone!(@weak this, @weak player => @default-return (), move |current_item, current_track| {
|
||||||
this.previous_button.set_sensitive(this.handle.backend.pl().has_previous());
|
this.previous_button.set_sensitive(this.handle.backend.pl().has_previous());
|
||||||
this.next_button.set_sensitive(this.handle.backend.pl().has_next());
|
this.next_button.set_sensitive(this.handle.backend.pl().has_next());
|
||||||
|
|
||||||
|
|
@ -122,14 +129,14 @@ impl Screen<(), ()> for PlayerScreen {
|
||||||
this.show_playlist();
|
this.show_playlist();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
player.add_duration_cb(clone!(@weak this => move |ms| {
|
player.add_duration_cb(clone!(@weak this => @default-return (), move |ms| {
|
||||||
let min = ms / 60000;
|
let min = ms / 60000;
|
||||||
let sec = (ms % 60000) / 1000;
|
let sec = (ms % 60000) / 1000;
|
||||||
this.duration_label.set_text(&format!("{}:{:02}", min, sec));
|
this.duration_label.set_text(&format!("{}:{:02}", min, sec));
|
||||||
this.position.set_upper(ms as f64);
|
this.position.set_upper(ms as f64);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
player.add_playing_cb(clone!(@weak this => move |playing| {
|
player.add_playing_cb(clone!(@weak this => @default-return (), move |playing| {
|
||||||
this.play_button.set_child(Some(if playing {
|
this.play_button.set_child(Some(if playing {
|
||||||
&this.pause_image
|
&this.pause_image
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -137,7 +144,7 @@ impl Screen<(), ()> for PlayerScreen {
|
||||||
}));
|
}));
|
||||||
}));
|
}));
|
||||||
|
|
||||||
player.add_position_cb(clone!(@weak this => move |ms| {
|
player.add_position_cb(clone!(@weak this => @default-return (), move |ms| {
|
||||||
if !this.seeking.get() {
|
if !this.seeking.get() {
|
||||||
let min = ms / 60000;
|
let min = ms / 60000;
|
||||||
let sec = (ms % 60000) / 1000;
|
let sec = (ms % 60000) / 1000;
|
||||||
|
|
@ -166,31 +173,24 @@ impl Screen<(), ()> for PlayerScreen {
|
||||||
this.handle.backend.pl().clear();
|
this.handle.backend.pl().clear();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// position_scale.connect_button_press_event(clone!(@strong seeking => move |_, _| {
|
// position_controller.connect_pressed(clone!(@weak this => move |_, _, _, _| {
|
||||||
// seeking.replace(true);
|
// this.seeking.replace(true);
|
||||||
// Inhibit(false)
|
|
||||||
// }));
|
// }));
|
||||||
|
|
||||||
// position_scale.connect_button_release_event(
|
// position_controller.connect_unpaired_release(clone!(@weak this => move |_, _, _, _, _| {
|
||||||
// clone!(@strong seeking, @strong position, @strong player => move |_, _| {
|
// this.handle.backend.pl().seek(this.position.get_value() as u64);
|
||||||
// if let Some(player) = &*player.borrow() {
|
// this.seeking.replace(false);
|
||||||
// player.seek(position.get_value() as u64);
|
// }));
|
||||||
// }
|
|
||||||
|
|
||||||
// seeking.replace(false);
|
// position_scale.connect_value_changed(clone!(@weak this => move |_| {
|
||||||
// Inhibit(false)
|
// if this.seeking.get() {
|
||||||
// }),
|
// let ms = this.position.get_value() as u64;
|
||||||
// );
|
// let min = ms / 60000;
|
||||||
|
// let sec = (ms % 60000) / 1000;
|
||||||
|
|
||||||
position_scale.connect_value_changed(clone!(@strong this => move |_| {
|
// this.position_label.set_text(&format!("{}:{:02}", min, sec));
|
||||||
if this.seeking.get() {
|
// }
|
||||||
let ms = this.position.get_value() as u64;
|
// }));
|
||||||
let min = ms / 60000;
|
|
||||||
let sec = (ms % 60000) / 1000;
|
|
||||||
|
|
||||||
this.position_label.set_text(&format!("{}:{:02}", min, sec));
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
this.list.set_make_widget_cb(clone!(@weak this => move |index| {
|
this.list.set_make_widget_cb(clone!(@weak this => move |index| {
|
||||||
match this.items.borrow()[index] {
|
match this.items.borrow()[index] {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue