[geary: 1/4] Link preview popup is way too big



commit b2f71792eb521dd53e7c0c990fdfc9941a5ad458
Author: Mario Ravalli <mario raval li>
Date:   Thu Nov 14 00:12:55 2019 +0000

    Link preview popup is way too big
    
    When on a message there is a link address very long, the popup displayed
    is oversize.
    To fix this situation, the link over 90 chars are shortened taking the
    first 40 chars and the last 40 chars, joined by a "..."
    
    https://gitlab.gnome.org/GNOME/geary/issues/356

 src/client/conversation-viewer/conversation-message.vala | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
---
diff --git a/src/client/conversation-viewer/conversation-message.vala 
b/src/client/conversation-viewer/conversation-message.vala
index 1ccd7a7f..1dedf569 100644
--- a/src/client/conversation-viewer/conversation-message.vala
+++ b/src/client/conversation-viewer/conversation-message.vala
@@ -1149,11 +1149,19 @@ public class ConversationMessage : Gtk.Grid, Geary.BaseInterface {
                                          WebKit.HitTestResult hit_test,
                                          uint modifiers) {
         this.body_container.set_tooltip_text(
-            hit_test.context_is_link() ? hit_test.get_link_uri() : null
+            hit_test.context_is_link() ? this.get_link_uri(hit_test.get_link_uri()) : null
         );
         this.body_container.trigger_tooltip_query();
     }
 
+    private string get_link_uri(string uri) {
+        if (uri.length < 90) {
+            return uri;
+        } else {
+            return uri.substring(0,40) + "..." + uri.substring(-40);
+        }
+    }
+
     // Check for possible phishing links, displays a popover if found.
     // If not, lets it go through to the default handler.
     private void on_deceptive_link_clicked(ConversationWebView.DeceptiveText reason,


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