diff --git a/src/pages/search_page.py b/src/pages/search_page.py index 7f85290..2b6b5f1 100644 --- a/src/pages/search_page.py +++ b/src/pages/search_page.py @@ -76,25 +76,25 @@ def _load_page(self): artists = results["artists"] if len(artists) > 0: self.page_content.append(carousel) - for artist in artists: - artist_card = self.get_artist_card(artist) - carousel.append_card(artist_card) + carousel.set_items(artists, "artist") carousel = CarouselWidget("Albums") albums = results["albums"] if len(albums) > 0: self.page_content.append(carousel) - for album in albums: - album_card = self.get_album_card(album) - carousel.append_card(album_card) + carousel.set_items(albums, "album") carousel = CarouselWidget("Playlists") playlists = results["playlists"] if len(playlists) > 0: self.page_content.append(carousel) - for playlist in playlists: - playlist_card = self.get_playlist_card(playlist) - carousel.append_card(playlist_card) + carousel.set_items(playlists, "playlist") + + carousel = CarouselWidget("Tracks") + tracks = results["tracks"] + if len(tracks) > 0: + self.page_content.append(carousel) + carousel.set_items(tracks, "track") scrolled_window = Gtk.ScrolledWindow(vexpand=True, hscrollbar_policy=Gtk.PolicyType.NEVER) diff --git a/src/widgets/top_hit_widget.py b/src/widgets/top_hit_widget.py index bfba0b1..915ba0a 100644 --- a/src/widgets/top_hit_widget.py +++ b/src/widgets/top_hit_widget.py @@ -70,9 +70,18 @@ def __init__(self, _item): # self.make_playlist_card() if isinstance(_item, Artist): self.make_artist() + # elif isinstance(_item, Track): + # self.make_track() elif isinstance(_item, PageItem): self.make_page_item_card() + def make_track(self): + self.artist_label.set_text(self.item.name) + + th = threading.Thread(target=utils.add_image_to_avatar, args=(self.artist_avatar, self.item.album.artist)) + th.deamon = True + th.start() + def make_mix_card(self): self.title_label.set_text(self.item.title) self.detail_label.set_text(self.item.sub_title) @@ -160,6 +169,12 @@ def _on_image_button_clicked(self, *args): page.load() variables.navigation_view.push(page) + elif isinstance(self.item, Track): + from ..pages.artist_page import albumPage + page = artistPage(self.item.album, f"{self.item.album.name}") + page.load() + variables.navigation_view.push(page) + def delete_signals(self): disconnected_signals = 0 for obj, signal_id in self.signals: