[gnome-music] playlist-dialog: don't show static playlists
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music] playlist-dialog: don't show static playlists
- Date: Wed, 17 Aug 2016 06:08:22 +0000 (UTC)
commit 6bb7fbf58fb1b2e6ca522b3d2743a2839184d2d3
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Thu Aug 11 16:43:44 2016 -0300
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
gnomemusic/playlists.py | 10 ++++++++++
gnomemusic/widgets.py | 8 +++++++-
2 files changed, 17 insertions(+), 1 deletions(-)
---
diff --git a/gnomemusic/playlists.py b/gnomemusic/playlists.py
index a7aaaf8..7fb6d25 100644
--- a/gnomemusic/playlists.py
+++ b/gnomemusic/playlists.py
@@ -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
diff --git a/gnomemusic/widgets.py b/gnomemusic/widgets.py
index 7b52c05..e4edf4b 100644
--- a/gnomemusic/widgets.py
+++ b/gnomemusic/widgets.py
@@ -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),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]