media-export: Add "All" container below "Artist"
authorJens Georg <jensg@openismus.com>
Sat, 15 Dec 2012 00:31:18 +0000 (01:31 +0100)
committerJens Georg <jensg@openismus.com>
Mon, 17 Dec 2012 13:05:22 +0000 (14:05 +0100)
https://bugzilla.gnome.org/show_bug.cgi?id=676136

src/plugins/media-export/rygel-media-export-node-query-container.vala

index 1d40084..f619288 100644 (file)
@@ -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;
+    }
 }