[gnome-music/wip/gbsneto/flowbox: 4/7] 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/wip/gbsneto/flowbox: 4/7] playlist-dialog: don't show static playlists
- Date: Sun, 14 Aug 2016 00:07:15 +0000 (UTC)
commit e4f544d661c452b373135c644a53b7677eead948
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 120d07b..e2b62ae 100644
--- a/gnomemusic/playlists.py
+++ b/gnomemusic/playlists.py
@@ -299,3 +299,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 1471b30..8f9f0fb 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]