[gnome-music] playlists: Rewrite delete_playlist to use Tracker queries



commit a1e4c3c6a0069b051fe88cdd4d25d0b75011cedb
Author: Arnel Borja <arnelborja src gnome org>
Date:   Tue Jun 3 21:50:59 2014 +0800

    playlists: Rewrite delete_playlist to use Tracker queries

 gnomemusic/playlists.py |   20 ++++++++++++--------
 1 files changed, 12 insertions(+), 8 deletions(-)
---
diff --git a/gnomemusic/playlists.py b/gnomemusic/playlists.py
index e5f1920..7e3bb4f 100644
--- a/gnomemusic/playlists.py
+++ b/gnomemusic/playlists.py
@@ -20,7 +20,7 @@ except Exception as e:
 class Playlists(GObject.GObject):
     __gsignals__ = {
         'playlist-created': (GObject.SIGNAL_RUN_FIRST, None, (Grl.Media,)),
-        'playlist-deleted': (GObject.SIGNAL_RUN_FIRST, None, (str,)),
+        'playlist-deleted': (GObject.SIGNAL_RUN_FIRST, None, (Grl.Media,)),
         'song-added-to-playlist': (GObject.SIGNAL_RUN_FIRST, None, (str, Grl.Media)),
         'song-removed-from-playlist': (GObject.SIGNAL_RUN_FIRST, None, (str, str)),
     }
@@ -67,6 +67,17 @@ class Playlists(GObject.GObject):
         )
 
     @log
+    def delete_playlist(self, item):
+        def update_callback(conn, res, data):
+            conn.update_finish(res)
+            self.emit('playlist-deleted', item)
+
+        tracker.update_async(
+            Query.delete_playlist(item.get_id()), GLib.PRIORITY_DEFAULT,
+            None, update_callback, None
+        )
+
+    @log
     def get_playlists(self):
         playlist_files = [pl_file for pl_file in os.listdir(self.playlist_dir)
                           if os.path.isfile(os.path.join(self.playlist_dir,
@@ -133,13 +144,6 @@ class Playlists(GObject.GObject):
         )
 
     @log
-    def delete_playlist(self, playlist_name):
-        playlist_file = self.get_path_to_playlist(playlist_name)
-        if os.path.isfile(playlist_file):
-            os.remove(playlist_file)
-            self.emit('playlist-deleted', playlist_name)
-
-    @log
     def get_path_to_playlist(self, playlist_name):
         return os.path.join(self.playlist_dir, "%s.pls" % playlist_name)
 


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