[grilo-plugins] jamendo: Fix browsing root category



commit 28290af796cd6c227fd9ed5448b59b58a6c61fe0
Author: Juan A. Suarez Romero <jasuarez igalia com>
Date:   Tue Apr 8 10:05:43 2014 +0200

    jamendo: Fix browsing root category
    
    Handle correctly the skip and count values when browsing root category.

 src/jamendo/grl-jamendo.c |   32 +++++++++++++++-----------------
 1 files changed, 15 insertions(+), 17 deletions(-)
---
diff --git a/src/jamendo/grl-jamendo.c b/src/jamendo/grl-jamendo.c
index cff3798..db147a4 100644
--- a/src/jamendo/grl-jamendo.c
+++ b/src/jamendo/grl-jamendo.c
@@ -805,32 +805,30 @@ send_toplevel_categories (GrlSourceBrowseSpec *bs)
   gint count = grl_operation_options_get_count (bs->options);
 
   /* Check if all elements must be skipped */
-  if (skip > 1 || count == 0) {
+  if (skip > 2 || count == 0) {
     bs->callback (bs->source, bs->operation_id, NULL, 0, bs->user_data, NULL);
     return;
   }
 
-  remaining = count;
+  count = MIN (count, 3);
+  remaining = MIN (count, 3 - skip);
 
-  if (skip == 0) {
+  while (remaining > 0) {
     media = grl_media_box_new ();
-    update_media_from_artists (media);
+    switch (skip) {
+    case 0:
+      update_media_from_artists (media);
+      break;
+    case 1:
+      update_media_from_albums (media);
+      break;
+    default:
+      update_media_from_feeds (media);
+    }
     remaining--;
+    skip++;
     bs->callback (bs->source, bs->operation_id, media, remaining, bs->user_data, NULL);
   }
-
-  if (remaining) {
-    media = grl_media_box_new ();
-    update_media_from_albums (media);
-    bs->callback (bs->source, bs->operation_id, media, remaining, bs->user_data, NULL);
-    remaining--;
-  }
-
-  if (remaining) {
-    media = grl_media_box_new ();
-    update_media_from_feeds (media);
-    bs->callback (bs->source, bs->operation_id, media, 0, bs->user_data, NULL);
-  }
 }
 
 static void


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