[geary/mjog/121-search-tokenising: 6/7] Move display-related Util.Email.shorten_url function to Util.Gtk
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/mjog/121-search-tokenising: 6/7] Move display-related Util.Email.shorten_url function to Util.Gtk
- Date: Tue, 17 Dec 2019 23:22:43 +0000 (UTC)
commit e7f85710e982cb110fc3eb09a376586fcf18a4ff
Author: Michael Gratton <mike vee net>
Date: Sun Dec 15 12:20:44 2019 +1100
Move display-related Util.Email.shorten_url function to Util.Gtk
Add a short doc comment, tweak slightly.
src/client/conversation-viewer/conversation-message.vala | 4 +++-
src/client/util/util-email.vala | 9 ---------
src/client/util/util-gtk.vala | 9 +++++++++
3 files changed, 12 insertions(+), 10 deletions(-)
---
diff --git a/src/client/conversation-viewer/conversation-message.vala
b/src/client/conversation-viewer/conversation-message.vala
index 3d98d991..f232968e 100644
--- a/src/client/conversation-viewer/conversation-message.vala
+++ b/src/client/conversation-viewer/conversation-message.vala
@@ -1279,7 +1279,9 @@ public class ConversationMessage : Gtk.Grid, Geary.BaseInterface {
WebKit.HitTestResult hit_test,
uint modifiers) {
this.body_container.set_tooltip_text(
- hit_test.context_is_link() ? Util.Email.shorten_url(hit_test.get_link_uri()) : null
+ hit_test.context_is_link()
+ ? Util.Gtk.shorten_url(hit_test.get_link_uri())
+ : null
);
this.body_container.trigger_tooltip_query();
}
diff --git a/src/client/util/util-email.vala b/src/client/util/util-email.vala
index 784cbdca..db321b8c 100644
--- a/src/client/util/util-email.vala
+++ b/src/client/util/util-email.vala
@@ -281,13 +281,4 @@ namespace Util.Email {
return body_text;
}
- private string shorten_url(string url) {
- string new_url = "";
- if (url.length < 90) {
- new_url = url;
- } else {
- new_url = url.substring(0,40) + "..." + url.substring(-40);
- }
- return new_url;
- }
}
diff --git a/src/client/util/util-gtk.vala b/src/client/util/util-gtk.vala
index 798ad0ed..18429bad 100644
--- a/src/client/util/util-gtk.vala
+++ b/src/client/util/util-gtk.vala
@@ -202,4 +202,13 @@ namespace Util.Gtk {
return copy;
}
+ /** Returns a truncated form of a URL if it is too long for display. */
+ public string shorten_url(string url) {
+ string new_url = url;
+ if (url.length >= 90) {
+ new_url = url.substring(0,40) + "…" + url.substring(-40);
+ }
+ return new_url;
+ }
+
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]