[gnome-contacts] Initial setup for nicer link text for known uris
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-contacts] Initial setup for nicer link text for known uris
- Date: Thu, 30 Jun 2011 13:31:14 +0000 (UTC)
commit 171c6b9f3312c5ab32891103bed2beb46261e095
Author: Alexander Larsson <alexl redhat com>
Date: Wed Jun 29 11:40:24 2011 +0200
Initial setup for nicer link text for known uris
src/contacts-contact-pane.vala | 4 +---
src/contacts-contact.vala | 17 +++++++++++++++++
2 files changed, 18 insertions(+), 3 deletions(-)
---
diff --git a/src/contacts-contact-pane.vala b/src/contacts-contact-pane.vala
index 0a18cf4..0fa992b 100644
--- a/src/contacts-contact-pane.vala
+++ b/src/contacts-contact-pane.vala
@@ -655,9 +655,7 @@ public class Contacts.ContactPane : EventBox {
if (!urls.is_empty) {
layout.add_label ("Links");
foreach (var url_details in urls) {
- var url = url_details.value;
- // TODO: Detect link type, possibly using types parameter (to be standardized)
- layout.add_link (url, url);
+ layout.add_link (url_details.value, contact.format_uri_link_text (url_details));
}
}
diff --git a/src/contacts-contact.vala b/src/contacts-contact.vala
index 75d1c5a..6969730 100644
--- a/src/contacts-contact.vala
+++ b/src/contacts-contact.vala
@@ -660,4 +660,21 @@ public class Contacts.Contact : GLib.Object {
return Gdk.pixbuf_get_from_surface (cst, 0, 0, size, size);
}
+
+ public static string format_uri_link_text (FieldDetails detail) {
+ // TODO: Detect link type, possibly using types parameter (to be standardized bz#653623)
+ // TODO: Add more custom url matches
+
+ string uri = detail.value;
+
+ if (/https?:\/\/www.facebook.com\/profile\.php\?id=[0-9]+$/.match(uri) ||
+ /https?:\/\/www.facebook.com\/[a-zA-Z0-9]+$/.match(uri))
+ return _("Facebook");
+
+ if (/https?:\/\/twitter.com\/#!\/[a-zA-Z0-9]+$/.match(uri))
+ return _("Twitter");
+
+ return uri;
+ }
+
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]