[polari] entryArea: Fix constant background spinning of spinner
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari] entryArea: Fix constant background spinning of spinner
- Date: Thu, 7 May 2020 10:07:27 +0000 (UTC)
commit 018238df32ef0a2ad81898527232e3d35c895e0d
Author: Philip Withnall <withnall endlessm com>
Date: Wed May 6 17:30:42 2020 +0100
entryArea: Fix constant background spinning of spinner
The `GtkSpinner` for showing progress when pasting content to a pastebin
service was always being spun in the background, causing an endless loop
of size requests and style refreshes in GTK which kept Polari using 1–2%
of the CPU.
The `active` property of the spinner was bound to whether the upload
label was visible, and the upload label was visible iff the confirmation
label was *not* visible. However, this was all quite hard to reason
about, and fixing this issue by following that logic would have lead to
calling `this._confirmLabel.show()` once the upload is complete, which
would be quite confusing for someone to read in the future.
Instead, explicitly control the state of the spinner, which is hopefully
a bit more understandable.
Signed-off-by: Philip Withnall <withnall endlessm com>
https://gitlab.gnome.org/GNOME/polari/-/merge_requests/157
data/resources/entry-area.ui | 7 ++++---
src/entryArea.js | 7 ++++++-
2 files changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/data/resources/entry-area.ui b/data/resources/entry-area.ui
index 6f07e0ab..483ab089 100644
--- a/data/resources/entry-area.ui
+++ b/data/resources/entry-area.ui
@@ -67,14 +67,14 @@
<property name="margin">6</property>
<property name="margin-end">0</property>
<child>
- <object class="GtkSpinner">
+ <object class="GtkSpinner" id="uploadSpinner">
<property name="visible">True</property>
- <property name="active" bind-source="uploadLabel"
- bind-property="visible" bind-flags="sync-create" />
+ <property name="active">False</property>
</object>
</child>
<child>
<object class="GtkLabel" id="uploadLabel">
+ <property name="no-show-all">True</property>
<property name="visible" bind-source="confirmLabel"
bind-property="visible"
bind-flags="sync-create|invert-boolean" />
@@ -91,6 +91,7 @@
<property name="hexpand">True</property>
<property name="ellipsize">end</property>
<property name="xalign">0</property>
+ <property name="visible">True</property>
</object>
</child>
<child>
diff --git a/src/entryArea.js b/src/entryArea.js
index ac05e070..a2ddefa7 100644
--- a/src/entryArea.js
+++ b/src/entryArea.js
@@ -161,6 +161,7 @@ var EntryArea = GObject.registerClass({
'pasteBox',
'confirmLabel',
'uploadLabel',
+ 'uploadSpinner',
'cancelButton',
'pasteButton',
],
@@ -415,10 +416,14 @@ var EntryArea = GObject.registerClass({
else
title = _('Paste from %s').format(nick);
+ this._confirmLabel.hide();
+ this._uploadSpinner.start();
+
let app = Gio.Application.get_default();
try {
app.pasteManager.pasteContent(this._pasteContent, title, url => {
// TODO: handle errors
+ this._uploadSpinner.stop();
this._setPasteContent(null);
if (url)
this._chatEntry.emit('insert-at-cursor', url);
@@ -428,8 +433,8 @@ var EntryArea = GObject.registerClass({
if (type === 'object')
type = this._pasteContent.toString();
debug(`Failed to paste content of type ${type}`);
+ this._uploadSpinner.stop();
}
- this._confirmLabel.hide();
}
_onCancelClicked() {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]