[gnome-music] Remove Load More button
- From: Vadim Rutkovsky <vrutkovsky src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music] Remove Load More button
- Date: Mon, 28 Apr 2014 11:48:46 +0000 (UTC)
commit e3a459100d02e649a8e3be01c1cde1e8dbd4c7f1
Author: Vadim Rutkovsky <vrutkovs redhat com>
Date: Mon Apr 28 13:11:53 2014 +0200
Remove Load More button
The most expensive operation now is setting a thubmnail.
After the fix for bug 702565 has landed we can now remove the button
https://bugzilla.gnome.org/show_bug.cgi?id=699832
gnomemusic/grilo.py | 4 +-
gnomemusic/view.py | 46 ---------------------
gnomemusic/widgets.py | 107 +------------------------------------------------
3 files changed, 3 insertions(+), 154 deletions(-)
---
diff --git a/gnomemusic/grilo.py b/gnomemusic/grilo.py
index 2f24f97..fffafe2 100644
--- a/gnomemusic/grilo.py
+++ b/gnomemusic/grilo.py
@@ -150,7 +150,7 @@ class Grilo(GObject.GObject):
self.populate_items(Query.ARTISTS, offset, callback, count)
@log
- def populate_albums(self, offset, callback, count=50):
+ def populate_albums(self, offset, callback, count=-1):
self.populate_items(Query.ALBUMS, offset, callback, count)
@log
@@ -162,7 +162,7 @@ class Grilo(GObject.GObject):
self.populate_items(Query.album_songs(album_id), 0, callback, count)
@log
- def populate_items(self, query, offset, callback, count=50):
+ def populate_items(self, query, offset, callback, count=-1):
options = self.options.copy()
options.set_skip(offset)
if count != -1:
diff --git a/gnomemusic/view.py b/gnomemusic/view.py
index 3c75d18..a21aa67 100644
--- a/gnomemusic/view.py
+++ b/gnomemusic/view.py
@@ -46,7 +46,6 @@ from gnomemusic.grilo import grilo
from gnomemusic.toolbar import ToolbarState
import gnomemusic.widgets as Widgets
from gnomemusic.playlists import Playlists
-from gnomemusic.query import Query
from gnomemusic.albumArtCache import AlbumArtCache as albumArtCache
from gnomemusic import log
import logging
@@ -69,7 +68,6 @@ class ViewContainer(Gtk.Stack):
nowPlayingIconName = 'media-playback-start-rtl-symbolic'
errorIconName = 'dialog-error-symbolic'
starIconName = 'starred-symbolic'
- countQuery = None
filter = None
@log
@@ -122,10 +120,6 @@ class ViewContainer(Gtk.Stack):
if not use_sidebar or sidebar:
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)
self.view.connect('item-activated', self._on_item_activated)
self.view.connect('selection-mode-request', self._on_selection_mode_request)
self._cursor = None
@@ -140,7 +134,6 @@ class ViewContainer(Gtk.Stack):
self.show_all()
self._items = []
- self._loadMore.widget.hide()
self._connect_view()
self.cache = albumArtCache.get_default()
self._symbolicIcon = self.cache.get_default_icon(self._iconHeight,
@@ -163,12 +156,6 @@ class ViewContainer(Gtk.Stack):
pass
@log
- 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
-
- @log
def _on_header_bar_toggled(self, button):
if button.get_active():
self.view.set_selection_mode(True)
@@ -229,9 +216,6 @@ class ViewContainer(Gtk.Stack):
@log
def _connect_view(self):
- self._adjustmentValueId = self.vadjustment.connect(
- 'value-changed',
- self._on_scrolled_win_change)
self.view.connect_after('draw', self._on_view_draw)
self.view.add_events(Gdk.EventMask.EXPOSURE_MASK)
@@ -281,30 +265,6 @@ class ViewContainer(Gtk.Stack):
break
@log
- def _on_scrolled_win_change(self, adjustment=None):
- vScrollbar = self.view.get_vscrollbar()
- revealAreaHeight = 32
-
- # if there's no vscrollbar, or if it's not visible, hide the button
- if not vScrollbar or not vScrollbar.get_visible():
- self._loadMore.set_block(True)
- return
-
- value = self.vadjustment.get_value()
- upper = self.vadjustment.get_upper()
- page_size = self.vadjustment.get_page_size()
-
- end = False
- # special case self values which happen at construction
- if (value == 0) and (upper == 1) and (page_size == 1):
- end = False
- else:
- end = not (value < (upper - page_size - revealAreaHeight))
- if self._get_remaining_item_count() <= 0:
- end = False
- self._loadMore.set_block(not end)
-
- @log
def populate(self):
print('populate')
@@ -385,7 +345,6 @@ class Albums(ViewContainer):
def __init__(self, header_bar, selection_toolbar, player):
ViewContainer.__init__(self, _("Albums"), header_bar,
selection_toolbar, Gd.MainViewType.ICON)
- self.countQuery = Query.ALBUMS_COUNT
self._albumWidget = Widgets.AlbumWidget(player)
self.player = player
self.add(self._albumWidget)
@@ -397,7 +356,6 @@ class Albums(ViewContainer):
def _on_changes_pending(self, data=None):
if (self._init):
self._offset = 0
- self._cached_count = -1
self._model.clear()
self.populate()
@@ -464,7 +422,6 @@ class Songs(ViewContainer):
@log
def __init__(self, header_bar, selection_toolbar, player):
ViewContainer.__init__(self, _("Songs"), header_bar, selection_toolbar, Gd.MainViewType.LIST)
- self.countQuery = Query.SONGS_COUNT
self._items = {}
self.isStarred = None
self.iter_to_clean = None
@@ -484,7 +441,6 @@ class Songs(ViewContainer):
if (self._init):
self._model.clear()
self._offset = 0
- self._cached_count = -1
self.populate()
@log
@@ -631,7 +587,6 @@ class Artists (ViewContainer):
self.albums_selected = []
self.items_selected = []
self.items_selected_callback = None
- self.countQuery = Query.ARTISTS_COUNT
self.artistAlbumsStack = Gtk.Stack(
transition_type=Gtk.StackTransitionType.CROSSFADE,
)
@@ -662,7 +617,6 @@ class Artists (ViewContainer):
self._model.clear()
self._artists.clear()
self._offset = 0
- self._cached_count = -1
self._populate()
@log
diff --git a/gnomemusic/widgets.py b/gnomemusic/widgets.py
index 3b6ae7a..fc0b7af 100644
--- a/gnomemusic/widgets.py
+++ b/gnomemusic/widgets.py
@@ -36,7 +36,6 @@ from gi.repository import GdkPixbuf, Gio, Grl
from gi.repository import Tracker
from gettext import gettext as _, ngettext
from gnomemusic.grilo import grilo
-from gnomemusic.query import Query
from gnomemusic.albumArtCache import AlbumArtCache
from gnomemusic.playlists import Playlists
from gnomemusic import log
@@ -60,64 +59,6 @@ else:
ERROR_ICON_NAME = 'dialog-error-symbolic'
- log
-def get_count(countQuery):
- count = -1
- if countQuery:
- cursor = tracker.query(countQuery, None)
- if cursor and cursor.next(None):
- count = cursor.get_integer(0)
- return count
-
-
-class LoadMoreButton:
- @log
- def __init__(self, counter):
- self._block = False
- self._counter = counter
- child = Gtk.Grid(column_spacing=10,
- hexpand=False,
- halign=Gtk.Align.CENTER,
- visible=True)
- self._spinner = Gtk.Spinner(halign=Gtk.Align.CENTER,
- no_show_all=True)
- self._spinner.set_size_request(16, 16)
- child.add(self._spinner)
- self._label = Gtk.Label(label=_("Load More"),
- visible=True)
- child.add(self._label)
- self.widget = Gtk.Button(no_show_all=True,
- child=child)
- self.widget.get_style_context().add_class('documents-load-more')
- self.widget.connect('clicked', self._on_load_more_clicked)
- self._on_item_count_changed()
-
- @log
- def _on_load_more_clicked(self, data=None):
- self._label.set_label(_("Loading..."))
- self._spinner.show()
- self._spinner.start()
-
- @log
- def _on_item_count_changed(self):
- remaining_docs = self._counter()
- visible = remaining_docs >= 0 and not self._block
- self.widget.set_visible(visible)
-
- if visible:
- self._label.set_label(_("Load More"))
- self._spinner.stop()
- self._spinner.hide()
-
- @log
- def set_block(self, block):
- if (self._block == block):
- return
-
- self._block = block
- self._on_item_count_changed()
-
-
class AlbumWidget(Gtk.EventBox):
tracks = []
@@ -485,59 +426,13 @@ class AllArtistsAlbums(ArtistAlbums):
def __init__(self, player):
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)
- self.vadjustment = self._scrolledWindow.get_vadjustment()
- self._connect_view()
self._populate()
@log
- def _get_remaining_item_count(self):
- if self._cached_count < 0:
- self._cached_count = get_count(self.countQuery)
- return self._cached_count - self._offset
-
- @log
- def _connect_view(self):
- self._adjustmentValueId =\
- self.vadjustment.connect('value-changed', self._on_scrolled_win_change)
- self._adjustmentChangedId =\
- self.vadjustment.connect('changed', self._on_scrolled_win_change)
- self._scrollbarVisibleId =\
- self._scrolledWindow.get_vscrollbar().connect(
- 'notify::visible',
- self._on_scrolled_win_change)
- self._on_scrolled_win_change()
-
- @log
- def _on_scrolled_win_change(self, scrollbar=None, pspec=None, data=None):
- vScrollbar = self._scrolledWindow.get_vscrollbar()
- revealAreaHeight = 32
-
- # if there's no vscrollbar, or if it's not visible, hide the button
- if not vScrollbar or not vScrollbar.get_visible():
- self._load_more.set_block(True)
- return
-
- value = self.vadjustment.get_value()
- upper = self.vadjustment.get_upper()
- page_size = self.vadjustment.get_page_size()
- end = False
-
- # 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):
- end = not (value < (upper - page_size - revealAreaHeight))
- self._load_more.set_block(not end)
-
- @log
def _populate(self, data=None):
if grilo.tracker:
GLib.idle_add(grilo.populate_albums,
- self._offset, self.add_item, 5)
+ self._offset, self.add_item, -1)
@log
def add_item(self, source, param, item, remaining):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]