+2005-11-17 Ross Burton <ross@burtonini.com>
+
+ * libedataserver/e-account-list.c:
+ * libedataserver/e-account.c:
+ * libedataserver/e-component-listener.c:
+ * libedataserver/e-file-cache.c:
+ * libedataserver/e-iterator.c:
+ * libedataserver/e-list-iterator.c:
+ * libedataserver/e-list.c:
+ * libedataserver/e-sexp.c:
+ * libedataserver/e-source-group.c:
+ * libedataserver/e-source-list.c:
+ * libedataserver/e-source.c:
+ Use G_DEFINE_TYPE and add some more const keywords.
+
2005-11-15 Ross Burton <ross@burtonini.com>
* libedataserver/e-data-server-module.c
static guint signals [LAST_SIGNAL] = { 0 };
-#define PARENT_TYPE E_TYPE_LIST
-static EListClass *parent_class = NULL;
-
static void dispose (GObject *);
static void finalize (GObject *);
+G_DEFINE_TYPE (EAccountList, e_account_list, E_TYPE_LIST);
+
static void
-class_init (GObjectClass *object_class)
+e_account_list_class_init (EAccountListClass *klass)
{
- parent_class = g_type_class_ref (PARENT_TYPE);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
/* virtual method override */
object_class->dispose = dispose;
}
static void
-init (GObject *object)
+e_account_list_init (EAccountList *account_list)
{
- EAccountList *account_list = E_ACCOUNT_LIST (object);
-
account_list->priv = g_new0 (EAccountListPrivate, 1);
}
account_list->priv->gconf = NULL;
}
- G_OBJECT_CLASS (parent_class)->dispose (object);
+ G_OBJECT_CLASS (e_account_list_parent_class)->dispose (object);
}
static void
g_free (account_list->priv);
- G_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-GType
-e_account_list_get_type (void)
-{
- static GType type = 0;
-
- if (!type) {
- static GTypeInfo const object_info = {
- sizeof (EAccountListClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) class_init,
- (GClassFinalizeFunc) NULL,
- NULL,
- sizeof (EAccountList),
- 0,
- (GInstanceInitFunc) init
- };
- type = g_type_register_static (PARENT_TYPE, "EAccountList", &object_info, 0);
- }
-
- return type;
+ G_OBJECT_CLASS (e_account_list_parent_class)->finalize (object);
}
static void
#include <libxml/tree.h>
#include <libxml/xmlmemory.h>
-#define PARENT_TYPE G_TYPE_OBJECT
-static GObjectClass *parent_class = NULL;
-
static void finalize (GObject *);
+G_DEFINE_TYPE (EAccount, e_account, G_TYPE_OBJECT);
+
static void
-class_init (GObjectClass *object_class)
+e_account_class_init (EAccountClass *account_class)
{
- parent_class = g_type_class_ref (PARENT_TYPE);
+ GObjectClass *object_class = G_OBJECT_CLASS (account_class);
/* virtual method override */
object_class->finalize = finalize;
}
static void
-init (EAccount *account)
+e_account_init (EAccount *account)
{
account->id = g_new0 (EAccountIdentity, 1);
account->source = g_new0 (EAccountService, 1);
g_free (account->smime_sign_key);
g_free (account->smime_encrypt_key);
- G_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-GType
-e_account_get_type (void)
-{
- static GType type = 0;
-
- if (!type) {
- static GTypeInfo const object_info = {
- sizeof (EAccountClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) class_init,
- (GClassFinalizeFunc) NULL,
- NULL,
- sizeof (EAccount),
- 0,
- (GInstanceInitFunc) init
- };
- type = g_type_register_static (PARENT_TYPE, "EAccount", &object_info, 0);
- }
-
- return type;
+ G_OBJECT_CLASS (e_account_parent_class)->finalize (object);
}
/**
#include <bonobo/bonobo-object.h>
#include "e-component-listener.h"
-#define PARENT_TYPE GTK_TYPE_OBJECT
-
struct _EComponentListenerPrivate {
Bonobo_Unknown component;
};
static void e_component_listener_init (EComponentListener *cl, EComponentListenerClass *klass);
static void e_component_listener_finalize (GObject *object);
-static GObjectClass *parent_class = NULL;
static GList *watched_connections = NULL;
enum {
}
}
+G_DEFINE_TYPE (EComponentListener, e_component_listener, G_TYPE_OBJECT);
+
static void
e_component_listener_class_init (EComponentListenerClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- parent_class = g_type_class_peek_parent (klass);
-
object_class->finalize = e_component_listener_finalize;
klass->component_died = NULL;
g_free (cl->priv);
cl->priv = NULL;
- if (G_OBJECT_CLASS (parent_class)->finalize)
- (* G_OBJECT_CLASS (parent_class)->finalize) (object);
-}
-
-GType
-e_component_listener_get_type (void)
-{
- static GType type = 0;
-
- if (!type) {
- static GTypeInfo info = {
- sizeof (EComponentListenerClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) e_component_listener_class_init,
- NULL, NULL,
- sizeof (EComponentListener),
- 0,
- (GInstanceInitFunc) e_component_listener_init
- };
- type = g_type_register_static (G_TYPE_OBJECT, "EComponentListener", &info, 0);
- }
-
- return type;
+ if (G_OBJECT_CLASS (e_component_listener_parent_class)->finalize)
+ (* G_OBJECT_CLASS (e_component_listener_parent_class)->finalize) (object);
}
/**
PROP_FILENAME
};
-static GObjectClass *parent_class = NULL;
+G_DEFINE_TYPE (EFileCache, e_file_cache, G_TYPE_OBJECT);
static void
e_file_cache_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
cache->priv = NULL;
}
- parent_class->finalize (object);
+ G_OBJECT_CLASS (e_file_cache_parent_class)->finalize (object);
}
static void
{
GObjectClass *object_class;
- parent_class = g_type_class_peek_parent (klass);
-
object_class = G_OBJECT_CLASS (klass);
object_class->finalize = e_file_cache_finalize;
object_class->set_property = e_file_cache_set_property;
}
/**
- * e_file_cache_get_type:
- * @void:
- *
- * Registers the #EFileCache class if necessary, and returns the type ID
- * associated to it.
- *
- * Return value: The type ID of the #EFileCache class.
- **/
-GType
-e_file_cache_get_type (void)
-{
- static GType type = 0;
-
- if (!type) {
- static GTypeInfo info = {
- sizeof (EFileCacheClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) e_file_cache_class_init,
- NULL, NULL,
- sizeof (EFileCache),
- 0,
- (GInstanceInitFunc) e_file_cache_init,
- };
- type = g_type_register_static (G_TYPE_OBJECT, "EFileCache", &info, 0);
- }
-
- return type;
-}
-
-/**
* e_file_cache_new
* @filename: filename where the cache is kept.
*
static void e_iterator_init (EIterator *card);
static void e_iterator_class_init (EIteratorClass *klass);
-#define PARENT_TYPE G_TYPE_OBJECT
-
-static GObjectClass *parent_class;
-
enum {
INVALIDATE,
LAST_SIGNAL
static guint e_iterator_signals [LAST_SIGNAL] = { 0, };
-/**
- * e_iterator_get_type:
- * @void:
- *
- * Registers the &EIterator class if necessary, and returns the type ID
- * associated to it.
- *
- * Return value: The type ID of the &EIterator class.
- **/
-GType
-e_iterator_get_type (void)
-{
- static GType type = 0;
-
- if (! type) {
- GTypeInfo info = {
- sizeof (EIteratorClass),
- NULL, /* base_class_init */
- NULL, /* base_class_finalize */
- (GClassInitFunc) e_iterator_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (EIterator),
- 0, /* n_preallocs */
- (GInstanceInitFunc) e_iterator_init
- };
-
- type = g_type_register_static (PARENT_TYPE, "EIterator", &info, 0);
- }
-
- return type;
-}
+G_DEFINE_TYPE (EIterator, e_iterator, G_TYPE_OBJECT);
static void
e_iterator_class_init (EIteratorClass *klass)
object_class = G_OBJECT_CLASS(klass);
- parent_class = g_type_class_ref (PARENT_TYPE);
-
e_iterator_signals [INVALIDATE] =
g_signal_new ("invalidate",
G_OBJECT_CLASS_TYPE (object_class),
static const void *e_list_iterator_get (EIterator *iterator);
static void e_list_iterator_dispose (GObject *object);
-#define PARENT_TYPE E_TYPE_ITERATOR
-
-static EIteratorClass *parent_class;
-
-/**
- * e_list_iterator_get_type:
- * @void:
- *
- * Registers the &EListIterator class if necessary, and returns the type ID
- * associated to it.
- *
- * Return value: The type ID of the &EListIterator class.
- **/
-GType
-e_list_iterator_get_type (void)
-{
- static GType type = 0;
-
- if (! type) {
- GTypeInfo info = {
- sizeof (EListIteratorClass),
- NULL, /* base_class_init */
- NULL, /* base_class_finalize */
- (GClassInitFunc) e_list_iterator_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (EListIterator),
- 0, /* n_preallocs */
- (GInstanceInitFunc) e_list_iterator_init
- };
-
- type = g_type_register_static (PARENT_TYPE, "EListIterator", &info, 0);
- }
-
- return type;
-}
+G_DEFINE_TYPE(EListIterator, e_list_iterator, E_TYPE_ITERATOR);
static void
e_list_iterator_class_init (EListIteratorClass *klass)
object_class = G_OBJECT_CLASS(klass);
iterator_class = E_ITERATOR_CLASS(klass);
- parent_class = g_type_class_ref (PARENT_TYPE);
-
object_class->dispose = e_list_iterator_dispose;
iterator_class->invalidate = e_list_iterator_invalidate;
iterator_class->is_valid = e_list_iterator_is_valid;
}
-
-
/**
* e_list_iterator_init:
*/
e_list_remove_iterator(iterator->list, E_ITERATOR(iterator));
g_object_unref(iterator->list);
- if (G_OBJECT_CLASS (parent_class)->dispose)
- (* G_OBJECT_CLASS (parent_class)->dispose) (object);
+ if (G_OBJECT_CLASS (e_list_iterator_parent_class)->dispose)
+ (* G_OBJECT_CLASS (e_list_iterator_parent_class)->dispose) (object);
}
static const void *
static void e_list_class_init (EListClass *klass);
static void e_list_dispose (GObject *object);
-static GObjectClass *parent_class;
-
-/**
- * e_list_get_type:
- * @void:
- *
- * Registers the &EList class if necessary, and returns the type ID
- * associated to it.
- *
- * Return value: The type ID of the &EList class.
- **/
-GType
-e_list_get_type (void)
-{
- static GType type = 0;
-
- if (! type) {
- GTypeInfo info = {
- sizeof (EListClass),
- NULL, /* base_class_init */
- NULL, /* base_class_finalize */
- (GClassInitFunc) e_list_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (EList),
- 0, /* n_preallocs */
- (GInstanceInitFunc) e_list_init
- };
-
- type = g_type_register_static (G_TYPE_OBJECT, "EList", &info, 0);
- }
-
- return type;
-}
+G_DEFINE_TYPE (EList, e_list, G_TYPE_OBJECT);
static void
e_list_class_init (EListClass *klass)
object_class = G_OBJECT_CLASS(klass);
- parent_class = g_type_class_ref (G_TYPE_OBJECT);
-
object_class->dispose = e_list_dispose;
}
g_list_foreach(list->list, (GFunc) list->free, list->closure);
g_list_free(list->list);
- (* G_OBJECT_CLASS (parent_class)->dispose) (object);
+ (* G_OBJECT_CLASS (e_list_parent_class)->dispose) (object);
}
static GObjectClass *parent_class;
#endif
-static GScannerConfig scanner_config =
+static const GScannerConfig scanner_config =
{
( " \t\r\n") /* cset_skip_characters */,
( G_CSET_a_2_z
#endif
/* 'builtin' functions */
-static struct {
+static const struct {
char *name;
ESExpFunc *func;
int type; /* set to 1 if a function can perform shortcut evaluation, or
#include "e-uid.h"
#include "e-source-group.h"
-static GObjectClass *parent_class = NULL;
-
/* Private members. */
struct _ESourceGroupPrivate {
/* GObject methods. */
+G_DEFINE_TYPE (ESourceGroup, e_source_group, G_TYPE_OBJECT);
+
static void
impl_dispose (GObject *object)
{
priv->sources = NULL;
}
- (* G_OBJECT_CLASS (parent_class)->dispose) (object);
+ (* G_OBJECT_CLASS (e_source_group_parent_class)->dispose) (object);
}
static void
g_free (priv->base_uri);
g_free (priv);
- (* G_OBJECT_CLASS (parent_class)->finalize) (object);
+ (* G_OBJECT_CLASS (e_source_group_parent_class)->finalize) (object);
}
object_class->dispose = impl_dispose;
object_class->finalize = impl_finalize;
- parent_class = g_type_class_peek_parent (class);
-
signals[CHANGED] =
g_signal_new ("changed",
G_OBJECT_CLASS_TYPE (object_class),
source_group->priv = priv;
}
-GType
-e_source_group_get_type (void)
-{
- static GType e_source_group_type = 0;
-
- if (!e_source_group_type) {
- static GTypeInfo info = {
- sizeof (ESourceGroupClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) e_source_group_class_init,
- NULL, NULL,
- sizeof (ESourceGroup),
- 0,
- (GInstanceInitFunc) e_source_group_init
- };
- e_source_group_type = g_type_register_static (G_TYPE_OBJECT, "ESourceGroup", &info, 0);
- }
-
- return e_source_group_type;
-}
-
/* Public methods. */
ESourceGroup *
#include "e-data-server-marshal.h"
#include "e-source-list.h"
-static GObjectClass *parent_class = NULL;
-
struct _ESourceListPrivate {
GConfClient *gconf_client;
char *gconf_path;
new_groups_hash = g_hash_table_new (g_direct_hash, g_direct_equal);
for (p = conf_list, pos = 0; p != NULL; p = p->next, pos++) {
- const char *xml = p->data;
+ const xmlChar *xml = p->data;
xmlDocPtr xmldoc;
char *group_uid;
ESourceGroup *existing_group;
- xmldoc = xmlParseDoc ((char *) xml);
+ xmldoc = xmlParseDoc (xml);
if (xmldoc == NULL)
continue;
/* GObject methods. */
+G_DEFINE_TYPE (ESourceList, e_source_list, G_TYPE_OBJECT);
+
static void
impl_dispose (GObject *object)
{
priv->gconf_client = NULL;
}
- (* G_OBJECT_CLASS (parent_class)->dispose) (object);
+ (* G_OBJECT_CLASS (e_source_list_parent_class)->dispose) (object);
}
static void
g_free (priv->gconf_path);
g_free (priv);
- (* G_OBJECT_CLASS (parent_class)->finalize) (object);
+ (* G_OBJECT_CLASS (e_source_list_parent_class)->finalize) (object);
}
object_class->dispose = impl_dispose;
object_class->finalize = impl_finalize;
- parent_class = g_type_class_peek_parent (class);
-
signals[CHANGED] =
g_signal_new ("changed",
G_OBJECT_CLASS_TYPE (object_class),
source_list->priv = priv;
}
-GType
-e_source_list_get_type (void)
-{
- static GType e_source_list_type = 0;
-
- if (!e_source_list_type) {
- static GTypeInfo info = {
- sizeof (ESourceListClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) e_source_list_class_init,
- NULL, NULL,
- sizeof (ESourceList),
- 0,
- (GInstanceInitFunc) e_source_list_init
- };
- e_source_list_type = g_type_register_static (G_TYPE_OBJECT, "ESourceList", &info, 0);
- }
-
- return e_source_list_type;
-}
-
/* Public methods. */
ESourceList *
#include "e-uid.h"
#include "e-source.h"
-static GObjectClass *parent_class = NULL;
-
#define ES_CLASS(obj) E_SOURCE_CLASS (G_OBJECT_GET_CLASS (obj))
/* GObject methods. */
+G_DEFINE_TYPE (ESource, e_source, G_TYPE_OBJECT);
+
static void
impl_finalize (GObject *object)
{
g_free (priv);
- (* G_OBJECT_CLASS (parent_class)->finalize) (object);
+ (* G_OBJECT_CLASS (e_source_parent_class)->finalize) (object);
}
static void
priv->group = NULL;
}
- (* G_OBJECT_CLASS (parent_class)->dispose) (object);
+ (* G_OBJECT_CLASS (e_source_parent_class)->dispose) (object);
}
object_class->dispose = impl_dispose;
object_class->finalize = impl_finalize;
- parent_class = g_type_class_peek_parent (class);
-
signals[CHANGED] =
g_signal_new ("changed",
G_OBJECT_CLASS_TYPE (object_class),
g_free, g_free);
}
-GType
-e_source_get_type (void)
-{
- static GType e_source_type = 0;
-
- if (!e_source_type) {
- static GTypeInfo info = {
- sizeof (ESourceClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) e_source_class_init,
- NULL, NULL,
- sizeof (ESource),
- 0,
- (GInstanceInitFunc) e_source_init
- };
- e_source_type = g_type_register_static (G_TYPE_OBJECT, "ESource", &info, 0);
- }
-
- return e_source_type;
-}
-
/* Public methods. */
ESource *