Closes #211: fixed issue where you couldn't create a playlist with a space in the name

This commit is contained in:
Sumner Evans
2020-05-23 18:09:03 -06:00
parent 57bb939664
commit dbb86350db
4 changed files with 20 additions and 11 deletions

View File

@@ -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:

View File

@@ -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,

View File

@@ -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)

View File

@@ -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()