[evolution] Bug #668989 - Add a twitter username to IM in contacts



commit 13d4a2c8ba973bfa5afca4221056f88989671a07
Author: Milan Crha <mcrha redhat com>
Date:   Thu Apr 26 13:47:09 2012 +0200

    Bug #668989 - Add a twitter username to IM in contacts

 addressbook/gui/contact-editor/e-contact-editor.c |    4 +++-
 addressbook/gui/widgets/eab-contact-formatter.c   |   21 ++++++++++++++++++++-
 addressbook/importers/evolution-vcard-importer.c  |    2 ++
 3 files changed, 25 insertions(+), 2 deletions(-)
---
diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c
index 7ad3bcd..af92ba2 100644
--- a/addressbook/gui/contact-editor/e-contact-editor.c
+++ b/addressbook/gui/contact-editor/e-contact-editor.c
@@ -181,7 +181,8 @@ im_service[] =
 	{ E_CONTACT_IM_MSN,       N_ ("MSN")       },
 	{ E_CONTACT_IM_ICQ,       N_ ("ICQ")       },
 	{ E_CONTACT_IM_GROUPWISE, N_ ("GroupWise") },
-	{ E_CONTACT_IM_SKYPE,     N_ ("Skype") }
+	{ E_CONTACT_IM_SKYPE,     N_ ("Skype")     },
+	{ E_CONTACT_IM_TWITTER,   N_ ("Twitter")   }
 };
 
 /* Defaults from the table above */
@@ -3703,6 +3704,7 @@ static const EContactField  non_string_fields[] = {
 	E_CONTACT_IM_MSN,
 	E_CONTACT_IM_ICQ,
 	E_CONTACT_IM_SKYPE,
+	E_CONTACT_IM_TWITTER,
 	E_CONTACT_PHOTO,
 	E_CONTACT_LOGO,
 	E_CONTACT_X509_CERT,
diff --git a/addressbook/gui/widgets/eab-contact-formatter.c b/addressbook/gui/widgets/eab-contact-formatter.c
index b87944c..0c594b9 100644
--- a/addressbook/gui/widgets/eab-contact-formatter.c
+++ b/addressbook/gui/widgets/eab-contact-formatter.c
@@ -83,6 +83,7 @@ common_location[] =
 #define YAHOO_ICON        "im-yahoo"
 #define GADUGADU_ICON	  "im-gadugadu"
 #define SKYPE_ICON	  "stock_people"
+#define TWITTER_ICON	  "im-twitter"
 #define VIDEOCONF_ICON    "stock_video-conferencing"
 
 #define MAX_COMPACT_IMAGE_DIMENSION 48
@@ -110,6 +111,23 @@ common_location[] =
 "</script>\n" \
 "</head>\n"
 
+static gboolean
+icon_available (const gchar *icon)
+{
+	GtkIconTheme *icon_theme;
+	GtkIconInfo *icon_info;
+
+	if (!icon)
+		return FALSE;
+
+	icon_theme = gtk_icon_theme_get_default ();
+	icon_info = gtk_icon_theme_lookup_icon (icon_theme, icon, 16, 0);
+	if (icon_info != NULL)
+		gtk_icon_info_free (icon_info);
+
+	return icon_info != NULL;
+}
+
 static void
 render_address_link (GString *buffer,
                      EContact *contact,
@@ -264,7 +282,7 @@ render_table_row (GString *buffer,
 	else
 		value = (gchar *) str;
 
-	if (icon) {
+	if (icon && icon_available (icon)) {
 		icon_html = g_strdup_printf ("<img src=\"gtk-stock://%s\" width=\"16\" height=\"16\" />", icon);
 	} else {
 		icon_html = "";
@@ -604,6 +622,7 @@ render_contact_column (EABContactFormatter *formatter,
 	accum_attribute_multival (accum, contact, _("Yahoo"), E_CONTACT_IM_YAHOO, YAHOO_ICON, 0);
 	accum_attribute_multival (accum, contact, _("Gadu-Gadu"), E_CONTACT_IM_GADUGADU, GADUGADU_ICON, 0);
 	accum_attribute_multival (accum, contact, _("Skype"), E_CONTACT_IM_SKYPE, SKYPE_ICON, 0);
+	accum_attribute_multival (accum, contact, _("Twitter"), E_CONTACT_IM_TWITTER, TWITTER_ICON, 0);
 
 	if (accum->len)
 		g_string_append_printf (
diff --git a/addressbook/importers/evolution-vcard-importer.c b/addressbook/importers/evolution-vcard-importer.c
index 1dbbed0..5094ab6 100644
--- a/addressbook/importers/evolution-vcard-importer.c
+++ b/addressbook/importers/evolution-vcard-importer.c
@@ -748,6 +748,7 @@ preview_contact (EWebViewPreview *preview,
 		E_CONTACT_IM_ICQ,
 		E_CONTACT_IM_GADUGADU,
 		E_CONTACT_IM_SKYPE,
+		E_CONTACT_IM_TWITTER,
 
 		-1,
 
@@ -837,6 +838,7 @@ preview_contact (EWebViewPreview *preview,
 			   field == E_CONTACT_IM_ICQ ||
 			   field == E_CONTACT_IM_GADUGADU ||
 			   field == E_CONTACT_IM_SKYPE ||
+			   field == E_CONTACT_IM_TWITTER ||
 			   field == E_CONTACT_EMAIL) {
 			GList *attrs, *a;
 			gboolean have = FALSE;



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