no more 2
This commit is contained in:
parent
56a43b466b
commit
fc32b0dc2b
1 changed files with 19 additions and 20 deletions
|
@ -28,8 +28,8 @@ mod imp {
|
||||||
|
|
||||||
pub(super) setup: crate::ui::Setup,
|
pub(super) setup: crate::ui::Setup,
|
||||||
|
|
||||||
pub(super) playbin2: Rc<Playbin>,
|
pub(super) playbin: Rc<Playbin>,
|
||||||
pub(super) api2: RefCell<Option<Rc<crate::subsonic::Client>>>,
|
pub(super) api: RefCell<Option<Rc<crate::subsonic::Client>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[glib::object_subclass]
|
#[glib::object_subclass]
|
||||||
|
@ -53,7 +53,7 @@ mod imp {
|
||||||
fn constructed(&self) {
|
fn constructed(&self) {
|
||||||
self.parent_constructed();
|
self.parent_constructed();
|
||||||
|
|
||||||
let playbin = Rc::downgrade(&self.playbin2);
|
let playbin = Rc::downgrade(&self.playbin);
|
||||||
glib::spawn_future_local(glib::clone!(async move {
|
glib::spawn_future_local(glib::clone!(async move {
|
||||||
loop {
|
loop {
|
||||||
match playbin.upgrade() {
|
match playbin.upgrade() {
|
||||||
|
@ -67,7 +67,7 @@ mod imp {
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
self.play_queue.set_playbin(&self.playbin2);
|
self.play_queue.set_playbin(&self.playbin);
|
||||||
|
|
||||||
// set up mpris
|
// set up mpris
|
||||||
let window = self.obj().clone();
|
let window = self.obj().clone();
|
||||||
|
@ -93,7 +93,7 @@ mod imp {
|
||||||
crate::Mpris::setup(conn.object_server(), &window)
|
crate::Mpris::setup(conn.object_server(), &window)
|
||||||
.await
|
.await
|
||||||
.expect("could not serve mpris");
|
.expect("could not serve mpris");
|
||||||
crate::mpris::Player::setup(conn.object_server(), &window.imp().playbin2)
|
crate::mpris::Player::setup(conn.object_server(), &window.imp().playbin)
|
||||||
.await
|
.await
|
||||||
.expect("could not serve mpris player");
|
.expect("could not serve mpris player");
|
||||||
|
|
||||||
|
@ -125,12 +125,11 @@ mod imp {
|
||||||
#[template_callback]
|
#[template_callback]
|
||||||
async fn shuffle_all(&self) {
|
async fn shuffle_all(&self) {
|
||||||
self.obj().set_can_click_shuffle_all(false);
|
self.obj().set_can_click_shuffle_all(false);
|
||||||
self.playbin2.stop();
|
self.playbin.stop();
|
||||||
let api = self.api2.borrow();
|
let api = self.api.borrow();
|
||||||
let api = api.as_ref().unwrap();
|
let api = api.as_ref().unwrap();
|
||||||
for song in api.get_random_songs(10).await.unwrap().into_iter() {
|
for song in api.get_random_songs(10).await.unwrap().into_iter() {
|
||||||
self.playbin2
|
self.playbin.push_entry(PlaybinSong::from_child(api, &song));
|
||||||
.push_entry(PlaybinSong::from_child(api, &song));
|
|
||||||
}
|
}
|
||||||
self.obj().set_can_click_shuffle_all(true);
|
self.obj().set_can_click_shuffle_all(true);
|
||||||
}
|
}
|
||||||
|
@ -196,8 +195,8 @@ impl Window {
|
||||||
window
|
window
|
||||||
.imp()
|
.imp()
|
||||||
.playbar
|
.playbar
|
||||||
.set_volume(window.imp().playbin2.volume() as i32);
|
.set_volume(window.imp().playbin.volume() as i32);
|
||||||
window.imp().playbin2.volume_changed().connect_object(
|
window.imp().playbin.volume_changed().connect_object(
|
||||||
&*window.imp().playbar,
|
&*window.imp().playbar,
|
||||||
|playbin, playbar, ()| {
|
|playbin, playbar, ()| {
|
||||||
playbar.set_volume(playbin.volume() as i32);
|
playbar.set_volume(playbin.volume() as i32);
|
||||||
|
@ -208,13 +207,13 @@ impl Window {
|
||||||
Some("volume"),
|
Some("volume"),
|
||||||
glib::clone!(
|
glib::clone!(
|
||||||
#[weak(rename_to = playbin)]
|
#[weak(rename_to = playbin)]
|
||||||
window.imp().playbin2,
|
window.imp().playbin,
|
||||||
move |playbar, _| playbin.set_volume(playbar.volume() as i64)
|
move |playbar, _| playbin.set_volume(playbar.volume() as i64)
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
window.imp().playbar.set_mute(window.imp().playbin2.muted());
|
window.imp().playbar.set_mute(window.imp().playbin.muted());
|
||||||
window.imp().playbin2.muted_changed().connect_object(
|
window.imp().playbin.muted_changed().connect_object(
|
||||||
&*window.imp().playbar,
|
&*window.imp().playbar,
|
||||||
|playbin, playbar, ()| {
|
|playbin, playbar, ()| {
|
||||||
playbar.set_mute(playbin.muted());
|
playbar.set_mute(playbin.muted());
|
||||||
|
@ -225,12 +224,12 @@ impl Window {
|
||||||
Some("mute"),
|
Some("mute"),
|
||||||
glib::clone!(
|
glib::clone!(
|
||||||
#[weak(rename_to = playbin)]
|
#[weak(rename_to = playbin)]
|
||||||
window.imp().playbin2,
|
window.imp().playbin,
|
||||||
move |playbar, _| playbin.set_muted(playbar.mute())
|
move |playbar, _| playbin.set_muted(playbar.mute())
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
window.imp().playbin2.file_started().connect_object(
|
window.imp().playbin.file_started().connect_object(
|
||||||
&*window.imp().playbar,
|
&*window.imp().playbar,
|
||||||
|playbin, playbar, ()| {
|
|playbin, playbar, ()| {
|
||||||
let entry = &playbin.entries()[playbin.current_entry().unwrap()];
|
let entry = &playbin.entries()[playbin.current_entry().unwrap()];
|
||||||
|
@ -242,7 +241,7 @@ impl Window {
|
||||||
// update position every 100 ms
|
// update position every 100 ms
|
||||||
glib::source::timeout_add_local(std::time::Duration::from_millis(100), {
|
glib::source::timeout_add_local(std::time::Duration::from_millis(100), {
|
||||||
let playbar = window.imp().playbar.downgrade();
|
let playbar = window.imp().playbar.downgrade();
|
||||||
let playbin = Rc::downgrade(&window.imp().playbin2);
|
let playbin = Rc::downgrade(&window.imp().playbin);
|
||||||
move || {
|
move || {
|
||||||
let playbar = match playbar.upgrade() {
|
let playbar = match playbar.upgrade() {
|
||||||
None => return glib::ControlFlow::Break,
|
None => return glib::ControlFlow::Break,
|
||||||
|
@ -262,8 +261,8 @@ impl Window {
|
||||||
.setup
|
.setup
|
||||||
.connected()
|
.connected()
|
||||||
.connect_object(&window, |_setup, window, api| {
|
.connect_object(&window, |_setup, window, api| {
|
||||||
window.imp().api2.replace(Some(api));
|
window.imp().api.replace(Some(api));
|
||||||
window.imp().playbin2.stop();
|
window.imp().playbin.stop();
|
||||||
window.set_can_click_shuffle_all(true);
|
window.set_can_click_shuffle_all(true);
|
||||||
true
|
true
|
||||||
});
|
});
|
||||||
|
@ -271,7 +270,7 @@ impl Window {
|
||||||
|
|
||||||
window
|
window
|
||||||
.imp()
|
.imp()
|
||||||
.playbin2
|
.playbin
|
||||||
.file_started()
|
.file_started()
|
||||||
.connect_object(&window, |playbin, window, ()| {
|
.connect_object(&window, |playbin, window, ()| {
|
||||||
window
|
window
|
||||||
|
|
Loading…
Reference in a new issue