parent
a72db0880b
commit
3fcb88c056
1 changed files with 1 additions and 40 deletions
|
@ -1,8 +1,7 @@
|
||||||
use crate::model::{Album, Song};
|
use crate::model::Song;
|
||||||
use crate::{mpris, mpv};
|
use crate::{mpris, mpv};
|
||||||
use adw::prelude::*;
|
use adw::prelude::*;
|
||||||
use adw::subclass::prelude::*;
|
use adw::subclass::prelude::*;
|
||||||
use futures::TryStreamExt;
|
|
||||||
use glib::subclass::InitializingObject;
|
use glib::subclass::InitializingObject;
|
||||||
use glib::JoinHandle;
|
use glib::JoinHandle;
|
||||||
use gtk::{gdk, gio, glib};
|
use gtk::{gdk, gio, glib};
|
||||||
|
@ -54,9 +53,6 @@ mod imp {
|
||||||
#[property(get)]
|
#[property(get)]
|
||||||
playlist_model: gio::ListStore,
|
playlist_model: gio::ListStore,
|
||||||
|
|
||||||
#[property(get)]
|
|
||||||
albums_model: gio::ListStore,
|
|
||||||
|
|
||||||
#[property(type = i64, get = Self::volume, set = Self::set_volume)]
|
#[property(type = i64, get = Self::volume, set = Self::set_volume)]
|
||||||
_volume: (),
|
_volume: (),
|
||||||
#[property(type = bool, get = Self::mute, set = Self::set_mute)]
|
#[property(type = bool, get = Self::mute, set = Self::set_mute)]
|
||||||
|
@ -126,7 +122,6 @@ mod imp {
|
||||||
mpv,
|
mpv,
|
||||||
|
|
||||||
playlist_model: gio::ListStore::new::<Song>(),
|
playlist_model: gio::ListStore::new::<Song>(),
|
||||||
albums_model: gio::ListStore::new::<Album>(),
|
|
||||||
|
|
||||||
_volume: (),
|
_volume: (),
|
||||||
_mute: (),
|
_mute: (),
|
||||||
|
@ -798,37 +793,6 @@ mod imp {
|
||||||
// cancel queued seek always
|
// cancel queued seek always
|
||||||
self.queued_seek.set(None);
|
self.queued_seek.set(None);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[template_callback]
|
|
||||||
pub(super) async fn on_refresh_albums_clicked(&self) {
|
|
||||||
self.obj().set_refreshing_albums(true);
|
|
||||||
self.albums_model.remove_all();
|
|
||||||
|
|
||||||
let api = Rc::clone(self.api.borrow().as_ref().unwrap());
|
|
||||||
let albums_model = self.obj().albums_model().clone();
|
|
||||||
let perform = async move {
|
|
||||||
let mut albums =
|
|
||||||
std::pin::pin!(api.album_list_full(crate::subsonic::AlbumListType::Newest));
|
|
||||||
while let Some(album) = albums.try_next().await? {
|
|
||||||
albums_model.append(
|
|
||||||
&glib::Object::builder::<crate::model::Album>()
|
|
||||||
.property("id", &album.id)
|
|
||||||
.property("name", &album.name)
|
|
||||||
.property("artist", &album.artist)
|
|
||||||
.build(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok::<(), crate::subsonic::Error>(())
|
|
||||||
};
|
|
||||||
|
|
||||||
match perform.await {
|
|
||||||
Ok(()) => {}
|
|
||||||
Err(err) => event!(Level::ERROR, "could not refresh album list: {err}"),
|
|
||||||
}
|
|
||||||
|
|
||||||
self.obj().set_refreshing_albums(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for Window {
|
impl Drop for Window {
|
||||||
|
@ -904,9 +868,6 @@ impl Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
self.set_can_click_shuffle_all(true);
|
self.set_can_click_shuffle_all(true);
|
||||||
|
|
||||||
let window = self.clone();
|
|
||||||
glib::spawn_future_local(async move { window.imp().on_refresh_albums_clicked().await });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn playlist_next(&self) {
|
pub fn playlist_next(&self) {
|
||||||
|
|
Loading…
Reference in a new issue