[gnome-packagekit] Use G_DECLARE_FINAL_TYPE



commit 3cb32d094419a49cb34168944e2d5a251c4e2ceb
Author: Richard Hughes <richard hughsie com>
Date:   Tue Jul 19 09:34:06 2016 +0100

    Use G_DECLARE_FINAL_TYPE

 src/gpk-cell-renderer-info.c    |   42 +++++++++++++++++---------------------
 src/gpk-cell-renderer-info.h    |   23 +-------------------
 src/gpk-cell-renderer-restart.c |    8 ++++++-
 src/gpk-cell-renderer-restart.h |   23 +-------------------
 src/gpk-cell-renderer-size.c    |    9 ++++++-
 src/gpk-cell-renderer-size.h    |   23 +-------------------
 6 files changed, 39 insertions(+), 89 deletions(-)
---
diff --git a/src/gpk-cell-renderer-info.c b/src/gpk-cell-renderer-info.c
index f7ea25c..e52fe81 100644
--- a/src/gpk-cell-renderer-info.c
+++ b/src/gpk-cell-renderer-info.c
@@ -29,21 +29,21 @@
 #include "gpk-enum.h"
 #include "gpk-cell-renderer-info.h"
 
-enum {
-       PROP_0,
-       PROP_VALUE,
-       PROP_IGNORE_VALUES
-};
-
-#define GPK_CELL_RENDERER_INFO_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), 
GPK_TYPE_CELL_RENDERER_INFO, GpkCellRendererInfoPrivate))
-
-struct _GpkCellRendererInfoPrivate
+struct _GpkCellRendererInfo
 {
+       GtkCellRendererPixbuf    parent_instance;
+       GPtrArray               *array;
        PkInfoEnum               value;
        const gchar             *icon_name;
        GPtrArray               *ignore;
 };
 
+enum {
+       PROP_0,
+       PROP_VALUE,
+       PROP_IGNORE_VALUES
+};
+
 G_DEFINE_TYPE (GpkCellRendererInfo, gpk_cell_renderer_info, GTK_TYPE_CELL_RENDERER_PIXBUF)
 
 static gpointer parent_class = NULL;
@@ -56,7 +56,7 @@ gpk_cell_renderer_info_get_property (GObject *object, guint param_id,
 
        switch (param_id) {
        case PROP_VALUE:
-               g_value_set_uint (value, cru->priv->value);
+               g_value_set_uint (value, cru->value);
                break;
        default:
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
@@ -72,10 +72,10 @@ gpk_cell_renderer_should_show (GpkCellRendererInfo *cru)
        PkInfoEnum info;
 
        /* are we in the ignore array */
-       array = cru->priv->ignore;
+       array = cru->ignore;
        for (i = 0; i < array->len; i++) {
                info = GPOINTER_TO_UINT (g_ptr_array_index (array, i));
-               if (info == cru->priv->value)
+               if (info == cru->value)
                        return FALSE;
        }
        return TRUE;
@@ -94,13 +94,13 @@ gpk_cell_renderer_info_set_property (GObject *object, guint param_id,
 
        switch (param_id) {
        case PROP_VALUE:
-               cru->priv->value = g_value_get_uint (value);
+               cru->value = g_value_get_uint (value);
                ret = gpk_cell_renderer_should_show (cru);
                if (!ret) {
                        g_object_set (cru, "icon-name", NULL, NULL);
                } else {
-                       cru->priv->icon_name = gpk_info_status_enum_to_icon_name (cru->priv->value);
-                       g_object_set (cru, "icon-name", cru->priv->icon_name, NULL);
+                       cru->icon_name = gpk_info_status_enum_to_icon_name (cru->value);
+                       g_object_set (cru, "icon-name", cru->icon_name, NULL);
                }
                break;
        case PROP_IGNORE_VALUES:
@@ -109,7 +109,7 @@ gpk_cell_renderer_info_set_property (GObject *object, guint param_id,
                split = g_strsplit (text, ",", -1);
                for (i=0; split[i] != NULL; i++) {
                        info = pk_info_enum_from_string (split[i]);
-                       g_ptr_array_add (cru->priv->ignore, GUINT_TO_POINTER (info));
+                       g_ptr_array_add (cru->ignore, GUINT_TO_POINTER (info));
                }
                break;
        default:
@@ -123,7 +123,7 @@ gpk_cell_renderer_finalize (GObject *object)
 {
        GpkCellRendererInfo *cru;
        cru = GPK_CELL_RENDERER_INFO (object);
-       g_ptr_array_free (cru->priv->ignore, TRUE);
+       g_ptr_array_free (cru->ignore, TRUE);
        G_OBJECT_CLASS (parent_class)->finalize (object);
 }
 
@@ -144,17 +144,13 @@ gpk_cell_renderer_info_class_init (GpkCellRendererInfoClass *class)
        g_object_class_install_property (object_class, PROP_IGNORE_VALUES,
                                         g_param_spec_string ("ignore-values", "IGNORE-VALUES",
                                         "IGNORE-VALUES", "unknown", G_PARAM_WRITABLE));
-
-       g_type_class_add_private (object_class, sizeof (GpkCellRendererInfoPrivate));
 }
 
 static void
 gpk_cell_renderer_info_init (GpkCellRendererInfo *cru)
 {
-       cru->priv = GPK_CELL_RENDERER_INFO_GET_PRIVATE (cru);
-       cru->priv->value = PK_INFO_ENUM_UNKNOWN;
-       cru->priv->icon_name = NULL;
-       cru->priv->ignore = g_ptr_array_new ();
+       cru->value = PK_INFO_ENUM_UNKNOWN;
+       cru->ignore = g_ptr_array_new ();
 }
 
 GtkCellRenderer *
diff --git a/src/gpk-cell-renderer-info.h b/src/gpk-cell-renderer-info.h
index 63d8c21..e38286d 100644
--- a/src/gpk-cell-renderer-info.h
+++ b/src/gpk-cell-renderer-info.h
@@ -26,29 +26,10 @@
 #include <gtk/gtk.h>
 #include <packagekit-glib2/packagekit.h>
 
-#define GPK_TYPE_CELL_RENDERER_INFO            (gpk_cell_renderer_info_get_type())
-#define GPK_CELL_RENDERER_INFO(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), 
GPK_TYPE_CELL_RENDERER_INFO, GpkCellRendererInfo))
-#define GPK_CELL_RENDERER_INFO_CLASS(cls)      (G_TYPE_CHECK_CLASS_CAST((cls), GPK_TYPE_CELL_RENDERER_INFO, 
GpkCellRendererInfoClass))
-#define GPK_IS_CELL_RENDERER_INFO(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), 
GPK_TYPE_CELL_RENDERER_INFO))
-#define GPK_IS_CELL_RENDERER_INFO_CLASS(cls)   (G_TYPE_CHECK_CLASS_TYPE((cls), GPK_TYPE_CELL_RENDERER_INFO))
-#define GPK_CELL_RENDERER_INFO_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj), 
GPK_TYPE_CELL_RENDERER_INFO, GpkCellRendererInfoClass))
-
 G_BEGIN_DECLS
 
-typedef struct _GpkCellRendererInfo            GpkCellRendererInfo;
-typedef struct _GpkCellRendererInfoClass       GpkCellRendererInfoClass;
-typedef struct _GpkCellRendererInfoPrivate     GpkCellRendererInfoPrivate;
-
-struct _GpkCellRendererInfo
-{
-       GtkCellRendererPixbuf            parent;
-       GpkCellRendererInfoPrivate      *priv;
-};
-
-struct _GpkCellRendererInfoClass
-{
-       GtkCellRendererPixbufClass parent_class;
-};
+#define GPK_TYPE_CELL_RENDERER_INFO (gpk_cell_renderer_info_get_type())
+G_DECLARE_FINAL_TYPE (GpkCellRendererInfo, gpk_cell_renderer_info, GPK, CELL_RENDERER_INFO, 
GtkCellRendererPixbuf)
 
 GType           gpk_cell_renderer_info_get_type        (void);
 GtkCellRenderer        *gpk_cell_renderer_info_new             (void);
diff --git a/src/gpk-cell-renderer-restart.c b/src/gpk-cell-renderer-restart.c
index 06c9b8b..610d7ae 100644
--- a/src/gpk-cell-renderer-restart.c
+++ b/src/gpk-cell-renderer-restart.c
@@ -29,6 +29,13 @@
 #include "gpk-enum.h"
 #include "gpk-cell-renderer-restart.h"
 
+struct _GpkCellRendererRestart
+{
+       GtkCellRendererPixbuf    parent_instance;
+       PkRestartEnum            value;
+       const gchar             *icon_name;
+};
+
 enum {
        PROP_0,
        PROP_VALUE
@@ -98,7 +105,6 @@ static void
 gpk_cell_renderer_restart_init (GpkCellRendererRestart *cru)
 {
        cru->value = PK_RESTART_ENUM_NONE;
-       cru->icon_name = NULL;
 }
 
 GtkCellRenderer *
diff --git a/src/gpk-cell-renderer-restart.h b/src/gpk-cell-renderer-restart.h
index 57411e0..a62845e 100644
--- a/src/gpk-cell-renderer-restart.h
+++ b/src/gpk-cell-renderer-restart.h
@@ -26,29 +26,10 @@
 #include <gtk/gtk.h>
 #include <packagekit-glib2/packagekit.h>
 
-#define GPK_TYPE_CELL_RENDERER_RESTART                 (gpk_cell_renderer_restart_get_type())
-#define GPK_CELL_RENDERER_RESTART(obj)                 (G_TYPE_CHECK_INSTANCE_CAST((obj), 
GPK_TYPE_CELL_RENDERER_RESTART, GpkCellRendererRestart))
-#define GPK_CELL_RENDERER_RESTART_CLASS(cls)           (G_TYPE_CHECK_CLASS_CAST((cls), 
GPK_TYPE_CELL_RENDERER_RESTART, GpkCellRendererRestartClass))
-#define GPK_IS_CELL_RENDERER_RESTART(obj)              (G_TYPE_CHECK_INSTANCE_TYPE((obj), 
GPK_TYPE_CELL_RENDERER_RESTART))
-#define GPK_IS_CELL_RENDERER_RESTART_CLASS(cls)                (G_TYPE_CHECK_CLASS_TYPE((cls), 
GPK_TYPE_CELL_RENDERER_RESTART))
-#define GPK_CELL_RENDERER_RESTART_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS((obj), 
GPK_TYPE_CELL_RENDERER_RESTART, GpkCellRendererRestartClass))
-
 G_BEGIN_DECLS
 
-typedef struct _GpkCellRendererRestart         GpkCellRendererRestart;
-typedef struct _GpkCellRendererRestartClass    GpkCellRendererRestartClass;
-
-struct _GpkCellRendererRestart
-{
-       GtkCellRendererPixbuf    parent;
-       PkRestartEnum            value;
-       const gchar             *icon_name;
-};
-
-struct _GpkCellRendererRestartClass
-{
-       GtkCellRendererPixbufClass parent_class;
-};
+#define GPK_TYPE_CELL_RENDERER_RESTART (gpk_cell_renderer_restart_get_type())
+G_DECLARE_FINAL_TYPE (GpkCellRendererRestart, gpk_cell_renderer_restart, GPK, CELL_RENDERER_RESTART, 
GtkCellRendererPixbuf)
 
 GType           gpk_cell_renderer_restart_get_type     (void);
 GtkCellRenderer        *gpk_cell_renderer_restart_new          (void);
diff --git a/src/gpk-cell-renderer-size.c b/src/gpk-cell-renderer-size.c
index d65e46f..cb98af2 100644
--- a/src/gpk-cell-renderer-size.c
+++ b/src/gpk-cell-renderer-size.c
@@ -27,6 +27,13 @@
 
 #include "gpk-cell-renderer-size.h"
 
+struct _GpkCellRendererSize
+{
+       GtkCellRendererText      parent_instance;
+       guint                    value;
+       gchar                   *markup;
+};
+
 enum {
        PROP_0,
        PROP_VALUE
@@ -102,8 +109,6 @@ gpk_cell_renderer_size_class_init (GpkCellRendererSizeClass *class)
 static void
 gpk_cell_renderer_size_init (GpkCellRendererSize *cru)
 {
-       cru->value = 0;
-       cru->markup = NULL;
 }
 
 GtkCellRenderer *
diff --git a/src/gpk-cell-renderer-size.h b/src/gpk-cell-renderer-size.h
index 70cbe23..f49fa1d 100644
--- a/src/gpk-cell-renderer-size.h
+++ b/src/gpk-cell-renderer-size.h
@@ -25,29 +25,10 @@
 #include <glib-object.h>
 #include <gtk/gtk.h>
 
-#define GPK_TYPE_CELL_RENDERER_SIZE            (gpk_cell_renderer_size_get_type())
-#define GPK_CELL_RENDERER_SIZE(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), 
GPK_TYPE_CELL_RENDERER_SIZE, GpkCellRendererSize))
-#define GPK_CELL_RENDERER_SIZE_CLASS(cls)      (G_TYPE_CHECK_CLASS_CAST((cls), GPK_TYPE_CELL_RENDERER_SIZE, 
GpkCellRendererSizeClass))
-#define GPK_IS_CELL_RENDERER_SIZE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), 
GPK_TYPE_CELL_RENDERER_SIZE))
-#define GPK_IS_CELL_RENDERER_SIZE_CLASS(cls)   (G_TYPE_CHECK_CLASS_TYPE((cls), GPK_TYPE_CELL_RENDERER_SIZE))
-#define GPK_CELL_RENDERER_SIZE_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj), 
GPK_TYPE_CELL_RENDERER_SIZE, GpkCellRendererSizeClass))
-
 G_BEGIN_DECLS
 
-typedef struct _GpkCellRendererSize            GpkCellRendererSize;
-typedef struct _GpkCellRendererSizeClass       GpkCellRendererSizeClass;
-
-struct _GpkCellRendererSize
-{
-       GtkCellRendererText      parent;
-       guint                    value;
-       gchar                   *markup;
-};
-
-struct _GpkCellRendererSizeClass
-{
-       GtkCellRendererTextClass parent_class;
-};
+#define GPK_TYPE_CELL_RENDERER_SIZE (gpk_cell_renderer_size_get_type())
+G_DECLARE_FINAL_TYPE (GpkCellRendererSize, gpk_cell_renderer_size, GPK, CELL_RENDERER_SIZE, 
GtkCellRendererText)
 
 GType           gpk_cell_renderer_size_get_type        (void);
 GtkCellRenderer        *gpk_cell_renderer_size_new             (void);


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