[gnome-music] fix querying songs of an album from tracker to use album_id



commit af64f0fd3b5c49a9ebd2bf6d0617c617ea6d66e7
Author: Seif Lotfy <seif lotfy com>
Date:   Tue Apr 2 13:45:19 2013 +0200

    fix querying songs of an album from tracker to use album_id

 src/grilo.js   |    4 ++--
 src/query.js   |    6 ++----
 src/widgets.js |   19 +++++--------------
 3 files changed, 9 insertions(+), 20 deletions(-)
---
diff --git a/src/grilo.js b/src/grilo.js
index 2372f1b..44a6ed8 100644
--- a/src/grilo.js
+++ b/src/grilo.js
@@ -85,8 +85,8 @@ const Grilo = new Lang.Class({
                 Lang.bind(this, callback, null));
     },
 
-    getAlbumSongs: function (artist, album, callback) {
-        var query =  Query.album_songs(artist, album);
+    getAlbumSongs: function (album_id, callback) {
+        var query =  Query.album_songs(album_id);
         var options = Grl.OperationOptions.new(null);
         options.set_flags (Grl.ResolutionFlags.FULL | Grl.ResolutionFlags.IDLE_RELAY);
         grilo.tracker.query(
diff --git a/src/query.js b/src/query.js
index 8d4b1ed..4403ef9 100644
--- a/src/query.js
+++ b/src/query.js
@@ -27,9 +27,7 @@ const songs = 'SELECT rdf:type(?song) tracker:id(?song) as id nie:url(?song) as
 
 const songs_count = 'SELECT COUNT(?song) AS childcount WHERE { ?song a nmm:MusicPiece }';
 
-function album_songs (artistName, albumTitle) {
-    var query = "SELECT rdf:type(?song) tracker:id(?song) as id nie:url(?song) as url nie:title(?song) as 
title nmm:artistName(nmm:performer(?song)) as artist nie:title(nmm:musicAlbum(?song)) as album 
nfo:duration(?song) as duration { ?song a nmm:MusicPiece ; nmm:performer [ nmm:artistName \"%an\" ] ; 
nmm:musicAlbum [ nmm:albumTitle \"%at\" ] } ORDER BY tracker:added(?song)";
-    query = query.replace("%an", Tracker.sparql_escape_string(artistName));
-    query = query.replace("%at", Tracker.sparql_escape_string(albumTitle));
+function album_songs (album_id) {
+    var query = "SELECT rdf:type(?song) tracker:id(?song) as id nie:url(?song) as url nie:title(?song) as 
title nmm:artistName(nmm:performer(?song)) as artist nie:title(nmm:musicAlbum(?song)) as album 
nfo:duration(?song) as duration WHERE { ?song a nmm:MusicPiece ; nmm:musicAlbum ?album . filter 
(tracker:id(?album) ="+ album_id +") } ORDER BY tracker:added(?song)";
     return query;
 }
diff --git a/src/widgets.js b/src/widgets.js
index 8f74f5a..961a237 100644
--- a/src/widgets.js
+++ b/src/widgets.js
@@ -88,7 +88,6 @@ const AlbumWidget = new Lang.Class({
         this.vbox = new Gtk.VBox();
         this.title_label = new Gtk.Label({label : ""});
         this.artist_label = new Gtk.Label({label : ""});
-        this.tracks_labels = {};
         this.running_length = 0;
         this.released_label = new Gtk.Label()
         this.released_label.set_markup ("<span color='grey'>Released</span>");
@@ -148,11 +147,12 @@ const AlbumWidget = new Lang.Class({
     update: function (artist, album, item) {
         var pixbuf = albumArtCache.lookup (256, artist, item.get_string(Grl.METADATA_KEY_ALBUM));
         let duration = 0;
-        for (let t in this.tracks_labels) {
-            this.songsList.remove(this.tracks_labels[t]);
+        var children = this.songsList.get_children();
+        for (let i in children) {
+            if (i > 0 && i < children.length - 1)
+            this.songsList.remove(children[i]);
         }
-        this.tracks_labels = {};
-        grilo.getAlbumSongs(artist, album, Lang.bind(this, function (source, prefs, track) {
+        grilo.getAlbumSongs(item.get_id(), Lang.bind(this, function (source, prefs, track) {
             if (track != null) {
                 duration = duration + track.get_duration()
                 this.tracks_labels[track.get_title()] = new ClickableLabel (track);
@@ -161,15 +161,6 @@ const AlbumWidget = new Lang.Class({
             }
         }));
 
-        //update labels view
-        var i = 0 ;
-        for (let t in this.tracks_labels) {
-            let length = new Gtk.Label ({label : tracks[t]});
-            this.songsList.pack_start(this.tracks_labels[t], false, false, 0);
-            this.running_length = this.running_length+ parseInt(tracks[t], 10);
-            i++;
-        }
-
         if (pixbuf == null) {
             let path = "/usr/share/icons/gnome/scalable/places/folder-music-symbolic.svg";
             pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(path, -1, 256, true);


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