[gnome-documents] load-more: simplify the button's label
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents] load-more: simplify the button's label
- Date: Mon, 19 Nov 2012 22:21:45 +0000 (UTC)
commit 06d194aea79f11fbfa4ecfe0cb68613d52b7359b
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Mon Nov 19 21:36:11 2012 +0100
load-more: simplify the button's label
And add a spinner while loading.
https://bugzilla.gnome.org/show_bug.cgi?id=688676
src/view.js | 39 ++++++++++++++++++++++++++-------------
1 files changed, 26 insertions(+), 13 deletions(-)
---
diff --git a/src/view.js b/src/view.js
index f5fdd34..902e85b 100644
--- a/src/view.js
+++ b/src/view.js
@@ -48,10 +48,29 @@ const LoadMoreButton = new Lang.Class({
this._controller.connect('item-count-changed',
Lang.bind(this, this._onItemCountChanged));
- this.widget = new Gtk.Button({ no_show_all: true });
+ 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._controller.increaseOffset();
}));
@@ -65,20 +84,14 @@ const LoadMoreButton = new Lang.Class({
_onItemCountChanged: function() {
let remainingDocs = this._controller.getRemainingDocs();
- let offsetStep = this._controller.getOffsetStep();
+ let visible = !(remainingDocs <= 0 || this._block);
+ this.widget.set_visible(visible);
- if (remainingDocs <= 0 || this._block) {
- this.widget.hide();
- return;
+ if (!visible) {
+ this._label.label = _("Load More");
+ this._spinner.stop();
+ this._spinner.hide();
}
-
- if (remainingDocs > offsetStep)
- remainingDocs = offsetStep;
-
- this.widget.label = Gettext.ngettext("Load %d more document",
- "Load %d more documents",
- remainingDocs).format(remainingDocs);
- this.widget.show();
},
setBlock: function(block) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]