Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nest "More from artist" menu entries in submenu #531

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions src/app/components/artist_details/artist_details_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,27 @@ impl PlaylistModel for ArtistDetailsModel {

let menu = gio::Menu::new();
menu.append(Some(&*labels::VIEW_ALBUM), Some("song.view_album"));
for artist in song.artists.iter().filter(|a| self.id != a.id) {
menu.append(
Some(&labels::more_from_label(&artist.name)),
Some(&format!("song.view_artist_{}", artist.id)),
);

let artists_iter = song.artists.iter();

if artists_iter.len() > 1 {
let submenu = gio::Menu::new();

for artist in artists_iter {
submenu.append(
Some(&artist.name),
Some(&format!("song.view_artist_{}", artist.id)),
);
}

menu.append_submenu(Some("More from"), &submenu);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these strings wont be translated -- you have to add a gettext call here, or I guess we could cheat and have labels::more_from_label("") here 🙈

} else {
for artist in artists_iter {
menu.append(
Some(&labels::more_from_label(&artist.name)),
Some(&format!("song.view_artist_{}", artist.id)),
);
}
}

menu.append(Some(&*labels::COPY_LINK), Some("song.copy_link"));
Expand Down
26 changes: 21 additions & 5 deletions src/app/components/details/details_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,27 @@ impl PlaylistModel for DetailsModel {
let song = song.description();

let menu = gio::Menu::new();
for artist in song.artists.iter() {
menu.append(
Some(&labels::more_from_label(&artist.name)),
Some(&format!("song.view_artist_{}", artist.id)),
);

let artists_iter = song.artists.iter();

if artists_iter.len() > 1 {
let submenu = gio::Menu::new();

for artist in artists_iter {
submenu.append(
Some(&artist.name),
Some(&format!("song.view_artist_{}", artist.id)),
);
}

menu.append_submenu(Some("More from"), &submenu);
} else {
for artist in artists_iter {
menu.append(
Some(&labels::more_from_label(&artist.name)),
Some(&format!("song.view_artist_{}", artist.id)),
);
}
}

menu.append(Some(&*labels::COPY_LINK), Some("song.copy_link"));
Expand Down
26 changes: 21 additions & 5 deletions src/app/components/now_playing/now_playing_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,27 @@ impl PlaylistModel for NowPlayingModel {

let menu = gio::Menu::new();
menu.append(Some(&*labels::VIEW_ALBUM), Some("song.view_album"));
for artist in song.artists.iter() {
menu.append(
Some(&labels::more_from_label(&artist.name)),
Some(&format!("song.view_artist_{}", artist.id)),
);

let artists_iter = song.artists.iter();

if artists_iter.len() > 1 {
let submenu = gio::Menu::new();

for artist in artists_iter {
submenu.append(
Some(&artist.name),
Some(&format!("song.view_artist_{}", artist.id)),
);
}

menu.append_submenu(Some("More from"), &submenu);
} else {
for artist in artists_iter {
menu.append(
Some(&labels::more_from_label(&artist.name)),
Some(&format!("song.view_artist_{}", artist.id)),
);
}
}

menu.append(Some(&*labels::COPY_LINK), Some("song.copy_link"));
Expand Down
26 changes: 21 additions & 5 deletions src/app/components/playlist_details/playlist_details_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,27 @@ impl PlaylistModel for PlaylistDetailsModel {

let menu = gio::Menu::new();
menu.append(Some(&*labels::VIEW_ALBUM), Some("song.view_album"));
for artist in song.artists.iter() {
menu.append(
Some(&labels::more_from_label(&artist.name)),
Some(&format!("song.view_artist_{}", artist.id)),
);

let artists_iter = song.artists.iter();

if artists_iter.len() > 1 {
let submenu = gio::Menu::new();

for artist in artists_iter {
submenu.append(
Some(&artist.name),
Some(&format!("song.view_artist_{}", artist.id)),
);
}

menu.append_submenu(Some("More from"), &submenu);
} else {
for artist in artists_iter {
menu.append(
Some(&labels::more_from_label(&artist.name)),
Some(&format!("song.view_artist_{}", artist.id)),
);
}
}

menu.append(Some(&*labels::COPY_LINK), Some("song.copy_link"));
Expand Down
26 changes: 21 additions & 5 deletions src/app/components/saved_tracks/saved_tracks_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,27 @@ impl PlaylistModel for SavedTracksModel {

let menu = gio::Menu::new();
menu.append(Some(&*labels::VIEW_ALBUM), Some("song.view_album"));
for artist in song.artists.iter() {
menu.append(
Some(&labels::more_from_label(&artist.name)),
Some(&format!("song.view_artist_{}", artist.id)),
);

let artists_iter = song.artists.iter();

if artists_iter.len() > 1 {
let submenu = gio::Menu::new();

for artist in artists_iter {
submenu.append(
Some(&artist.name),
Some(&format!("song.view_artist_{}", artist.id)),
);
}

menu.append_submenu(Some("More from"), &submenu);
} else {
for artist in artists_iter {
menu.append(
Some(&labels::more_from_label(&artist.name)),
Some(&format!("song.view_artist_{}", artist.id)),
);
}
}

menu.append(Some(&*labels::COPY_LINK), Some("song.copy_link"));
Expand Down