Skip to content
Merged
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
22 changes: 22 additions & 0 deletions data/ui/pages_ui/artist_page_template.blp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ Box _main {
spacing: 6;
valign: center;

Adw.LayoutSlot {
id: "radio-button";
}

Adw.LayoutSlot {
id: "share-button";
}
Expand Down Expand Up @@ -128,6 +132,10 @@ Box _main {
Adw.LayoutSlot {
id: "share-button";
}

Adw.LayoutSlot {
id: "radio-button";
}
}
};
}
Expand Down Expand Up @@ -168,6 +176,20 @@ Box _main {
visible: false;
}

[radio-button]
Button _radio_button {
icon-name: "explore2-large-symbolic";
tooltip-text: _("Radio");
action-name: "win.push-artist-radio-page";
action-target: "''";
valign: center;

styles [
"flat",
"circular",
]
}

[share-button]
Button _share_button {
icon-name: "share-alt-symbolic";
Expand Down
8 changes: 4 additions & 4 deletions data/ui/window.blp
Original file line number Diff line number Diff line change
Expand Up @@ -527,24 +527,24 @@ template $HighTideWindow: Adw.ApplicationWindow {
icon-name: "explore2-large-symbolic";
tooltip-text: _("Go to track radio");
valign: center;
action-name: "win.push-track-radio-page";
action-target: "''";

styles [
"flat",
]

clicked => $on_track_radio_button_clicked();
}

Button album_button {
icon-name: "library-music-symbolic";
tooltip-text: _("Go to album");
valign: center;
action-name: "win.push-album-page";
action-target: "''";

styles [
"flat",
]

clicked => $on_album_button_clicked();
}

Button copy_share_link {
Expand Down
1 change: 0 additions & 1 deletion src/pages/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from .explore_page import HTExplorePage
from .artist_page import HTArtistPage
from .search_page import HTSearchPage
from .track_radio_page import HTHrackRadioPage
from .playlist_page import HTPlaylistPage
from .not_logged_in_page import HTNotLoggedInPage
from .mix_page import HTMixPage
Expand Down
15 changes: 5 additions & 10 deletions src/pages/artist_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#
# SPDX-License-Identifier: GPL-3.0-or-later

from gi.repository import Gtk
from gi.repository import Gtk, GLib

from .page import Page
from ..lib import utils
Expand Down Expand Up @@ -106,6 +106,10 @@ def _load_finish(self) -> None:

self.new_carousel_for(_("Similar Artists"), self.similar)

builder.get_object("_radio_button").set_action_target_value(
GLib.Variant("s", str(self.artist.id))
)

if self.bio is None:
return

Expand Down Expand Up @@ -137,12 +141,3 @@ def on_play_button_clicked(self, btn) -> None:

def on_shuffle_button_clicked(self, btn) -> None:
utils.player_object.shuffle_this(self.top_tracks, 0)

def on_artist_radio_button_clicked(self, btn) -> None:
from .track_radio_page import HTHrackRadioPage

page = HTHrackRadioPage.new_from_id(
self.artist, _("Radio of {}").format(self.artist.name)
)
page.load()
utils.navigation_view.push(page)
42 changes: 41 additions & 1 deletion src/pages/mix_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,50 @@ class HTMixPage(Page):

__gtype_name__ = "HTMixPage"

id_type = None
tracks = None

@classmethod
def new_from_track(cls, id):
"""Create a new HTMixPage instance from a Track id.

Args:
id: The track id

Returns:
HTMixPage: A new instance configured with the provided id
"""
instance = cls()

instance.id = id
instance.id_type = "track"

return instance

@classmethod
def new_from_artist(cls, id):
"""Create a new HTMixPage instance from an Artist id.

Args:
id: The artist id

Returns:
HTMixPage: A new instance configured with the provided id
"""
instance = cls()

instance.id = id
instance.id_type = "artist"

return instance

def _load_async(self) -> None:
self.item = utils.get_mix(self.id)
if self.id_type is None:
self.item = utils.get_mix(self.id)
elif self.id_type == "track":
self.item = utils.get_track(self.id).get_radio_mix()
elif self.id_type == "artist":
self.item = utils.get_artist(self.id).get_radio_mix()

self.tracks = self.item.items()

Expand Down
101 changes: 0 additions & 101 deletions src/pages/track_radio_page.py

This file was deleted.

54 changes: 38 additions & 16 deletions src/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,13 @@
from .login import LoginDialog
# from .new_playlist import NewPlaylistWindow

from .pages import HTNotLoggedInPage, HTGenericPage, HTExplorePage
from .pages import HTGenericPage
from .pages import HTExplorePage
from .pages import HTNotLoggedInPage
from .pages import HTCollectionPage
from .pages import HTArtistPage, HTMixPage, HTHrackRadioPage, HTPlaylistPage
from .pages import HTArtistPage
from .pages import HTMixPage
from .pages import HTPlaylistPage
from .pages import HTAlbumPage

from .widgets import HTGenericTrackWidget
Expand Down Expand Up @@ -89,6 +93,9 @@ class HighTideWindow(Adw.ApplicationWindow):
sidebar_stack = Gtk.Template.Child()
go_next_button = Gtk.Template.Child()
go_prev_button = Gtk.Template.Child()
track_radio_button = Gtk.Template.Child()
album_button = Gtk.Template.Child()
copy_share_link = Gtk.Template.Child()

app_id_dialog = Gtk.Template.Child()

Expand Down Expand Up @@ -126,7 +133,13 @@ def __init__(self, **kwargs):
self.create_action_with_target(
"push-track-radio-page",
GLib.VariantType.new("s"),
self.on_push_track_radio_page,
self.on_push_track_radio_page
)

self.create_action_with_target(
"push-artist-radio-page",
GLib.VariantType.new("s"),
self.on_push_artist_radio_page
)

# self.create_action_with_target(
Expand Down Expand Up @@ -344,6 +357,11 @@ def on_song_changed(self, *args):

self.set_quality_label()

self.track_radio_button.set_action_target_value(
GLib.Variant("s", str(track.id)))
self.album_button.set_action_target_value(
GLib.Variant("s", str(album.id)))

if utils.is_favourited(track):
self.in_my_collection_button.set_icon_name("heart-filled-symbolic")
else:
Expand Down Expand Up @@ -508,18 +526,6 @@ def on_share_clicked(self, *args):
if track:
utils.share_this(track)

@Gtk.Template.Callback("on_track_radio_button_clicked")
def on_track_radio_button_clicked_func(self, widget):
track = self.player_object.playing_track
page = HTHrackRadioPage.new_from_id(track.id).load()
self.navigation_view.push(page)

@Gtk.Template.Callback("on_album_button_clicked")
def on_album_button_clicked_func(self, widget):
track = self.player_object.playing_track
page = HTAlbumPage.new_from_id(track.album.id).load()
self.navigation_view.push(page)

@Gtk.Template.Callback("on_skip_forward_button_clicked")
def on_skip_forward_button_clicked_func(self, widget):
self.player_object.play_next()
Expand Down Expand Up @@ -746,23 +752,39 @@ def change_discord_rpc_enabled(self, state):
#

def on_push_artist_page(self, action, parameter):
if parameter.get_string() == "":
return
Comment on lines +755 to +756
Copy link
Collaborator

Choose a reason for hiding this comment

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

What are those for?

Copy link
Owner Author

Choose a reason for hiding this comment

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

In case the parameter of the action is empty it will not try to load the page with an empty id.

Copy link
Collaborator

Choose a reason for hiding this comment

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

In case the parameter of the action is empty

does that ever actually happen? and if it happens, will it pop off the stack or will it just load a blank page?

page = HTArtistPage.new_from_id(parameter.get_string()).load()
self.navigation_view.push(page)

def on_push_album_page(self, action, parameter):
if parameter.get_string() == "":
return
page = HTAlbumPage.new_from_id(parameter.get_string()).load()
self.navigation_view.push(page)

def on_push_playlist_page(self, action, parameter):
if parameter.get_string() == "":
return
page = HTPlaylistPage.new_from_id(parameter.get_string()).load()
self.navigation_view.push(page)

def on_push_mix_page(self, action, parameter):
if parameter.get_string() == "":
return
page = HTMixPage.new_from_id(parameter.get_string()).load()
self.navigation_view.push(page)

def on_push_track_radio_page(self, action, parameter):
page = HTHrackRadioPage.new_from_id(parameter.get_string()).load()
if parameter.get_string() == "":
return
page = HTMixPage.new_from_track(parameter.get_string()).load()
self.navigation_view.push(page)

def on_push_artist_radio_page(self, action, parameter):
if parameter.get_string() == "":
return
page = HTMixPage.new_from_artist(parameter.get_string()).load()
self.navigation_view.push(page)

#
Expand Down
Loading