[libgda] gda-holder: ported to G_DECLARE/G_DEFINE
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda] gda-holder: ported to G_DECLARE/G_DEFINE
- Date: Thu, 20 Sep 2018 00:23:01 +0000 (UTC)
commit f50f05b21a976e357f3f01f3630174459117480e
Author: Daniel Espinosa <esodan gmail com>
Date: Wed Sep 19 14:26:43 2018 -0500
gda-holder: ported to G_DECLARE/G_DEFINE
libgda/gda-holder.c | 51 +++++----------------------------------------------
libgda/gda-holder.h | 13 ++-----------
2 files changed, 7 insertions(+), 57 deletions(-)
---
diff --git a/libgda/gda-holder.c b/libgda/gda-holder.c
index ac1f9a24c..3cedb4acd 100644
--- a/libgda/gda-holder.c
+++ b/libgda/gda-holder.c
@@ -66,8 +66,6 @@ static void bound_holder_changed_cb (GdaHolder *alias_of, GdaHolder *holder);
static void full_bound_holder_changed_cb (GdaHolder *alias_of, GdaHolder *holder);
static void gda_holder_set_full_bind (GdaHolder *holder, GdaHolder *alias_of);
-/* get a pointer to the parents to be able to call their destructor */
-static GObjectClass *parent_class = NULL;
GdaAttributesManager *gda_holder_attributes_manager;
/* signals */
@@ -125,7 +123,9 @@ typedef struct {
gboolean validate_changes;
} GdaHolderPrivate;
-#define gda_holder_get_instance_private(obj) G_TYPE_INSTANCE_GET_PRIVATE(obj, GDA_TYPE_HOLDER,
GdaHolderPrivate)
+G_DEFINE_TYPE_WITH_CODE (GdaHolder, gda_holder, G_TYPE_OBJECT,
+ G_ADD_PRIVATE (GdaHolder)
+ G_IMPLEMENT_INTERFACE(GDA_TYPE_LOCKABLE, gda_holder_lockable_init))
/* module error */
GQuark gda_holder_error_quark (void)
{
@@ -135,43 +135,6 @@ GQuark gda_holder_error_quark (void)
return quark;
}
-GType
-gda_holder_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0)) {
- static GMutex registering;
- static const GTypeInfo info = {
- sizeof (GdaHolderClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) gda_holder_class_init,
- NULL,
- NULL,
- sizeof (GdaHolder),
- 0,
- (GInstanceInitFunc) gda_holder_init,
- 0
- };
-
- static GInterfaceInfo lockable_info = {
- (GInterfaceInitFunc) gda_holder_lockable_init,
- NULL,
- NULL
- };
-
- g_mutex_lock (®istering);
- if (type == 0) {
- type = g_type_register_static (G_TYPE_OBJECT, "GdaHolder", &info, 0);
- g_type_add_interface_static (type, GDA_TYPE_LOCKABLE, &lockable_info);
- }
- g_mutex_unlock (®istering);
- }
-
- return type;
-}
-
static gboolean
validate_change_accumulator (G_GNUC_UNUSED GSignalInvocationHint *ihint,
GValue *return_accu,
@@ -204,10 +167,6 @@ gda_holder_class_init (GdaHolderClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
- parent_class = g_type_class_peek_parent (class);
-
- g_type_class_add_private (object_class, sizeof (GdaHolderPrivate));
-
/**
* GdaHolder::source-changed:
* @holder: the #GdaHolder
@@ -594,7 +553,7 @@ gda_holder_dispose (GObject *object)
}
/* parent class */
- parent_class->dispose (object);
+ G_OBJECT_CLASS (gda_holder_parent_class)->dispose (object);
}
static void
@@ -611,7 +570,7 @@ gda_holder_finalize (GObject * object)
g_rec_mutex_clear (& (priv->mutex));
/* parent class */
- parent_class->finalize (object);
+ G_OBJECT_CLASS (gda_holder_parent_class)->finalize (object);
}
diff --git a/libgda/gda-holder.h b/libgda/gda-holder.h
index 636f92e4c..286161caf 100644
--- a/libgda/gda-holder.h
+++ b/libgda/gda-holder.h
@@ -28,11 +28,6 @@
G_BEGIN_DECLS
-#define GDA_TYPE_HOLDER (gda_holder_get_type())
-#define GDA_HOLDER(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, gda_holder_get_type(), GdaHolder)
-#define GDA_HOLDER_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, gda_holder_get_type (), GdaHolderClass)
-#define GDA_IS_HOLDER(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, gda_holder_get_type ())
-
/* error reporting */
extern GQuark gda_holder_error_quark (void);
#define GDA_HOLDER_ERROR gda_holder_error_quark ()
@@ -43,11 +38,8 @@ typedef enum {
GDA_HOLDER_VALUE_NULL_ERROR
} GdaHolderError;
-/* struct for the object's data */
-struct _GdaHolder
-{
- GObject object;
-};
+#define GDA_TYPE_HOLDER (gda_holder_get_type())
+G_DECLARE_DERIVABLE_TYPE(GdaHolder, gda_holder, GDA, HOLDER, GObject)
/* struct for the object's class */
@@ -83,7 +75,6 @@ struct _GdaHolderClass
* Each GdaHolder object is thread safe.
*/
-GType gda_holder_get_type (void) G_GNUC_CONST;
GdaHolder *gda_holder_new (GType type);
GdaHolder *gda_holder_new_inline (GType type, const gchar *id, ...);
GdaHolder *gda_holder_copy (GdaHolder *orig);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]