[geary/wip/conversation-polish: 8/22] Make ConversationEmail and ConversationMessage coordinate progress
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/conversation-polish: 8/22] Make ConversationEmail and ConversationMessage coordinate progress
- Date: Tue, 29 Jan 2019 05:39:08 +0000 (UTC)
commit 43a0ef2da5e9886026c984201f735337ccffab4f
Author: Michael Gratton <mike vee net>
Date: Thu Jan 24 10:04:10 2019 +1100
Make ConversationEmail and ConversationMessage coordinate progress
Don't bother hiding the progress bar after loading the email, handle
transition when loading message body.
.../conversation-viewer/conversation-email.vala | 6 ------
.../conversation-viewer/conversation-message.vala | 22 +++++++++++++++++-----
2 files changed, 17 insertions(+), 11 deletions(-)
---
diff --git a/src/client/conversation-viewer/conversation-email.vala
b/src/client/conversation-viewer/conversation-email.vala
index b354d233..0eb5bedc 100644
--- a/src/client/conversation-viewer/conversation-email.vala
+++ b/src/client/conversation-viewer/conversation-email.vala
@@ -758,9 +758,6 @@ public class ConversationEmail : Gtk.Box, Geary.BaseInterface {
this.load_cancellable
);
} catch (GLib.IOError.CANCELLED err) {
- // Don't stop message progress pulse here since if
- // cancelled, this could be well after the widgets have
- // been removed and destroyed
throw err;
} catch (Geary.ImapError.TIMED_OUT err) {
if (retries < MAX_RETRIES) {
@@ -769,19 +766,16 @@ public class ConversationEmail : Gtk.Box, Geary.BaseInterface {
} else {
debug("Remote message download timed out, giving up %s",
err.message);
- this.primary_message.stop_progress_pulse();
throw err;
}
} catch (GLib.Error err) {
// XXX Notify user of a problem here
debug("Remote message download failed: %s", err.message);
- this.primary_message.stop_progress_pulse();
throw err;
}
}
if (loaded != null) {
- this.primary_message.stop_progress_pulse();
try {
this.email = loaded;
yield update_body();
diff --git a/src/client/conversation-viewer/conversation-message.vala
b/src/client/conversation-viewer/conversation-message.vala
index 9e76459f..c7186e67 100644
--- a/src/client/conversation-viewer/conversation-message.vala
+++ b/src/client/conversation-viewer/conversation-message.vala
@@ -25,6 +25,8 @@ public class ConversationMessage : Gtk.Grid, Geary.BaseInterface {
private const int MAX_PREVIEW_BYTES = Geary.Email.MAX_PREVIEW_BYTES;
+ private const int SHOW_PROGRESS_TIMEOUT_SEC = 1;
+ private const int HIDE_PROGRESS_TIMEOUT_SEC = 1;
private const int PULSE_TIMEOUT_MSEC = 250;
@@ -460,10 +462,10 @@ public class ConversationMessage : Gtk.Grid, Geary.BaseInterface {
this.body_container.set_has_tooltip(true); // Used to show link URLs
this.body_container.add(this.web_view);
this.show_progress_timeout = new Geary.TimeoutManager.seconds(
- 1, () => { this.body_progress.show(); }
+ SHOW_PROGRESS_TIMEOUT_SEC, this.on_show_progress_timeout
);
this.hide_progress_timeout = new Geary.TimeoutManager.seconds(
- 1, () => { this.body_progress.hide(); }
+ HIDE_PROGRESS_TIMEOUT_SEC, this.on_hide_progress_timeout
);
this.progress_pulse = new Geary.TimeoutManager.milliseconds(
@@ -808,6 +810,15 @@ public class ConversationMessage : Gtk.Grid, Geary.BaseInterface {
revealer.set_transition_type(transition);
}
+ private void on_show_progress_timeout() {
+ this.progress_pulse.start();
+ }
+
+ private void on_hide_progress_timeout() {
+ this.progress_pulse.reset();
+ this.body_progress.hide();
+ }
+
private void on_load_changed(WebKit.LoadEvent load_event) {
if (load_event != WebKit.LoadEvent.FINISHED) {
this.hide_progress_timeout.reset();
@@ -829,8 +840,10 @@ public class ConversationMessage : Gtk.Grid, Geary.BaseInterface {
// in on_load_changed.
if (this.is_loading_images &&
!res.get_uri().has_prefix(ClientWebView.INTERNAL_URL_PREFIX)) {
+ double min_step = this.body_progress.get_pulse_step();
+ this.progress_pulse.reset();
this.show_progress_timeout.start();
- this.body_progress.pulse();
+ this.body_progress.set_fraction(min_step);
if (!this.web_view.is_loading) {
// The initial page load has finished, so we must be
// loading a remote image afterwards at the user's
@@ -842,8 +855,7 @@ public class ConversationMessage : Gtk.Grid, Geary.BaseInterface {
this.remote_resources_loaded++;
this.body_progress.set_fraction(
(this.remote_resources_loaded /
- this.remote_resources_requested) +
- this.body_progress.get_pulse_step()
+ this.remote_resources_requested) * (1.0 - min_step)
);
if (this.remote_resources_loaded >=
this.remote_resources_requested) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]