aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/reference/evolution-mail-formatter/evolution-mail-formatter-sections.txt11
-rw-r--r--em-format/e-mail-formatter.c255
-rw-r--r--em-format/e-mail-formatter.h38
-rw-r--r--modules/settings/e-settings-mail-formatter.c83
4 files changed, 2 insertions, 385 deletions
diff --git a/doc/reference/evolution-mail-formatter/evolution-mail-formatter-sections.txt b/doc/reference/evolution-mail-formatter/evolution-mail-formatter-sections.txt
index 2d344cf9aa..98285ab878 100644
--- a/doc/reference/evolution-mail-formatter/evolution-mail-formatter-sections.txt
+++ b/doc/reference/evolution-mail-formatter/evolution-mail-formatter-sections.txt
@@ -44,7 +44,6 @@ EMailFormatterExtensionRegistryPrivate
<TITLE>EMailFormatter</TITLE>
EMailFormatter
EMailFormatterHeaderFlags
-EMailFormatterHeader
EMailFormatterMode
EMailFormatterContext
e_mail_formatter_new
@@ -76,22 +75,12 @@ e_mail_formatter_set_charset
e_mail_formatter_get_default_charset
e_mail_formatter_dup_default_charset
e_mail_formatter_set_default_charset
-e_mail_formatter_dup_headers
-e_mail_formatter_clear_headers
-e_mail_formatter_set_default_headers
-e_mail_formatter_add_header
-e_mail_formatter_add_header_struct
-e_mail_formatter_remove_header
-e_mail_formatter_remove_header_struct
e_mail_formatter_format_header
e_mail_formatter_format_text_header
e_mail_formatter_format_address
e_mail_formatter_canon_header_name
e_mail_formatter_find_rfc822_end_iter
e_mail_formatter_parse_html_mnemonics
-e_mail_formatter_header_new
-e_mail_formatter_header_copy
-e_mail_formatter_header_free
<SUBSECTION Standard>
E_MAIL_FORMATTER
E_IS_MAIL_FORMATTER
diff --git a/em-format/e-mail-formatter.c b/em-format/e-mail-formatter.c
index 6e022c1947..4c3c8d0ed1 100644
--- a/em-format/e-mail-formatter.c
+++ b/em-format/e-mail-formatter.c
@@ -51,8 +51,6 @@ struct _EMailFormatterPrivate {
gchar *charset;
gchar *default_charset;
-
- GQueue *header_list;
};
struct _AsyncContext {
@@ -355,12 +353,6 @@ e_mail_formatter_finalize (GObject *object)
g_free (priv->charset);
g_free (priv->default_charset);
- if (priv->header_list) {
- e_mail_formatter_clear_headers (E_MAIL_FORMATTER (object));
- g_queue_free (priv->header_list);
- priv->header_list = NULL;
- }
-
g_mutex_clear (&priv->property_lock);
/* Chain up to parent's finalize() method. */
@@ -767,8 +759,6 @@ e_mail_formatter_init (EMailFormatter *formatter)
formatter->priv = E_MAIL_FORMATTER_GET_PRIVATE (formatter);
g_mutex_init (&formatter->priv->property_lock);
- formatter->priv->header_list = g_queue_new ();
- e_mail_formatter_set_default_headers (formatter);
}
static void
@@ -1438,248 +1428,3 @@ e_mail_formatter_set_default_charset (EMailFormatter *formatter,
g_object_notify (G_OBJECT (formatter), "default-charset");
}
-/* note: also copied in em-mailer-prefs.c */
-static const struct {
- const gchar *name;
- guint32 flags;
-} default_headers[] = {
- { N_("From"), E_MAIL_FORMATTER_HEADER_FLAG_BOLD },
- { N_("Reply-To"), E_MAIL_FORMATTER_HEADER_FLAG_BOLD },
- { N_("To"), E_MAIL_FORMATTER_HEADER_FLAG_BOLD },
- { N_("Cc"), E_MAIL_FORMATTER_HEADER_FLAG_BOLD },
- { N_("Bcc"), E_MAIL_FORMATTER_HEADER_FLAG_BOLD },
- { N_("Subject"), E_MAIL_FORMATTER_HEADER_FLAG_BOLD },
- { N_("Date"), E_MAIL_FORMATTER_HEADER_FLAG_BOLD },
- { N_("Newsgroups"), E_MAIL_FORMATTER_HEADER_FLAG_BOLD },
- { N_("Face"), 0 },
-};
-
-/**
- * e_mail_formatter_dup_headers:
- * @formatter: an #EMailFormatter
- *
- * Returns copy of a list of currently set headers.
- *
- * Returns: (transfer-full): A new #GQueue of currently set headers;
- * the pointer should be freed when no longer needed with command:
- * g_queue_free_full (queue, (GDestroyNotify) e_mail_formatter_header_free);
- */
-GQueue *
-e_mail_formatter_dup_headers (EMailFormatter *formatter)
-{
- GQueue *header_list;
- GList *head, *link;
-
- g_return_val_if_fail (E_IS_MAIL_FORMATTER (formatter), NULL);
-
- g_mutex_lock (&formatter->priv->property_lock);
-
- header_list = g_queue_new ();
-
- head = g_queue_peek_head_link (formatter->priv->header_list);
-
- for (link = head; link != NULL; link = g_list_next (link)) {
- const EMailFormatterHeader *header = link->data;
- EMailFormatterHeader *copy;
-
- /* FIXME Need to guarantee this is never NULL. */
- if (header != NULL) {
- copy = e_mail_formatter_header_copy (header);
- g_queue_push_tail (header_list, copy);
- }
- }
-
- g_mutex_unlock (&formatter->priv->property_lock);
-
- return header_list;
-}
-
-/**
- * e_mail_formatter_clear_headers:
- * @formatter: an #EMailFormatter
- *
- * Clear the list of headers to be displayed. This will force all headers to
- * be shown.
- **/
-void
-e_mail_formatter_clear_headers (EMailFormatter *formatter)
-{
- EMailFormatterHeader *header;
-
- g_return_if_fail (E_IS_MAIL_FORMATTER (formatter));
-
- g_mutex_lock (&formatter->priv->property_lock);
-
- while (!g_queue_is_empty (formatter->priv->header_list)) {
- header = g_queue_pop_head (formatter->priv->header_list);
- e_mail_formatter_header_free (header);
- }
-
- g_mutex_unlock (&formatter->priv->property_lock);
-}
-
-/**
- * e_mail_formatter_set_default_headers:
- * @formatter: an #EMailFormatter
- *
- * Clear the list of headers and sets the default ones, e.g. "To", "From", "Cc"
- * "Subject", etc...
- */
-void
-e_mail_formatter_set_default_headers (EMailFormatter *formatter)
-{
- gint ii;
-
- g_return_if_fail (E_IS_MAIL_FORMATTER (formatter));
-
- /* Set the default headers */
- e_mail_formatter_clear_headers (formatter);
- for (ii = 0; ii < G_N_ELEMENTS (default_headers); ii++) {
- e_mail_formatter_add_header (
- formatter, default_headers[ii].name, NULL,
- default_headers[ii].flags);
- }
-}
-
-/**
- * e_mail_formatter_add_header:
- * @formatter:
- * @name: The name of the header, as it will appear during output.
- * @value: Value of the header. Can be %NULL.
- * @flags: a set of #EMailFormatterHeaderFlags to control display attributes.
- *
- * Add a specific header to show. If any headers are set, they will
- * be displayed in the order set by this function. Certain known
- * headers included in this list will be shown using special
- * formatting routines.
- **/
-void
-e_mail_formatter_add_header (EMailFormatter *formatter,
- const gchar *name,
- const gchar *value,
- EMailFormatterHeaderFlags flags)
-{
- EMailFormatterHeader header;
-
- g_return_if_fail (E_IS_MAIL_FORMATTER (formatter));
- g_return_if_fail (name != NULL && *name != '\0');
-
- header.name = (gchar *) name;
- header.value = (gchar *) value;
- header.flags = flags;
-
- e_mail_formatter_add_header_struct (formatter, &header);
-}
-
-void
-e_mail_formatter_add_header_struct (EMailFormatter *formatter,
- const EMailFormatterHeader *header)
-{
- EMailFormatterHeader *copy;
-
- g_return_if_fail (E_IS_MAIL_FORMATTER (formatter));
- g_return_if_fail (header != NULL);
-
- g_mutex_lock (&formatter->priv->property_lock);
-
- copy = e_mail_formatter_header_copy (header);
- g_queue_push_tail (formatter->priv->header_list, copy);
-
- g_mutex_unlock (&formatter->priv->property_lock);
-
- g_signal_emit (formatter, signals[NEED_REDRAW], 0, NULL);
-}
-
-void
-e_mail_formatter_remove_header (EMailFormatter *formatter,
- const gchar *name,
- const gchar *value)
-{
- GQueue trash = G_QUEUE_INIT;
- GList *head, *link;
-
- g_return_if_fail (E_IS_MAIL_FORMATTER (formatter));
- g_return_if_fail (name != NULL && *name != '\0');
-
- g_mutex_lock (&formatter->priv->property_lock);
-
- head = g_queue_peek_head_link (formatter->priv->header_list);
-
- for (link = head; link != NULL; link = g_list_next (link)) {
- EMailFormatterHeader *header = link->data;
-
- if (g_strcmp0 (name, header->name) == 0) {
- if (header->value == NULL || *header->value == '\0') {
- g_queue_push_tail (&trash, link);
- /* do not break */
- } else if (value == NULL || *value == '\0') {
- g_queue_push_tail (&trash, link);
- break;
- } else if (g_strcmp0 (value, header->value) == 0) {
- g_queue_push_tail (&trash, link);
- break;
- }
- }
- }
-
- while (!g_queue_is_empty (&trash)) {
- link = g_queue_pop_head (&trash);
- e_mail_formatter_header_free (link->data);
- g_queue_delete_link (formatter->priv->header_list, link);
- }
-
- g_mutex_unlock (&formatter->priv->property_lock);
-}
-
-void
-e_mail_formatter_remove_header_struct (EMailFormatter *formatter,
- const EMailFormatterHeader *header)
-{
- g_return_if_fail (E_IS_MAIL_FORMATTER (formatter));
- g_return_if_fail (header != NULL);
-
- e_mail_formatter_remove_header (
- formatter, header->name, header->value);
-}
-
-EMailFormatterHeader *
-e_mail_formatter_header_new (const gchar *name,
- const gchar *value)
-{
- EMailFormatterHeader *header;
-
- g_return_val_if_fail (name != NULL && *name != '\0', NULL);
-
- header = g_new0 (EMailFormatterHeader, 1);
- header->name = g_strdup (name);
- if (value != NULL && *value != '\0')
- header->value = g_strdup (value);
-
- return header;
-}
-
-EMailFormatterHeader *
-e_mail_formatter_header_copy (const EMailFormatterHeader *header)
-{
- EMailFormatterHeader *copy;
-
- g_return_val_if_fail (header != NULL, NULL);
-
- copy = g_new0 (EMailFormatterHeader, 1);
- copy->name = g_strdup (header->name);
- copy->value = g_strdup (header->value);
- copy->flags = header->flags;
-
- return copy;
-}
-
-void
-e_mail_formatter_header_free (EMailFormatterHeader *header)
-{
- g_return_if_fail (header != NULL);
-
- g_free (header->name);
- g_free (header->value);
-
- g_free (header);
-}
diff --git a/em-format/e-mail-formatter.h b/em-format/e-mail-formatter.h
index ce20c4674d..9405789b72 100644
--- a/em-format/e-mail-formatter.h
+++ b/em-format/e-mail-formatter.h
@@ -50,15 +50,8 @@ G_BEGIN_DECLS;
typedef struct _EMailFormatter EMailFormatter;
typedef struct _EMailFormatterClass EMailFormatterClass;
typedef struct _EMailFormatterPrivate EMailFormatterPrivate;
-typedef struct _EMailFormatterHeader EMailFormatterHeader;
typedef struct _EMailFormatterContext EMailFormatterContext;
-struct _EMailFormatterHeader {
- EMailFormatterHeaderFlags flags;
- gchar *name;
- gchar *value;
-};
-
struct _EMailFormatterContext {
EMailPartList *part_list;
EMailFormatterMode mode;
@@ -194,37 +187,6 @@ void e_mail_formatter_set_default_charset
(EMailFormatter *formatter,
const gchar *charset);
-GQueue * e_mail_formatter_dup_headers (EMailFormatter *formatter);
-
-void e_mail_formatter_clear_headers (EMailFormatter *formatter);
-
-void e_mail_formatter_set_default_headers
- (EMailFormatter *formatter);
-
-void e_mail_formatter_add_header (EMailFormatter *formatter,
- const gchar *name,
- const gchar *value,
- EMailFormatterHeaderFlags flags);
-
-void e_mail_formatter_add_header_struct
- (EMailFormatter *formatter,
- const EMailFormatterHeader *header);
-
-void e_mail_formatter_remove_header (EMailFormatter *formatter,
- const gchar *name,
- const gchar *value);
-
-void e_mail_formatter_remove_header_struct
- (EMailFormatter *formatter,
- const EMailFormatterHeader *header);
-
-EMailFormatterHeader *
- e_mail_formatter_header_new (const gchar *name,
- const gchar *value);
-EMailFormatterHeader *
- e_mail_formatter_header_copy (const EMailFormatterHeader *header);
-void e_mail_formatter_header_free (EMailFormatterHeader *header);
-
G_END_DECLS
#endif /* E_MAIL_FORMATTER_H_ */
diff --git a/modules/settings/e-settings-mail-formatter.c b/modules/settings/e-settings-mail-formatter.c
index 2c3b4697fc..fb80b317b5 100644
--- a/modules/settings/e-settings-mail-formatter.c
+++ b/modules/settings/e-settings-mail-formatter.c
@@ -26,15 +26,6 @@
#include <em-format/e-mail-formatter.h>
#include <mail/e-mail-reader-utils.h>
-#define E_SETTINGS_MAIL_FORMATTER_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_SETTINGS_MAIL_FORMATTER, ESettingsMailFormatterPrivate))
-
-struct _ESettingsMailFormatterPrivate {
- GSettings *settings;
- gulong headers_changed_id;
-};
-
G_DEFINE_DYNAMIC_TYPE (
ESettingsMailFormatter,
e_settings_mail_formatter,
@@ -69,59 +60,6 @@ settings_mail_formatter_map_string_to_rgba (GValue *value,
}
static void
-settings_mail_formatter_headers_changed_cb (GSettings *settings,
- const gchar *key,
- ESettingsMailFormatter *extension)
-{
- EMailFormatter *formatter;
- GVariant *variant;
- gsize ii, n_children;
-
- formatter = settings_mail_formatter_get_extensible (extension);
- e_mail_formatter_clear_headers (formatter);
-
- variant = g_settings_get_value (settings, "show-headers");
- n_children = g_variant_n_children (variant);
-
- for (ii = 0; ii < n_children; ii++) {
- const gchar *name = NULL;
- gboolean enabled = FALSE;
-
- g_variant_get_child (variant, ii, "(&sb)", &name, &enabled);
- if (name != NULL && enabled)
- e_mail_formatter_add_header (
- formatter, name, NULL,
- E_MAIL_FORMATTER_HEADER_FLAG_BOLD);
- }
-
- if (n_children == 0)
- e_mail_formatter_set_default_headers (formatter);
-
- g_variant_unref (variant);
-}
-
-static void
-settings_mail_formatter_dispose (GObject *object)
-{
- ESettingsMailFormatterPrivate *priv;
-
- priv = E_SETTINGS_MAIL_FORMATTER_GET_PRIVATE (object);
-
- if (priv->headers_changed_id > 0) {
- g_signal_handler_disconnect (
- priv->settings,
- priv->headers_changed_id);
- priv->headers_changed_id = 0;
- }
-
- g_clear_object (&priv->settings);
-
- /* Chain up to parent's dispose() method. */
- G_OBJECT_CLASS (e_settings_mail_formatter_parent_class)->
- dispose (object);
-}
-
-static void
settings_mail_formatter_constructed (GObject *object)
{
ESettingsMailFormatter *extension;
@@ -131,7 +69,7 @@ settings_mail_formatter_constructed (GObject *object)
extension = E_SETTINGS_MAIL_FORMATTER (object);
formatter = settings_mail_formatter_get_extensible (extension);
- settings = extension->priv->settings;
+ settings = g_settings_new ("org.gnome.evolution.mail");
g_settings_bind_with_mapping (
settings, "citation-color",
@@ -166,14 +104,7 @@ settings_mail_formatter_constructed (GObject *object)
formatter, "animate-images",
G_SETTINGS_BIND_GET);
- extension->priv->headers_changed_id = g_signal_connect (
- extension->priv->settings, "changed::headers",
- G_CALLBACK (settings_mail_formatter_headers_changed_cb),
- extension);
-
- /* Initial synchronization */
- settings_mail_formatter_headers_changed_cb (
- extension->priv->settings, NULL, extension);
+ g_object_unref (settings);
/* Chain up to parent's constructed() method. */
G_OBJECT_CLASS (e_settings_mail_formatter_parent_class)->
@@ -186,11 +117,7 @@ e_settings_mail_formatter_class_init (ESettingsMailFormatterClass *class)
GObjectClass *object_class;
EExtensionClass *extension_class;
- g_type_class_add_private (
- class, sizeof (ESettingsMailFormatterPrivate));
-
object_class = G_OBJECT_CLASS (class);
- object_class->dispose = settings_mail_formatter_dispose;
object_class->constructed = settings_mail_formatter_constructed;
extension_class = E_EXTENSION_CLASS (class);
@@ -205,12 +132,6 @@ e_settings_mail_formatter_class_finalize (ESettingsMailFormatterClass *class)
static void
e_settings_mail_formatter_init (ESettingsMailFormatter *extension)
{
- GSettings *settings;
-
- extension->priv = E_SETTINGS_MAIL_FORMATTER_GET_PRIVATE (extension);
-
- settings = g_settings_new ("org.gnome.evolution.mail");
- extension->priv->settings = settings;
}
void