From fc32b0dc2be82116938fc1f545588e20d09c169a Mon Sep 17 00:00:00 2001 From: Erica Z Date: Mon, 4 Nov 2024 08:03:59 +0100 Subject: [PATCH] no more 2 --- src/ui/window.rs | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/src/ui/window.rs b/src/ui/window.rs index 8057c3d..437e65f 100644 --- a/src/ui/window.rs +++ b/src/ui/window.rs @@ -28,8 +28,8 @@ mod imp { pub(super) setup: crate::ui::Setup, - pub(super) playbin2: Rc, - pub(super) api2: RefCell>>, + pub(super) playbin: Rc, + pub(super) api: RefCell>>, } #[glib::object_subclass] @@ -53,7 +53,7 @@ mod imp { fn constructed(&self) { self.parent_constructed(); - let playbin = Rc::downgrade(&self.playbin2); + let playbin = Rc::downgrade(&self.playbin); glib::spawn_future_local(glib::clone!(async move { loop { 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 let window = self.obj().clone(); @@ -93,7 +93,7 @@ mod imp { crate::Mpris::setup(conn.object_server(), &window) .await .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 .expect("could not serve mpris player"); @@ -125,12 +125,11 @@ mod imp { #[template_callback] async fn shuffle_all(&self) { self.obj().set_can_click_shuffle_all(false); - self.playbin2.stop(); - let api = self.api2.borrow(); + self.playbin.stop(); + let api = self.api.borrow(); let api = api.as_ref().unwrap(); for song in api.get_random_songs(10).await.unwrap().into_iter() { - self.playbin2 - .push_entry(PlaybinSong::from_child(api, &song)); + self.playbin.push_entry(PlaybinSong::from_child(api, &song)); } self.obj().set_can_click_shuffle_all(true); } @@ -196,8 +195,8 @@ impl Window { window .imp() .playbar - .set_volume(window.imp().playbin2.volume() as i32); - window.imp().playbin2.volume_changed().connect_object( + .set_volume(window.imp().playbin.volume() as i32); + window.imp().playbin.volume_changed().connect_object( &*window.imp().playbar, |playbin, playbar, ()| { playbar.set_volume(playbin.volume() as i32); @@ -208,13 +207,13 @@ impl Window { Some("volume"), glib::clone!( #[weak(rename_to = playbin)] - window.imp().playbin2, + window.imp().playbin, move |playbar, _| playbin.set_volume(playbar.volume() as i64) ), ); - window.imp().playbar.set_mute(window.imp().playbin2.muted()); - window.imp().playbin2.muted_changed().connect_object( + window.imp().playbar.set_mute(window.imp().playbin.muted()); + window.imp().playbin.muted_changed().connect_object( &*window.imp().playbar, |playbin, playbar, ()| { playbar.set_mute(playbin.muted()); @@ -225,12 +224,12 @@ impl Window { Some("mute"), glib::clone!( #[weak(rename_to = playbin)] - window.imp().playbin2, + window.imp().playbin, move |playbar, _| playbin.set_muted(playbar.mute()) ), ); - window.imp().playbin2.file_started().connect_object( + window.imp().playbin.file_started().connect_object( &*window.imp().playbar, |playbin, playbar, ()| { let entry = &playbin.entries()[playbin.current_entry().unwrap()]; @@ -242,7 +241,7 @@ impl Window { // update position every 100 ms glib::source::timeout_add_local(std::time::Duration::from_millis(100), { let playbar = window.imp().playbar.downgrade(); - let playbin = Rc::downgrade(&window.imp().playbin2); + let playbin = Rc::downgrade(&window.imp().playbin); move || { let playbar = match playbar.upgrade() { None => return glib::ControlFlow::Break, @@ -262,8 +261,8 @@ impl Window { .setup .connected() .connect_object(&window, |_setup, window, api| { - window.imp().api2.replace(Some(api)); - window.imp().playbin2.stop(); + window.imp().api.replace(Some(api)); + window.imp().playbin.stop(); window.set_can_click_shuffle_all(true); true }); @@ -271,7 +270,7 @@ impl Window { window .imp() - .playbin2 + .playbin .file_started() .connect_object(&window, |playbin, window, ()| { window