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.

https://bugzilla.gnome.org/show_bug.cgi?id=744834
parent ea71c1ef
......@@ -290,3 +290,13 @@ class Playlists(GObject.GObject):
GLib.PRIORITY_LOW,
None, update_callback, item
)
@log
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():
@log
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()
self.model.set(
new_iter,
......@@ -913,7 +919,7 @@ class PlaylistDialog():
@log
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.set_cursor(self.model.get_path(new_iter),
self.view.get_columns()[0], False)
self.view.row_activated(self.model.get_path(new_iter),
......
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