[libgovirt] Update usage of GObject private structures



commit 1692f448b06d3d830a3456a2572e86894b4f42bf
Author: Eduardo Lima (Etrunko) <etrunko redhat com>
Date:   Wed Feb 6 11:34:12 2019 -0200

    Update usage of GObject private structures
    
    New functions and macros have been added in glib 2.38 to better handle
    this case.
    
    https://gitlab.gnome.org/GNOME/glib/blob/c8de2b11bbbf5705ee20bf68d0c11e455b441312/NEWS
    
    The old method is being deprecated as of version 2.58.
    
    https://gitlab.gnome.org/GNOME/glib/merge_requests/7/commits
    
    Signed-off-by: Eduardo Lima (Etrunko) <etrunko redhat com>

 govirt/ovirt-action-rest-call.c   |  3 ---
 govirt/ovirt-api.c                | 10 ++--------
 govirt/ovirt-cdrom.c              |  9 ++-------
 govirt/ovirt-cluster.c            |  9 ++-------
 govirt/ovirt-collection.c         |  9 ++-------
 govirt/ovirt-data-center.c        |  9 ++-------
 govirt/ovirt-host.c               |  9 ++-------
 govirt/ovirt-proxy.c              |  8 ++------
 govirt/ovirt-resource-rest-call.c |  9 ++-------
 govirt/ovirt-resource.c           | 10 +++-------
 govirt/ovirt-rest-call.c          | 10 ++--------
 govirt/ovirt-storage-domain.c     |  9 ++-------
 govirt/ovirt-vm-display.c         |  9 ++-------
 govirt/ovirt-vm-pool.c            |  8 ++------
 govirt/ovirt-vm.c                 | 10 +++-------
 15 files changed, 30 insertions(+), 101 deletions(-)
---
diff --git a/govirt/ovirt-action-rest-call.c b/govirt/ovirt-action-rest-call.c
index 37a5481..03c6044 100644
--- a/govirt/ovirt-action-rest-call.c
+++ b/govirt/ovirt-action-rest-call.c
@@ -29,9 +29,6 @@
 #include "ovirt-rest-call-error.h"
 #include <rest/rest-params.h>
 
-#define OVIRT_ACTION_REST_CALL_GET_PRIVATE(obj)                         \
-        (G_TYPE_INSTANCE_GET_PRIVATE((obj), OVIRT_TYPE_ACTION_REST_CALL, OvirtActionRestCallPrivate))
-
 G_DEFINE_TYPE(OvirtActionRestCall, ovirt_action_rest_call, OVIRT_TYPE_REST_CALL);
 
 static gboolean ovirt_action_rest_call_class_serialize_params(RestProxyCall *call,
diff --git a/govirt/ovirt-api.c b/govirt/ovirt-api.c
index d78ba7e..e55a67b 100644
--- a/govirt/ovirt-api.c
+++ b/govirt/ovirt-api.c
@@ -36,10 +36,6 @@
 #include <stdlib.h>
 #include <string.h>
 
-#define OVIRT_API_GET_PRIVATE(obj)                         \
-        (G_TYPE_INSTANCE_GET_PRIVATE((obj), OVIRT_TYPE_API, OvirtApiPrivate))
-
-
 struct _OvirtApiPrivate {
     OvirtCollection *clusters;
     OvirtCollection *data_centers;
@@ -50,7 +46,7 @@ struct _OvirtApiPrivate {
 };
 
 
-G_DEFINE_TYPE(OvirtApi, ovirt_api, OVIRT_TYPE_RESOURCE);
+G_DEFINE_TYPE_WITH_PRIVATE(OvirtApi, ovirt_api, OVIRT_TYPE_RESOURCE);
 
 
 static gboolean ovirt_api_init_from_xml(OvirtResource *resource,
@@ -92,8 +88,6 @@ static void ovirt_api_class_init(OvirtApiClass *klass)
     GObjectClass *object_class = G_OBJECT_CLASS(klass);
     OvirtResourceClass *resource_class = OVIRT_RESOURCE_CLASS(klass);
 
-    g_type_class_add_private(klass, sizeof(OvirtApiPrivate));
-
     object_class->dispose = ovirt_api_dispose;
 
     resource_class->init_from_xml = ovirt_api_init_from_xml;
@@ -101,7 +95,7 @@ static void ovirt_api_class_init(OvirtApiClass *klass)
 
 static void ovirt_api_init(G_GNUC_UNUSED OvirtApi *api)
 {
-    api->priv = OVIRT_API_GET_PRIVATE(api);
+    api->priv = ovirt_api_get_instance_private(api);
 }
 
 G_GNUC_INTERNAL
diff --git a/govirt/ovirt-cdrom.c b/govirt/ovirt-cdrom.c
index f625a0c..59e8fac 100644
--- a/govirt/ovirt-cdrom.c
+++ b/govirt/ovirt-cdrom.c
@@ -30,14 +30,11 @@
 #include "ovirt-resource-rest-call.h"
 #include "ovirt-utils.h"
 
-#define OVIRT_CDROM_GET_PRIVATE(obj)                         \
-        (G_TYPE_INSTANCE_GET_PRIVATE((obj), OVIRT_TYPE_CDROM, OvirtCdromPrivate))
-
 struct _OvirtCdromPrivate {
     char *file;
 };
 
-G_DEFINE_TYPE(OvirtCdrom, ovirt_cdrom, OVIRT_TYPE_RESOURCE);
+G_DEFINE_TYPE_WITH_PRIVATE(OvirtCdrom, ovirt_cdrom, OVIRT_TYPE_RESOURCE);
 
 
 enum {
@@ -156,8 +153,6 @@ static void ovirt_cdrom_class_init(OvirtCdromClass *klass)
     OvirtResourceClass *resource_class = OVIRT_RESOURCE_CLASS(klass);
     GParamSpec *param_spec;
 
-    g_type_class_add_private(klass, sizeof(OvirtCdromPrivate));
-
     resource_class->init_from_xml = ovirt_cdrom_init_from_xml;
     resource_class->to_xml = ovirt_cdrom_to_xml;
     resource_class->add_rest_params = ovirt_cdrom_add_rest_params;
@@ -179,7 +174,7 @@ static void ovirt_cdrom_class_init(OvirtCdromClass *klass)
 
 static void ovirt_cdrom_init(OvirtCdrom *cdrom)
 {
-    cdrom->priv = OVIRT_CDROM_GET_PRIVATE(cdrom);
+    cdrom->priv = ovirt_cdrom_get_instance_private(cdrom);
 }
 
 
diff --git a/govirt/ovirt-cluster.c b/govirt/ovirt-cluster.c
index ae25d63..8c3e19f 100644
--- a/govirt/ovirt-cluster.c
+++ b/govirt/ovirt-cluster.c
@@ -25,16 +25,13 @@
 #include "ovirt-cluster.h"
 #include "govirt-private.h"
 
-#define OVIRT_CLUSTER_GET_PRIVATE(obj)                         \
-        (G_TYPE_INSTANCE_GET_PRIVATE((obj), OVIRT_TYPE_CLUSTER, OvirtClusterPrivate))
-
 struct _OvirtClusterPrivate {
     gchar *data_center_href;
     gchar *data_center_id;
     OvirtCollection *hosts;
 };
 
-G_DEFINE_TYPE(OvirtCluster, ovirt_cluster, OVIRT_TYPE_RESOURCE);
+G_DEFINE_TYPE_WITH_PRIVATE(OvirtCluster, ovirt_cluster, OVIRT_TYPE_RESOURCE);
 
 enum {
     PROP_0,
@@ -139,8 +136,6 @@ static void ovirt_cluster_class_init(OvirtClusterClass *klass)
     OvirtResourceClass *resource_class = OVIRT_RESOURCE_CLASS(klass);
     GParamSpec *param_spec;
 
-    g_type_class_add_private(klass, sizeof(OvirtClusterPrivate));
-
     resource_class->init_from_xml = ovirt_cluster_init_from_xml;
     object_class->dispose = ovirt_cluster_dispose;
     object_class->get_property = ovirt_cluster_get_property;
@@ -169,7 +164,7 @@ static void ovirt_cluster_class_init(OvirtClusterClass *klass)
 
 static void ovirt_cluster_init(OvirtCluster *cluster)
 {
-    cluster->priv = OVIRT_CLUSTER_GET_PRIVATE(cluster);
+    cluster->priv = ovirt_cluster_get_instance_private(cluster);
 }
 
 G_GNUC_INTERNAL
diff --git a/govirt/ovirt-collection.c b/govirt/ovirt-collection.c
index 8008903..fc5d101 100644
--- a/govirt/ovirt-collection.c
+++ b/govirt/ovirt-collection.c
@@ -30,9 +30,6 @@
 #include "ovirt-error.h"
 #include "govirt-private.h"
 
-#define OVIRT_COLLECTION_GET_PRIVATE(obj)                         \
-        (G_TYPE_INSTANCE_GET_PRIVATE((obj), OVIRT_TYPE_COLLECTION, OvirtCollectionPrivate))
-
 struct _OvirtCollectionPrivate {
     char *href;
     char *collection_xml_name;
@@ -42,7 +39,7 @@ struct _OvirtCollectionPrivate {
     GHashTable *resources;
 };
 
-G_DEFINE_TYPE(OvirtCollection, ovirt_collection, G_TYPE_OBJECT);
+G_DEFINE_TYPE_WITH_PRIVATE(OvirtCollection, ovirt_collection, G_TYPE_OBJECT);
 
 
 enum {
@@ -129,8 +126,6 @@ static void ovirt_collection_class_init(OvirtCollectionClass *klass)
     GObjectClass *object_class = G_OBJECT_CLASS(klass);
     GParamSpec *param_spec;
 
-    g_type_class_add_private(klass, sizeof(OvirtCollectionPrivate));
-
     object_class->finalize = ovirt_collection_finalize;
     object_class->get_property = ovirt_collection_get_property;
     object_class->set_property = ovirt_collection_set_property;
@@ -193,7 +188,7 @@ static void ovirt_collection_class_init(OvirtCollectionClass *klass)
 
 static void ovirt_collection_init(OvirtCollection *collection)
 {
-    collection->priv = OVIRT_COLLECTION_GET_PRIVATE(collection);
+    collection->priv = ovirt_collection_get_instance_private(collection);
 }
 
 /**
diff --git a/govirt/ovirt-data-center.c b/govirt/ovirt-data-center.c
index 577a31f..f4133fb 100644
--- a/govirt/ovirt-data-center.c
+++ b/govirt/ovirt-data-center.c
@@ -25,15 +25,12 @@
 #include "ovirt-data-center.h"
 #include "govirt-private.h"
 
-#define OVIRT_DATA_CENTER_GET_PRIVATE(obj)                         \
-        (G_TYPE_INSTANCE_GET_PRIVATE((obj), OVIRT_TYPE_DATA_CENTER, OvirtDataCenterPrivate))
-
 struct _OvirtDataCenterPrivate {
     OvirtCollection *clusters;
     OvirtCollection *storage_domains;
 };
 
-G_DEFINE_TYPE(OvirtDataCenter, ovirt_data_center, OVIRT_TYPE_RESOURCE);
+G_DEFINE_TYPE_WITH_PRIVATE(OvirtDataCenter, ovirt_data_center, OVIRT_TYPE_RESOURCE);
 
 static void
 ovirt_data_center_dispose(GObject *obj)
@@ -50,15 +47,13 @@ static void ovirt_data_center_class_init(OvirtDataCenterClass *klass)
 {
     GObjectClass *object_class = G_OBJECT_CLASS(klass);
 
-    g_type_class_add_private(klass, sizeof(OvirtDataCenterPrivate));
-
     object_class->dispose = ovirt_data_center_dispose;
 }
 
 
 static void ovirt_data_center_init(OvirtDataCenter *data_center)
 {
-    data_center->priv = OVIRT_DATA_CENTER_GET_PRIVATE(data_center);
+    data_center->priv = ovirt_data_center_get_instance_private(data_center);
 }
 
 G_GNUC_INTERNAL
diff --git a/govirt/ovirt-host.c b/govirt/ovirt-host.c
index 1570cba..e0fa8ec 100644
--- a/govirt/ovirt-host.c
+++ b/govirt/ovirt-host.c
@@ -25,16 +25,13 @@
 #include "ovirt-host.h"
 #include "govirt-private.h"
 
-#define OVIRT_HOST_GET_PRIVATE(obj)                         \
-        (G_TYPE_INSTANCE_GET_PRIVATE((obj), OVIRT_TYPE_HOST, OvirtHostPrivate))
-
 struct _OvirtHostPrivate {
     gchar *cluster_href;
     gchar *cluster_id;
     OvirtCollection *vms;
 };
 
-G_DEFINE_TYPE(OvirtHost, ovirt_host, OVIRT_TYPE_RESOURCE);
+G_DEFINE_TYPE_WITH_PRIVATE(OvirtHost, ovirt_host, OVIRT_TYPE_RESOURCE);
 
 enum {
     PROP_0,
@@ -140,8 +137,6 @@ static void ovirt_host_class_init(OvirtHostClass *klass)
     OvirtResourceClass *resource_class = OVIRT_RESOURCE_CLASS(klass);
     GParamSpec *param_spec;
 
-    g_type_class_add_private(klass, sizeof(OvirtHostPrivate));
-
     resource_class->init_from_xml = ovirt_host_init_from_xml;
     object_class->dispose = ovirt_host_dispose;
     object_class->get_property = ovirt_host_get_property;
@@ -170,7 +165,7 @@ static void ovirt_host_class_init(OvirtHostClass *klass)
 
 static void ovirt_host_init(OvirtHost *host)
 {
-    host->priv = OVIRT_HOST_GET_PRIVATE(host);
+    host->priv = ovirt_host_get_instance_private(host);
 }
 
 G_GNUC_INTERNAL
diff --git a/govirt/ovirt-proxy.c b/govirt/ovirt-proxy.c
index b337d93..739bb25 100644
--- a/govirt/ovirt-proxy.c
+++ b/govirt/ovirt-proxy.c
@@ -40,9 +40,7 @@
 #include <rest/rest-xml-node.h>
 #include <rest/rest-xml-parser.h>
 
-G_DEFINE_TYPE (OvirtProxy, ovirt_proxy, REST_TYPE_PROXY);
-
-#define OVIRT_PROXY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), OVIRT_TYPE_PROXY, OvirtProxyPrivate))
+G_DEFINE_TYPE_WITH_PRIVATE (OvirtProxy, ovirt_proxy, REST_TYPE_PROXY);
 
 enum {
     PROP_0,
@@ -964,8 +962,6 @@ ovirt_proxy_class_init(OvirtProxyClass *klass)
                                                         NULL,
                                                         G_PARAM_READWRITE |
                                                         G_PARAM_STATIC_STRINGS));
-
-    g_type_class_add_private(klass, sizeof(OvirtProxyPrivate));
 }
 
 static void ssl_ca_file_changed(GObject *gobject,
@@ -985,7 +981,7 @@ ovirt_proxy_init(OvirtProxy *self)
 {
     gulong handler_id;
 
-    self->priv = OVIRT_PROXY_GET_PRIVATE(self);
+    self->priv = ovirt_proxy_get_instance_private(self);
 
     handler_id = g_signal_connect(G_OBJECT(self), "notify::ssl-ca-file",
                                   (GCallback)ssl_ca_file_changed, NULL);
diff --git a/govirt/ovirt-resource-rest-call.c b/govirt/ovirt-resource-rest-call.c
index e72b0e9..ff94468 100644
--- a/govirt/ovirt-resource-rest-call.c
+++ b/govirt/ovirt-resource-rest-call.c
@@ -34,13 +34,10 @@
 #include "ovirt-rest-call-error.h"
 #include "ovirt-utils.h"
 
-#define OVIRT_RESOURCE_REST_CALL_GET_PRIVATE(obj)                         \
-        (G_TYPE_INSTANCE_GET_PRIVATE((obj), OVIRT_TYPE_RESOURCE_REST_CALL, OvirtResourceRestCallPrivate))
-
 struct _OvirtResourceRestCallPrivate {
     OvirtResource *resource;
 } ;
-G_DEFINE_TYPE(OvirtResourceRestCall, ovirt_resource_rest_call, OVIRT_TYPE_REST_CALL);
+G_DEFINE_TYPE_WITH_PRIVATE(OvirtResourceRestCall, ovirt_resource_rest_call, OVIRT_TYPE_REST_CALL);
 
 enum {
     PROP_0,
@@ -166,8 +163,6 @@ static void ovirt_resource_rest_call_class_init(OvirtResourceRestCallClass *klas
     GParamSpec *param_spec;
     GObjectClass *object_class = G_OBJECT_CLASS(klass);
 
-    g_type_class_add_private(klass, sizeof(OvirtResourceRestCallPrivate));
-
     object_class->dispose = ovirt_resource_rest_call_dispose;
     object_class->get_property = ovirt_resource_rest_call_get_property;
     object_class->set_property = ovirt_resource_rest_call_set_property;
@@ -186,7 +181,7 @@ static void ovirt_resource_rest_call_class_init(OvirtResourceRestCallClass *klas
 
 static void ovirt_resource_rest_call_init(OvirtResourceRestCall *call)
 {
-    call->priv = OVIRT_RESOURCE_REST_CALL_GET_PRIVATE(call);
+    call->priv = ovirt_resource_rest_call_get_instance_private(call);
 }
 
 OvirtResourceRestCall *ovirt_resource_rest_call_new(RestProxy *proxy,
diff --git a/govirt/ovirt-resource.c b/govirt/ovirt-resource.c
index 1984b1d..85c55a1 100644
--- a/govirt/ovirt-resource.c
+++ b/govirt/ovirt-resource.c
@@ -35,9 +35,6 @@
 #include "ovirt-resource.h"
 #undef GOVIRT_UNSTABLE_API_ABI
 
-#define OVIRT_RESOURCE_GET_PRIVATE(obj)                         \
-        (G_TYPE_INSTANCE_GET_PRIVATE((obj), OVIRT_TYPE_RESOURCE, OvirtResourcePrivate))
-
 struct _OvirtResourcePrivate {
     char *guid;
     char *href;
@@ -60,7 +57,8 @@ static gboolean ovirt_resource_init_from_xml(OvirtResource *resource,
 
 G_DEFINE_TYPE_WITH_CODE(OvirtResource, ovirt_resource, G_TYPE_OBJECT,
                         G_IMPLEMENT_INTERFACE(G_TYPE_INITABLE,
-                                              ovirt_resource_initable_iface_init));
+                                              ovirt_resource_initable_iface_init);
+                        G_ADD_PRIVATE(OvirtResource));
 
 
 enum {
@@ -204,8 +202,6 @@ static void ovirt_resource_class_init(OvirtResourceClass *klass)
 {
     GObjectClass *object_class = G_OBJECT_CLASS(klass);
 
-    g_type_class_add_private(klass, sizeof(OvirtResourcePrivate));
-
     klass->init_from_xml = ovirt_resource_init_from_xml_real;
     object_class->dispose = ovirt_resource_dispose;
     object_class->finalize = ovirt_resource_finalize;
@@ -257,7 +253,7 @@ static void ovirt_resource_class_init(OvirtResourceClass *klass)
 
 static void ovirt_resource_init(OvirtResource *resource)
 {
-    resource->priv = OVIRT_RESOURCE_GET_PRIVATE(resource);
+    resource->priv = ovirt_resource_get_instance_private(resource);
     resource->priv->actions = g_hash_table_new_full(g_str_hash, g_str_equal,
                                                     g_free, g_free);
     resource->priv->sub_collections = g_hash_table_new_full(g_str_hash,
diff --git a/govirt/ovirt-rest-call.c b/govirt/ovirt-rest-call.c
index cab3240..14958ac 100644
--- a/govirt/ovirt-rest-call.c
+++ b/govirt/ovirt-rest-call.c
@@ -30,16 +30,12 @@
 #include "ovirt-rest-call-error.h"
 #include "ovirt-utils.h"
 
-#define OVIRT_REST_CALL_GET_PRIVATE(obj)                         \
-        (G_TYPE_INSTANCE_GET_PRIVATE((obj), OVIRT_TYPE_REST_CALL, OvirtRestCallPrivate))
-
-
 struct _OvirtRestCallPrivate {
     char *href;
 };
 
 
-G_DEFINE_ABSTRACT_TYPE(OvirtRestCall, ovirt_rest_call, REST_TYPE_PROXY_CALL);
+G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE(OvirtRestCall, ovirt_rest_call, REST_TYPE_PROXY_CALL);
 
 
 enum {
@@ -139,8 +135,6 @@ static void ovirt_rest_call_class_init(OvirtRestCallClass *klass)
     GObjectClass *object_class = G_OBJECT_CLASS(klass);
     GParamSpec *param_spec;
 
-    g_type_class_add_private(klass, sizeof(OvirtRestCallPrivate));
-
     object_class->get_property = ovirt_rest_call_get_property;
     object_class->set_property = ovirt_rest_call_set_property;
     object_class->constructed = ovirt_rest_call_constructed;
@@ -169,5 +163,5 @@ static void ovirt_rest_call_class_init(OvirtRestCallClass *klass)
 
 static void ovirt_rest_call_init(G_GNUC_UNUSED OvirtRestCall *call)
 {
-    call->priv = OVIRT_REST_CALL_GET_PRIVATE(call);
+    call->priv = ovirt_rest_call_get_instance_private(call);
 }
diff --git a/govirt/ovirt-storage-domain.c b/govirt/ovirt-storage-domain.c
index a9078f4..1d636e6 100644
--- a/govirt/ovirt-storage-domain.c
+++ b/govirt/ovirt-storage-domain.c
@@ -25,9 +25,6 @@
 #include "ovirt-storage-domain.h"
 #include "govirt-private.h"
 
-#define OVIRT_STORAGE_DOMAIN_GET_PRIVATE(obj)                         \
-        (G_TYPE_INSTANCE_GET_PRIVATE((obj), OVIRT_TYPE_STORAGE_DOMAIN, OvirtStorageDomainPrivate))
-
 struct _OvirtStorageDomainPrivate {
     OvirtCollection *files;
     GStrv data_center_ids;
@@ -41,7 +38,7 @@ struct _OvirtStorageDomainPrivate {
     OvirtStorageDomainState state;
 };
 
-G_DEFINE_TYPE(OvirtStorageDomain, ovirt_storage_domain, OVIRT_TYPE_RESOURCE);
+G_DEFINE_TYPE_WITH_PRIVATE(OvirtStorageDomain, ovirt_storage_domain, OVIRT_TYPE_RESOURCE);
 
 enum {
     PROP_0,
@@ -196,8 +193,6 @@ static void ovirt_storage_domain_class_init(OvirtStorageDomainClass *klass)
     OvirtResourceClass *resource_class = OVIRT_RESOURCE_CLASS(klass);
     GParamSpec *param_spec;
 
-    g_type_class_add_private(klass, sizeof(OvirtStorageDomainPrivate));
-
     resource_class->init_from_xml = ovirt_storage_domain_init_from_xml;
     object_class->dispose = ovirt_storage_domain_dispose;
     object_class->get_property = ovirt_storage_domain_get_property;
@@ -295,7 +290,7 @@ static void ovirt_storage_domain_class_init(OvirtStorageDomainClass *klass)
 
 static void ovirt_storage_domain_init(OvirtStorageDomain *domain)
 {
-    domain->priv = OVIRT_STORAGE_DOMAIN_GET_PRIVATE(domain);
+    domain->priv = ovirt_storage_domain_get_instance_private(domain);
 }
 
 G_GNUC_INTERNAL
diff --git a/govirt/ovirt-vm-display.c b/govirt/ovirt-vm-display.c
index ebb04c2..5721578 100644
--- a/govirt/ovirt-vm-display.c
+++ b/govirt/ovirt-vm-display.c
@@ -26,9 +26,6 @@
 #include "ovirt-vm-display.h"
 #include "ovirt-utils.h"
 
-#define OVIRT_VM_DISPLAY_GET_PRIVATE(obj)                         \
-        (G_TYPE_INSTANCE_GET_PRIVATE((obj), OVIRT_TYPE_VM_DISPLAY, OvirtVmDisplayPrivate))
-
 struct _OvirtVmDisplayPrivate {
     OvirtVmDisplayType type;
     char *address;
@@ -44,7 +41,7 @@ struct _OvirtVmDisplayPrivate {
     char *proxy_url;
 };
 
-G_DEFINE_TYPE(OvirtVmDisplay, ovirt_vm_display, G_TYPE_OBJECT);
+G_DEFINE_TYPE_WITH_PRIVATE(OvirtVmDisplay, ovirt_vm_display, G_TYPE_OBJECT);
 
 enum {
     PROP_0,
@@ -186,8 +183,6 @@ static void ovirt_vm_display_class_init(OvirtVmDisplayClass *klass)
 {
     GObjectClass *object_class = G_OBJECT_CLASS(klass);
 
-    g_type_class_add_private(klass, sizeof(OvirtVmDisplayPrivate));
-
     object_class->finalize = ovirt_vm_display_finalize;
     object_class->get_property = ovirt_vm_display_get_property;
     object_class->set_property = ovirt_vm_display_set_property;
@@ -297,7 +292,7 @@ static void ovirt_vm_display_class_init(OvirtVmDisplayClass *klass)
 
 static void ovirt_vm_display_init(G_GNUC_UNUSED OvirtVmDisplay *display)
 {
-    display->priv = OVIRT_VM_DISPLAY_GET_PRIVATE(display);
+    display->priv = ovirt_vm_display_get_instance_private(display);
 }
 
 OvirtVmDisplay *ovirt_vm_display_new(void)
diff --git a/govirt/ovirt-vm-pool.c b/govirt/ovirt-vm-pool.c
index 9d0d742..cd153f9 100644
--- a/govirt/ovirt-vm-pool.c
+++ b/govirt/ovirt-vm-pool.c
@@ -29,8 +29,6 @@
 
 
 static gboolean ovirt_vm_pool_refresh_from_xml(OvirtVmPool *vm_pool, RestXmlNode *node);
-#define OVIRT_VM_POOL_GET_PRIVATE(obj)                         \
-        (G_TYPE_INSTANCE_GET_PRIVATE((obj), OVIRT_TYPE_VM_POOL, OvirtVmPoolPrivate))
 
 struct _OvirtVmPoolPrivate {
         guint prestarted_vms;
@@ -38,7 +36,7 @@ struct _OvirtVmPoolPrivate {
         guint size;
 };
 
-G_DEFINE_TYPE(OvirtVmPool, ovirt_vm_pool, OVIRT_TYPE_RESOURCE);
+G_DEFINE_TYPE_WITH_PRIVATE(OvirtVmPool, ovirt_vm_pool, OVIRT_TYPE_RESOURCE);
 
 enum OvirtResponseStatus {
     OVIRT_RESPONSE_UNKNOWN,
@@ -125,8 +123,6 @@ static void ovirt_vm_pool_class_init(OvirtVmPoolClass *klass)
     GObjectClass *object_class = G_OBJECT_CLASS(klass);
     OvirtResourceClass *resource_class = OVIRT_RESOURCE_CLASS(klass);
 
-    g_type_class_add_private(klass, sizeof(OvirtVmPoolPrivate));
-
     resource_class->init_from_xml = ovirt_vm_pool_init_from_xml;
     object_class->dispose = ovirt_vm_pool_dispose;
     object_class->get_property = ovirt_vm_pool_get_property;
@@ -163,7 +159,7 @@ static void ovirt_vm_pool_class_init(OvirtVmPoolClass *klass)
 
 static void ovirt_vm_pool_init(G_GNUC_UNUSED OvirtVmPool *vm_pool)
 {
-    vm_pool->priv = OVIRT_VM_POOL_GET_PRIVATE(vm_pool);
+    vm_pool->priv = ovirt_vm_pool_get_instance_private(vm_pool);
 }
 
 OvirtVmPool *ovirt_vm_pool_new(void)
diff --git a/govirt/ovirt-vm.c b/govirt/ovirt-vm.c
index 8cd482b..0dc0e60 100644
--- a/govirt/ovirt-vm.c
+++ b/govirt/ovirt-vm.c
@@ -34,9 +34,6 @@
 static gboolean parse_ticket_status(RestXmlNode *root, OvirtResource *resource,
                                     GError **error);
 
-#define OVIRT_VM_GET_PRIVATE(obj)                         \
-        (G_TYPE_INSTANCE_GET_PRIVATE((obj), OVIRT_TYPE_VM, OvirtVmPrivate))
-
 struct _OvirtVmPrivate {
     OvirtCollection *cdroms;
 
@@ -47,7 +44,8 @@ struct _OvirtVmPrivate {
     gchar *cluster_href;
     gchar *cluster_id;
 } ;
-G_DEFINE_TYPE(OvirtVm, ovirt_vm, OVIRT_TYPE_RESOURCE);
+
+G_DEFINE_TYPE_WITH_PRIVATE(OvirtVm, ovirt_vm, OVIRT_TYPE_RESOURCE);
 
 enum OvirtResponseStatus {
     OVIRT_RESPONSE_UNKNOWN,
@@ -232,8 +230,6 @@ static void ovirt_vm_class_init(OvirtVmClass *klass)
     GObjectClass *object_class = G_OBJECT_CLASS(klass);
     OvirtResourceClass *resource_class = OVIRT_RESOURCE_CLASS(klass);
 
-    g_type_class_add_private(klass, sizeof(OvirtVmPrivate));
-
     resource_class->init_from_xml = ovirt_vm_init_from_xml;
     object_class->dispose = ovirt_vm_dispose;
     object_class->get_property = ovirt_vm_get_property;
@@ -292,7 +288,7 @@ static void ovirt_vm_class_init(OvirtVmClass *klass)
 
 static void ovirt_vm_init(G_GNUC_UNUSED OvirtVm *vm)
 {
-    vm->priv = OVIRT_VM_GET_PRIVATE(vm);
+    vm->priv = ovirt_vm_get_instance_private(vm);
 }
 
 G_GNUC_INTERNAL


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