[libgda] gda-data-comparator: ported to G_DEFINE



commit 20d067d14a9287a6822a3365af2f4f597fecf8c7
Author: Daniel Espinosa <esodan gmail com>
Date:   Tue Sep 11 09:22:10 2018 -0500

    gda-data-comparator: ported to G_DEFINE

 libgda/gda-data-comparator.c | 39 +++------------------------------------
 1 file changed, 3 insertions(+), 36 deletions(-)
---
diff --git a/libgda/gda-data-comparator.c b/libgda/gda-data-comparator.c
index 353b021ad..1632ad019 100644
--- a/libgda/gda-data-comparator.c
+++ b/libgda/gda-data-comparator.c
@@ -41,8 +41,6 @@ static void gda_data_comparator_get_property (GObject *object,
                                              guint param_id,
                                              GValue *value,
                                              GParamSpec *pspec);
-/* get a pointer to the parents to be able to call their destructor */
-static GObjectClass  *parent_class = NULL;
 
 static void gda_diff_free (GdaDiff *diff);
 
@@ -71,7 +69,8 @@ typedef struct {
        gint              *key_columns;
        GArray            *diffs; /* array of GdaDiff pointers */
 } GdaDataComparatorPrivate;
-#define gda_data_comparator_get_instance_private(obj) G_TYPE_INSTANCE_GET_PRIVATE(obj, 
GDA_TYPE_DATA_COMPARATOR, GdaDataComparatorPrivate)
+
+G_DEFINE_TYPE_WITH_PRIVATE (GdaDataComparator, gda_data_comparator, G_TYPE_OBJECT)
 
 
 /* module error */
@@ -83,34 +82,6 @@ GQuark gda_data_comparator_error_quark (void)
        return quark;
 }
 
-GType
-gda_data_comparator_get_type (void)
-{
-       static GType type = 0;
-
-       if (G_UNLIKELY (type == 0)) {
-               static GMutex registering;
-               static const GTypeInfo info = {
-                       sizeof (GdaDataComparatorClass),
-                       (GBaseInitFunc) NULL,
-                       (GBaseFinalizeFunc) NULL,
-                       (GClassInitFunc) gda_data_comparator_class_init,
-                       NULL,
-                       NULL,
-                       sizeof (GdaDataComparator),
-                       0,
-                       (GInstanceInitFunc) gda_data_comparator_init,
-                       0
-               };
-
-               g_mutex_lock (&registering);
-               if (type == 0)
-                       type = g_type_register_static (G_TYPE_OBJECT, "GdaDataComparator", &info, 0);
-               g_mutex_unlock (&registering);
-       }
-       return type;
-}
-
 static gboolean
 diff_computed_accumulator (G_GNUC_UNUSED GSignalInvocationHint *ihint,
                           GValue *return_accu,
@@ -136,10 +107,6 @@ gda_data_comparator_class_init (GdaDataComparatorClass *class)
 {
        GObjectClass   *object_class = G_OBJECT_CLASS (class);
 
-       parent_class = g_type_class_peek_parent (class);
-
-       g_type_class_add_private (object_class, sizeof (GdaDataComparatorPrivate));
-
        /* signals */
 
        gda_data_comparator_signals [DIFF_COMPUTED] =
@@ -237,7 +204,7 @@ gda_data_comparator_dispose (GObject *object)
        g_array_free (priv->diffs, TRUE);
 
        /* parent class */
-       parent_class->dispose (object);
+       G_OBJECT_CLASS (gda_data_comparator_parent_class)->dispose (object);
 }
 
 static void


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