aboutsummaryrefslogtreecommitdiffstats
path: root/mail/em-format-hook.c
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2011-11-21 22:51:03 +0800
committerMatthew Barnes <mbarnes@redhat.com>2011-11-22 13:12:36 +0800
commitf9ffebc2f7a6fb285e686133dcccf17766c2ba79 (patch)
tree3f569321ed8d54f2579c151d64600d1e3738590c /mail/em-format-hook.c
parent6f3b2df27f1bcd71880879bf8236663b72002086 (diff)
downloadgsoc2013-evolution-f9ffebc2f7a6fb285e686133dcccf17766c2ba79.tar
gsoc2013-evolution-f9ffebc2f7a6fb285e686133dcccf17766c2ba79.tar.gz
gsoc2013-evolution-f9ffebc2f7a6fb285e686133dcccf17766c2ba79.tar.bz2
gsoc2013-evolution-f9ffebc2f7a6fb285e686133dcccf17766c2ba79.tar.lz
gsoc2013-evolution-f9ffebc2f7a6fb285e686133dcccf17766c2ba79.tar.xz
gsoc2013-evolution-f9ffebc2f7a6fb285e686133dcccf17766c2ba79.tar.zst
gsoc2013-evolution-f9ffebc2f7a6fb285e686133dcccf17766c2ba79.zip
Mail widget cleanups.
Diffstat (limited to 'mail/em-format-hook.c')
-rw-r--r--mail/em-format-hook.c76
1 files changed, 31 insertions, 45 deletions
diff --git a/mail/em-format-hook.c b/mail/em-format-hook.c
index 51608ca07d..7777914577 100644
--- a/mail/em-format-hook.c
+++ b/mail/em-format-hook.c
@@ -31,7 +31,7 @@
#include <glib/gi18n.h>
-/* class name -> klass map for EMFormat and subclasses */
+/* class name -> class map for EMFormat and subclasses */
static GHashTable *emfh_types;
/* ********************************************************************** */
@@ -48,7 +48,6 @@ static GHashTable *emfh_types;
* </hook>
*/
-static gpointer emfh_parent_class;
#define emfh ((EMFormatHook *)eph)
#define d(x)
@@ -59,6 +58,8 @@ static const EPluginHookTargetKey emfh_flag_map[] = {
{ NULL }
};
+G_DEFINE_TYPE (EMFormatHook, em_format_hook, E_TYPE_PLUGIN_HOOK)
+
static void
emfh_format_format (EMFormat *md,
CamelStream *stream,
@@ -171,7 +172,7 @@ emfh_construct (EPluginHook *eph,
d(printf("loading format hook\n"));
- if (((EPluginHookClass *) emfh_parent_class)->construct (eph, ep, root) == -1)
+ if (((EPluginHookClass *) em_format_hook_parent_class)->construct (eph, ep, root) == -1)
return -1;
node = root->children;
@@ -181,10 +182,10 @@ emfh_construct (EPluginHook *eph,
group = emfh_construct_group (eph, node);
if (group) {
- EMFormatClass *klass;
+ EMFormatClass *class;
if (emfh_types
- && (klass = g_hash_table_lookup (emfh_types, group->id))) {
+ && (class = g_hash_table_lookup (emfh_types, group->id))) {
GSList *l = group->items;
for (; l; l = g_slist_next (l)) {
@@ -194,7 +195,7 @@ emfh_construct (EPluginHook *eph,
* if we leave as is, then we can enable the
* plugin after startup and it will start
* working automagically */
- em_format_class_add_handler (klass, &item->handler);
+ em_format_class_add_handler (class, &item->handler);
}
}
/* We don't actually need to keep this
@@ -217,7 +218,7 @@ emfh_enable (EPluginHook *eph,
gint state)
{
GSList *g, *l;
- EMFormatClass *klass;
+ EMFormatClass *class;
g = emfh->groups;
if (emfh_types == NULL)
@@ -226,75 +227,60 @@ emfh_enable (EPluginHook *eph,
for (; g; g = g_slist_next (g)) {
struct _EMFormatHookGroup *group = g->data;
- klass = g_hash_table_lookup (emfh_types, group->id);
+ class = g_hash_table_lookup (emfh_types, group->id);
for (l = group->items; l; l = g_slist_next (l)) {
EMFormatHookItem *item = l->data;
if (state)
- em_format_class_add_handler (klass, &item->handler);
+ em_format_class_add_handler (class, &item->handler);
else
- em_format_class_remove_handler (klass, &item->handler);
+ em_format_class_remove_handler (class, &item->handler);
}
}
}
static void
-emfh_finalize (GObject *o)
+format_hook_finalize (GObject *object)
{
- EPluginHook *eph = (EPluginHook *) o;
+ EPluginHook *eph = (EPluginHook *) object;
g_slist_foreach (emfh->groups, (GFunc) emfh_free_group, NULL);
g_slist_free (emfh->groups);
- ((GObjectClass *) emfh_parent_class)->finalize (o);
+ /* Chain up to parent's finalize() method. */
+ G_OBJECT_CLASS (em_format_hook_parent_class)->finalize (object);
}
static void
-emfh_class_init (EPluginHookClass *klass)
+em_format_hook_class_init (EMFormatHookClass *class)
{
- ((GObjectClass *) klass)->finalize = emfh_finalize;
- klass->construct = emfh_construct;
- klass->enable = emfh_enable;
- klass->id = "org.gnome.evolution.mail.format:1.0";
-}
+ GObjectClass *object_class;
+ EPluginHookClass *hook_class;
-GType
-em_format_hook_get_type (void)
-{
- static GType type = 0;
-
- if (!type) {
- static const GTypeInfo info = {
- sizeof (EMFormatHookClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) emfh_class_init,
- (GClassFinalizeFunc) NULL,
- NULL, /* class_data */
- sizeof (EMFormatHook),
- 0, /* n_preallocs */
- (GInstanceInitFunc) NULL,
- NULL /* value_table */
- };
+ object_class = G_OBJECT_CLASS (class);
+ object_class->finalize = format_hook_finalize;
- emfh_parent_class = g_type_class_ref (E_TYPE_PLUGIN_HOOK);
- type = g_type_register_static (
- E_TYPE_PLUGIN_HOOK, "EMFormatHook", &info, 0);
- }
+ hook_class = E_PLUGIN_HOOK_CLASS (class);
+ hook_class->construct = emfh_construct;
+ hook_class->enable = emfh_enable;
+ hook_class->id = "org.gnome.evolution.mail.format:1.0";
+}
- return type;
+static void
+em_format_hook_init (EMFormatHook *hook)
+{
}
void
em_format_hook_register_type (GType type)
{
- EMFormatClass *klass;
+ EMFormatClass *class;
if (emfh_types == NULL)
emfh_types = g_hash_table_new (g_str_hash, g_str_equal);
d(printf("registering formatter type '%s'\n", g_type_name(type)));
- klass = g_type_class_ref (type);
- g_hash_table_insert (emfh_types, (gpointer) g_type_name (type), klass);
+ class = g_type_class_ref (type);
+ g_hash_table_insert (emfh_types, (gpointer) g_type_name (type), class);
}