WIP
This commit is contained in:
@@ -485,12 +485,12 @@ class ArtistDetailPanel(Gtk.Box):
|
||||
|
||||
def on_play_all_clicked(self, _):
|
||||
songs = self.get_artist_song_ids()
|
||||
run_action(self, 'app.play-song', 0, songs, {"force_shuffle_state": False})
|
||||
run_action(self, 'app.play-song', 0, songs, {"force_shuffle_state": GLib.Variant('b', False)})
|
||||
|
||||
def on_shuffle_all_button(self, _):
|
||||
songs = self.get_artist_song_ids()
|
||||
song_idx = randint(0, len(songs) - 1)
|
||||
run_action(self, 'app.play-song', song_idx, songs, {"force_shuffle_state": True})
|
||||
run_action(self, 'app.play-song', song_idx, songs, {"force_shuffle_state": GLib.Variant('b', True)})
|
||||
|
||||
# Helper Methods
|
||||
# =========================================================================
|
||||
|
@@ -1,5 +1,5 @@
|
||||
from random import randint
|
||||
from typing import Any, cast, List
|
||||
from typing import Any, cast, List, Dict
|
||||
|
||||
from gi.repository import Gdk, GLib, GObject, Gtk, Pango, Handy
|
||||
|
||||
@@ -243,13 +243,13 @@ class AlbumWithSongs(Gtk.Box):
|
||||
)
|
||||
|
||||
def play_btn_clicked(self, btn: Any):
|
||||
self.play_song(0, {"force_shuffle_state": False})
|
||||
self.play_song(0, {"force_shuffle_state": GLib.Variant('b', False)})
|
||||
|
||||
def shuffle_btn_clicked(self, btn: Any):
|
||||
self.play_song(randint(0, len(self.album_song_store) - 1),
|
||||
{"force_shuffle_state": True})
|
||||
{"force_shuffle_state": GLib.Variant('b', True)})
|
||||
|
||||
def play_song(self, index: int, metadata: Any):
|
||||
def play_song(self, index: int, metadata: Dict[str, GLib.Variant]):
|
||||
run_action(self, 'app.play-song', index, [m[-1] for m in self.album_song_store], metadata)
|
||||
|
||||
# Helper Methods
|
||||
|
@@ -131,19 +131,6 @@ class EditPlaylistWindow(Handy.Window):
|
||||
class PlaylistsPanel(Handy.Leaflet):
|
||||
"""Defines the playlists panel."""
|
||||
|
||||
__gsignals__ = {
|
||||
"song-clicked": (
|
||||
GObject.SignalFlags.RUN_FIRST,
|
||||
GObject.TYPE_NONE,
|
||||
(int, object, object),
|
||||
),
|
||||
"refresh-window": (
|
||||
GObject.SignalFlags.RUN_FIRST,
|
||||
GObject.TYPE_NONE,
|
||||
(object, bool),
|
||||
),
|
||||
}
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
Gtk.Paned.__init__(self, transition_type=Handy.LeafletTransitionType.SLIDE, can_swipe_forward=False, interpolate_size=False)
|
||||
|
||||
@@ -154,14 +141,6 @@ class PlaylistsPanel(Handy.Leaflet):
|
||||
|
||||
details_sizer = Sizer(hexpand=True, natural_width=800)
|
||||
self.playlist_detail_panel = PlaylistDetailPanel()
|
||||
self.playlist_detail_panel.connect(
|
||||
"song-clicked",
|
||||
lambda _, *args: self.emit("song-clicked", *args),
|
||||
)
|
||||
self.playlist_detail_panel.connect(
|
||||
"refresh-window",
|
||||
lambda _, *args: self.emit("refresh-window", *args),
|
||||
)
|
||||
details_sizer.add(self.playlist_detail_panel)
|
||||
self.add(details_sizer)
|
||||
|
||||
@@ -382,16 +361,6 @@ class PlaylistList(Gtk.Box):
|
||||
class PlaylistDetailPanel(Gtk.Overlay):
|
||||
__gsignals__ = {
|
||||
"back-clicked": (GObject.SignalFlags.RUN_FIRST, GObject.TYPE_NONE, ()),
|
||||
"song-clicked": (
|
||||
GObject.SignalFlags.RUN_FIRST,
|
||||
GObject.TYPE_NONE,
|
||||
(int, object, object),
|
||||
),
|
||||
"refresh-window": (
|
||||
GObject.SignalFlags.RUN_FIRST,
|
||||
GObject.TYPE_NONE,
|
||||
(object, bool),
|
||||
),
|
||||
}
|
||||
|
||||
show_mobile = GObject.Property(type=bool, default=False)
|
||||
@@ -769,39 +738,26 @@ class PlaylistDetailPanel(Gtk.Overlay):
|
||||
on_song_download_complete=download_state_change,
|
||||
)
|
||||
|
||||
def play_song(self, index: int, metadata: Dict[str, Any]):
|
||||
metadata["active_playlist_id"] = GLib.Variant('s', self.playlist_id)
|
||||
run_action(self, 'app.play-song', index, [m[-1] for m in self.playlist_song_store], metadata)
|
||||
|
||||
def on_play_all_clicked(self, _):
|
||||
self.emit(
|
||||
"song-clicked",
|
||||
0,
|
||||
[m[-1] for m in self.playlist_song_store],
|
||||
{"force_shuffle_state": False, "active_playlist_id": self.playlist_id},
|
||||
)
|
||||
self.play_song(0, {"force_shuffle_state": GLib.Variant('b', False)})
|
||||
|
||||
def on_shuffle_all_button(self, _):
|
||||
self.emit(
|
||||
"song-clicked",
|
||||
self.play_song(
|
||||
randint(0, len(self.playlist_song_store) - 1),
|
||||
[m[-1] for m in self.playlist_song_store],
|
||||
{"force_shuffle_state": True, "active_playlist_id": self.playlist_id},
|
||||
)
|
||||
{"force_shuffle_state": GLib.Variant('b', True)})
|
||||
|
||||
def on_expand_collapse_click(self, _):
|
||||
self.emit(
|
||||
"refresh-window",
|
||||
{"playlist_details_expanded": not self.playlist_details_expanded},
|
||||
False,
|
||||
)
|
||||
run_action(self, 'playlists.set-details-expanded', not self.playlist_details_expanded)
|
||||
|
||||
def on_song_activated(self, _, idx: Gtk.TreePath, col: Any):
|
||||
if not self.playlist_song_store[idx[0]][0]:
|
||||
return
|
||||
# The song ID is in the last column of the model.
|
||||
self.emit(
|
||||
"song-clicked",
|
||||
idx.get_indices()[0],
|
||||
[m[-1] for m in self.playlist_song_store],
|
||||
{"active_playlist_id": self.playlist_id},
|
||||
)
|
||||
self.play_song(idx.get_indices()[0], {})
|
||||
|
||||
def on_song_button_press(self, tree: Gtk.TreeView, event: Gdk.EventButton) -> bool:
|
||||
if event.button == 3: # Right click
|
||||
@@ -873,7 +829,7 @@ class PlaylistDetailPanel(Gtk.Overlay):
|
||||
on_remove_songs_click,
|
||||
)
|
||||
],
|
||||
on_playlist_state_change=lambda: self.emit("refresh-window", {}, True),
|
||||
on_playlist_state_change=lambda: run_action(self, 'app.refresh'),
|
||||
)
|
||||
|
||||
# If the click was on a selected row, don't deselect anything.
|
||||
|
Reference in New Issue
Block a user