[geary/mjog/info-bar-cleanup: 1/3] ConversationMessage: Don't show multiple remote image infobars



commit 96a4b3fea394a992e4146fea641e82c2b77de0ae
Author: Michael Gratton <mike vee net>
Date:   Fri Apr 3 09:27:26 2020 +1100

    ConversationMessage: Don't show multiple remote image infobars
    
    The `remote-images-blocked` signal can be emitted multiple times, so
    take care to only show the infobar once.

 .../conversation-viewer/conversation-message.vala  | 40 ++++++++++++----------
 1 file changed, 21 insertions(+), 19 deletions(-)
---
diff --git a/src/client/conversation-viewer/conversation-message.vala 
b/src/client/conversation-viewer/conversation-message.vala
index fd239d52..a7494ad8 100644
--- a/src/client/conversation-viewer/conversation-message.vala
+++ b/src/client/conversation-viewer/conversation-message.vala
@@ -1299,26 +1299,28 @@ public class ConversationMessage : Gtk.Grid, Geary.BaseInterface {
     }
 
     private void on_remote_images_blocked() {
-        this.remote_images_info_bar = new Components.InfoBar(
-            // Translators: Info bar status message
-            _("Remote images not shown"),
-            // Translators: Info bar description
-            _("Only show remote images from senders you trust.")
-        );
-        var show = this.remote_images_info_bar.add_button(
-            // Translators: Info bar button label
-            _("Show"), 1
-        );
-        this.remote_images_info_bar.add_button(
-            // Translators: Info bar button label
-            _("Always show from sender"), 2
-        );
-        this.remote_images_info_bar.response.connect(on_remote_images_response);
-        var buttons = this.remote_images_info_bar.get_action_area() as Gtk.ButtonBox;
-        if (buttons != null) {
-            buttons.set_child_non_homogeneous(show, true);
+        if (this.remote_images_info_bar == null) {
+            this.remote_images_info_bar = new Components.InfoBar(
+                // Translators: Info bar status message
+                _("Remote images not shown"),
+                // Translators: Info bar description
+                _("Only show remote images from senders you trust.")
+            );
+            var show = this.remote_images_info_bar.add_button(
+                // Translators: Info bar button label
+                _("Show"), 1
+            );
+            this.remote_images_info_bar.add_button(
+                // Translators: Info bar button label
+                _("Always show from sender"), 2
+            );
+            this.remote_images_info_bar.response.connect(on_remote_images_response);
+            var buttons = this.remote_images_info_bar.get_action_area() as Gtk.ButtonBox;
+            if (buttons != null) {
+                buttons.set_child_non_homogeneous(show, true);
+            }
+            this.info_bars.add(this.remote_images_info_bar);
         }
-        this.info_bars.add(this.remote_images_info_bar);
     }
 
     private void on_remote_images_response(Gtk.InfoBar info_bar, int response_id) {


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