[gnome-music/wip/jfelder/rename-smart-playlist] playlists: Rename StaticPlaylists to SmartPlaylists



commit 1fde8b0ba8d6415cc7370c29c4bedd640a67059a
Author: Jean Felder <jfelder src gnome org>
Date:   Mon May 13 20:40:24 2019 +0200

    playlists: Rename StaticPlaylists to SmartPlaylists
    
    Favorites, RecentlyAdded, RecentlyPlayed, NeverPlayed and MostPlayed
    playlists are supposed to be call SmartPlaylists in GNOME Music
    terminology.
    
    In summary, it exists two types of playlists:
    - SmartPlaylists: playlists are auto generated
    - user playlists: playlists created by the user

 gnomemusic/player.py                    |  4 +-
 gnomemusic/playlists.py                 | 72 ++++++++++++++++-----------------
 gnomemusic/views/playlistview.py        |  6 +--
 gnomemusic/widgets/playlistdialog.py    |  2 +-
 gnomemusic/widgets/songwidget.py        |  4 +-
 gnomemusic/widgets/starhandlerwidget.py |  4 +-
 6 files changed, 46 insertions(+), 46 deletions(-)
---
diff --git a/gnomemusic/player.py b/gnomemusic/player.py
index a02c799f..677b792c 100644
--- a/gnomemusic/player.py
+++ b/gnomemusic/player.py
@@ -792,10 +792,10 @@ class Player(GObject.GObject):
             if (percentage > 0.5
                     and self._new_clock):
                 self._new_clock = False
-                # FIXME: we should not need to update static
+                # FIXME: we should not need to update smart
                 # playlists here but removing it may introduce
                 # a bug. So, we keep it for the time being.
-                playlists.update_all_static_playlists()
+                playlists.update_all_smart_playlists()
                 grilo.bump_play_count(current_song)
                 grilo.set_last_played(current_song)
 
diff --git a/gnomemusic/playlists.py b/gnomemusic/playlists.py
index 3081857d..eafcf299 100644
--- a/gnomemusic/playlists.py
+++ b/gnomemusic/playlists.py
@@ -41,17 +41,17 @@ logger = logging.getLogger(__name__)
 
 
 class Playlist:
-    """ Base class of static and intelligent playlists """
+    """ Base class of all playlists """
     ID = None
     QUERY = None
     TAG_TEXT = ""
     TITLE = ""
 
 
-class StaticPlaylists:
+class SmartPlaylists:
 
     def __repr__(self):
-        return '<StaticPlaylists>'
+        return '<SmartPlaylists>'
 
     class MostPlayed(Playlist):
         TAG_TEXT = "MOST_PLAYED"
@@ -88,21 +88,21 @@ class StaticPlaylists:
 
     @staticmethod
     def get_ids():
-        """Get all static playlist IDs
+        """Get all smart playlist IDs
 
         :return: A list of tracker.id's
         :rtype: A list of integers
         """
-        return [str(playlist.ID) for playlist in StaticPlaylists.get_all()]
+        return [str(playlist.ID) for playlist in SmartPlaylists.get_all()]
 
     @staticmethod
     def get_all():
-        """Get all static playlist classes
+        """Get all smart playlist classes
 
-        :return: All StaticPlaylists innerclasses
+        :return: All SmartPlaylists innerclasses
         :rtype: A list of classes
         """
-        return [cls for name, cls in inspect.getmembers(StaticPlaylists)
+        return [cls for name, cls in inspect.getmembers(SmartPlaylists)
                 if inspect.isclass(cls) and not name == "__class__"]
 
 
@@ -147,13 +147,13 @@ class Playlists(GObject.GObject):
     def __init__(self):
         super().__init__()
 
-        self._static_playlists = StaticPlaylists()
+        self._smart_playlists = SmartPlaylists()
 
         grilo.connect('ready', self._on_grilo_ready)
 
     @log
     def _on_grilo_ready(self, data=None):
-        """For all static playlists: get ID, if exists; if not, create
+        """For all smart playlists: get ID, if exists; if not, create
         the playlist and get ID."""
 
         def playlist_id_fetched_cb(cursor, res, playlist):
@@ -167,11 +167,11 @@ class Playlists(GObject.GObject):
             playlist.ID = cursor.get_integer(1)
 
             if not playlist.ID:
-                # Create the  static playlist
-                self._create_static_playlist(playlist)
+                # Create the smart playlist
+                self._create_smart_playlist(playlist)
             else:
                 # Update playlist
-                self.update_static_playlist(playlist)
+                self.update_smart_playlist(playlist)
 
         def callback(obj, result, playlist):
             """ Starts retrieving the playlist id """
@@ -185,15 +185,15 @@ class Playlists(GObject.GObject):
             cursor.next_async(None, playlist_id_fetched_cb, playlist)
 
         self._tracker = grilo.tracker_sparql
-        # Start fetching all the static playlists
-        for playlist in self._static_playlists.get_all():
+        # Start fetching all the smart playlists
+        for playlist in self._smart_playlists.get_all():
             self._tracker.query_async(
                 Query.get_playlist_with_tag(playlist.TAG_TEXT), None,
                 callback, playlist)
 
     @log
-    def _create_static_playlist(self, playlist):
-        """ Create the tag and the static playlist, and fetch the newly created
+    def _create_smart_playlist(self, playlist):
+        """ Create the tag and the smart playlist, and fetch the newly created
         playlist's songs.
         """
         title = playlist.TITLE
@@ -212,7 +212,7 @@ class Playlists(GObject.GObject):
             playlist.ID = cursor.get_integer(0)
 
             # Fetch the playlist contents
-            self.update_static_playlist(playlist)
+            self.update_smart_playlist(playlist)
 
         def playlist_queried_cb(obj, res, playlist):
             """ Called after the playlist is created and the ID is fetched """
@@ -225,7 +225,7 @@ class Playlists(GObject.GObject):
             cursor.next_async(None, playlist_next_async_cb, playlist)
 
         def playlist_created_cb(obj, res, playlist):
-            """ Called when the static playlist is created """
+            """ Called when the smart playlist is created """
             data = obj.update_blank_finish(res)
             playlist_urn = data.get_child_value(0).get_child_value(0).\
                 get_child_value(0).get_child_value(1).get_string()
@@ -251,8 +251,8 @@ class Playlists(GObject.GObject):
             tag_created_cb, playlist)
 
     @log
-    def update_static_playlist(self, playlist):
-        """Given a static playlist (subclass of StaticPlaylists),
+    def update_smart_playlist(self, playlist):
+        """Given a smart playlist (subclass of SmartPlaylists),
         updates according to its query."""
         # Clear the playlist
         self.clear_playlist(playlist)
@@ -262,18 +262,18 @@ class Playlists(GObject.GObject):
         """Starts cleaning the playlist"""
         query = Query.clear_playlist_with_id(playlist.ID)
         self._tracker.update_async(
-            query, GLib.PRIORITY_LOW, None, self._static_playlist_cleared_cb,
+            query, GLib.PRIORITY_LOW, None, self._smart_playlist_cleared_cb,
             playlist)
 
     @log
-    def _static_playlist_cleared_cb(self, connection, res, playlist):
+    def _smart_playlist_cleared_cb(self, connection, res, playlist):
         """After clearing the playlist, start querying the playlist's songs"""
         # Get a list of matching songs
         self._tracker.query_async(
-            playlist.QUERY, None, self._static_playlist_query_cb, playlist)
+            playlist.QUERY, None, self._smart_playlist_query_cb, playlist)
 
     @log
-    def _static_playlist_query_cb(self, connection, res, playlist):
+    def _smart_playlist_query_cb(self, connection, res, playlist):
         """Fetch the playlist's songs"""
         final_query = ''
 
@@ -300,19 +300,19 @@ class Playlists(GObject.GObject):
             else:
                 self._tracker.update_blank_async(
                     final_query, GLib.PRIORITY_LOW, None,
-                    self._static_playlist_update_finished, playlist)
+                    self._smart_playlist_update_finished, playlist)
 
         # Asynchronously form the playlist's final query
         cursor.next_async(None, callback, final_query)
 
     @log
-    def _static_playlist_update_finished(self, source, res, static_playlist):
-        self.emit('playlist-updated', static_playlist.ID)
+    def _smart_playlist_update_finished(self, source, res, smart_playlist):
+        self.emit('playlist-updated', smart_playlist.ID)
 
     @log
-    def update_all_static_playlists(self):
-        for playlist in self._static_playlists.get_all():
-            self.update_static_playlist(playlist)
+    def update_all_smart_playlists(self):
+        for playlist in self._smart_playlists.get_all():
+            self.update_smart_playlist(playlist)
 
     @log
     def create_playlist(self, title):
@@ -442,14 +442,14 @@ 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
+    def is_smart_playlist(self, playlist):
+        """Checks whether the given playlist is smart or not
 
-        :return: True if the playlist is static
+        :return: True if the playlist is smart
         :rtype: bool
         """
-        for static_playlist_id in self._static_playlists.get_ids():
-            if playlist.get_id() == static_playlist_id:
+        for smart_playlist_id in self._smart_playlists.get_ids():
+            if playlist.get_id() == smart_playlist_id:
                 return True
 
         return False
diff --git a/gnomemusic/views/playlistview.py b/gnomemusic/views/playlistview.py
index 6d0184a5..bf1c3b1f 100644
--- a/gnomemusic/views/playlistview.py
+++ b/gnomemusic/views/playlistview.py
@@ -305,7 +305,7 @@ class PlaylistView(BaseView):
         """
         if index is None:
             index = -1
-        if playlists.is_static_playlist(playlist):
+        if playlists.is_smart_playlist(playlist):
             index = 0
 
         title = utils.get_media_title(playlist)
@@ -519,7 +519,7 @@ class PlaylistView(BaseView):
     @log
     def remove_playlist(self):
         """Removes the current selected playlist"""
-        if playlists.is_static_playlist(self._current_playlist):
+        if playlists.is_smart_playlist(self._current_playlist):
             return
         self._stage_playlist_for_deletion(None)
 
@@ -546,7 +546,7 @@ class PlaylistView(BaseView):
         self._pl_ctrls.props.display_songs_count = False
         grilo.populate_playlist_songs(playlist, self._add_song)
 
-        protected_pl = playlists.is_static_playlist(self._current_playlist)
+        protected_pl = playlists.is_smart_playlist(self._current_playlist)
         self._playlist_delete_action.set_enabled(not protected_pl)
         self._playlist_rename_action.set_enabled(not protected_pl)
         self._remove_song_action.set_enabled(not protected_pl)
diff --git a/gnomemusic/widgets/playlistdialog.py b/gnomemusic/widgets/playlistdialog.py
index 3b77abae..b87ca5df 100644
--- a/gnomemusic/widgets/playlistdialog.py
+++ b/gnomemusic/widgets/playlistdialog.py
@@ -115,7 +115,7 @@ class PlaylistDialog(Gtk.Dialog):
 
     @log
     def _add_item_to_model(self, item):
-        """Adds (non-static only) playlists to the model"""
+        """Adds (non-smart only) playlists to the model"""
 
         # Hide playlists that are going to be deleted
         if item.get_id() in self._playlists_todelete_ids:
diff --git a/gnomemusic/widgets/songwidget.py b/gnomemusic/widgets/songwidget.py
index 4322f8a8..78c87181 100644
--- a/gnomemusic/widgets/songwidget.py
+++ b/gnomemusic/widgets/songwidget.py
@@ -32,7 +32,7 @@ from gi.repository.Dazzle import BoldingLabel  # noqa: F401
 from gnomemusic import log
 from gnomemusic import utils
 from gnomemusic.grilo import grilo
-from gnomemusic.playlists import Playlists, StaticPlaylists
+from gnomemusic.playlists import Playlists, SmartPlaylists
 from gnomemusic.widgets.starimage import StarImage  # noqa: F401
 
 
@@ -143,7 +143,7 @@ class SongWidget(Gtk.EventBox):
 
         # TODO: Rework and stop updating widgets from here directly.
         grilo.set_favorite(self._media, favorite)
-        self._playlists.update_static_playlist(StaticPlaylists.Favorites)
+        self._playlists.update_smart_playlist(SmartPlaylists.Favorites)
 
         return True
 
diff --git a/gnomemusic/widgets/starhandlerwidget.py b/gnomemusic/widgets/starhandlerwidget.py
index 41c5c07f..e55af8c7 100644
--- a/gnomemusic/widgets/starhandlerwidget.py
+++ b/gnomemusic/widgets/starhandlerwidget.py
@@ -26,7 +26,7 @@ from gi.repository import GObject, Gtk
 
 from gnomemusic import log
 from gnomemusic.grilo import grilo
-from gnomemusic.playlists import Playlists, StaticPlaylists
+from gnomemusic.playlists import Playlists, SmartPlaylists
 
 playlists = Playlists.get_default()
 
@@ -152,7 +152,7 @@ class StarHandlerWidget(object):
         self._parent.model[_iter][self._star_index] = new_value
         song_item = self._parent.model[_iter][5]
         grilo.toggle_favorite(song_item)
-        playlists.update_static_playlist(StaticPlaylists.Favorites)
+        playlists.update_smart_playlist(SmartPlaylists.Favorites)
 
         # Use this flag to ignore the upcoming _on_item_activated call
         self.star_renderer_click = True


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]