From a6cac3f275db19342e57f2d96141ccfbbf13a8ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=20Vr=C3=A1til?= Date: Fri, 8 Jun 2012 11:30:03 +0200 Subject: Bug #670876 - Missing mnemonics for buttons for vcard attached to email --- em-format/e-mail-formatter-utils.c | 40 ++++++++++++++++++++++++++++++++++++++ em-format/e-mail-formatter-utils.h | 6 +++++- 2 files changed, 45 insertions(+), 1 deletion(-) (limited to 'em-format') diff --git a/em-format/e-mail-formatter-utils.c b/em-format/e-mail-formatter-utils.c index 12ee042c90..7f2108eb38 100644 --- a/em-format/e-mail-formatter-utils.c +++ b/em-format/e-mail-formatter-utils.c @@ -432,3 +432,43 @@ e_mail_formatter_find_rfc822_end_iter (GSList *iter) g_free (end); return iter; } + +gchar * +e_mail_formatter_parse_html_mnemonics (const gchar *label, + gchar **access_key) +{ + const gchar *pos = NULL; + gchar ak = 0; + GString *html_label = NULL; + + pos = strstr (label, "_"); + if (pos != NULL) { + ak = pos[1]; + + /* Convert to uppercase */ + if (ak >= 'a') + ak = ak - 32; + + html_label = g_string_new (""); + g_string_append_len (html_label, label, pos - label); + g_string_append_printf (html_label, "%c", pos[1]); + g_string_append (html_label, &pos[2]); + + if (access_key) { + if (ak) { + *access_key = g_strdup_printf ("%c", ak); + } else { + *access_key = NULL; + } + } + + } else { + html_label = g_string_new (label); + + if (access_key) { + *access_key = NULL; + } + } + + return g_string_free (html_label, FALSE); +} diff --git a/em-format/e-mail-formatter-utils.h b/em-format/e-mail-formatter-utils.h index 59d8e43257..e89c3f42b4 100644 --- a/em-format/e-mail-formatter-utils.h +++ b/em-format/e-mail-formatter-utils.h @@ -48,9 +48,13 @@ gchar * e_mail_formatter_format_address (EMailFormatter *formatter, void e_mail_formatter_canon_header_name (gchar *name); -GSList * e_mail_formatter_find_rfc822_end_iter +GSList * e_mail_formatter_find_rfc822_end_iter (GSList *rfc822_start_iter); +gchar * e_mail_formatter_parse_html_mnemonics + (const gchar *label, + gchar **access_key); + G_END_DECLS #endif /* E_MAIL_FORMATTER_UTILS_H_ */ -- cgit v1.2.3