[grilo-plugins] vimeo: Compute proper page size



commit 028674eef56aadba68a1c4819098bcab4371e5ad
Author: Juan A. Suarez Romero <jasuarez igalia com>
Date:   Thu Nov 29 11:53:41 2012 +0000

    vimeo: Compute proper page size
    
    Fix the computing of page_size.
    
    Also, use the autosplit feature so Grilo takes care of requests bigger than the
    allowed page size.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=688821

 src/vimeo/grl-vimeo.c |   18 +++++++++++++-----
 1 files changed, 13 insertions(+), 5 deletions(-)
---
diff --git a/src/vimeo/grl-vimeo.c b/src/vimeo/grl-vimeo.c
index ef72b07..1d0b970 100644
--- a/src/vimeo/grl-vimeo.c
+++ b/src/vimeo/grl-vimeo.c
@@ -55,6 +55,8 @@ GRL_LOG_DOMAIN_STATIC(vimeo_log_domain);
 #define SOURCE_NAME "Vimeo"
 #define SOURCE_DESC "A source for browsing and searching Vimeo videos"
 
+#define MAX_ELEMENTS 50
+
 typedef struct {
   GrlSourceSearchSpec *ss;
   gint offset;
@@ -178,6 +180,8 @@ static void
 grl_vimeo_source_init (GrlVimeoSource *source)
 {
   source->priv = GRL_VIMEO_SOURCE_GET_PRIVATE (source);
+
+  grl_source_set_auto_split_threshold (GRL_SOURCE (source), MAX_ELEMENTS);
 }
 
 G_DEFINE_TYPE (GrlVimeoSource, grl_vimeo_source, GRL_TYPE_SOURCE);
@@ -418,13 +422,17 @@ grl_vimeo_source_search (GrlSource *source,
     return;
   }
 
+  sd = g_slice_new (SearchData);
+
   /* Compute items per page and page offset */
-  per_page = CLAMP (1 + skip + count, 0, 100);
-  g_vimeo_set_per_page (vimeo, per_page);
+  grl_paging_translate (skip,
+                        count,
+                        MAX_ELEMENTS,
+                        (guint *) &per_page,
+                        (guint *) &(sd->page),
+                        (guint *) &(sd->offset));
 
-  sd = g_slice_new (SearchData);
-  sd->page = 1 + (skip / per_page);
-  sd->offset = skip % per_page;
+  g_vimeo_set_per_page (vimeo, per_page);
   sd->ss = ss;
 
   g_vimeo_videos_search (vimeo, ss->text, sd->page, search_cb, sd);



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