aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@src.gnome.org>2009-04-15 02:32:57 +0800
committerMatthew Barnes <mbarnes@src.gnome.org>2009-04-15 02:32:57 +0800
commit4279d2042844fddc4429b8690a550778740222e3 (patch)
treea035b753a0eab170f5354dcfdfea21f7b74fc2c2 /mail
parent942cdf2df9091e347e09c25d62015e77775f38b6 (diff)
downloadgsoc2013-evolution-4279d2042844fddc4429b8690a550778740222e3.tar.gz
gsoc2013-evolution-4279d2042844fddc4429b8690a550778740222e3.tar.zst
gsoc2013-evolution-4279d2042844fddc4429b8690a550778740222e3.zip
Commit some code cleanups that I want to keep separate.
svn path=/branches/kill-bonobo/; revision=37522
Diffstat (limited to 'mail')
-rw-r--r--mail/em-format-html-print.c20
-rw-r--r--mail/em-format-html-print.h44
-rw-r--r--mail/em-format-quote.c76
-rw-r--r--mail/em-format-quote.h44
-rw-r--r--mail/em-format.c34
5 files changed, 142 insertions, 76 deletions
diff --git a/mail/em-format-html-print.c b/mail/em-format-html-print.c
index 28767d216d..137711dbb7 100644
--- a/mail/em-format-html-print.c
+++ b/mail/em-format-html-print.c
@@ -38,22 +38,27 @@
static gpointer parent_class = NULL;
static void
-efhp_finalize (GObject *o)
+efhp_finalize (GObject *object)
{
- EMFormatHTMLPrint *efhp = (EMFormatHTMLPrint *)o;
+ EMFormatHTMLPrint *efhp = (EMFormatHTMLPrint *)object;
gtk_widget_destroy (efhp->window);
if (efhp->source != NULL)
g_object_unref (efhp->source);
- ((GObjectClass *) parent_class)->finalize (o);
+ /* Chain up to parent's finalize() method. */
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
-efhp_class_init (GObjectClass *class)
+efhp_class_init (EMFormatHTMLPrintClass *class)
{
+ GObjectClass *object_class;
+
parent_class = g_type_class_peek_parent (class);
- class->finalize = efhp_finalize;
+
+ object_class = G_OBJECT_CLASS (class);
+ object_class->finalize = efhp_finalize;
}
static void
@@ -93,7 +98,7 @@ em_format_html_print_get_type (void)
};
type = g_type_register_static (
- em_format_html_get_type (), "EMFormatHTMLPrint",
+ EM_TYPE_FORMAT_HTML, "EMFormatHTMLPrint",
&type_info, 0);
}
@@ -101,7 +106,8 @@ em_format_html_print_get_type (void)
}
EMFormatHTMLPrint *
-em_format_html_print_new (EMFormatHTML *source, GtkPrintOperationAction action)
+em_format_html_print_new (EMFormatHTML *source,
+ GtkPrintOperationAction action)
{
EMFormatHTMLPrint *efhp;
diff --git a/mail/em-format-html-print.h b/mail/em-format-html-print.h
index e308b065fa..ef25b63033 100644
--- a/mail/em-format-html-print.h
+++ b/mail/em-format-html-print.h
@@ -16,13 +16,32 @@
*
* Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
*/
-#ifndef _EM_FORMAT_HTML_PRINT_H
-#define _EM_FORMAT_HTML_PRINT_H
+
+#ifndef EM_FORMAT_HTML_PRINT_H
+#define EM_FORMAT_HTML_PRINT_H
#include "mail/em-format-html.h"
+/* Standard GObject macros */
#define EM_TYPE_FORMAT_HTML_PRINT \
(em_format_html_print_get_type ())
+#define EM_FORMAT_HTML_PRINT(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), EM_TYPE_FORMAT_HTML_PRINT, EMFormatHTMLPrint))
+#define EM_FORMAT_HTML_PRINT_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), EM_TYPE_FORMAT_HTML_PRINT, EMFormatHTMLPrintClass))
+#define EM_IS_FORMAT_HTML_PRINT(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), EM_TYPE_FORMAT_HTML_PRINT))
+#define EM_IS_FORMAT_HTML_PRINT_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), EM_TYPE_FORMAT_HTML_PRINT))
+#define EM_FORMAT_HTML_PRINT_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), EM_TYPE_FORMAT_HTML_PRINT, EMFormatHTMLPrintClass))
+
+G_BEGIN_DECLS
typedef struct _EMFormatHTMLPrint EMFormatHTMLPrint;
typedef struct _EMFormatHTMLPrintClass EMFormatHTMLPrintClass;
@@ -40,13 +59,16 @@ struct _EMFormatHTMLPrintClass {
EMFormatHTMLClass parent_class;
};
-GType em_format_html_print_get_type (void);
-EMFormatHTMLPrint * em_format_html_print_new (EMFormatHTML *source,
- GtkPrintOperationAction action);
-void em_format_html_print_message (EMFormatHTMLPrint *efhp,
- CamelFolder *folder,
- const char *uid);
-void em_format_html_print_raw_message (EMFormatHTMLPrint *efhp,
- CamelMimeMessage *msg);
+GType em_format_html_print_get_type (void);
+EMFormatHTMLPrint *
+ em_format_html_print_new (EMFormatHTML *source,
+ GtkPrintOperationAction action);
+void em_format_html_print_message (EMFormatHTMLPrint *efhp,
+ CamelFolder *folder,
+ const gchar *uid);
+void em_format_html_print_raw_message(EMFormatHTMLPrint *efhp,
+ CamelMimeMessage *msg);
+
+G_END_DECLS
-#endif /* ! _EM_FORMAT_HTML_PRINT_H */
+#endif /* EM_FORMAT_HTML_PRINT_H */
diff --git a/mail/em-format-quote.c b/mail/em-format-quote.c
index 49c546863a..43c7e2e55c 100644
--- a/mail/em-format-quote.c
+++ b/mail/em-format-quote.c
@@ -28,7 +28,6 @@
#include <string.h>
#include <camel/camel-iconv.h>
-#include <camel/camel-stream.h>
#include <camel/camel-stream-filter.h>
#include <camel/camel-mime-filter-tohtml.h>
#include <camel/camel-mime-filter-enriched.h>
@@ -55,82 +54,94 @@ static void emfq_format_attachment(EMFormat *, CamelStream *, CamelMimePart *, c
static void emfq_builtin_init(EMFormatQuoteClass *efhc);
-static EMFormatClass *emfq_parent;
+static gpointer parent_class;
static void
emfq_init(GObject *o)
{
EMFormatQuote *emfq =(EMFormatQuote *) o;
- emfq->priv = g_malloc0(sizeof(*emfq->priv));
-
/* we want to convert url's etc */
emfq->text_html_flags = CAMEL_MIME_FILTER_TOHTML_PRE | CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS
| CAMEL_MIME_FILTER_TOHTML_CONVERT_ADDRESSES;
}
static void
-emfq_finalise(GObject *o)
+emfq_finalize (GObject *object)
{
- EMFormatQuote *emfq =(EMFormatQuote *) o;
+ EMFormatQuote *emfq =(EMFormatQuote *) object;
if (emfq->stream)
camel_object_unref(emfq->stream);
g_free(emfq->credits);
- g_free(emfq->priv);
- ((GObjectClass *) emfq_parent)->finalize(o);
+ /* Chain up to parent's finalize() method. */
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
-emfq_base_init(EMFormatQuoteClass *emfqklass)
+emfq_base_init(EMFormatQuoteClass *emfqclass)
{
- emfq_builtin_init(emfqklass);
+ emfq_builtin_init(emfqclass);
}
static void
-emfq_class_init(GObjectClass *klass)
+emfq_class_init (EMFormatQuoteClass *class)
{
- ((EMFormatClass *) klass)->format_clone = emfq_format_clone;
- ((EMFormatClass *) klass)->format_error = emfq_format_error;
- ((EMFormatClass *) klass)->format_source = emfq_format_source;
- ((EMFormatClass *) klass)->format_attachment = emfq_format_attachment;
+ GObjectClass *object_class;
+ EMFormatClass *format_class;
+
+ parent_class = g_type_class_peek_parent (class);
+ g_type_class_add_private (class, sizeof (EMFormatQuotePrivate));
+
+ object_class = G_OBJECT_CLASS (class);
+ object_class->finalize = emfq_finalize;
- klass->finalize = emfq_finalise;
+ format_class = EM_FORMAT_CLASS (class);
+ format_class->format_clone = emfq_format_clone;
+ format_class->format_error = emfq_format_error;
+ format_class->format_source = emfq_format_source;
+ format_class->format_attachment = emfq_format_attachment;
}
GType
-em_format_quote_get_type(void)
+em_format_quote_get_type (void)
{
static GType type = 0;
- if (type == 0) {
- static const GTypeInfo info = {
- sizeof(EMFormatQuoteClass),
- (GBaseInitFunc)emfq_base_init, NULL,
- (GClassInitFunc)emfq_class_init,
- NULL, NULL,
- sizeof(EMFormatQuote), 0,
- (GInstanceInitFunc) emfq_init
+ if (G_UNLIKELY (type == 0)) {
+ static const GTypeInfo type_info = {
+ sizeof (EMFormatQuoteClass),
+ (GBaseInitFunc) emfq_base_init,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) emfq_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL, /* class_data */
+ sizeof (EMFormatQuote),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) emfq_init,
+ NULL /* value_table */
};
- emfq_parent = g_type_class_ref(em_format_get_type());
- type = g_type_register_static(em_format_get_type(), "EMFormatQuote", &info, 0);
+ type = g_type_register_static (
+ EM_TYPE_FORMAT, "EMFormatQuote", &type_info, 0);
}
return type;
}
EMFormatQuote *
-em_format_quote_new(const char *credits, CamelStream *stream, guint32 flags)
+em_format_quote_new (const gchar *credits,
+ CamelStream *stream,
+ guint32 flags)
{
EMFormatQuote *emfq;
- emfq = (EMFormatQuote *)g_object_new(em_format_quote_get_type(), NULL);
+ emfq = g_object_new (EM_TYPE_FORMAT_QUOTE, NULL);
- emfq->credits = g_strdup(credits);
+ emfq->credits = g_strdup (credits);
emfq->stream = stream;
- camel_object_ref(stream);
+ camel_object_ref (stream);
emfq->flags = flags;
return emfq;
@@ -148,7 +159,8 @@ emfq_format_clone(EMFormat *emf, CamelFolder *folder, const char *uid, CamelMime
EMFormatQuote *emfq = (EMFormatQuote *) emf;
const EMFormatHandler *handle;
- ((EMFormatClass *)emfq_parent)->format_clone(emf, folder, uid, msg, src);
+ /* Chain up to parent's format_clone() method. */
+ EM_FORMAT_CLASS (parent_class)->format_clone (emf, folder, uid, msg, src);
camel_stream_reset(emfq->stream);
if (gconf_client_get_bool(mail_config_get_gconf_client(), "/apps/evolution/mail/composer/top_signature", NULL))
diff --git a/mail/em-format-quote.h b/mail/em-format-quote.h
index 6b48fb87b4..87f0151a50 100644
--- a/mail/em-format-quote.h
+++ b/mail/em-format-quote.h
@@ -20,24 +20,47 @@
*
*/
-#ifndef _EM_FORMAT_QUOTE_H
-#define _EM_FORMAT_QUOTE_H
+#ifndef EM_FORMAT_QUOTE_H
+#define EM_FORMAT_QUOTE_H
+#include <camel/camel-stream.h>
#include "mail/em-format.h"
-typedef struct _EMFormatQuote EMFormatQuote;
-typedef struct _EMFormatQuoteClass EMFormatQuoteClass;
+/* Standard GObject macros */
+#define EM_TYPE_FORMAT_QUOTE \
+ (em_format_quote_get_type ())
+#define EM_FORMAT_QUOTE(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), EM_TYPE_FORMAT_QUOTE, EMFormatQuote))
+#define EM_FORMAT_QUOTE_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), EM_TYPE_FORMAT_QUOTE, EMFormatQuoteClass))
+#define EM_IS_FORMAT_QUOTE(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), EM_TYPE_FORMAT_QUOTE))
+#define EM_IS_FORMAT_QUOTE_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), EM_TYPE_FORMAT_QUOTE))
+#define EM_FORMAT_QUOTE_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), EM_TYPE_FORMAT_QUOTE, EMFormatQuoteClass))
#define EM_FORMAT_QUOTE_CITE (1<<0)
#define EM_FORMAT_QUOTE_HEADERS (1<<1)
+G_BEGIN_DECLS
+
+typedef struct _EMFormatQuote EMFormatQuote;
+typedef struct _EMFormatQuoteClass EMFormatQuoteClass;
+typedef struct _EMFormatQuotePrivate EMFormatQuotePrivate;
+
struct _EMFormatQuote {
EMFormat format;
- struct _EMFormatQuotePrivate *priv;
+ EMFormatQuotePrivate *priv;
char *credits;
- struct _CamelStream *stream;
+ CamelStream *stream;
guint32 flags;
guint32 text_html_flags;
@@ -48,8 +71,11 @@ struct _EMFormatQuoteClass {
EMFormatClass format_class;
};
-GType em_format_quote_get_type (void);
+GType em_format_quote_get_type (void);
+EMFormatQuote * em_format_quote_new (const gchar *credits,
+ CamelStream *stream,
+ guint32 flags);
-EMFormatQuote *em_format_quote_new (const char *credits, struct _CamelStream *stream, guint32 flags);
+G_END_DECLS
-#endif /* !_EM_FORMAT_QUOTE_H */
+#endif /* EM_FORMAT_QUOTE_H */
diff --git a/mail/em-format.c b/mail/em-format.c
index 95db7daeec..27c627a185 100644
--- a/mail/em-format.c
+++ b/mail/em-format.c
@@ -111,23 +111,6 @@ emf_insert_cache(EMFormat *emf, const char *partid)
}
static void
-emf_init (EMFormat *emf)
-{
- emf->inline_table = g_hash_table_new_full (
- g_str_hash, g_str_equal,
- (GDestroyNotify) NULL,
- (GDestroyNotify) emf_free_cache);
- emf->composer = FALSE;
- emf->print = FALSE;
- e_dlist_init(&emf->header_list);
- em_format_default_headers(emf);
- emf->part_id = g_string_new("");
-
- emf->session = session;
- camel_object_ref (emf->session);
-}
-
-static void
emf_finalize (GObject *object)
{
EMFormat *emf = EM_FORMAT (object);
@@ -184,6 +167,23 @@ emf_class_init (EMFormatClass *class)
emf_builtin_init (class);
}
+static void
+emf_init (EMFormat *emf)
+{
+ emf->inline_table = g_hash_table_new_full (
+ g_str_hash, g_str_equal,
+ (GDestroyNotify) NULL,
+ (GDestroyNotify) emf_free_cache);
+ emf->composer = FALSE;
+ emf->print = FALSE;
+ e_dlist_init(&emf->header_list);
+ em_format_default_headers(emf);
+ emf->part_id = g_string_new("");
+
+ emf->session = session;
+ camel_object_ref (emf->session);
+}
+
GType
em_format_get_type (void)
{