[polari] chatView: Display a loading indicator while fetching backlog
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari] chatView: Display a loading indicator while fetching backlog
- Date: Fri, 19 Dec 2014 11:41:49 +0000 (UTC)
commit 649e750775da46f75fc273366ad97bfdd8eb1d6e
Author: Florian Müllner <fmuellner gnome org>
Date: Fri Nov 28 18:55:21 2014 +0000
chatView: Display a loading indicator while fetching backlog
Provide some feedback to the user that we are fetching logs by
displaying a line with a 'content-loading' icon while we are
waiting for the result.
https://bugzilla.gnome.org/show_bug.cgi?id=740132
src/chatView.js | 34 ++++++++++++++++++++++++++++++++--
1 files changed, 32 insertions(+), 2 deletions(-)
---
diff --git a/src/chatView.js b/src/chatView.js
index b3ae78f..b53a648 100644
--- a/src/chatView.js
+++ b/src/chatView.js
@@ -172,8 +172,9 @@ const ChatView = new Lang.Class({
{ name: 'action',
left_margin: MARGIN },
{ name: 'url',
- underline: Pango.Underline.SINGLE
- }
+ underline: Pango.Underline.SINGLE },
+ { name: 'loading',
+ justification: Gtk.Justification.CENTER }
];
tags.forEach(function(tagProps) {
tagTable.add(new Gtk.TextTag(tagProps));
@@ -265,6 +266,8 @@ const ChatView = new Lang.Class({
},
_onLogEventsReady: function(lw, res) {
+ this._hideLoadingIndicator();
+
let [, events] = lw.get_events_finish(res);
this._pendingLogs = events.concat(this._pendingLogs);
this._insertPendingLogs();
@@ -374,6 +377,7 @@ const ChatView = new Lang.Class({
return Gdk.EVENT_STOP;
this._fetchingBacklog = true;
+ this._showLoadingIndicator();
Mainloop.timeout_add(500, Lang.bind(this,
function() {
this._logWalker.get_events_async(NUM_LOG_EVENTS,
@@ -483,6 +487,32 @@ const ChatView = new Lang.Class({
return Gdk.EVENT_PROPAGATE;
},
+ _showLoadingIndicator: function() {
+ let indicator = new Gtk.Image({ icon_name: 'content-loading-symbolic',
+ visible: true });
+
+ let buffer = this._view.buffer;
+ let iter = buffer.get_start_iter();
+ let anchor = buffer.create_child_anchor(iter);
+ this._view.add_child_at_anchor(indicator, anchor);
+ buffer.insert(iter, '\n', -1);
+
+ let start = buffer.get_start_iter();
+ buffer.remove_all_tags(start, iter);
+ buffer.apply_tag(this._lookupTag('loading'), start, iter);
+ },
+
+ _hideLoadingIndicator: function() {
+ let buffer = this._view.buffer;
+ let iter = buffer.get_start_iter();
+
+ if (!iter.get_child_anchor())
+ return;
+
+ iter.forward_line();
+ buffer.delete(buffer.get_start_iter(), iter);
+ },
+
_checkMessages: function() {
if (!this._active || !this._toplevelFocus || !this._channel)
return;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]