Skip to content

Commit

Permalink
fixed tracks not playing when clicked in from_function_page
Browse files Browse the repository at this point in the history
  • Loading branch information
Nokse22 committed Apr 19, 2024
1 parent 27c9749 commit 455c3a5
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions src/pages/from_function_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ def __init__(self, _window, _function, _type):

self.parent = None

self.tracks = []

self.items_limit = 50
self.items_n = 0

Expand Down Expand Up @@ -86,19 +88,18 @@ def load_items(self):
def add_tracks(self):
if self.parent == None:
self.parent = Gtk.ListBox(css_classes=["boxed-list"], margin_bottom=12, margin_start=12, margin_end=12, margin_top=12)
self.page_content.append(self.parent)
GLib.idle_add(self.page_content.append,self.parent)

tracks = self.function(limit=self.items_limit, offset=(self.items_n))
new_tracks = self.function(limit=self.items_limit, offset=(self.items_n))
self.tracks.extend(new_tracks)
self.items_n += self.items_limit
# self.parent.connect("row-activated", self.on_tracks_row_selected, favourite_tracks)
self.parent.connect("row-activated", self.on_tracks_row_selected)

for index, track in enumerate(tracks):
for index, track in enumerate(new_tracks):
listing = self.get_track_listing(track)
listing.set_name(str(index))
self.parent.append(listing)

print("adding track")

def add_mixes(self):
if self.parent == None:
self.parent = Gtk.FlowBox(selection_mode=0)
Expand All @@ -109,7 +110,7 @@ def add_mixes(self):

for index, mix in enumerate(mixes):
card = self.get_mix_card(mix)
self.parent.append(card)
GLib.idle_add(self.parent.append, card)

print("adding mix")

Expand All @@ -123,7 +124,7 @@ def add_artists(self):

for index, artist in enumerate(artists):
card = self.get_artist_card(artist)
self.parent.append(card)
GLib.idle_add(self.parent.append, card)

print("adding artist")

Expand All @@ -137,7 +138,7 @@ def add_playlists(self):

for index, playlist in enumerate(playlists):
card = self.get_playlist_card(playlist)
self.parent.append(card)
GLib.idle_add(self.parent.append, card)

print("adding playlist")

Expand All @@ -151,16 +152,11 @@ def add_albums(self):

for index, album in enumerate(albums):
card = self.get_album_card(album)
self.parent.append(card)
GLib.idle_add(self.parent.append, card)

print("adding album")

def on_tracks_row_selected(self, list_box, row, favourite_tracks):
def on_tracks_row_selected(self, list_box, row):
index = int(row.get_name())

self.window.player_object.current_mix_album_list = favourite_tracks
track = favourite_tracks[index]
print(track)
self.window.player_object.song_album = track.album
self.window.player_object.play_track(track)
self.window.player_object.current_song_index = index
self.window.player_object.play_this(self.tracks, index)

0 comments on commit 455c3a5

Please sign in to comment.