[gnome-music] Revert "Autopopulate on scrolling to end"
- From: Vadim Rutkovsky <vrutkovsky src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music] Revert "Autopopulate on scrolling to end"
- Date: Thu, 4 Apr 2013 12:23:12 +0000 (UTC)
commit d80a7b5183d7ff07487cdacd36bc6c7a22f9db1c
Author: Vadim Rutkovsky <vrutkovs redhat com>
Date: Thu Apr 4 14:22:03 2013 +0200
Revert "Autopopulate on scrolling to end"
This reverts commit e44bb1d884484f4a5164270911b789db5cddf5d6.
The change should be approved by designers
Conflicts:
src/view.js
src/view.js | 75 +++++++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 58 insertions(+), 17 deletions(-)
---
diff --git a/src/view.js b/src/view.js
index 853a008..eb69c1d 100644
--- a/src/view.js
+++ b/src/view.js
@@ -48,6 +48,58 @@ function extractFileName(uri) {
const grilo = Grilo.grilo;
+const LoadMoreButton = new Lang.Class({
+ Name: 'LoadMoreButton',
+ _init: function(counter) {
+ this._block = false;
+ this._counter = counter;
+ let child = new Gtk.Grid({ column_spacing: 10,
+ hexpand: true,
+ halign: Gtk.Align.CENTER,
+ visible: true });
+
+ this._spinner = new Gtk.Spinner({ halign: Gtk.Align.CENTER,
+ no_show_all: true });
+ this._spinner.set_size_request(16, 16);
+ child.add(this._spinner);
+
+ this._label = new Gtk.Label({ label: "Load More",
+ visible: true });
+ child.add(this._label);
+
+ this.widget = new Gtk.Button({ no_show_all: true,
+ child: child });
+ this.widget.get_style_context().add_class('documents-load-more');
+ this.widget.connect('clicked', Lang.bind(this,
+ function() {
+ this._label.label = "Loading...";
+ this._spinner.show();
+ this._spinner.start();
+ }));
+
+ this._onItemCountChanged();
+ },
+
+ _onItemCountChanged: function() {
+ let remainingDocs = this._counter();
+ let visible = !(remainingDocs <= 0 || this._block);
+ this.widget.set_visible(visible);
+
+ if (!visible) {
+ this._label.label = "Load More";
+ this._spinner.stop();
+ this._spinner.hide();
+ }
+ },
+
+ setBlock: function(block) {
+ if (this._block == block)
+ return;
+
+ this._block = block;
+ this._onItemCountChanged();
+ }
+});
const ViewContainer = new Lang.Class({
Name: "ViewContainer",
@@ -56,11 +108,9 @@ const ViewContainer = new Lang.Class({
_init: function(title, header_bar) {
this.parent({transition_type: Gd.StackTransitionType.CROSSFADE});
this._grid = new Gtk.Grid({orientation: Gtk.Orientation.VERTICAL})
- this._populated = false;
this._iconWidth = -1
this._iconHeight = 128
this._offset = 0;
- this._offset_old = 0;
this._adjustmentValueId = 0;
this._adjustmentChangedId = 0;
this._scrollbarVisibleId = 0;
@@ -80,9 +130,9 @@ const ViewContainer = new Lang.Class({
this.view.set_model(this._model);
this._grid.add(this.view);
- //this._loadMore = new LoadMoreButton(this._getRemainingItemCount);
- //this._grid.add(this._loadMore.widget);
- //this._loadMore.widget.connect("clicked", Lang.bind(this, this.populate))
+ this._loadMore = new LoadMoreButton(this._getRemainingItemCount);
+ this._grid.add(this._loadMore.widget);
+ this._loadMore.widget.connect("clicked", Lang.bind(this, this.populate))
this.view.connect('item-activated',
Lang.bind(this, this._onItemActivated));
this._cursor = null;
@@ -93,7 +143,7 @@ const ViewContainer = new Lang.Class({
this.show_all();
this._items = [];
- //this._loadMore.widget.hide();
+ this._loadMore.widget.hide();
this._connectView();
grilo.connect('ready', Lang.bind(this, this.populate));
this.header_bar.connect('state-changed', Lang.bind(this, this._onStateChanged))
@@ -126,7 +176,7 @@ const ViewContainer = new Lang.Class({
// if there's no vscrollbar, or if it's not visible, hide the button
if (!vScrollbar ||
!vScrollbar.get_visible()) {
- //this._loadMore.setBlock(true);
+ this._loadMore.setBlock(true);
return;
}
@@ -142,12 +192,7 @@ const ViewContainer = new Lang.Class({
end = !(value < (upper - page_size - revealAreaHeight));
if (this._getRemainingItemCount() <= 0)
end = false;
- if (end && this._populated) {
- if ((this._offset - this._offset_old) >= 5) {
- this._offset_old = this._offset;
- this.populate();
- }
- }
+ this._loadMore.setBlock(!end);
},
populate: function() {
@@ -260,10 +305,8 @@ const Albums = new Lang.Class({
},
populate: function() {
- this._populated = false;
if (grilo.tracker != null)
grilo.populateAlbums (this._offset, Lang.bind(this, this._addItem, null));
- this._populated = true;
},
});
@@ -329,11 +372,9 @@ const Songs = new Lang.Class({
},
populate: function() {
- this._populated = false;
this.player.playlist = [];
if (grilo.tracker != null)
grilo.populateSongs (this._offset, Lang.bind(this, this._addItem, null));
- this._populated = true;
},
});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]