Skip to content

Commit

Permalink
misc
Browse files Browse the repository at this point in the history
  • Loading branch information
Nokse22 committed Dec 31, 2024
1 parent 62d9cc4 commit 49fb673
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 154 deletions.
125 changes: 64 additions & 61 deletions data/ui/widgets/top_hit_widget.blp
Original file line number Diff line number Diff line change
Expand Up @@ -16,84 +16,87 @@ template $HTTopHitWidget: Box {
]

label: 'Top Hit';
margin-start: 6;
xalign: 0.0;
}

Stack {
Adw.Bin {
styles [
"card",
"activatable",
]

valign: start;

StackPage {
child: Adw.Bin {
styles [
"cart",
"activatable",
]
Box {
margin-bottom: 12;
margin-end: 12;
margin-start: 12;
margin-top: 12;
orientation: vertical;
spacing: 12;

Box {
spacing: 12;

valign: start;
Image image {
pixel-size: 100;
overflow: hidden;

styles [
"small-image",
]
}

Box {
margin-bottom: 12;
margin-end: 12;
margin-start: 12;
margin-top: 12;
orientation: vertical;
spacing: 12;

Box {
spacing: 12;

Adw.Avatar artist_avatar {
size: 80;
}

Box {
orientation: vertical;
spacing: 6;

Label artist_label {
styles [
"title-1",
]

ellipsize: end;
vexpand: true;
xalign: 0.0;
}

Label {
label: 'Artist';
vexpand: true;
xalign: 0.0;
}
}
spacing: 6;

Label primary_label {
styles [
"title-1",
]

ellipsize: end;
vexpand: true;
xalign: 0.0;
}

Box {
spacing: 12;
Label secondary_label{
vexpand: true;
xalign: 0.0;
}

Button play_button {
styles [
"pill",
"suggested-action",
]
$HTLinkLabelWidget artist_label {
ellipsize: "end";
visible: false;
}
}
}

hexpand: true;
icon-name: 'media-playback-start-symbolic';
}
Box {
spacing: 12;
halign: end;

Button shuffle_button {
styles [
"pill",
]
Button play_button {
styles [
"pill",
"suggested-action",
]

hexpand: true;
icon-name: 'media-playlist-shuffle-symbolic';
}
}
hexpand: true;
icon-name: 'media-playback-start-symbolic';
}
};

name: 'artist';
Button shuffle_button {
styles [
"pill",
]

hexpand: true;
icon-name: 'media-playlist-shuffle-symbolic';
}
}
}
}
}
6 changes: 3 additions & 3 deletions data/ui/window.blp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ template $HighTideWindow: Adw.ApplicationWindow {
height-request: 290;
title: "High Tide";
Adw.Breakpoint {
condition ("max-width: 620sp")
condition ("max-width: 680sp")

setters {
multilayout_view.layout-name: "mobile";
Expand Down Expand Up @@ -242,7 +242,7 @@ template $HighTideWindow: Adw.ApplicationWindow {
orientation: vertical;

Image {
icon-name: "bookmark-new-symbolic";
icon-name: "library-symbolic";
}

Label {
Expand Down Expand Up @@ -466,7 +466,7 @@ template $HighTideWindow: Adw.ApplicationWindow {
Adw.ViewStackPage {
child: $HTQueueWidget queue_widget {};

icon-name: "library-symbolic";
icon-name: "view-list-ordered-symbolic";
name: "queue_page";
title: "Queue";
}
Expand Down
4 changes: 1 addition & 3 deletions src/lib/player_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,7 @@ def play_pause(self):
self.play()

def play_track(self, track):
th = threading.Thread(target=self.th_play_track, args=(track,))
th.deamon = True
th.start()
threading.Thread(target=self.th_play_track, args=(track,)).start()

def th_play_track(self, track):
print(f"""play track: {track.name} by {track.artist.name}""" +
Expand Down
2 changes: 1 addition & 1 deletion src/pages/search_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,6 @@ def _th_load_page(self):
self.page_content.append(carousel)
carousel.set_items(tracks, "track")

scrolled_window = Gtk.ScrolledWindow(vexpand=True, hscrollbar_policy=Gtk.PolicyType.NEVER)
# scrolled_window = Gtk.ScrolledWindow(vexpand=True, hscrollbar_policy=Gtk.PolicyType.NEVER)

self._page_loaded()
130 changes: 44 additions & 86 deletions src/widgets/top_hit_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,135 +40,93 @@ class HTTopHitWidget(Gtk.Box, IDisconnectable):
"""It is used to display the top hit when searching regardless
of the type"""

artist_avatar = Gtk.Template.Child()
artist_label = Gtk.Template.Child()
image = Gtk.Template.Child()
primary_label = Gtk.Template.Child()
secondary_label = Gtk.Template.Child()
play_button = Gtk.Template.Child()
shuffle_button = Gtk.Template.Child()
# track_artist_label = Gtk.Template.Child()
# track_artist_button = Gtk.Template.Child()
artist_label = Gtk.Template.Child()

def __init__(self, _item):
IDisconnectable.__init__(self)
super().__init__()

self.signals.append((
self,
self.connect("unrealize", self.__on_unrealized)))

self.item = _item

# if isinstance(_item, Mix):
# self.make_mix_card()
# elif isinstance(_item, Album):
# self.make_album_card()
# elif isinstance(_item, Playlist):
# self.make_playlist_card()
if isinstance(_item, Mix):
self.make_mix()
elif isinstance(_item, Album):
self.make_album()
elif isinstance(_item, Playlist):
self.make_playlist()
if isinstance(_item, Artist):
self.make_artist()
# elif isinstance(_item, Track):
# self.make_track()
elif isinstance(_item, PageItem):
self.make_page_item_card()
elif isinstance(_item, Track):
self.make_track()

def make_track(self):
self.artist_label.set_text(self.item.name)
self.primary_label.set_label(self.item.name)
self.secondary_label.set_label("Track")

self.artist_label.set_visible(True)
self.artist_label.set_artists(self.item.artists)

self.shuffle_button.set_visible(False)

self.signals.append((
self.play_button,
self.play_button.connect(
"clicked",
lambda *args: variables.player_object.play_track(self.item))))

threading.Thread(
target=utils.add_image_to_avatar,
args=(self.artist_avatar, self.item.album.artist)).start()
target=utils.add_image,
args=(self.image, self.item.album)).start()

def make_mix_card(self):
self.title_label.set_text(self.item.title)
self.detail_label.set_text(self.item.sub_title)
self.track_artist_label.set_visible(False)
def make_mix(self):
self.primary_label.set_label(self.item.title)
self.secondary_label.set_label("Mix")

# self.signals.append(
# (self.play_button, self.play_button.connect("clicked", self.on_))
# )
# self.signals.append(
# (self.shuffle_button, self.shuffle_button.connect("clicked", self.on_))
# )
self.artist_label.set_visible(True)
self.artist_label.set_label(self.item.sub_title)

threading.Thread(
target=utils.add_image,
args=(self.image, self.item)).start()

def make_album_card(self):
self.title_label.set_text(self.item.name)
self.track_artist_label.set_text(self.item.artist.name)
self.detail_label.set_visible(False)
def make_album(self):
self.primary_label.set_label(self.item.name)
self.secondary_label.set_label("Album")

self.artist_label.set_visible(True)
self.artist_label.set_artists(self.item.artist.name)

threading.Thread(
target=utils.add_image,
args=(self.image, self.item)).start()

def make_playlist_card(self):
self.title_label.set_text(self.item.name)
self.track_artist_label.set_visible(False)
def make_playlist(self):
self.primary_label.set_label(self.item.name)
self.secondary_label.set_visible(False)

creator = self.item.creator
if creator:
creator = creator.name
else:
creator = "TIDAL"
self.detail_label.set_text(f"by {creator}")
self.detail_label.set_label(f"by {creator}")

threading.Thread(
target=utils.add_image,
args=(self.image, self.item)).start()

def make_artist(self):
self.artist_label.set_text(self.item.name)

threading.Thread(
target=utils.add_image_to_avatar,
args=(self.artist_avatar, self.item)).start()

def make_page_item_card(self):
self.title_label.set_text(self.item.short_header)
self.detail_label.set_text(self.item.short_sub_header)
self.track_artist_label.set_visible(False)
self.primary_label.set_label(self.item.name)
self.secondary_label.set_label("Artist")

threading.Thread(
target=utils.add_image,
args=(self.image, self.item)).start()

def _on_artist_button_clicked(self, *args):
from ..pages.artist_page import artistPage
page = artistPage(self.item.artist, f"{self.item.artist.name}")
page.load()
variables.navigation_view.push(page)

def _on_image_button_clicked(self, *args):
if isinstance(self.item, Mix):
from ..pages.mix_page import mixPage
page = mixPage(self.item, f"{self.item.title}")
page.load()
variables.navigation_view.push(page)

elif isinstance(self.item, Album):
from ..pages.album_page import albumPage
page = albumPage(self.item, f"{self.item.name}")
page.load()
variables.navigation_view.push(page)

elif isinstance(self.item, Playlist):
from ..pages.playlist_page import playlistPage
page = playlistPage(self.item, f"{self.item.name}")
page.load()
variables.navigation_view.push(page)

elif isinstance(self.item, Artist):
from ..pages.artist_page import artistPage
page = artistPage(self.item, f"{self.item.name}")
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 __repr__(self, *args):
return "<HTCardWidget>"

0 comments on commit 49fb673

Please sign in to comment.