aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Vrátil <dvratil@redhat.com>2012-06-08 17:30:03 +0800
committerDan Vrátil <dvratil@redhat.com>2012-06-08 17:30:44 +0800
commita6cac3f275db19342e57f2d96141ccfbbf13a8ec (patch)
treee2274b05feb669fae22f3ef03a2ee504ffed3d21
parentb3c57ed8e5f1bcbda9ec0fa37a252aeb5313f279 (diff)
downloadgsoc2013-evolution-a6cac3f275db19342e57f2d96141ccfbbf13a8ec.tar.gz
gsoc2013-evolution-a6cac3f275db19342e57f2d96141ccfbbf13a8ec.tar.zst
gsoc2013-evolution-a6cac3f275db19342e57f2d96141ccfbbf13a8ec.zip
Bug #670876 - Missing mnemonics for buttons for vcard attached to email
-rw-r--r--em-format/e-mail-formatter-utils.c40
-rw-r--r--em-format/e-mail-formatter-utils.h6
-rw-r--r--modules/itip-formatter/itip-view.c47
-rw-r--r--modules/vcard-inline/e-mail-formatter-vcard-inline.c39
-rw-r--r--modules/vcard-inline/e-mail-parser-vcard-inline.c33
5 files changed, 106 insertions, 59 deletions
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, "<u>%c</u>", 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_ */
diff --git a/modules/itip-formatter/itip-view.c b/modules/itip-formatter/itip-view.c
index 5e655eb74d..16a6d5cb09 100644
--- a/modules/itip-formatter/itip-view.c
+++ b/modules/itip-formatter/itip-view.c
@@ -47,6 +47,7 @@
#include <mail/em-config.h>
#include <mail/em-utils.h>
+#include <em-format/e-mail-formatter-utils.h>
#include <calendar/gui/itip-utils.h>
@@ -835,46 +836,6 @@ source_changed_cb (WebKitDOMElement *select,
g_object_unref (source);
}
-static gchar *
-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, "<u>%c</u>", 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);
-}
-
static void
append_checkbox_table_row (GString *buffer,
const gchar *name,
@@ -882,7 +843,7 @@ append_checkbox_table_row (GString *buffer,
{
gchar *access_key, *html_label;
- html_label = parse_html_mnemonics (label, &access_key);
+ html_label = e_mail_formatter_parse_html_mnemonics (label, &access_key);
g_string_append_printf (
buffer,
@@ -1017,7 +978,7 @@ buttons_table_write_button (GString *buffer,
{
gchar *access_key, *html_label;
- html_label = parse_html_mnemonics (label, &access_key);
+ html_label = e_mail_formatter_parse_html_mnemonics (label, &access_key);
g_string_append_printf (
buffer,
@@ -1839,7 +1800,7 @@ itip_view_set_item_type (ItipView *view,
return;
}
- html_label = parse_html_mnemonics (header, &access_key);
+ html_label = e_mail_formatter_parse_html_mnemonics (header, &access_key);
webkit_dom_html_element_set_access_key (
WEBKIT_DOM_HTML_ELEMENT (label), access_key);
diff --git a/modules/vcard-inline/e-mail-formatter-vcard-inline.c b/modules/vcard-inline/e-mail-formatter-vcard-inline.c
index 25cdacb116..54d095fc31 100644
--- a/modules/vcard-inline/e-mail-formatter-vcard-inline.c
+++ b/modules/vcard-inline/e-mail-formatter-vcard-inline.c
@@ -29,6 +29,7 @@
#include <em-format/e-mail-formatter-extension.h>
#include <em-format/e-mail-formatter.h>
+#include <em-format/e-mail-formatter-utils.h>
#include <em-format/e-mail-part-utils.h>
#include <camel/camel.h>
@@ -93,6 +94,7 @@ emfe_vcard_inline_format (EMailFormatterExtension *extension,
const gchar *label = NULL;
EABContactDisplayMode mode;
const gchar *info = NULL;
+ gchar *html_label, *access_key;
length = g_slist_length (vcard_part->contact_list);
if (length < 1)
@@ -113,33 +115,50 @@ emfe_vcard_inline_format (EMailFormatterExtension *extension,
mode = eab_contact_formatter_get_display_mode (vcard_part->formatter);
if (mode == EAB_CONTACT_DISPLAY_RENDER_COMPACT) {
mode = EAB_CONTACT_DISPLAY_RENDER_NORMAL;
- label =_("Show Full vCard");
+ label = _("Show F_ull vCard");
} else {
mode = EAB_CONTACT_DISPLAY_RENDER_COMPACT;
- label = _("Show Compact vCard");
+ label = _("Show Com_pact vCard");
}
str = g_strdup_printf (
- "<div id=\"%s\">"
+ "<div id=\"%s\">", part->id);
+ camel_stream_write_string (stream, str, cancellable, NULL);
+ g_free (str);
+
+ html_label = e_mail_formatter_parse_html_mnemonics (
+ label, &access_key);
+ str = g_strdup_printf (
"<button type=\"button\" "
"name=\"set-display-mode\" "
"class=\"org-gnome-vcard-inline-display-mode-button\" "
- "value=\"%d\">%s</button>"
+ "value=\"%d\" "
+ "accesskey=\"%s\">%s</button>",
+ mode, access_key, html_label);
+ camel_stream_write_string (stream, str, cancellable, NULL);
+ g_free (str);
+ g_free (html_label);
+ if (access_key)
+ g_free (access_key);
+
+ html_label = e_mail_formatter_parse_html_mnemonics (
+ _("Save _To Addressbook"), &access_key);
+ str = g_strdup_printf (
"<button type=\"button\" "
"name=\"save-to-addressbook\" "
"class=\"org-gnome-vcard-inline-save-button\" "
- "value=\"%s\">%s</button><br/>"
+ "value=\"%s\" "
+ "accesskey=\"%s\">%s</button><br/>"
"<iframe width=\"100%%\" height=\"auto\" frameborder=\"0\""
"src=\"%s\" name=\"%s\"></iframe>"
"</div>",
- part->id,
- mode, label,
- part->id, _("Save To Addressbook"),
+ part->id, access_key, html_label,
uri, part->id);
-
camel_stream_write_string (stream, str, cancellable, NULL);
-
g_free (str);
+ g_free (html_label);
+ if (access_key)
+ g_free (access_key);
if (length == 2) {
diff --git a/modules/vcard-inline/e-mail-parser-vcard-inline.c b/modules/vcard-inline/e-mail-parser-vcard-inline.c
index 562ca75c72..e4827d0709 100644
--- a/modules/vcard-inline/e-mail-parser-vcard-inline.c
+++ b/modules/vcard-inline/e-mail-parser-vcard-inline.c
@@ -34,7 +34,7 @@
#include <em-format/e-mail-parser-extension.h>
#include <em-format/e-mail-part.h>
#include <em-format/e-mail-part-utils.h>
-#include <em-format/e-mail-formatter.h>
+#include <em-format/e-mail-formatter-utils.h>
#include <libebook/libebook.h>
#include <libedataserver/libedataserver.h>
@@ -191,21 +191,44 @@ display_mode_toggle_cb (WebKitDOMEventTarget *button,
{
EABContactDisplayMode mode;
gchar *uri;
+ gchar *html_label, *access_key;
mode = eab_contact_formatter_get_display_mode (vcard_part->formatter);
if (mode == EAB_CONTACT_DISPLAY_RENDER_NORMAL) {
mode = EAB_CONTACT_DISPLAY_RENDER_COMPACT;
- webkit_dom_html_element_set_inner_text (
+ html_label = e_mail_formatter_parse_html_mnemonics (
+ _("Show F_ull vCard"), &access_key);
+
+ webkit_dom_html_element_set_inner_html (
WEBKIT_DOM_HTML_ELEMENT (button),
- _("Show Full vCard"), NULL);
+ html_label, NULL);
+ if (access_key) {
+ webkit_dom_html_element_set_access_key (
+ WEBKIT_DOM_HTML_ELEMENT (button),
+ access_key);
+ g_free (access_key);
+ }
+
+ g_free (html_label);
} else {
mode = EAB_CONTACT_DISPLAY_RENDER_NORMAL;
- webkit_dom_html_element_set_inner_text (
+ html_label = e_mail_formatter_parse_html_mnemonics (
+ _("Show Com_pact vCard"), &access_key);
+
+ webkit_dom_html_element_set_inner_html (
WEBKIT_DOM_HTML_ELEMENT (button),
- _("Show Compact vCard"), NULL);
+ html_label, NULL);
+ if (access_key) {
+ webkit_dom_html_element_set_access_key (
+ WEBKIT_DOM_HTML_ELEMENT (button),
+ access_key);
+ g_free (access_key);
+ }
+
+ g_free (html_label);
}
eab_contact_formatter_set_display_mode (vcard_part->formatter, mode);