playlist-dialog: don't show static playlists

Static playlists are managed by GNOME Music and shouldn't
be exposed as available playlists in the playlist dialog,
even if adding to them works.

Fix that by adding a new method to check whether a playlist
is static or not, and teaching the playlists dialog to not
add static playlists.
parent ea71c1ef
......@@ -290,3 +290,13 @@ class Playlists(GObject.GObject):
None, update_callback, item
def is_static_playlist(self, playlist):
"""Checks whether the given playlist is static or not"""
for static_playlist_id in StaticPlaylists.get_protected_ids():
if playlist.get_id() == static_playlist_id:
return True
return False
......@@ -861,6 +861,12 @@ class PlaylistDialog():
def _add_item_to_model(self, item):
"""Adds (non-static only) playlists to the model"""
# Don't show static playlists
if self.playlist.is_static_playlist(item):
return None
new_iter = self.model.append()
......@@ -913,7 +919,7 @@ class PlaylistDialog():
def _on_playlist_created(self, playlists, item):
new_iter = self._add_item_to_model(item)
if self.view.get_columns():
if new_iter and self.view.get_columns():
self.view.get_columns()[0], False)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment