[gnome-music: 1/2] Eliminate duplication for _get_remaining_item_count function
- From: Arnel A. Borja <arnelborja src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music: 1/2] Eliminate duplication for _get_remaining_item_count function
- Date: Wed, 14 Aug 2013 12:47:01 +0000 (UTC)
commit 60516f7ff35798754d25f1f8c04ac5a4307f2009
Author: Shivani Poddar <shivani poddar92 gmail com>
Date: Mon Aug 12 19:19:56 2013 +0530
Eliminate duplication for _get_remaining_item_count function
gnomemusic/view.py | 11 +++--------
gnomemusic/widgets.py | 24 ++++++++++++++----------
2 files changed, 17 insertions(+), 18 deletions(-)
---
diff --git a/gnomemusic/view.py b/gnomemusic/view.py
index df1177c..a42609f 100644
--- a/gnomemusic/view.py
+++ b/gnomemusic/view.py
@@ -101,6 +101,9 @@ class ViewContainer(Stack):
self.view.connect('view-selection-changed',
self._on_view_selection_changed)
+ def _get_remaining_item_count(self):
+ return Widgets.get_remaining_item_count(self.countQuery, self._offset)
+
def _on_header_bar_toggled(self, button):
if button.get_active():
self.view.set_selection_mode(True)
@@ -198,14 +201,6 @@ class ViewContainer(Stack):
GLib.idle_add(add_new_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
-
def _insert_album_art(self, item, cb_item, itr, x=False):
if item and cb_item and not item.get_thumbnail():
if cb_item.get_thumbnail():
diff --git a/gnomemusic/widgets.py b/gnomemusic/widgets.py
index 55eafac..a6c8f80 100644
--- a/gnomemusic/widgets.py
+++ b/gnomemusic/widgets.py
@@ -17,6 +17,15 @@ else:
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):
self._block = False
@@ -394,6 +403,9 @@ class AllArtistsAlbums(ArtistAlbums):
self._connect_view()
self._populate()
+ def _get_remaining_item_count(self):
+ return get_remaining_item_count(self.countQuery, self._offset)
+
def _connect_view(self):
self._adjustmentValueId =\
self._scrolledWindow.get_vadjustment()\
@@ -425,9 +437,9 @@ class AllArtistsAlbums(ArtistAlbums):
page_size = adjustment.get_page_size()
end = False
- # special case self values which happen at construction
+ # 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)
@@ -441,14 +453,6 @@ 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):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]