aboutsummaryrefslogtreecommitdiffstats
path: root/em-format
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2012-12-05 03:38:07 +0800
committerMatthew Barnes <mbarnes@redhat.com>2012-12-08 03:01:04 +0800
commitaebf88cc8e3f45f8603a4706877dc59706be4963 (patch)
tree41680ddd1e7df71f0744a9fa780a572346552e07 /em-format
parent4f505b27728bdf817f849cc698130875f205201f (diff)
downloadgsoc2013-evolution-aebf88cc8e3f45f8603a4706877dc59706be4963.tar.gz
gsoc2013-evolution-aebf88cc8e3f45f8603a4706877dc59706be4963.tar.zst
gsoc2013-evolution-aebf88cc8e3f45f8603a4706877dc59706be4963.zip
EMailFormatter: Class method rearrangement.
Diffstat (limited to 'em-format')
-rw-r--r--em-format/e-mail-formatter.c312
1 files changed, 156 insertions, 156 deletions
diff --git a/em-format/e-mail-formatter.c b/em-format/e-mail-formatter.c
index 9ac8cf7678..656e08d5d7 100644
--- a/em-format/e-mail-formatter.c
+++ b/em-format/e-mail-formatter.c
@@ -79,106 +79,6 @@ enum {
static gint signals[LAST_SIGNAL];
-static void
-mail_formatter_run (EMailFormatter *formatter,
- EMailFormatterContext *context,
- CamelStream *stream,
- GCancellable *cancellable)
-{
- GSList *iter;
- gchar *hdr;
-
- hdr = e_mail_formatter_get_html_header (formatter);
- camel_stream_write_string (stream, hdr, cancellable, NULL);
- g_free (hdr);
-
- for (iter = context->parts; iter; iter = iter->next) {
-
- EMailPart *part;
- gboolean ok;
-
- if (g_cancellable_is_cancelled (cancellable))
- break;
-
- part = iter->data;
- if (!part)
- continue;
-
- if (part->is_hidden && !part->is_error) {
- if (g_str_has_suffix (part->id, ".rfc822")) {
- iter = e_mail_formatter_find_rfc822_end_iter (iter);
- }
-
- if (!iter)
- break;
-
- continue;
- }
-
- /* Force formatting as source if needed */
- if (context->mode != E_MAIL_FORMATTER_MODE_SOURCE) {
-
- if (!part->mime_type)
- continue;
-
- ok = e_mail_formatter_format_as (
- formatter, context, part, stream,
- part->mime_type, cancellable);
-
- /* If the written part was message/rfc822 then
- * jump to the end of the message, because content
- * of the whole message has been formatted by
- * message_rfc822 formatter */
- if (ok && g_str_has_suffix (part->id, ".rfc822")) {
- iter = e_mail_formatter_find_rfc822_end_iter (iter);
-
- if (!iter)
- break;
-
- continue;
- }
-
- } else {
- ok = FALSE;
- }
-
- if (!ok) {
- /* We don't want to source these */
- if (g_str_has_suffix (part->id, ".headers") ||
- g_str_has_suffix (part->id, "attachment-bar"))
- continue;
-
- e_mail_formatter_format_as (
- formatter, context, part, stream,
- "application/vnd.evolution.source", cancellable);
-
- /* .message is the entire message. There's nothing more
- * to be written. */
- if (g_strcmp0 (part->id, ".message") == 0)
- break;
-
- /* If we just wrote source of a rfc822 message, then jump
- * behind the message (otherwise source of all parts
- * would be rendered twice) */
- if (g_str_has_suffix (part->id, ".rfc822")) {
-
- do {
- part = iter->data;
- if (part && g_str_has_suffix (part->id, ".rfc822.end"))
- break;
-
- iter = iter->next;
- } while (iter);
-
- if (!iter)
- break;
- }
- }
- }
-
- camel_stream_write_string (stream, "</body></html>", cancellable, NULL);
-}
-
static EMailFormatterContext *
mail_formatter_create_context (EMailFormatter *formatter)
{
@@ -216,39 +116,6 @@ mail_formatter_free_context (EMailFormatter *formatter,
}
static void
-mail_formatter_set_style (EMailFormatter *formatter,
- GtkStyle *style,
- GtkStateType state)
-{
- GdkColor *color;
- EMailFormatterColorType type;
-
- g_object_freeze_notify (G_OBJECT (formatter));
-
- color = &style->bg[state];
- type = E_MAIL_FORMATTER_COLOR_BODY;
- e_mail_formatter_set_color (formatter, type, color);
-
- color = &style->base[GTK_STATE_NORMAL];
- type = E_MAIL_FORMATTER_COLOR_CONTENT;
- e_mail_formatter_set_color (formatter, type, color);
-
- color = &style->dark[state];
- type = E_MAIL_FORMATTER_COLOR_FRAME;
- e_mail_formatter_set_color (formatter, type, color);
-
- color = &style->fg[state];
- type = E_MAIL_FORMATTER_COLOR_HEADER;
- e_mail_formatter_set_color (formatter, type, color);
-
- color = &style->text[state];
- type = E_MAIL_FORMATTER_COLOR_TEXT;
- e_mail_formatter_set_color (formatter, type, color);
-
- g_object_thaw_notify (G_OBJECT (formatter));
-}
-
-static void
e_mail_formatter_set_property (GObject *object,
guint property_id,
const GValue *value,
@@ -465,15 +332,6 @@ e_mail_formatter_get_property (GObject *object,
}
static void
-e_mail_formatter_init (EMailFormatter *formatter)
-{
- formatter->priv = E_MAIL_FORMATTER_GET_PRIVATE (formatter);
-
- formatter->priv->header_list = g_queue_new ();
- e_mail_formatter_set_default_headers (formatter);
-}
-
-static void
e_mail_formatter_finalize (GObject *object)
{
EMailFormatterPrivate *priv;
@@ -501,6 +359,147 @@ e_mail_formatter_finalize (GObject *object)
}
static void
+e_mail_formatter_constructed (GObject *object)
+{
+ G_OBJECT_CLASS (e_mail_formatter_parent_class)->constructed (object);
+
+ e_extensible_load_extensions (E_EXTENSIBLE (object));
+}
+
+static void
+mail_formatter_run (EMailFormatter *formatter,
+ EMailFormatterContext *context,
+ CamelStream *stream,
+ GCancellable *cancellable)
+{
+ GSList *iter;
+ gchar *hdr;
+
+ hdr = e_mail_formatter_get_html_header (formatter);
+ camel_stream_write_string (stream, hdr, cancellable, NULL);
+ g_free (hdr);
+
+ for (iter = context->parts; iter; iter = iter->next) {
+
+ EMailPart *part;
+ gboolean ok;
+
+ if (g_cancellable_is_cancelled (cancellable))
+ break;
+
+ part = iter->data;
+ if (!part)
+ continue;
+
+ if (part->is_hidden && !part->is_error) {
+ if (g_str_has_suffix (part->id, ".rfc822")) {
+ iter = e_mail_formatter_find_rfc822_end_iter (iter);
+ }
+
+ if (!iter)
+ break;
+
+ continue;
+ }
+
+ /* Force formatting as source if needed */
+ if (context->mode != E_MAIL_FORMATTER_MODE_SOURCE) {
+
+ if (!part->mime_type)
+ continue;
+
+ ok = e_mail_formatter_format_as (
+ formatter, context, part, stream,
+ part->mime_type, cancellable);
+
+ /* If the written part was message/rfc822 then
+ * jump to the end of the message, because content
+ * of the whole message has been formatted by
+ * message_rfc822 formatter */
+ if (ok && g_str_has_suffix (part->id, ".rfc822")) {
+ iter = e_mail_formatter_find_rfc822_end_iter (iter);
+
+ if (!iter)
+ break;
+
+ continue;
+ }
+
+ } else {
+ ok = FALSE;
+ }
+
+ if (!ok) {
+ /* We don't want to source these */
+ if (g_str_has_suffix (part->id, ".headers") ||
+ g_str_has_suffix (part->id, "attachment-bar"))
+ continue;
+
+ e_mail_formatter_format_as (
+ formatter, context, part, stream,
+ "application/vnd.evolution.source", cancellable);
+
+ /* .message is the entire message. There's nothing more
+ * to be written. */
+ if (g_strcmp0 (part->id, ".message") == 0)
+ break;
+
+ /* If we just wrote source of a rfc822 message, then jump
+ * behind the message (otherwise source of all parts
+ * would be rendered twice) */
+ if (g_str_has_suffix (part->id, ".rfc822")) {
+
+ do {
+ part = iter->data;
+ if (part && g_str_has_suffix (part->id, ".rfc822.end"))
+ break;
+
+ iter = iter->next;
+ } while (iter);
+
+ if (!iter)
+ break;
+ }
+ }
+ }
+
+ camel_stream_write_string (stream, "</body></html>", cancellable, NULL);
+}
+
+static void
+mail_formatter_set_style (EMailFormatter *formatter,
+ GtkStyle *style,
+ GtkStateType state)
+{
+ GdkColor *color;
+ EMailFormatterColorType type;
+
+ g_object_freeze_notify (G_OBJECT (formatter));
+
+ color = &style->bg[state];
+ type = E_MAIL_FORMATTER_COLOR_BODY;
+ e_mail_formatter_set_color (formatter, type, color);
+
+ color = &style->base[GTK_STATE_NORMAL];
+ type = E_MAIL_FORMATTER_COLOR_CONTENT;
+ e_mail_formatter_set_color (formatter, type, color);
+
+ color = &style->dark[state];
+ type = E_MAIL_FORMATTER_COLOR_FRAME;
+ e_mail_formatter_set_color (formatter, type, color);
+
+ color = &style->fg[state];
+ type = E_MAIL_FORMATTER_COLOR_HEADER;
+ e_mail_formatter_set_color (formatter, type, color);
+
+ color = &style->text[state];
+ type = E_MAIL_FORMATTER_COLOR_TEXT;
+ e_mail_formatter_set_color (formatter, type, color);
+
+ g_object_thaw_notify (G_OBJECT (formatter));
+}
+
+static void
e_mail_formatter_base_init (EMailFormatterClass *class)
{
class->extension_registry = g_object_new (
@@ -527,14 +526,6 @@ e_mail_formatter_base_finalize (EMailFormatterClass *class)
}
static void
-e_mail_formatter_constructed (GObject *object)
-{
- G_OBJECT_CLASS (e_mail_formatter_parent_class)->constructed (object);
-
- e_extensible_load_extensions (E_EXTENSIBLE (object));
-}
-
-static void
e_mail_formatter_class_init (EMailFormatterClass *class)
{
GObjectClass *object_class;
@@ -543,6 +534,12 @@ e_mail_formatter_class_init (EMailFormatterClass *class)
e_mail_formatter_parent_class = g_type_class_peek_parent (class);
g_type_class_add_private (class, sizeof (EMailFormatterPrivate));
+ object_class = G_OBJECT_CLASS (class);
+ object_class->set_property = e_mail_formatter_set_property;
+ object_class->get_property = e_mail_formatter_get_property;
+ object_class->finalize = e_mail_formatter_finalize;
+ object_class->constructed = e_mail_formatter_constructed;
+
class->run = mail_formatter_run;
/* EMailFormatter calls these directly */
@@ -565,12 +562,6 @@ e_mail_formatter_class_init (EMailFormatterClass *class)
color = &class->colors[E_MAIL_FORMATTER_COLOR_TEXT];
gdk_color_parse ("#000000", color);
- object_class = G_OBJECT_CLASS (class);
- object_class->constructed = e_mail_formatter_constructed;
- object_class->get_property = e_mail_formatter_get_property;
- object_class->set_property = e_mail_formatter_set_property;
- object_class->finalize = e_mail_formatter_finalize;
-
g_object_class_install_property (
object_class,
PROP_BODY_COLOR,
@@ -729,6 +720,15 @@ e_mail_formatter_class_init (EMailFormatterClass *class)
}
static void
+e_mail_formatter_init (EMailFormatter *formatter)
+{
+ formatter->priv = E_MAIL_FORMATTER_GET_PRIVATE (formatter);
+
+ formatter->priv->header_list = g_queue_new ();
+ e_mail_formatter_set_default_headers (formatter);
+}
+
+static void
e_mail_formatter_extensible_interface_init (EExtensibleInterface *interface)
{