aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Vrátil <dvratil@redhat.com>2012-06-08 22:09:53 +0800
committerDan Vrátil <dvratil@redhat.com>2012-06-08 23:08:00 +0800
commitc4071b0a1d38a478d3ba51c81af222cdeb4ed4fd (patch)
tree52b0f8825f9defd6accf554c5b26ae1c8c7ead94
parenta601031be2fa34f3f860179c8448cc0b04d4bfa4 (diff)
downloadgsoc2013-evolution-c4071b0a1d38a478d3ba51c81af222cdeb4ed4fd.tar
gsoc2013-evolution-c4071b0a1d38a478d3ba51c81af222cdeb4ed4fd.tar.gz
gsoc2013-evolution-c4071b0a1d38a478d3ba51c81af222cdeb4ed4fd.tar.bz2
gsoc2013-evolution-c4071b0a1d38a478d3ba51c81af222cdeb4ed4fd.tar.lz
gsoc2013-evolution-c4071b0a1d38a478d3ba51c81af222cdeb4ed4fd.tar.xz
gsoc2013-evolution-c4071b0a1d38a478d3ba51c81af222cdeb4ed4fd.tar.zst
gsoc2013-evolution-c4071b0a1d38a478d3ba51c81af222cdeb4ed4fd.zip
Fix displayed message headers
The new formatter was ignoring selected headers, always displaying only From, To, Subject and Date (default headers). Handling of the currently displayed headers has been moved to EMailConfigFormatHTML extension, because it is related to configuration of EMailFormatter, rather then EMailReader.
-rw-r--r--em-format/e-mail-formatter.c20
-rw-r--r--em-format/e-mail-formatter.h2
-rw-r--r--mail/e-mail-display.c2
-rw-r--r--mail/e-mail-reader-utils.c107
-rw-r--r--mail/e-mail-reader-utils.h3
-rw-r--r--mail/e-mail-reader.c1
-rw-r--r--modules/mail/e-mail-config-format-html.c75
7 files changed, 99 insertions, 111 deletions
diff --git a/em-format/e-mail-formatter.c b/em-format/e-mail-formatter.c
index a08504a21f..0c8a0e7068 100644
--- a/em-format/e-mail-formatter.c
+++ b/em-format/e-mail-formatter.c
@@ -72,6 +72,13 @@ enum {
PROP_DEFAULT_CHARSET
};
+enum {
+ NEED_REDRAW,
+ LAST_SIGNAL
+};
+
+static int signals[LAST_SIGNAL];
+
static void
mail_formatter_run (EMailFormatter *formatter,
EMailFormatterContext *context,
@@ -492,6 +499,7 @@ e_mail_formatter_base_init (EMailFormatterClass *klass)
CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS |
CAMEL_MIME_FILTER_TOHTML_CONVERT_NL |
CAMEL_MIME_FILTER_TOHTML_CONVERT_SPACES |
+ CAMEL_MIME_FILTER_TOHTML_CONVERT_ADDRESSES |
CAMEL_MIME_FILTER_TOHTML_MARK_CITATION;
}
@@ -691,6 +699,16 @@ e_mail_formatter_class_init (EMailFormatterClass *klass)
NULL,
NULL,
G_PARAM_READWRITE));
+
+ signals[NEED_REDRAW] = g_signal_new (
+ "need-redraw",
+ E_TYPE_MAIL_FORMATTER,
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (EMailFormatterClass, need_redraw),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0, NULL);
}
static void
@@ -1414,6 +1432,8 @@ e_mail_formatter_add_header (EMailFormatter *formatter,
h = e_mail_formatter_header_new (name, value);
h->flags = flags;
g_queue_push_tail (formatter->priv->header_list, h);
+
+ g_signal_emit (formatter, signals[NEED_REDRAW], 0, NULL);
}
void
diff --git a/em-format/e-mail-formatter.h b/em-format/e-mail-formatter.h
index aea18439b2..c0c21c13b0 100644
--- a/em-format/e-mail-formatter.h
+++ b/em-format/e-mail-formatter.h
@@ -126,6 +126,8 @@ struct _EMailFormatterClass {
GtkStyle *style,
GtkStateType state);
+ /* Signals */
+ void (*need_redraw) (EMailFormatter *formatter);
};
GType e_mail_formatter_get_type (void);
diff --git a/mail/e-mail-display.c b/mail/e-mail-display.c
index 4f72e843f6..33922d8c0a 100644
--- a/mail/e-mail-display.c
+++ b/mail/e-mail-display.c
@@ -1552,6 +1552,8 @@ e_mail_display_set_mode (EMailDisplay *display,
G_CALLBACK (e_mail_display_reload), display,
"swapped-signal::notify::header-color",
G_CALLBACK (e_mail_display_reload), display,
+ "swapped-signal::need-redraw",
+ G_CALLBACK (e_mail_display_reload), display,
NULL);
e_mail_display_reload (display);
diff --git a/mail/e-mail-reader-utils.c b/mail/e-mail-reader-utils.c
index f18d881ba2..d1c3d3d7e5 100644
--- a/mail/e-mail-reader-utils.c
+++ b/mail/e-mail-reader-utils.c
@@ -1536,113 +1536,6 @@ e_mail_reader_header_free (EMailReaderHeader *header)
g_free (header);
}
-struct headers_changed_closure {
- EMailFormatter *formatter;
- EMailDisplay *display;
-};
-
-static void
-free_headers_changed_closure (struct headers_changed_closure *closure)
-{
- g_clear_object (&closure->formatter);
- g_clear_object (&closure->display);
-
- g_free (closure);
-}
-
-static void
-headers_changed_cb (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- struct headers_changed_closure *closure)
-{
- GSList *header_config_list, *p;
-
- g_return_if_fail (client != NULL);
-
- header_config_list = gconf_client_get_list (
- client, "/apps/evolution/mail/display/headers",
- GCONF_VALUE_STRING, NULL);
-
- e_mail_formatter_clear_headers (closure->formatter);
- for (p = header_config_list; p; p = g_slist_next (p)) {
- EMailReaderHeader *h;
- gchar *xml = (gchar *) p->data;
-
- h = e_mail_reader_header_from_xml (xml);
- if (h && h->enabled)
- e_mail_formatter_add_header (
- closure->formatter, h->name, NULL,
- E_MAIL_FORMATTER_HEADER_FLAG_BOLD);
-
- e_mail_reader_header_free (h);
- }
-
- if (!header_config_list)
- e_mail_formatter_set_default_headers (closure->formatter);
-
- g_slist_foreach (header_config_list, (GFunc) g_free, NULL);
- g_slist_free (header_config_list);
-
- /* force a redraw */
- if (closure->display) {
- e_mail_display_reload (closure->display);
- }
-}
-
-static void
-remove_header_notify_cb (gpointer data)
-{
- GConfClient *client;
- guint notify_id;
-
- notify_id = GPOINTER_TO_INT (data);
- g_return_if_fail (notify_id != 0);
-
- client = gconf_client_get_default ();
- gconf_client_notify_remove (client, notify_id);
- gconf_client_remove_dir (client, "/apps/evolution/mail/display", NULL);
- g_object_unref (client);
-}
-
-/**
- * e_mail_reader_connect_headers
- * @reader: an #EMailReader
- *
- * Connects @reader to listening for changes in headers and
- * updates the EMFormat whenever it changes and on this call too.
- **/
-void
-e_mail_reader_connect_headers (EMailReader *reader,
- EMailFormatter *formatter)
-{
- GConfClient *client;
- guint notify_id;
- struct headers_changed_closure *closure;
-
- client = gconf_client_get_default ();
-
- closure = g_new0 (struct headers_changed_closure, 1);
- closure->display = g_object_ref (e_mail_reader_get_mail_display (reader));
- closure->formatter = g_object_ref (formatter);
-
- gconf_client_add_dir (
- client, "/apps/evolution/mail/display",
- GCONF_CLIENT_PRELOAD_NONE, NULL);
- notify_id = gconf_client_notify_add (
- client, "/apps/evolution/mail/display/headers",
- (GConfClientNotifyFunc) headers_changed_cb,
- closure, (GFreeFunc) free_headers_changed_closure, NULL);
-
- g_object_set_data_full (
- G_OBJECT (formatter), "reader-header-notify-id",
- GINT_TO_POINTER (notify_id), remove_header_notify_cb);
-
- headers_changed_cb (client, 0, NULL, closure);
-
- g_object_unref (client);
-}
-
static GHashTable *
mail_reader_get_mail_register (void)
{
diff --git a/mail/e-mail-reader-utils.h b/mail/e-mail-reader-utils.h
index 887e399451..a3a1cdb86d 100644
--- a/mail/e-mail-reader-utils.h
+++ b/mail/e-mail-reader-utils.h
@@ -67,9 +67,6 @@ EMailReaderHeader *
gchar * e_mail_reader_header_to_xml (EMailReaderHeader *header);
void e_mail_reader_header_free (EMailReaderHeader *header);
-void e_mail_reader_connect_headers (EMailReader *reader,
- EMailFormatter *formatter);
-
EMailPartList * e_mail_reader_lookup_part_list (EMailReader *reader,
const gchar *uri);
diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c
index 3d0911b1fc..069f064953 100644
--- a/mail/e-mail-reader.c
+++ b/mail/e-mail-reader.c
@@ -4768,5 +4768,4 @@ e_mail_reader_set_formatter (EMailReader *reader,
priv->formatter = formatter;
- e_mail_reader_connect_headers (reader, formatter);
}
diff --git a/modules/mail/e-mail-config-format-html.c b/modules/mail/e-mail-config-format-html.c
index cbedecf914..a764e7d729 100644
--- a/modules/mail/e-mail-config-format-html.c
+++ b/modules/mail/e-mail-config-format-html.c
@@ -27,16 +27,74 @@
#include <shell/e-shell.h>
#include <e-util/e-util.h>
#include <em-format/e-mail-formatter.h>
+#include <mail/e-mail-reader-utils.h>
static gpointer parent_class;
static void
+headers_changed_cb (GConfClient *client,
+ guint cnxn_id,
+ GConfEntry *entry,
+ gpointer user_data)
+{
+ GSList *header_config_list, *p;
+ EExtension *extension;
+ EMailFormatter *formatter;
+
+ g_return_if_fail (client != NULL);
+
+ extension = user_data;
+ formatter = E_MAIL_FORMATTER (e_extension_get_extensible (extension));
+
+ header_config_list = gconf_client_get_list (
+ client, "/apps/evolution/mail/display/headers",
+ GCONF_VALUE_STRING, NULL);
+
+ e_mail_formatter_clear_headers (formatter);
+ for (p = header_config_list; p; p = g_slist_next (p)) {
+ EMailReaderHeader *h;
+ gchar *xml = (gchar *) p->data;
+
+ h = e_mail_reader_header_from_xml (xml);
+ if (h && h->enabled)
+ e_mail_formatter_add_header (
+ formatter, h->name, NULL,
+ E_MAIL_FORMATTER_HEADER_FLAG_BOLD);
+
+ e_mail_reader_header_free (h);
+ }
+
+ if (!header_config_list)
+ e_mail_formatter_set_default_headers (formatter);
+
+ g_slist_foreach (header_config_list, (GFunc) g_free, NULL);
+ g_slist_free (header_config_list);
+}
+
+static void
+remove_header_notify_cb (gpointer data)
+{
+ GConfClient *client;
+ guint notify_id;
+
+ notify_id = GPOINTER_TO_INT (data);
+ g_return_if_fail (notify_id != 0);
+
+ client = gconf_client_get_default ();
+ gconf_client_notify_remove (client, notify_id);
+ gconf_client_remove_dir (client, "/apps/evolution/mail/display", NULL);
+ g_object_unref (client);
+}
+
+static void
mail_config_format_html_constructed (GObject *object)
{
EExtension *extension;
EExtensible *extensible;
EShellSettings *shell_settings;
EShell *shell;
+ GConfClient *client;
+ guint notify_id;
extension = E_EXTENSION (object);
extensible = e_extension_get_extensible (extension);
@@ -81,6 +139,23 @@ mail_config_format_html_constructed (GObject *object)
extensible, "animate-images",
G_BINDING_SYNC_CREATE);
+
+ client = gconf_client_get_default ();
+ gconf_client_add_dir (
+ client, "/apps/evolution/mail/display",
+ GCONF_CLIENT_PRELOAD_NONE, NULL);
+ notify_id = gconf_client_notify_add (
+ client, "/apps/evolution/mail/display/headers",
+ (GConfClientNotifyFunc) headers_changed_cb,
+ object, NULL, NULL);
+
+ g_object_set_data_full (
+ G_OBJECT (extensible), "reader-header-notify-id",
+ GINT_TO_POINTER (notify_id), remove_header_notify_cb);
+
+ /* Initial synchronization */
+ headers_changed_cb (client, 0, NULL, object);
+
/* Chain up to parent's constructed() method. */
G_OBJECT_CLASS (parent_class)->constructed (object);
}