[geary/wip/conversation-polish: 10/22] Show a placeholder when an email body was not able to be loaded



commit ad25ee1df52c501ed5959bab02733eb91574ab80
Author: Michael Gratton <mike vee net>
Date:   Thu Jan 24 18:45:47 2019 +1100

    Show a placeholder when an email body was not able to be loaded

 .../conversation-viewer/conversation-email.vala    |  2 +
 .../conversation-viewer/conversation-message.vala  | 60 ++++++++++++++++++++++
 2 files changed, 62 insertions(+)
---
diff --git a/src/client/conversation-viewer/conversation-email.vala 
b/src/client/conversation-viewer/conversation-email.vala
index 1800950f..28dc720d 100644
--- a/src/client/conversation-viewer/conversation-email.vala
+++ b/src/client/conversation-viewer/conversation-email.vala
@@ -926,10 +926,12 @@ public class ConversationEmail : Gtk.Box, Geary.BaseInterface {
 
     private void handle_load_failure() {
         this.message_body_state = FAILED;
+        this.primary_message.show_load_error_pane();
     }
 
     private void handle_load_offline() {
         this.message_body_state = FAILED;
+        this.primary_message.show_offline_pane();
     }
 
     private inline bool is_online() {
diff --git a/src/client/conversation-viewer/conversation-message.vala 
b/src/client/conversation-viewer/conversation-message.vala
index c7186e67..6e5867bb 100644
--- a/src/client/conversation-viewer/conversation-message.vala
+++ b/src/client/conversation-viewer/conversation-message.vala
@@ -215,6 +215,8 @@ public class ConversationMessage : Gtk.Grid, Geary.BaseInterface {
     [GtkChild]
     private Gtk.InfoBar remote_images_infobar;
 
+    private Gtk.Widget? body_placeholder = null;
+
     // The web_view's context menu
     private Gtk.Menu? context_menu = null;
 
@@ -505,6 +507,59 @@ public class ConversationMessage : Gtk.Grid, Geary.BaseInterface {
         body_revealer.set_reveal_child(false);
     }
 
+    /** Shows an error panel when email loading failed. */
+    public void show_load_error_pane() {
+        Components.PlaceholderPane pane = new Components.PlaceholderPane();
+        pane.icon_name = "network-error-symbolic";
+        pane.title = _("An unexpected problem occurred");
+        pane.subtitle = _("Something went wrong, please file a bug report if the problem persists");
+
+        // Don't want to break the announced freeze for 0.13, so just
+        // use the above pre-existing translations for now and replace
+        // them with the ones below for 0.14.
+
+        // Translators: Title label for placeholder when multiple
+        // an error occurs loading a message for display.
+        //pane.title = _("A problem occurred");
+        // Translators: Sub-title label for placeholder when multiple
+        // an error occurs loading a message for display.
+        //pane.subtitle = _(
+        //    "This email cannot currently be displayed"
+        //);
+        this.body_placeholder = pane;
+        this.web_view.hide();
+        this.body_container.add(pane);
+        show_message_body(true);
+        stop_progress_pulse();
+    }
+
+    /** Shows an error panel when offline. */
+    public void show_offline_pane() {
+        show_message_body(true);
+        Components.PlaceholderPane pane = new Components.PlaceholderPane();
+        pane.icon_name = "network-offline-symbolic";
+        pane.title = "";
+        pane.subtitle = "";
+
+        // Don't want to break the announced freeze for 0.13, so just
+        // hope the icon gets the message across for now and replace
+        // them with the ones below for 0.14.
+
+        // // Translators: Title label for placeholder when loading a
+        // // message for display but the account is offline.
+        // pane.title = _("Offline");
+        // // Translators: Sub-title label for placeholder when loading a
+        // // message for display but the account is offline.
+        // pane.subtitle = _(
+        //     "This email will be downloaded when reconnected to the Internet"
+        // );
+        this.body_placeholder = pane;
+        this.web_view.hide();
+        this.body_container.add(pane);
+        show_message_body(true);
+        stop_progress_pulse();
+    }
+
     /** Shows and starts pulsing the progress meter. */
     public void start_progress_pulse() {
         this.body_progress.show();
@@ -561,6 +616,11 @@ public class ConversationMessage : Gtk.Grid, Geary.BaseInterface {
             throw new GLib.IOError.CANCELLED("Conversation load cancelled");
         }
 
+        this.web_view.show();
+        if (this.body_placeholder != null) {
+            this.body_placeholder.hide();
+        }
+
         string? body_text = null;
         try {
             body_text = (message.has_html_body())


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]