[libgda] gda-tree-node: ported to G_DECLARE/G_DEFINE
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda] gda-tree-node: ported to G_DECLARE/G_DEFINE
- Date: Thu, 20 Sep 2018 03:25:31 +0000 (UTC)
commit 9657fc5f57dc19ed4eb4b37e663a90f75f1c481a
Author: Daniel Espinosa <esodan gmail com>
Date: Wed Sep 19 22:23:27 2018 -0500
gda-tree-node: ported to G_DECLARE/G_DEFINE
libgda/gda-tree-node.c | 45 ++-------------------------------------------
libgda/gda-tree-node.h | 26 +++++++++-----------------
2 files changed, 11 insertions(+), 60 deletions(-)
---
diff --git a/libgda/gda-tree-node.c b/libgda/gda-tree-node.c
index c694b0b4d..5ddf1012a 100644
--- a/libgda/gda-tree-node.c
+++ b/libgda/gda-tree-node.c
@@ -29,7 +29,7 @@ typedef struct {
GSList *children; /* list of GdaTreeNodesList */
GdaTreeNode *parent;
} GdaTreeNodePrivate;
-#define gda_tree_node_get_instance_private(obj) G_TYPE_INSTANCE_GET_PRIVATE(obj, GDA_TYPE_TREE_NODE,
GdaTreeNodePrivate)
+G_DEFINE_TYPE_WITH_PRIVATE (GdaTreeNode, gda_tree_node, G_TYPE_OBJECT)
/*
* The GdaTreeNodesList stores the list of children nodes created by a GdaTreeManager object
*/
@@ -45,8 +45,6 @@ void _gda_nodes_list_free (GdaTreeNodesList *nl);
/*
* GObject functions
*/
-static void gda_tree_node_class_init (GdaTreeNodeClass *klass);
-static void gda_tree_node_init (GdaTreeNode *tnode);
static void gda_tree_node_dispose (GObject *object);
static void gda_tree_node_set_property (GObject *object,
guint param_id,
@@ -77,7 +75,6 @@ enum {
PROP_NAME
};
-static GObjectClass *parent_class = NULL;
GdaAttributesManager *_gda_tree_node_attributes_manager;
static void m_node_changed (GdaTreeNode *reporting, GdaTreeNode *node);
@@ -94,9 +91,6 @@ gda_tree_node_class_init (GdaTreeNodeClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- parent_class = g_type_class_peek_parent (klass);
-
- g_type_class_add_private (object_class, sizeof (GdaTreeNodePrivate));
/* signals */
/**
* GdaTreeNode::node-changed:
@@ -291,7 +285,7 @@ gda_tree_node_dispose (GObject *object)
}
/* chain to parent class */
- parent_class->dispose (object);
+ G_OBJECT_CLASS (gda_tree_node_parent_class)->dispose (object);
}
@@ -304,41 +298,6 @@ GQuark gda_tree_node_error_quark (void)
return quark;
}
-/**
- * gda_tree_node_get_type:
- *
- * Registers the #GdaTreeNode class on the GLib type system.
- *
- * Returns: the GType identifying the class.
- */
-GType
-gda_tree_node_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0)) {
- static GMutex registering;
- static const GTypeInfo info = {
- sizeof (GdaTreeNodeClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) gda_tree_node_class_init,
- NULL,
- NULL,
- sizeof (GdaTreeNode),
- 0,
- (GInstanceInitFunc) gda_tree_node_init,
- 0
- };
-
- g_mutex_lock (®istering);
- if (type == 0)
- type = g_type_register_static (G_TYPE_OBJECT, "GdaTreeNode", &info, 0);
- g_mutex_unlock (®istering);
- }
- return type;
-}
-
static void
gda_tree_node_set_property (GObject *object,
guint param_id,
diff --git a/libgda/gda-tree-node.h b/libgda/gda-tree-node.h
index 5e0650c9f..d1780d204 100644
--- a/libgda/gda-tree-node.h
+++ b/libgda/gda-tree-node.h
@@ -27,23 +27,8 @@
G_BEGIN_DECLS
#define GDA_TYPE_TREE_NODE (gda_tree_node_get_type())
-#define GDA_TREE_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, GDA_TYPE_TREE_NODE, GdaTreeNode))
-#define GDA_TREE_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST (klass, GDA_TYPE_TREE_NODE, GdaTreeNodeClass))
-#define GDA_IS_TREE_NODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE(obj, GDA_TYPE_TREE_NODE))
-#define GDA_IS_TREE_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GDA_TYPE_TREE_NODE))
-#define GDA_TREE_NODE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GDA_TYPE_TREE_NODE, GdaTreeNodeClass))
+G_DECLARE_DERIVABLE_TYPE (GdaTreeNode, gda_tree_node, GDA, TREE_NODE, GObject)
-/* error reporting */
-extern GQuark gda_tree_node_error_quark (void);
-#define GDA_TREE_NODE_ERROR gda_tree_node_error_quark ()
-
-typedef enum {
- GDA_TREE_NODE_UNKNOWN_ERROR
-} GdaTreeNodeError;
-
-struct _GdaTreeNode {
- GObject object;
-};
struct _GdaTreeNodeClass {
GObjectClass object_class;
@@ -66,6 +51,14 @@ struct _GdaTreeNodeClass {
void (*_gda_reserved4) (void);
};
+/* error reporting */
+extern GQuark gda_tree_node_error_quark (void);
+#define GDA_TREE_NODE_ERROR gda_tree_node_error_quark ()
+
+typedef enum {
+ GDA_TREE_NODE_UNKNOWN_ERROR
+} GdaTreeNodeError;
+
/**
* SECTION:gda-tree-node
* @short_description: A node in a #GdaTree
@@ -81,7 +74,6 @@ struct _GdaTreeNodeClass {
* calling gda_tree_manager_set_node_create_func()).
*/
-GType gda_tree_node_get_type (void) G_GNUC_CONST;
GdaTreeNode* gda_tree_node_new (const gchar *name);
GdaTreeNode *gda_tree_node_get_parent (GdaTreeNode *node);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]