Skip to content

Instantly share code, notes, and snippets.

@shivanipods
Created August 11, 2013 12:58
Show Gist options
  • Save shivanipods/6204791 to your computer and use it in GitHub Desktop.
Save shivanipods/6204791 to your computer and use it in GitHub Desktop.
index b3dda1c..0bccd19 100644
--- a/gnomemusic/view.py
+++ b/gnomemusic/view.py
@@ -65,7 +65,7 @@ class ViewContainer(Gtk.Stack):
else:
self._grid.add(box)
- self._loadMore = Widgets.LoadMoreButton(self._get_remaining_item_count)
+ self._loadMore = Widgets.LoadMoreButton(Widgets._get_remaining_item_count(self.countQuery, self._offset))
box.pack_end(self._loadMore.widget, False, False, 0)
self._loadMore.widget.connect("clicked", self._populate)
self.view.connect('item-activated', self._on_item_activated)
@@ -158,7 +158,7 @@ class ViewContainer(Gtk.Stack):
end = False
else:
end = not (value < (upper - page_size - revealAreaHeight))
- if self._get_remaining_item_count() <= 0:
+ if Widgets._get_remaining_item_count(self.countQuery, self._offset) <= 0:
end = False
self._loadMore.set_block(not end)
@@ -192,14 +192,6 @@ class ViewContainer(Gtk.Stack):
-1, self.errorIconName, False, True])
GLib.idle_add(self._update_album_art, item, _iter)
- def _get_remaining_item_count(self):
- count = -1
- if self.countQuery:
- cursor = tracker.query(self.countQuery, None)
- if cursor and cursor.next(None):
- count = cursor.get_integer(0)
- return count - self._offset
-
def _update_album_art(self, item, _iter):
albumArtCache.get_default().lookup(
item,
diff --git a/gnomemusic/widgets.py b/gnomemusic/widgets.py
index 7ad35e8..d66a62f 100644
--- a/gnomemusic/widgets.py
+++ b/gnomemusic/widgets.py
@@ -13,6 +13,13 @@ ALBUM_ART_CACHE = AlbumArtCache.get_default()
NOW_PLAYING_ICON_NAME = 'media-playback-start-symbolic'
ERROR_ICON_NAME = 'dialog-error-symbolic'
+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 - _offset
class LoadMoreButton:
def __init__(self, counter):
@@ -395,7 +402,7 @@ class AllArtistsAlbums(ArtistAlbums):
ArtistAlbums.__init__(self, _("All Artists"), [], player)
self._offset = 0
self.countQuery = Query.ALBUMS_COUNT
- self._load_more = LoadMoreButton(self._get_remaining_item_count)
+ self._load_more = LoadMoreButton(_get_remaining_item_count(self.countQuery, self._offset))
self.pack_end(self._load_more.widget, False, False, 0)
self._load_more.widget.connect("clicked", self._populate)
self._connect_view()
@@ -434,7 +441,7 @@ class AllArtistsAlbums(ArtistAlbums):
# special case self 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)
@@ -448,13 +455,7 @@ class AllArtistsAlbums(ArtistAlbums):
self._offset += 1
self.add_album(item)
- def _get_remaining_item_count(self):
- count = -1
- if self.countQuery:
- cursor = tracker.query(self.countQuery, None)
- if cursor and cursor.next(None):
- count = cursor.get_integer(0)
- return count - self._offset
+
class ArtistAlbumWidget(Gtk.HBox):
diff --git a/libgd b/libgd
--- a/libgd
+++ b/libgd
@@ -1 +1 @@
-Subproject commit f3822bc9fa387076a8005fb2665cc13390055156
+Subproject commit f3822bc9fa387076a8005fb2665cc13390055156-dirty
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment