[grilo-plugins] [jamendo] Notify remaining==0 when user cancels operation



commit e6b359fb394f028fb642de4a42c5373d4f8f40cb
Author: Juan A. Suarez Romero <jasuarez igalia com>
Date:   Wed Jun 2 17:45:54 2010 +0200

    [jamendo] Notify remaining==0 when user cancels operation
    
    When user cancels browse() operation, invoke the callback for last time, with
    remaining as 0, so UI knows that cancel was in fact done.
    
    It fixes GB#620335.

 src/jamendo/grl-jamendo.c |   19 +++++++++++--------
 1 files changed, 11 insertions(+), 8 deletions(-)
---
diff --git a/src/jamendo/grl-jamendo.c b/src/jamendo/grl-jamendo.c
index c146250..5da2553 100644
--- a/src/jamendo/grl-jamendo.c
+++ b/src/jamendo/grl-jamendo.c
@@ -522,8 +522,9 @@ xml_parse_entries_idle (gpointer user_data)
 {
   XmlParseEntries *xpe = (XmlParseEntries *) user_data;
   gboolean parse_more;
-  GrlMedia *media;
+  GrlMedia *media = NULL;
   Entry *entry;
+  gint remaining = 0;
 
   g_debug ("xml_parse_entries_idle");
 
@@ -541,12 +542,17 @@ xml_parse_entries_idle (gpointer user_data)
     free_entry (entry);
 
     xpe->index++;
+    xpe->node = xpe->node->next;
+    remaining = xpe->total_results - xpe->index;
+  }
+
+  if (parse_more || xpe->cancelled) {
     switch (xpe->type) {
     case BROWSE:
       xpe->spec.bs->callback (xpe->spec.bs->source,
                               xpe->spec.bs->browse_id,
                               media,
-                              xpe->total_results - xpe->index,
+                              remaining,
                               xpe->spec.bs->user_data,
                               NULL);
       break;
@@ -554,7 +560,7 @@ xml_parse_entries_idle (gpointer user_data)
       xpe->spec.qs->callback (xpe->spec.qs->source,
                               xpe->spec.qs->query_id,
                               media,
-                              xpe->total_results - xpe->index,
+                              remaining,
                               xpe->spec.qs->user_data,
                               NULL);
       break;
@@ -562,13 +568,11 @@ xml_parse_entries_idle (gpointer user_data)
       xpe->spec.ss->callback (xpe->spec.ss->source,
                               xpe->spec.ss->search_id,
                               media,
-                              xpe->total_results - xpe->index,
+                              remaining,
                               xpe->spec.ss->user_data,
                               NULL);
       break;
     }
-
-    xpe->node = xpe->node->next;
   }
 
   if (!parse_more) {
@@ -594,8 +598,7 @@ read_done_cb (GObject *source_object,
   /* Check if operation was cancelled */
   if (xpe->cancelled) {
     g_object_unref (source_object);
-    g_slice_free (XmlParseEntries, xpe);
-    return;
+    goto invoke_cb;
   }
 
   if (!g_file_load_contents_finish (G_FILE (source_object),



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