[rygel/rygel-0-16] media-export: Add "All" container below "Artist"



commit b349abc71254eec71ca67f857e2025ff10bbcd1c
Author: Jens Georg <jensg openismus com>
Date:   Sat Dec 15 01:31:18 2012 +0100

    media-export: Add "All" container below "Artist"
    
    https://bugzilla.gnome.org/show_bug.cgi?id=676136

 .../rygel-media-export-node-query-container.vala   |   21 +++++++++++++++++++-
 1 files changed, 20 insertions(+), 1 deletions(-)
---
diff --git a/src/plugins/media-export/rygel-media-export-node-query-container.vala b/src/plugins/media-export/rygel-media-export-node-query-container.vala
index 1d40084..f619288 100644
--- a/src/plugins/media-export/rygel-media-export-node-query-container.vala
+++ b/src/plugins/media-export/rygel-media-export-node-query-container.vala
@@ -50,6 +50,17 @@ internal class Rygel.MediaExport.NodeQueryContainer : QueryContainer {
                                          Cancellable? cancellable)
                                          throws GLib.Error {
         var children = new MediaObjects ();
+        var factory = QueryContainerFactory.get_default ();
+
+        if (this.add_all_container ()) {
+            var id = this.template.replace (",upnp:album,%s","");
+            var container = factory.create_from_description (this.media_db,
+                                                             id,
+                                                             _("All"));
+            container.parent = this;
+            children.add (container);
+        }
+
         var data = this.media_db.get_object_attribute_by_search_expression
                                         (this.attribute,
                                          this.expression,
@@ -62,7 +73,6 @@ internal class Rygel.MediaExport.NodeQueryContainer : QueryContainer {
             // template contains URL escaped text. This means it might
             // contain '%' chars which will makes sprintf crash
             new_id = this.template.replace ("%s", new_id);
-            var factory = QueryContainerFactory.get_default ();
             var container = factory.create_from_description (this.media_db,
                                                              new_id,
                                                              meta_data);
@@ -86,6 +96,15 @@ internal class Rygel.MediaExport.NodeQueryContainer : QueryContainer {
                                          this.expression,
                                          0,
                                          -1);
+        if (this.add_all_container ()) {
+            return data.size + 1;
+        }
+
         return data.size;
     }
+
+    private bool add_all_container () {
+        return this.attribute == "upnp:album" &&
+               "upnp:artist" in this.template;
+    }
 }



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