Skip to content

Commit

Permalink
fixed search for tracks
Browse files Browse the repository at this point in the history
  • Loading branch information
Nokse22 committed Jun 21, 2024
1 parent b6dd9f7 commit 0436258
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/pages/search_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
15 changes: 15 additions & 0 deletions src/widgets/top_hit_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 0436258

Please sign in to comment.