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]: def get_playlists(self) -> Sequence[API.Playlist]:
if playlists := self._get_json(self._make_url("getPlaylists")).playlists: if playlists := self._get_json(self._make_url("getPlaylists")).playlists:
return playlists.playlist return sorted(playlists.playlist, key=lambda p: p.name.lower())
return [] return []
def get_playlist_details(self, playlist_id: str) -> API.Playlist: 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.player.volume = self.app_config.state.volume
self.update_window() 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. # Need to use bitwise & here to see if CTRL is pressed.
if event.keyval == 102 and event.state & Gdk.ModifierType.CONTROL_MASK: if event.keyval == 102 and event.state & Gdk.ModifierType.CONTROL_MASK:
# Ctrl + F # Ctrl + F
window.search_entry.grab_focus() window.search_entry.grab_focus()
return False return False
# Allow spaces to work in the text entry boxes.
if window.search_entry.has_focus(): if window.search_entry.has_focus():
return False return False
if window.playlists_panel.playlist_list.new_playlist_entry.has_focus():
return False
# Spacebar, home/prev
keymap = { keymap = {
32: self.on_play_pause, 32: self.on_play_pause,
65360: self.on_prev_track, 65360: self.on_prev_track,

View File

@@ -35,11 +35,15 @@ class MainWindow(Gtk.ApplicationWindow):
self.set_default_size(1150, 768) self.set_default_size(1150, 768)
# Create the stack # 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( self.stack = self._create_stack(
Albums=albums.AlbumsPanel(), Albums=self.albums_panel,
Artists=artists.ArtistsPanel(), Artists=self.artists_panel,
Browse=browse.BrowsePanel(), Browse=self.browse_panel,
Playlists=playlists.PlaylistsPanel(), Playlists=self.playlists_panel,
) )
self.stack.set_transition_type(Gtk.StackTransitionType.SLIDE_LEFT_RIGHT) self.stack.set_transition_type(Gtk.StackTransitionType.SLIDE_LEFT_RIGHT)

View File

@@ -164,7 +164,8 @@ class PlaylistList(Gtk.Box):
list_scroll_window.add(self.list) list_scroll_window.add(self.list)
self.pack_start(list_scroll_window, True, True, 0) self.pack_start(list_scroll_window, True, True, 0)
def update(self, app_config: AppConfiguration, force: bool = False): 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.new_playlist_button.set_sensitive(not app_config.offline_mode)
self.list_refresh_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.new_playlist_row.hide()
@@ -178,7 +179,7 @@ class PlaylistList(Gtk.Box):
def update_list( def update_list(
self, self,
playlists: List[API.Playlist], playlists: List[API.Playlist],
app_config: AppConfiguration, app_config: AppConfiguration = None,
force: bool = False, force: bool = False,
order_token: int = None, order_token: int = None,
): ):
@@ -626,7 +627,7 @@ class PlaylistDetailPanel(Gtk.Overlay):
Gtk.ResponseType.CANCEL, Gtk.ResponseType.CANCEL,
) )
confirm_dialog.format_secondary_markup( 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() result = confirm_dialog.run()
confirm_dialog.destroy() confirm_dialog.destroy()