[gnome-software] GsVendor: Port to G_DECLARE_FINAL_TYPE macro
- From: Kalev Lember <klember src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] GsVendor: Port to G_DECLARE_FINAL_TYPE macro
- Date: Mon, 7 Sep 2015 17:38:58 +0000 (UTC)
commit 9adf7fa546cf1d85de014ab4e48f4b41aad8b3bc
Author: Kalev Lember <klember redhat com>
Date: Mon Sep 7 17:56:34 2015 +0200
GsVendor: Port to G_DECLARE_FINAL_TYPE macro
src/gs-vendor.c | 26 +++++++++-----------------
src/gs-vendor.h | 23 ++---------------------
2 files changed, 11 insertions(+), 38 deletions(-)
---
diff --git a/src/gs-vendor.c b/src/gs-vendor.c
index 59c4985..a5f1964 100644
--- a/src/gs-vendor.c
+++ b/src/gs-vendor.c
@@ -25,10 +25,10 @@
#include "gs-vendor.h"
-#define GS_VENDOR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GS_TYPE_VENDOR, GsVendorPrivate))
-
-struct GsVendorPrivate
+struct _GsVendor
{
+ GObject parent_instance;
+
GKeyFile *file;
};
@@ -62,7 +62,7 @@ gs_vendor_get_not_found_url (GsVendor *vendor, GsVendorUrlType type)
/* get data */
key = gs_vendor_type_to_string (type);
- url = g_key_file_get_string (vendor->priv->file, "PackagesNotFound", key, NULL);
+ url = g_key_file_get_string (vendor->file, "PackagesNotFound", key, NULL);
/* none is a special value */
if (g_strcmp0 (url, "none") == 0) {
@@ -81,7 +81,7 @@ gs_vendor_get_not_found_url (GsVendor *vendor, GsVendorUrlType type)
/* get fallback data */
g_debug ("using fallback");
key = gs_vendor_type_to_string (GS_VENDOR_URL_TYPE_DEFAULT);
- url = g_key_file_get_string (vendor->priv->file, "PackagesNotFound", key, NULL);
+ url = g_key_file_get_string (vendor->file, "PackagesNotFound", key, NULL);
/* none is a special value */
if (g_strcmp0 (url, "none") == 0) {
@@ -102,10 +102,8 @@ gs_vendor_init (GsVendor *vendor)
{
gboolean ret;
- vendor->priv = GS_VENDOR_GET_PRIVATE (vendor);
-
- vendor->priv->file = g_key_file_new ();
- ret = g_key_file_load_from_file (vendor->priv->file, "/etc/PackageKit/Vendor.conf", G_KEY_FILE_NONE,
NULL);
+ vendor->file = g_key_file_new ();
+ ret = g_key_file_load_from_file (vendor->file, "/etc/PackageKit/Vendor.conf", G_KEY_FILE_NONE, NULL);
if (!ret)
g_warning ("file not found");
}
@@ -117,14 +115,9 @@ gs_vendor_init (GsVendor *vendor)
static void
gs_vendor_finalize (GObject *object)
{
- GsVendor *vendor;
-
- g_return_if_fail (PK_IS_VENDOR (object));
-
- vendor = GS_VENDOR (object);
- g_return_if_fail (vendor->priv != NULL);
+ GsVendor *vendor = GS_VENDOR (object);
- g_key_file_free (vendor->priv->file);
+ g_key_file_free (vendor->file);
G_OBJECT_CLASS (gs_vendor_parent_class)->finalize (object);
}
@@ -138,7 +131,6 @@ gs_vendor_class_init (GsVendorClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = gs_vendor_finalize;
- g_type_class_add_private (klass, sizeof (GsVendorPrivate));
}
/**
diff --git a/src/gs-vendor.h b/src/gs-vendor.h
index 47c3e8e..dab2fe1 100644
--- a/src/gs-vendor.h
+++ b/src/gs-vendor.h
@@ -26,27 +26,9 @@
G_BEGIN_DECLS
-#define GS_TYPE_VENDOR (gs_vendor_get_type ())
-#define GS_VENDOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GS_TYPE_VENDOR, GsVendor))
-#define GS_VENDOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GS_TYPE_VENDOR, GsVendorClass))
-#define PK_IS_VENDOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GS_TYPE_VENDOR))
-#define PK_IS_VENDOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GS_TYPE_VENDOR))
-#define GS_VENDOR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GS_TYPE_VENDOR, GsVendorClass))
-#define GS_VENDOR_ERROR (gs_vendor_error_quark ())
-#define GS_VENDOR_TYPE_ERROR (gs_vendor_error_get_type ())
+#define GS_TYPE_VENDOR (gs_vendor_get_type ())
-typedef struct GsVendorPrivate GsVendorPrivate;
-
-typedef struct
-{
- GObject parent;
- GsVendorPrivate *priv;
-} GsVendor;
-
-typedef struct
-{
- GObjectClass parent_class;
-} GsVendorClass;
+G_DECLARE_FINAL_TYPE (GsVendor, gs_vendor, GS, VENDOR, GObject)
typedef enum
{
@@ -57,7 +39,6 @@ typedef enum
GS_VENDOR_URL_TYPE_DEFAULT
} GsVendorUrlType;
-GType gs_vendor_get_type (void);
GsVendor *gs_vendor_new (void);
gchar *gs_vendor_get_not_found_url (GsVendor *vendor,
GsVendorUrlType type);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]