[gnome-music] Revert "view: don't hit tracker every time the user scrolls"



commit c99b327234048da12ea85383420418a4cf03851f
Author: Arnel A. Borja <arnelborja src gnome org>
Date:   Sat Aug 17 20:16:04 2013 +0800

    Revert "view: don't hit tracker every time the user scrolls"
    
    This reverts commit 7bf56d19ad0a54c2b8eb1f1591c216424db92cbc.
    
    For some reason, the author was reassigned to me. Reverting this and
    pushing a new one with the correct author field.

 gnomemusic/view.py    |    5 +----
 gnomemusic/widgets.py |   11 ++++-------
 2 files changed, 5 insertions(+), 11 deletions(-)
---
diff --git a/gnomemusic/view.py b/gnomemusic/view.py
index fc1c82a..a42609f 100644
--- a/gnomemusic/view.py
+++ b/gnomemusic/view.py
@@ -72,7 +72,6 @@ class ViewContainer(Stack):
         else:
             self._grid.add(box)
 
-        self._cached_count = -1
         self._loadMore = Widgets.LoadMoreButton(self._get_remaining_item_count)
         box.pack_end(self._loadMore.widget, False, False, 0)
         self._loadMore.widget.connect('clicked', self._populate)
@@ -103,9 +102,7 @@ class ViewContainer(Stack):
                           self._on_view_selection_changed)
 
     def _get_remaining_item_count(self):
-        if self._cached_count < 0:
-            self._cached_count = Widgets.get_count(self.countQuery)
-        return self._cached_count - self._offset
+        return Widgets.get_remaining_item_count(self.countQuery, self._offset)
 
     def _on_header_bar_toggled(self, button):
         if button.get_active():
diff --git a/gnomemusic/widgets.py b/gnomemusic/widgets.py
index 34646ac..71fa00a 100644
--- a/gnomemusic/widgets.py
+++ b/gnomemusic/widgets.py
@@ -17,13 +17,13 @@ else:
 ERROR_ICON_NAME = 'dialog-error-symbolic'
 
 
-def get_count(countQuery):
+def get_remaining_item_count(countQuery, _offset):
     count = -1
     if countQuery:
         cursor = tracker.query(countQuery, None)
         if cursor and cursor.next(None):
             count = cursor.get_integer(0)
-    return count
+    return count - _offset
 
 
 class LoadMoreButton:
@@ -399,7 +399,6 @@ class AllArtistsAlbums(ArtistAlbums):
         ArtistAlbums.__init__(self, _("All Artists"), [], player)
         self._offset = 0
         self.countQuery = Query.ALBUMS_COUNT
-        self._cached_count = -1
         self._load_more = LoadMoreButton(self._get_remaining_item_count)
         self.pack_end(self._load_more.widget, False, False, 0)
         self._load_more.widget.connect('clicked', self._populate)
@@ -407,9 +406,7 @@ class AllArtistsAlbums(ArtistAlbums):
         self._populate()
 
     def _get_remaining_item_count(self):
-        if self._cached_count < 0:
-            self._cached_count = get_count(self.countQuery)
-        return self._cached_count - self._offset
+        return get_remaining_item_count(self.countQuery, self._offset)
 
     def _connect_view(self):
         self._adjustmentValueId =\
@@ -444,7 +441,7 @@ class AllArtistsAlbums(ArtistAlbums):
 
         # special case this values which happen at construction
         if (((value != 0) or (upper != 1) or (page_size != 1))
-                and self._get_remaining_item_count() > 0):
+                and get_remaining_item_count(self.countQuery, self._offset) > 0):
             end = not (value < (upper - page_size - revealAreaHeight))
         self._load_more.set_block(not end)
 


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