epiphany r7964 - in trunk/embed: . mozilla



Author: xan
Date: Sun Feb 17 23:23:36 2008
New Revision: 7964
URL: http://svn.gnome.org/viewvc/epiphany?rev=7964&view=rev

Log:
Use G_DEFINE_TYPE* where possible in embed/* (#517090)


Modified:
   trunk/embed/downloader-view.c
   trunk/embed/ephy-download.c
   trunk/embed/ephy-embed-dialog.c
   trunk/embed/ephy-embed-persist.c
   trunk/embed/ephy-embed-shell.c
   trunk/embed/ephy-encodings.c
   trunk/embed/ephy-favicon-cache.c
   trunk/embed/ephy-history.c
   trunk/embed/mozilla/mozilla-download.cpp
   trunk/embed/mozilla/mozilla-embed-event.cpp
   trunk/embed/mozilla/mozilla-embed-find.cpp
   trunk/embed/mozilla/mozilla-embed-persist.cpp
   trunk/embed/mozilla/mozilla-x509-cert.cpp

Modified: trunk/embed/downloader-view.c
==============================================================================
--- trunk/embed/downloader-view.c	(original)
+++ trunk/embed/downloader-view.c	Sun Feb 17 23:23:36 2008
@@ -143,43 +143,13 @@
 show_notification_window (DownloaderView *dv);
 #endif
 
-static GObjectClass *parent_class = NULL;
-
-GType
-downloader_view_get_type (void)
-{
-       static GType type = 0;
-
-	if (G_UNLIKELY (type == 0))
-	{
-		const GTypeInfo our_info =
-		{
-			sizeof (DownloaderViewClass),
-			NULL, /* base_init */
-			NULL, /* base_finalize */
-			(GClassInitFunc) downloader_view_class_init,
-			NULL, /* class_finalize */
-			NULL, /* class_data */
-			sizeof (DownloaderView),
-			0,    /* n_preallocs */
-			(GInstanceInitFunc) downloader_view_init
-		};
-
-		type = g_type_register_static (EPHY_TYPE_DIALOG,
-					       "DownloaderView",
-					       &our_info, 0);
-	}
-
-	return type;
-}
+G_DEFINE_TYPE (DownloaderView, downloader_view, EPHY_TYPE_DIALOG)
 
 static void
 downloader_view_class_init (DownloaderViewClass *klass)
 {
 	GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
-	parent_class = g_type_class_peek_parent (klass);
-
 	object_class->finalize = downloader_view_finalize;
 
 	g_type_class_add_private (object_class, sizeof(DownloaderViewPrivate));
@@ -329,7 +299,7 @@
 
 	g_hash_table_destroy (dv->priv->downloads_hash);
 
-	G_OBJECT_CLASS (parent_class)->finalize (object);
+	G_OBJECT_CLASS (downloader_view_parent_class)->finalize (object);
 
 #ifdef HAVE_LIBNOTIFY	
 	if (notify_is_initted ())

Modified: trunk/embed/ephy-download.c
==============================================================================
--- trunk/embed/ephy-download.c	(original)
+++ trunk/embed/ephy-download.c	Sun Feb 17 23:23:36 2008
@@ -45,45 +45,15 @@
 	gint64 remaining_time;
 };
 
-static GObjectClass *parent_class = NULL;
+static guint ephy_download_signals[LAST_SIGNAL];
 
-static guint ephy_download_signals[LAST_SIGNAL] = { 0 };
-
-GType
-ephy_download_get_type (void)
-{
-       static GType type = 0;
-
-        if (G_UNLIKELY (type == 0))
-        {
-                const GTypeInfo our_info =
-                {
-                        sizeof (EphyDownloadClass),
-                        NULL, /* base_init */
-                        NULL, /* base_finalize */
-                        (GClassInitFunc) ephy_download_class_init,
-                        NULL, /* class_finalize */
-                        NULL, /* class_data */
-                        sizeof (EphyDownload),
-                        0,    /* n_preallocs */
-                        (GInstanceInitFunc) ephy_download_init
-                };
-
-                type = g_type_register_static (G_TYPE_OBJECT,
-					       "EphyDownload",
-					       &our_info, 0);
-        }
-
-        return type;
-}
+G_DEFINE_TYPE (EphyDownload, ephy_download, G_TYPE_OBJECT)
 
 static void
 ephy_download_class_init (EphyDownloadClass *klass)
 {
         GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
-        parent_class = g_type_class_peek_parent (klass);
-
 	ephy_download_signals[CHANGED] =
                 g_signal_new ("changed",
                               EPHY_TYPE_DOWNLOAD,

Modified: trunk/embed/ephy-embed-dialog.c
==============================================================================
--- trunk/embed/ephy-embed-dialog.c	(original)
+++ trunk/embed/ephy-embed-dialog.c	Sun Feb 17 23:23:36 2008
@@ -52,43 +52,13 @@
 	EphyEmbed *embed;
 };
 
-static GObjectClass *parent_class = NULL;
-
-GType
-ephy_embed_dialog_get_type (void)
-{
-        static GType type = 0;
-
-        if (G_UNLIKELY (type == 0))
-        {
-                const GTypeInfo our_info =
-                {
-                        sizeof (EphyEmbedDialogClass),
-                        NULL, /* base_init */
-                        NULL, /* base_finalize */
-                        (GClassInitFunc) ephy_embed_dialog_class_init,
-                        NULL,
-                        NULL, /* class_data */
-                        sizeof (EphyEmbedDialog),
-                        0, /* n_preallocs */
-                        (GInstanceInitFunc) ephy_embed_dialog_init
-                };
-
-                type = g_type_register_static (EPHY_TYPE_DIALOG,
-					       "EphyEmbedDialog",
-					       &our_info, 0);
-        }
-
-        return type;
-}
+G_DEFINE_TYPE (EphyEmbedDialog, ephy_embed_dialog, EPHY_TYPE_DIALOG)
 
 static void
 ephy_embed_dialog_class_init (EphyEmbedDialogClass *klass)
 {
         GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
-        parent_class = g_type_class_peek_parent (klass);
-
         object_class->finalize = ephy_embed_dialog_finalize;
 	object_class->set_property = ephy_embed_dialog_set_property;
 	object_class->get_property = ephy_embed_dialog_get_property;
@@ -129,7 +99,7 @@
 
 	unset_embed (dialog);
 
-        G_OBJECT_CLASS (parent_class)->finalize (object);
+        G_OBJECT_CLASS (ephy_embed_dialog_parent_class)->finalize (object);
 }
 
 static void

Modified: trunk/embed/ephy-embed-persist.c
==============================================================================
--- trunk/embed/ephy-embed-persist.c	(original)
+++ trunk/embed/ephy-embed-persist.c	Sun Feb 17 23:23:36 2008
@@ -60,35 +60,7 @@
 static void	ephy_embed_persist_class_init	(EphyEmbedPersistClass *klass);
 static void	ephy_embed_persist_init		(EphyEmbedPersist *ges);
 
-static GObjectClass *parent_class = NULL;
-
-GType
-ephy_embed_persist_get_type (void)
-{
-       static GType type = 0;
-
-	if (G_UNLIKELY (type == 0))
-	{
-		const GTypeInfo our_info =
-		{
-			sizeof (EphyEmbedPersistClass),
-			NULL, /* base_init */
-			NULL, /* base_finalize */
-			(GClassInitFunc) ephy_embed_persist_class_init,
-			NULL, /* class_finalize */
-			NULL, /* class_data */
-			sizeof (EphyEmbedPersist),
-			0,    /* n_preallocs */
-			(GInstanceInitFunc) ephy_embed_persist_init
-		};
-
-		type = g_type_register_static (G_TYPE_OBJECT,
-					       "EphyEmbedPersist",
-					       &our_info, G_TYPE_FLAG_ABSTRACT);
-	}
-
-	return type;
-}
+G_DEFINE_TYPE (EphyEmbedPersist, ephy_embed_persist, G_TYPE_OBJECT)
 
 /**
  * ephy_embed_persist_set_dest:
@@ -522,7 +494,7 @@
 
 	LOG ("EphyEmbedPersist finalised %p", object);
 
-	G_OBJECT_CLASS (parent_class)->finalize (object);
+	G_OBJECT_CLASS (ephy_embed_persist_parent_class)->finalize (object);
 }
 
 static void
@@ -530,8 +502,6 @@
 {
 	GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
-	parent_class = g_type_class_peek_parent (klass);
-
 	object_class->finalize = ephy_embed_persist_finalize;
 	object_class->set_property = ephy_embed_persist_set_property;
 	object_class->get_property = ephy_embed_persist_get_property;

Modified: trunk/embed/ephy-embed-shell.c
==============================================================================
--- trunk/embed/ephy-embed-shell.c	(original)
+++ trunk/embed/ephy-embed-shell.c	Sun Feb 17 23:23:36 2008
@@ -68,42 +68,14 @@
 	LAST_SIGNAL
 };
 
-static guint signals[LAST_SIGNAL] = { 0 };
+static guint signals[LAST_SIGNAL];
 
 static void ephy_embed_shell_class_init	(EphyEmbedShellClass *klass);
 static void ephy_embed_shell_init	(EphyEmbedShell *shell);
 
 EphyEmbedShell *embed_shell = NULL;
 
-static GObjectClass *parent_class = NULL;
-
-GType
-ephy_embed_shell_get_type (void)
-{
-       static GType type = 0;
-
-	if (G_UNLIKELY (type == 0))
-	{
-		const GTypeInfo our_info =
-		{
-			sizeof (EphyEmbedShellClass),
-			NULL, /* base_init */
-			NULL, /* base_finalize */
-			(GClassInitFunc) ephy_embed_shell_class_init,
-			NULL, /* class_finalize */
-			NULL, /* class_data */
-			sizeof (EphyEmbedShell),
-			0,    /* n_preallocs */
-			(GInstanceInitFunc) ephy_embed_shell_init
-		};
-
-		type = g_type_register_static (G_TYPE_OBJECT,
-					       "EphyEmbedShell",
-					       &our_info, 0);
-	}
-
-	return type;
-}
+G_DEFINE_TYPE (EphyEmbedShell, ephy_embed_shell, G_TYPE_OBJECT)
 
 static void
 ephy_embed_shell_dispose (GObject *object)
@@ -148,7 +120,7 @@
 		priv->print_settings = NULL;
 	}
 
-	G_OBJECT_CLASS (parent_class)->dispose (object);
+	G_OBJECT_CLASS (ephy_embed_shell_parent_class)->dispose (object);
 }
 
 static void
@@ -175,7 +147,7 @@
 		shell->priv->adblock_manager = NULL;
 	}
 
-	G_OBJECT_CLASS (parent_class)->finalize (object);
+	G_OBJECT_CLASS (ephy_embed_shell_parent_class)->finalize (object);
 }
 
 /**
@@ -324,8 +296,6 @@
 {
 	GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
-	parent_class = (GObjectClass *) g_type_class_peek_parent (klass);
-
 	object_class->dispose = ephy_embed_shell_dispose;
 	object_class->finalize = ephy_embed_shell_finalize;
 

Modified: trunk/embed/ephy-encodings.c
==============================================================================
--- trunk/embed/ephy-encodings.c	(original)
+++ trunk/embed/ephy-encodings.c	Sun Feb 17 23:23:36 2008
@@ -187,35 +187,7 @@
 static void ephy_encodings_class_init	(EphyEncodingsClass *klass);
 static void ephy_encodings_init		(EphyEncodings *ma);
 
-static GObjectClass *parent_class = NULL;
-
-GType
-ephy_encodings_get_type (void)
-{
-	static GType type = 0;
-
-	if (G_UNLIKELY (type == 0))
-	{
-		const GTypeInfo our_info =
-		{
-			sizeof (EphyEncodingsClass),
-			NULL,
-			NULL,
-			(GClassInitFunc) ephy_encodings_class_init,
-			NULL,
-			NULL,
-			sizeof (EphyEncodings),
-			0,
-			(GInstanceInitFunc) ephy_encodings_init
-		};
-
-		type = g_type_register_static (G_TYPE_OBJECT,
-					       "EphyEncodings",
-					        &our_info, 0);
-	}
-
-	return type;
-}
+G_DEFINE_TYPE (EphyEncodings, ephy_encodings, G_TYPE_OBJECT)
 
 static void
 ephy_encodings_finalize (GObject *object)
@@ -235,7 +207,7 @@
 
 	LOG ("EphyEncodings finalised");
 
-	G_OBJECT_CLASS (parent_class)->finalize (object);
+	G_OBJECT_CLASS (ephy_encodings_parent_class)->finalize (object);
 }
 
 static void
@@ -243,8 +215,6 @@
 {
 	GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
-	parent_class = g_type_class_peek_parent (klass);
-
 	object_class->finalize = ephy_encodings_finalize;
 
 	g_type_class_add_private (object_class, sizeof (EphyEncodingsPrivate));

Modified: trunk/embed/ephy-favicon-cache.c
==============================================================================
--- trunk/embed/ephy-favicon-cache.c	(original)
+++ trunk/embed/ephy-favicon-cache.c	Sun Feb 17 23:23:36 2008
@@ -116,45 +116,15 @@
 	NEEDS_MASK	 = 0x3f
 };
 
-static guint signals[LAST_SIGNAL] = { 0 };
+static guint signals[LAST_SIGNAL];
 
-static GObjectClass *parent_class = NULL;
-
-GType
-ephy_favicon_cache_get_type (void)
-{
-	static GType type = 0;
-
-	if (G_UNLIKELY (type == 0))
-	{
-		const GTypeInfo our_info =
-		{
-			sizeof (EphyFaviconCacheClass),
-			NULL,
-			NULL,
-			(GClassInitFunc) ephy_favicon_cache_class_init,
-			NULL,
-			NULL,
-			sizeof (EphyFaviconCache),
-			0,
-			(GInstanceInitFunc) ephy_favicon_cache_init
-		};
-
-		type = g_type_register_static (G_TYPE_OBJECT,
-					       "EphyFaviconCache",
-					       &our_info, 0);
-	}
-
-	return type;
-}
+G_DEFINE_TYPE (EphyFaviconCache, ephy_favicon_cache, G_TYPE_OBJECT)
 
 static void
 ephy_favicon_cache_class_init (EphyFaviconCacheClass *klass)
 {
 	GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
-	parent_class = g_type_class_peek_parent (klass);
-
 	object_class->finalize = ephy_favicon_cache_finalize;
 
 	signals[CHANGED] =
@@ -473,7 +443,7 @@
 	LOG ("Requests: cached %" G_GUINT64_FORMAT " / total %" G_GUINT64_FORMAT " = %.3f",
 	     priv->cached, priv->requests, ((double) priv->cached) / ((double) priv->requests));
 
-	G_OBJECT_CLASS (parent_class)->finalize (object);
+	G_OBJECT_CLASS (ephy_favicon_cache_parent_class)->finalize (object);
 }
 
 static void

Modified: trunk/embed/ephy-history.c
==============================================================================
--- trunk/embed/ephy-history.c	(original)
+++ trunk/embed/ephy-history.c	Sun Feb 17 23:23:36 2008
@@ -88,42 +88,14 @@
 	LAST_SIGNAL
 };
 
-static guint signals[LAST_SIGNAL] = { 0 };
+static guint signals[LAST_SIGNAL];
 
 static void ephy_history_class_init	(EphyHistoryClass *klass);
 static void ephy_history_init		(EphyHistory *history);
 static void ephy_history_finalize	(GObject *object);
 static gboolean impl_add_page           (EphyHistory *, const char *, gboolean, gboolean);
 
-static GObjectClass *parent_class = NULL;
-
-GType
-ephy_history_get_type (void)
-{
-        static GType type = 0;
-
-        if (G_UNLIKELY (type == 0))
-        {
-                const GTypeInfo our_info =
-                {
-                        sizeof (EphyHistoryClass),
-                        NULL, /* base_init */
-                        NULL, /* base_finalize */
-                        (GClassInitFunc) ephy_history_class_init,
-                        NULL,
-                        NULL, /* class_data */
-                        sizeof (EphyHistory),
-                        0, /* n_preallocs */
-                        (GInstanceInitFunc) ephy_history_init
-                };
-
-                type = g_type_register_static (G_TYPE_OBJECT,
-					       "EphyHistory",
-					       &our_info, 0);
-        }
-
-        return type;
-}
+G_DEFINE_TYPE (EphyHistory, ephy_history, G_TYPE_OBJECT)
 
 static void
 ephy_history_set_property (GObject *object,
@@ -162,8 +134,6 @@
 {
         GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
-        parent_class = g_type_class_peek_parent (klass);
-
         object_class->finalize = ephy_history_finalize;
 	object_class->get_property = ephy_history_get_property;
 	object_class->set_property = ephy_history_set_property;
@@ -627,7 +597,7 @@
 
 	LOG ("Global history finalized");
 
-	G_OBJECT_CLASS (parent_class)->finalize (object);
+	G_OBJECT_CLASS (ephy_history_parent_class)->finalize (object);
 }
 
 EphyHistory *

Modified: trunk/embed/mozilla/mozilla-download.cpp
==============================================================================
--- trunk/embed/mozilla/mozilla-download.cpp	(original)
+++ trunk/embed/mozilla/mozilla-download.cpp	Sun Feb 17 23:23:36 2008
@@ -51,35 +51,7 @@
 
 #define MOZILLA_DOWNLOAD_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), MOZILLA_TYPE_DOWNLOAD, MozillaDownloadPrivate))
 
-static GObjectClass *parent_class = NULL;
-
-GType
-mozilla_download_get_type (void)
-{
-       static GType type = 0;
-
-        if (G_UNLIKELY (type == 0))
-        {
-                const GTypeInfo our_info =
-                {
-                        sizeof (MozillaDownloadClass),
-                        NULL, /* base_init */
-                        NULL, /* base_finalize */
-                        (GClassInitFunc) mozilla_download_class_init,
-                        NULL, /* class_finalize */
-                        NULL, /* class_data */
-                        sizeof (MozillaDownload),
-                        0,    /* n_preallocs */
-                        (GInstanceInitFunc) mozilla_download_init
-                };
-
-                type = g_type_register_static (EPHY_TYPE_DOWNLOAD,
-					       "MozillaDownload",
-					       &our_info, (GTypeFlags)0);
-        }
-
-        return type;
-}
+G_DEFINE_TYPE (MozillaDownload, mozilla_download, EPHY_TYPE_DOWNLOAD)
 
 static char *
 impl_get_target (EphyDownload *download)
@@ -221,7 +193,7 @@
 
 	LOG ("MozillaDownload %p finalised", object);
 
-        G_OBJECT_CLASS (parent_class)->finalize (object);
+        G_OBJECT_CLASS (mozilla_download_parent_class)->finalize (object);
 }
 
 static void
@@ -266,8 +238,6 @@
 	GObjectClass *object_class = G_OBJECT_CLASS (klass);
 	EphyDownloadClass *download_class = EPHY_DOWNLOAD_CLASS (klass);
 	
-        parent_class = (GObjectClass *) g_type_class_peek_parent (klass);
-
 	object_class->finalize = mozilla_download_finalize;
 	object_class->set_property = mozilla_download_set_property;
 	object_class->get_property = mozilla_download_get_property;

Modified: trunk/embed/mozilla/mozilla-embed-event.cpp
==============================================================================
--- trunk/embed/mozilla/mozilla-embed-event.cpp	(original)
+++ trunk/embed/mozilla/mozilla-embed-event.cpp	Sun Feb 17 23:23:36 2008
@@ -43,46 +43,9 @@
 static void mozilla_embed_event_init		(MozillaEmbedEvent *event);
 static void ephy_embed_event_iface_init		(EphyEmbedEventIface *iface);
 
-static GObjectClass *parent_class = NULL;
-
-GType
-mozilla_embed_event_get_type (void)
-{
-       static GType type = 0;
-
-	if (G_UNLIKELY (type == 0))
-	{
-		const GTypeInfo our_info =
-		{
-			sizeof (MozillaEmbedEventClass),
-			NULL, /* base_init */
-			NULL, /* base_finalize */
-			(GClassInitFunc) mozilla_embed_event_class_init,
-			NULL, /* class_finalize */
-			NULL, /* class_data */
-			sizeof (MozillaEmbedEvent),
-			0,    /* n_preallocs */
-			(GInstanceInitFunc) mozilla_embed_event_init
-		};
-
-		const GInterfaceInfo embed_event_info =
-		{
-			(GInterfaceInitFunc) ephy_embed_event_iface_init,
-        		NULL,
-        		NULL
-     		};
-
-		type = g_type_register_static (G_TYPE_OBJECT,
-					       "MozillaEmbedEvent",
-					       &our_info, (GTypeFlags) 0);
-
-		g_type_add_interface_static (type,
-                                   	     EPHY_TYPE_EMBED_EVENT,
-                                   	     &embed_event_info);
-	}
-
-	return type;
-}
+G_DEFINE_TYPE_WITH_CODE (MozillaEmbedEvent, mozilla_embed_event, G_TYPE_OBJECT,
+                         G_IMPLEMENT_INTERFACE (EPHY_TYPE_EMBED_EVENT,
+                                                ephy_embed_event_iface_init))
 
 MozillaEmbedEvent *
 mozilla_embed_event_new (gpointer dom_event)
@@ -193,7 +156,7 @@
 
 	LOG ("MozillaEmbedEvent %p finalised", object);
 
-	G_OBJECT_CLASS (parent_class)->finalize (object);
+	G_OBJECT_CLASS (mozilla_embed_event_parent_class)->finalize (object);
 }
 
 static void
@@ -213,8 +176,6 @@
 {
 	GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
-	parent_class = (GObjectClass *) g_type_class_peek_parent (klass);
-
 	object_class->finalize = mozilla_embed_event_finalize;
 
 	g_type_class_add_private (object_class, sizeof (MozillaEmbedEventPrivate));

Modified: trunk/embed/mozilla/mozilla-embed-find.cpp
==============================================================================
--- trunk/embed/mozilla/mozilla-embed-find.cpp	(original)
+++ trunk/embed/mozilla/mozilla-embed-find.cpp	Sun Feb 17 23:23:36 2008
@@ -30,6 +30,10 @@
 
 #include "mozilla-embed-find.h"
 
+static void mozilla_embed_find_class_init (MozillaEmbedFindClass *klass);
+static void mozilla_embed_find_init       (MozillaEmbedFind *self);
+static void ephy_find_iface_init          (EphyEmbedFindIface *iface);
+
 #define MOZILLA_EMBED_FIND_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), MOZILLA_TYPE_EMBED_FIND, MozillaEmbedFindPrivate))
 
 struct _MozillaEmbedFindPrivate
@@ -37,8 +41,6 @@
 	EphyFind *find;
 };
 
-static GObjectClass *parent_class = NULL;
-
 static void
 impl_set_embed (EphyEmbedFind *efind,
 		EphyEmbed *embed)
@@ -49,6 +51,10 @@
 	priv->find->SetEmbed (embed);
 }
 
+G_DEFINE_TYPE_WITH_CODE (MozillaEmbedFind, mozilla_embed_find, G_TYPE_OBJECT,
+                         G_IMPLEMENT_INTERFACE (EPHY_TYPE_EMBED_FIND,
+                                                ephy_find_iface_init))
+
 static void
 impl_set_properties (EphyEmbedFind *efind,
 		     const char *find_string,
@@ -129,8 +135,9 @@
 	/* we depend on single because of mozilla initialization */
 	ephy_embed_shell_get_embed_single (embed_shell);
 
-	return parent_class->constructor (type, n_construct_properties,
-					  construct_params);
+	return G_OBJECT_CLASS (mozilla_embed_find_parent_class)->constructor (type,
+                                                                              n_construct_properties,
+                                                                              construct_params);
 }
 
 static void
@@ -140,7 +147,7 @@
 
 	delete find->priv->find;
 
-	parent_class->finalize (object);
+	G_OBJECT_CLASS (mozilla_embed_find_parent_class)->finalize (object);
 
 	g_object_unref (embed_shell);
 }
@@ -150,49 +157,9 @@
 {
 	GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
-	parent_class = (GObjectClass *) g_type_class_peek_parent (klass);
-
 	object_class->constructor = mozilla_embed_find_constructor;
 	object_class->finalize = mozilla_embed_find_finalize;
 
 	g_type_class_add_private (object_class, sizeof (MozillaEmbedFindPrivate));
 }
 
-GType 
-mozilla_embed_find_get_type (void)
-{
-	static GType type = 0;
-
-	if (G_UNLIKELY (type == 0))
-	{
-		const GTypeInfo our_info =
-		{
-			sizeof (MozillaEmbedFindClass),
-			NULL, /* base_init */
-			NULL, /* base_finalize */
-			(GClassInitFunc) mozilla_embed_find_class_init,
-			NULL,
-			NULL, /* class_data */
-			sizeof (MozillaEmbedFind),
-			0, /* n_preallocs */
-			(GInstanceInitFunc) mozilla_embed_find_init
-		};
-
-		const GInterfaceInfo find_info =
-		{
-			(GInterfaceInitFunc) ephy_find_iface_init,
-			NULL,
-			NULL
-		};
-	
-		type = g_type_register_static (G_TYPE_OBJECT,
-					       "MozillaEmbedFind",
-					       &our_info, 
-					       (GTypeFlags)0);
-		g_type_add_interface_static (type,
-					     EPHY_TYPE_EMBED_FIND,
-					     &find_info);
-	}
-
-	return type;
-}

Modified: trunk/embed/mozilla/mozilla-embed-persist.cpp
==============================================================================
--- trunk/embed/mozilla/mozilla-embed-persist.cpp	(original)
+++ trunk/embed/mozilla/mozilla-embed-persist.cpp	Sun Feb 17 23:23:36 2008
@@ -71,35 +71,7 @@
 	nsCOMPtr<nsIWebBrowserPersist> mPersist;
 };
 
-static GObjectClass *parent_class = NULL;
-
-GType
-mozilla_embed_persist_get_type (void)
-{
-       static GType type = 0;
-
-        if (G_UNLIKELY (type == 0))
-        {
-                const GTypeInfo our_info =
-                {
-                        sizeof (MozillaEmbedPersistClass),
-                        NULL, /* base_init */
-                        NULL, /* base_finalize */
-                        (GClassInitFunc) mozilla_embed_persist_class_init,
-                        NULL, /* class_finalize */
-                        NULL, /* class_data */
-                        sizeof (MozillaEmbedPersist),
-                        0,    /* n_preallocs */
-                        (GInstanceInitFunc) mozilla_embed_persist_init
-                };
-
-                type = g_type_register_static (EPHY_TYPE_EMBED_PERSIST,
-					       "MozillaEmbedPersist",
-					       &our_info, (GTypeFlags) 0);
-        }
-
-        return type;
-}
+G_DEFINE_TYPE (MozillaEmbedPersist, mozilla_embed_persist, EPHY_TYPE_EMBED_PERSIST)
 
 static void
 mozilla_embed_persist_init (MozillaEmbedPersist *persist)
@@ -116,7 +88,7 @@
 
 	persist->priv->mPersist = nsnull;
 
-        G_OBJECT_CLASS (parent_class)->finalize (object);
+        G_OBJECT_CLASS (mozilla_embed_persist_parent_class)->finalize (object);
 }
 
 void
@@ -393,8 +365,9 @@
 	/* this will ensure that mozilla is started up */
 	ephy_embed_shell_get_embed_single (embed_shell);
 
-	return parent_class->constructor (type, n_construct_properties,
-					  construct_params);
+	return G_OBJECT_CLASS (mozilla_embed_persist_parent_class)->constructor (type,
+                                                                                 n_construct_properties,
+                                                                                 construct_params);
 }
 
 static void
@@ -403,8 +376,6 @@
         GObjectClass *object_class = G_OBJECT_CLASS (klass);
 	EphyEmbedPersistClass *persist_class = EPHY_EMBED_PERSIST_CLASS (klass);
 	
-        parent_class = (GObjectClass *) g_type_class_peek_parent (klass);
-	
         object_class->finalize = mozilla_embed_persist_finalize;
 	object_class->constructor = mozilla_embed_persist_constructor;
 

Modified: trunk/embed/mozilla/mozilla-x509-cert.cpp
==============================================================================
--- trunk/embed/mozilla/mozilla-x509-cert.cpp	(original)
+++ trunk/embed/mozilla/mozilla-x509-cert.cpp	Sun Feb 17 23:23:36 2008
@@ -47,46 +47,9 @@
 	PROP_MOZILLA_CERT
 };
 
-static GObjectClass *parent_class = NULL;
-
-GType 
-mozilla_x509_cert_get_type (void)
-{
-	static GType mozilla_x509_cert_type = 0;
-
-	if (mozilla_x509_cert_type == 0)
-	{
-		const GTypeInfo our_info =
-		{
-			sizeof (MozillaX509CertClass),
-			NULL, /* base_init */
-			NULL, /* base_finalize */
-			(GClassInitFunc) mozilla_x509_cert_class_init,
-			NULL,
-			NULL, /* class_data */
-			sizeof (MozillaX509Cert),
-			0, /* n_preallocs */
-			(GInstanceInitFunc) mozilla_x509_cert_init
-		};
-
-		const GInterfaceInfo x509_cert_info =
-		{
-			(GInterfaceInitFunc) ephy_x509_cert_init,      /* interface_init */
-			NULL,                                          /* interface_finalize */
-			NULL                                           /* interface_data */
-     		 };
-		
-		mozilla_x509_cert_type = g_type_register_static (G_TYPE_OBJECT,
-                                                                 "MozillaX509Cert",
-                                                                 &our_info, 
-                                                                 (GTypeFlags)0);
-		g_type_add_interface_static (mozilla_x509_cert_type,
-					     EPHY_TYPE_X509_CERT,
-					     &x509_cert_info);
-	}
-
-	return mozilla_x509_cert_type;
-}
+G_DEFINE_TYPE_WITH_CODE (MozillaX509Cert, mozilla_x509_cert, G_TYPE_OBJECT,
+                         G_IMPLEMENT_INTERFACE (EPHY_TYPE_X509_CERT,
+                                                ephy_x509_cert_init))
 
 static void
 mozilla_x509_cert_set_mozilla_cert (MozillaX509Cert *cert,
@@ -219,7 +182,7 @@
 		g_free (cert->priv->title);
 	}
 	
-	G_OBJECT_CLASS (parent_class)->finalize (object);
+	G_OBJECT_CLASS (mozilla_x509_cert_parent_class)->finalize (object);
 }
 
 static void
@@ -233,8 +196,6 @@
 {
 	GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
-	parent_class = (GObjectClass*)g_type_class_peek_parent (klass);
-
 	object_class->finalize = mozilla_x509_cert_finalize;
 	object_class->set_property = impl_set_property;
 	object_class->get_property = impl_get_property;
@@ -252,10 +213,7 @@
 MozillaX509Cert *
 mozilla_x509_cert_new (nsIX509Cert *moz_cert)
 {
-	MozillaX509Cert *cert;
-
-	cert = (MozillaX509Cert*)g_object_new (MOZILLA_TYPE_X509_CERT,
-					       "mozilla-cert", moz_cert,
-					       (char *) NULL);
-	return cert;
+	return g_object_new (MOZILLA_TYPE_X509_CERT,
+                             "mozilla-cert", moz_cert,
+                             NULL);
 }



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