From a4b5014066775d0ae88d3e19c034f77e8d83876a Mon Sep 17 00:00:00 2001 From: Armin Begert Date: Wed, 10 Nov 2021 18:51:32 +0100 Subject: [PATCH] Show cover art for songs per default, but not in Albums Albums instead show the songs' index. --- src/app/components/artist_details/artist_details.rs | 1 + src/app/components/details/details.rs | 1 + src/app/components/now_playing/now_playing.rs | 7 ++++++- src/app/components/playlist/playlist.rs | 9 +++++++-- src/app/components/playlist/song.rs | 11 +++++++---- .../components/playlist_details/playlist_details.rs | 1 + src/app/components/saved_tracks/saved_tracks.rs | 7 ++++++- 7 files changed, 29 insertions(+), 8 deletions(-) diff --git a/src/app/components/artist_details/artist_details.rs b/src/app/components/artist_details/artist_details.rs index 4ff3a17a..0c180848 100644 --- a/src/app/components/artist_details/artist_details.rs +++ b/src/app/components/artist_details/artist_details.rs @@ -144,6 +144,7 @@ impl ArtistDetails { widget.top_tracks_widget().clone(), Rc::clone(&model), worker, + true, )); Self { diff --git a/src/app/components/details/details.rs b/src/app/components/details/details.rs index c85e8f69..84a18b9f 100644 --- a/src/app/components/details/details.rs +++ b/src/app/components/details/details.rs @@ -186,6 +186,7 @@ impl Details { widget.album_tracks_widget().clone(), model.clone(), worker.clone(), + false, )); let modal = ReleaseDetailsWindow::new(); diff --git a/src/app/components/now_playing/now_playing.rs b/src/app/components/now_playing/now_playing.rs index a1cece5e..a6c68bcb 100644 --- a/src/app/components/now_playing/now_playing.rs +++ b/src/app/components/now_playing/now_playing.rs @@ -86,7 +86,12 @@ impl NowPlaying { model.load_more(); })); - let playlist = Playlist::new(widget.song_list_widget().clone(), model.clone(), worker); + let playlist = Playlist::new( + widget.song_list_widget().clone(), + model.clone(), + worker, + true, + ); Self { widget, diff --git a/src/app/components/playlist/playlist.rs b/src/app/components/playlist/playlist.rs index bb6b4a11..ca44074d 100644 --- a/src/app/components/playlist/playlist.rs +++ b/src/app/components/playlist/playlist.rs @@ -64,7 +64,12 @@ impl Playlist where Model: PlaylistModel + 'static, { - pub fn new(listview: gtk::ListView, model: Rc, worker: Worker) -> Self { + pub fn new( + listview: gtk::ListView, + model: Rc, + worker: Worker, + show_song_covers: bool, + ) -> Self { let list_model = ListStore::new(); let selection_model = gtk::NoSelection::new(Some(list_model.unsafe_store())); let factory = gtk::SignalListItemFactory::new(); @@ -84,7 +89,7 @@ where song_model.set_state(Self::get_item_state(&*model, &song_model)); let widget = item.child().unwrap().downcast::().unwrap(); - widget.bind(&song_model, worker.clone()); + widget.bind(&song_model, worker.clone(), show_song_covers); let id = &song_model.get_id(); widget.set_actions(model.actions_for(id).as_ref()); diff --git a/src/app/components/playlist/song.rs b/src/app/components/playlist/song.rs index f4e045d5..b4b45da7 100644 --- a/src/app/components/playlist/song.rs +++ b/src/app/components/playlist/song.rs @@ -77,7 +77,7 @@ impl SongWidget { pub fn for_model(model: SongModel, worker: Worker) -> Self { let _self = Self::new(); - _self.bind(&model, worker); + _self.bind(&model, worker, true); _self } @@ -138,14 +138,17 @@ impl SongWidget { } } - pub fn bind(&self, model: &SongModel, worker: Worker) { + pub fn bind(&self, model: &SongModel, worker: Worker, show_cover: bool) { let widget = imp::SongWidget::from_instance(self); - model.bind_index(&*widget.song_index, "label"); model.bind_title(&*widget.song_title, "label"); model.bind_artist(&*widget.song_artist, "label"); model.bind_duration(&*widget.song_length, "label"); - self.bind_art(model, worker); + if show_cover { + self.bind_art(model, worker); + } else { + model.bind_index(&*widget.song_index, "label"); + } self.set_playing(model.get_playing()); model.connect_playing_local(clone!(@weak self as _self => move |song| { diff --git a/src/app/components/playlist_details/playlist_details.rs b/src/app/components/playlist_details/playlist_details.rs index 0267d766..e61c61a4 100644 --- a/src/app/components/playlist_details/playlist_details.rs +++ b/src/app/components/playlist_details/playlist_details.rs @@ -175,6 +175,7 @@ impl PlaylistDetails { widget.playlist_tracks_widget().clone(), model.clone(), worker.clone(), + true, )); widget.connect_header(); diff --git a/src/app/components/saved_tracks/saved_tracks.rs b/src/app/components/saved_tracks/saved_tracks.rs index ebf93225..4f25fe67 100644 --- a/src/app/components/saved_tracks/saved_tracks.rs +++ b/src/app/components/saved_tracks/saved_tracks.rs @@ -87,7 +87,12 @@ impl SavedTracks { model.load_more(); })); - let playlist = Playlist::new(widget.song_list_widget().clone(), model.clone(), worker); + let playlist = Playlist::new( + widget.song_list_widget().clone(), + model.clone(), + worker, + true, + ); Self { widget,