diff --git a/sublime/adapters/subsonic/adapter.py b/sublime/adapters/subsonic/adapter.py index c0a3ab5..8c8a5fd 100644 --- a/sublime/adapters/subsonic/adapter.py +++ b/sublime/adapters/subsonic/adapter.py @@ -335,7 +335,7 @@ class SubsonicAdapter(Adapter): # ================================================================================== def get_playlists(self) -> Sequence[API.Playlist]: if playlists := self._get_json(self._make_url("getPlaylists")).playlists: - return playlists.playlist + return sorted(playlists.playlist, key=lambda p: p.name.lower()) return [] def get_playlist_details(self, playlist_id: str) -> API.Playlist: diff --git a/sublime/app.py b/sublime/app.py index 521ac4e..5918574 100644 --- a/sublime/app.py +++ b/sublime/app.py @@ -816,16 +816,20 @@ class SublimeMusicApp(Gtk.Application): self.player.volume = self.app_config.state.volume self.update_window() - def on_window_key_press(self, window: Gtk.Window, event: Gdk.EventKey,) -> bool: + def on_window_key_press(self, window: Gtk.Window, event: Gdk.EventKey) -> bool: # Need to use bitwise & here to see if CTRL is pressed. if event.keyval == 102 and event.state & Gdk.ModifierType.CONTROL_MASK: # Ctrl + F window.search_entry.grab_focus() return False + # Allow spaces to work in the text entry boxes. if window.search_entry.has_focus(): return False + if window.playlists_panel.playlist_list.new_playlist_entry.has_focus(): + return False + # Spacebar, home/prev keymap = { 32: self.on_play_pause, 65360: self.on_prev_track, diff --git a/sublime/ui/main.py b/sublime/ui/main.py index 31cf4f5..aa9041b 100644 --- a/sublime/ui/main.py +++ b/sublime/ui/main.py @@ -35,11 +35,15 @@ class MainWindow(Gtk.ApplicationWindow): self.set_default_size(1150, 768) # Create the stack + self.albums_panel = albums.AlbumsPanel() + self.artists_panel = artists.ArtistsPanel() + self.browse_panel = browse.BrowsePanel() + self.playlists_panel = playlists.PlaylistsPanel() self.stack = self._create_stack( - Albums=albums.AlbumsPanel(), - Artists=artists.ArtistsPanel(), - Browse=browse.BrowsePanel(), - Playlists=playlists.PlaylistsPanel(), + Albums=self.albums_panel, + Artists=self.artists_panel, + Browse=self.browse_panel, + Playlists=self.playlists_panel, ) self.stack.set_transition_type(Gtk.StackTransitionType.SLIDE_LEFT_RIGHT) diff --git a/sublime/ui/playlists.py b/sublime/ui/playlists.py index 92a6abd..6744c20 100644 --- a/sublime/ui/playlists.py +++ b/sublime/ui/playlists.py @@ -164,9 +164,10 @@ class PlaylistList(Gtk.Box): list_scroll_window.add(self.list) self.pack_start(list_scroll_window, True, True, 0) - def update(self, app_config: AppConfiguration, force: bool = False): - self.new_playlist_button.set_sensitive(not app_config.offline_mode) - self.list_refresh_button.set_sensitive(not app_config.offline_mode) + def update(self, app_config: AppConfiguration = None, force: bool = False): + if app_config: + self.new_playlist_button.set_sensitive(not app_config.offline_mode) + self.list_refresh_button.set_sensitive(not app_config.offline_mode) self.new_playlist_row.hide() self.update_list(app_config=app_config, force=force) @@ -178,7 +179,7 @@ class PlaylistList(Gtk.Box): def update_list( self, playlists: List[API.Playlist], - app_config: AppConfiguration, + app_config: AppConfiguration = None, force: bool = False, order_token: int = None, ): @@ -626,7 +627,7 @@ class PlaylistDetailPanel(Gtk.Overlay): Gtk.ResponseType.CANCEL, ) confirm_dialog.format_secondary_markup( - 'Are you sure you want to delete the "{playlist.name}" playlist?' + f'Are you sure you want to delete the "{playlist.name}" playlist?' ) result = confirm_dialog.run() confirm_dialog.destroy()