[evolution-mapi] Use thread safe G_DEFINE_TYPE macro



commit b51b94df3b7111ba28528323b970a7593500d98b
Author: Milan Crha <mcrha redhat com>
Date:   Wed Feb 17 19:04:22 2010 +0100

    Use thread safe G_DEFINE_TYPE macro

 .../exchange-mapi-account-listener.c               |   32 +++----------------
 src/addressbook/e-book-backend-mapi-gal-factory.c  |    2 +-
 src/addressbook/e-book-backend-mapi-gal.c          |   32 +++----------------
 src/addressbook/e-book-backend-mapi-gal.h          |    6 ++--
 src/addressbook/e-book-backend-mapi.c              |   27 +---------------
 src/calendar/e-cal-backend-mapi.c                  |   28 ++---------------
 6 files changed, 19 insertions(+), 108 deletions(-)
---
diff --git a/src/account-setup-eplugin/exchange-mapi-account-listener.c b/src/account-setup-eplugin/exchange-mapi-account-listener.c
index 5ed27a5..badcf07 100644
--- a/src/account-setup-eplugin/exchange-mapi-account-listener.c
+++ b/src/account-setup-eplugin/exchange-mapi-account-listener.c
@@ -49,6 +49,8 @@ LIMBAPI_CFLAGS or something is going wrong */
 
 #define d(x) x
 
+G_DEFINE_TYPE (ExchangeMAPIAccountListener, exchange_mapi_account_listener, G_TYPE_OBJECT)
+
 struct _ExchangeMAPIAccountListenerPrivate {
 	GConfClient *gconf_client;
 	/* we get notification about mail account changes from this object */
@@ -68,8 +70,6 @@ struct _ExchangeMAPIAccountInfo {
 /* list of ExchangeMAPIAccountInfo structures */
 static 	GList *mapi_accounts = NULL;
 
-#define PARENT_TYPE G_TYPE_OBJECT
-
 static GObjectClass *parent_class = NULL;
 
 static void 
@@ -113,7 +113,7 @@ exchange_mapi_account_listener_class_init (ExchangeMAPIAccountListenerClass *cla
 {
 	GObjectClass *object_class;
 	
-	parent_class = g_type_class_ref (PARENT_TYPE);
+	parent_class = g_type_class_ref (G_TYPE_OBJECT);
 	object_class = G_OBJECT_CLASS (class);
 	
 	/* virtual method override */
@@ -122,7 +122,7 @@ exchange_mapi_account_listener_class_init (ExchangeMAPIAccountListenerClass *cla
 }
 
 static void 
-exchange_mapi_account_listener_init (ExchangeMAPIAccountListener *config_listener, ExchangeMAPIAccountListenerClass *class)
+exchange_mapi_account_listener_init (ExchangeMAPIAccountListener *config_listener)
 {
 	config_listener->priv = g_new0 (ExchangeMAPIAccountListenerPrivate, 1);
 }
@@ -770,30 +770,8 @@ exchange_mapi_account_listener_construct (ExchangeMAPIAccountListener *config_li
 	g_signal_connect (config_listener->priv->account_list, "account_removed", G_CALLBACK (mapi_account_removed), NULL);
 }
 
-GType
-exchange_mapi_account_listener_get_type (void)
-{
-	static GType exchange_mapi_account_listener_type = 0;
-
-	if (!exchange_mapi_account_listener_type) {
-		static GTypeInfo info = {
-			sizeof (ExchangeMAPIAccountListenerClass),
-			(GBaseInitFunc) NULL,
-			(GBaseFinalizeFunc) NULL,
-			(GClassInitFunc) exchange_mapi_account_listener_class_init,
-			NULL, NULL,
-			sizeof (ExchangeMAPIAccountListener),
-			0,
-			(GInstanceInitFunc) exchange_mapi_account_listener_init
-		};
-		exchange_mapi_account_listener_type = g_type_register_static (PARENT_TYPE, "ExchangeMAPIAccountListener", &info, 0);
-	}
-
-	return exchange_mapi_account_listener_type;
-}
-
 ExchangeMAPIAccountListener *
-exchange_mapi_account_listener_new ()
+exchange_mapi_account_listener_new (void)
 {
 	ExchangeMAPIAccountListener *config_listener;
 
diff --git a/src/addressbook/e-book-backend-mapi-gal-factory.c b/src/addressbook/e-book-backend-mapi-gal-factory.c
index 0fc5a8f..3e4e8de 100644
--- a/src/addressbook/e-book-backend-mapi-gal-factory.c
+++ b/src/addressbook/e-book-backend-mapi-gal-factory.c
@@ -28,7 +28,7 @@
 #include <libedata-book/e-book-backend-factory.h>
 #include "e-book-backend-mapi-gal.h"
 
-E_BOOK_BACKEND_FACTORY_SIMPLE (mapigal, MAPIGAL, e_book_backend_mapigal_new)
+E_BOOK_BACKEND_FACTORY_SIMPLE (mapigal, MAPIGAL, e_book_backend_mapi_gal_new)
 
 static GType  mapigal_type;
 
diff --git a/src/addressbook/e-book-backend-mapi-gal.c b/src/addressbook/e-book-backend-mapi-gal.c
index 4a31de7..401e102 100644
--- a/src/addressbook/e-book-backend-mapi-gal.c
+++ b/src/addressbook/e-book-backend-mapi-gal.c
@@ -21,7 +21,8 @@
 #include <libedata-book/e-book-backend-summary.h>
 #include "e-book-backend-mapi-gal.h"
 
-static EBookBackendClass *e_book_backend_mapi_gal_parent_class;
+G_DEFINE_TYPE (EBookBackendMAPIGAL, e_book_backend_mapi_gal, E_TYPE_BOOK_BACKEND)
+
 static gboolean enable_debug = TRUE;
 static GList *supported_fields;
 
@@ -936,15 +937,15 @@ static void e_book_backend_mapi_gal_class_init (EBookBackendMAPIGALClass *klass)
 }
 
 /**
- * e_book_backend_mapigal_new:
+ * e_book_backend_mapi_gal_new:
  */
 EBookBackend *
-e_book_backend_mapigal_new (void)
+e_book_backend_mapi_gal_new (void)
 {
 	EBookBackendMAPIGAL *backend;
 
 //	if (enable_debug)
-		printf ("\ne_book_backend_mapigal_new...\n");
+		printf ("\ne_book_backend_mapi_gal_new...\n");
 
 	backend = g_object_new (E_TYPE_BOOK_BACKEND_MAPIGAL, NULL);
 
@@ -972,26 +973,3 @@ static void	e_book_backend_mapi_gal_init (EBookBackendMAPIGAL *backend)
 	else
 		enable_debug = FALSE;	
 }
-
-GType	e_book_backend_mapigal_get_type (void)
-{
-	static GType type = 0;
-	
-	if (! type) {
-		GTypeInfo info = {
-			sizeof (EBookBackendMAPIGALClass),
-			NULL, /* base_class_init */
-			NULL, /* base_class_finalize */
-			(GClassInitFunc)  e_book_backend_mapi_gal_class_init,
-			NULL, /* class_finalize */
-			NULL, /* class_data */
-			sizeof (EBookBackendMAPIGAL),
-			0,    /* n_preallocs */
-			(GInstanceInitFunc) e_book_backend_mapi_gal_init
-		};
-		
-		type = g_type_register_static (E_TYPE_BOOK_BACKEND, "EBookBackendMAPIGAL", &info, 0);
-	}
-	
-	return type;
-}
diff --git a/src/addressbook/e-book-backend-mapi-gal.h b/src/addressbook/e-book-backend-mapi-gal.h
index 3e17ae1..080968c 100644
--- a/src/addressbook/e-book-backend-mapi-gal.h
+++ b/src/addressbook/e-book-backend-mapi-gal.h
@@ -41,10 +41,10 @@ typedef struct {
 	EBookBackendClass parent_class;
 } EBookBackendMAPIGALClass;
 
-EBookBackend *e_book_backend_mapigal_new      (void);
-GType       e_book_backend_mapigal_get_type (void);
+EBookBackend *e_book_backend_mapi_gal_new      (void);
+GType       e_book_backend_mapi_gal_get_type (void);
 
-#define E_TYPE_BOOK_BACKEND_MAPIGAL        (e_book_backend_mapigal_get_type ())
+#define E_TYPE_BOOK_BACKEND_MAPIGAL        (e_book_backend_mapi_gal_get_type ())
 #define E_BOOK_BACKEND_MAPIGAL(o)          (G_TYPE_CHECK_INSTANCE_CAST ((o), E_TYPE_BOOK_BACKEND_MAPIGAL, EBookBackendMAPIGAL))
 #define E_BOOK_BACKEND_MAPIGAL_CLASS(k)    (G_TYPE_CHECK_CLASS_CAST ((k), E_TYPE_BOOK_BACKEND_MAPIGAL, EBookBackendMAPIGALClass))
 #define E_IS_BOOK_BACKEND_MAPIGAL(o)       (G_TYPE_CHECK_INSTANCE_TYPE ((o), E_TYPE_BOOK_BACKEND_MAPIGAL))
diff --git a/src/addressbook/e-book-backend-mapi.c b/src/addressbook/e-book-backend-mapi.c
index acc99e8..1a50828 100644
--- a/src/addressbook/e-book-backend-mapi.c
+++ b/src/addressbook/e-book-backend-mapi.c
@@ -47,7 +47,8 @@
 #include <libedata-book/e-book-backend-summary.h>
 #include "e-book-backend-mapi.h"
 
-static EBookBackendClass *e_book_backend_mapi_parent_class;
+G_DEFINE_TYPE (EBookBackendMAPI, e_book_backend_mapi, E_TYPE_BOOK_BACKEND)
+
 static gboolean enable_debug = TRUE;
 
 struct _EBookBackendMAPIPrivate
@@ -1790,27 +1791,3 @@ static void	e_book_backend_mapi_init (EBookBackendMAPI *backend)
 	
 	
 }
-
-
-GType	e_book_backend_mapi_get_type (void)
-{
-	static GType type = 0;
-	
-	if (! type) {
-		GTypeInfo info = {
-			sizeof (EBookBackendMAPIClass),
-			NULL, /* base_class_init */
-			NULL, /* base_class_finalize */
-			(GClassInitFunc)  e_book_backend_mapi_class_init,
-			NULL, /* class_finalize */
-			NULL, /* class_data */
-			sizeof (EBookBackendMAPI),
-			0,    /* n_preallocs */
-			(GInstanceInitFunc) e_book_backend_mapi_init
-		};
-		
-		type = g_type_register_static (E_TYPE_BOOK_BACKEND, "EBookBackendMAPI", &info, 0);
-	}
-	
-	return type;
-}
diff --git a/src/calendar/e-cal-backend-mapi.c b/src/calendar/e-cal-backend-mapi.c
index 6234126..0572e6a 100644
--- a/src/calendar/e-cal-backend-mapi.c
+++ b/src/calendar/e-cal-backend-mapi.c
@@ -49,6 +49,8 @@
 #define gmtime_r(tp,tmp) (gmtime(tp)?(*(tmp)=*gmtime(tp),(tmp)):0)
 #endif
 
+G_DEFINE_TYPE (ECalBackendMAPI, e_cal_backend_mapi, E_TYPE_CAL_BACKEND_SYNC)
+
 typedef struct {
 	GCond *cond;
 	GMutex *mutex;
@@ -2453,7 +2455,7 @@ e_cal_backend_mapi_class_init (ECalBackendMAPIClass *class)
 
 
 static void
-e_cal_backend_mapi_init (ECalBackendMAPI *cbmapi, ECalBackendMAPIClass *class)
+e_cal_backend_mapi_init (ECalBackendMAPI *cbmapi)
 {
 	ECalBackendMAPIPrivate *priv;
 	
@@ -2470,30 +2472,6 @@ e_cal_backend_mapi_init (ECalBackendMAPI *cbmapi, ECalBackendMAPIClass *class)
 	e_cal_backend_sync_set_lock (E_CAL_BACKEND_SYNC (cbmapi), TRUE);
 }
 
-GType
-e_cal_backend_mapi_get_type (void)
-{
-	static GType e_cal_backend_mapi_type = 0;
-
-	if (!e_cal_backend_mapi_type) {
-		static GTypeInfo info = {
-                        sizeof (ECalBackendMAPIClass),
-                        (GBaseInitFunc) NULL,
-                        (GBaseFinalizeFunc) NULL,
-                        (GClassInitFunc) e_cal_backend_mapi_class_init,
-                        NULL, NULL,
-                        sizeof (ECalBackendMAPI),
-                        0,
-                        (GInstanceInitFunc) e_cal_backend_mapi_init
-                };
-		e_cal_backend_mapi_type = g_type_register_static (E_TYPE_CAL_BACKEND_SYNC,
-								  "ECalBackendMAPI", &info, 0);
-	}
-
-	return e_cal_backend_mapi_type;
-}
-
-
 /***** UTILITY FUNCTIONS *****/
 const char *	
 e_cal_backend_mapi_get_local_attachments_store (ECalBackendMAPI *cbmapi)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]