Skip to content

Commit

Permalink
Show cover art for songs per default, but not in Albums
Browse files Browse the repository at this point in the history
Albums instead show the songs' index.
  • Loading branch information
abegert committed Nov 11, 2021
1 parent 11f7ce4 commit a4b5014
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/app/components/artist_details/artist_details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ impl ArtistDetails {
widget.top_tracks_widget().clone(),
Rc::clone(&model),
worker,
true,
));

Self {
Expand Down
1 change: 1 addition & 0 deletions src/app/components/details/details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ impl Details {
widget.album_tracks_widget().clone(),
model.clone(),
worker.clone(),
false,
));

let modal = ReleaseDetailsWindow::new();
Expand Down
7 changes: 6 additions & 1 deletion src/app/components/now_playing/now_playing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 7 additions & 2 deletions src/app/components/playlist/playlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,12 @@ impl<Model> Playlist<Model>
where
Model: PlaylistModel + 'static,
{
pub fn new(listview: gtk::ListView, model: Rc<Model>, worker: Worker) -> Self {
pub fn new(
listview: gtk::ListView,
model: Rc<Model>,
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();
Expand All @@ -84,7 +89,7 @@ where
song_model.set_state(Self::get_item_state(&*model, &song_model));

let widget = item.child().unwrap().downcast::<SongWidget>().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());
Expand Down
11 changes: 7 additions & 4 deletions src/app/components/playlist/song.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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| {
Expand Down
1 change: 1 addition & 0 deletions src/app/components/playlist_details/playlist_details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ impl PlaylistDetails {
widget.playlist_tracks_widget().clone(),
model.clone(),
worker.clone(),
true,
));

widget.connect_header();
Expand Down
7 changes: 6 additions & 1 deletion src/app/components/saved_tracks/saved_tracks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit a4b5014

Please sign in to comment.