[gnome-software] category tile: Port to G_DECLARE_FINAL_TYPE macro



commit 78fddbcd32eb88c7d632f7a7ad8c5ba5dc447f04
Author: Kalev Lember <klember redhat com>
Date:   Mon Sep 7 16:27:18 2015 +0200

    category tile: Port to G_DECLARE_FINAL_TYPE macro

 src/gs-category-tile.c |   28 ++++++++++------------------
 src/gs-category-tile.h |   23 ++---------------------
 2 files changed, 12 insertions(+), 39 deletions(-)
---
diff --git a/src/gs-category-tile.c b/src/gs-category-tile.c
index 14cca99..1f6956b 100644
--- a/src/gs-category-tile.c
+++ b/src/gs-category-tile.c
@@ -26,50 +26,42 @@
 
 #include "gs-category-tile.h"
 
-struct _GsCategoryTilePrivate
+struct _GsCategoryTile
 {
+       GtkButton        parent_instance;
+
        GsCategory      *cat;
        GtkWidget       *label;
 };
 
-G_DEFINE_TYPE_WITH_PRIVATE (GsCategoryTile, gs_category_tile, GTK_TYPE_BUTTON)
+G_DEFINE_TYPE (GsCategoryTile, gs_category_tile, GTK_TYPE_BUTTON)
 
 GsCategory *
 gs_category_tile_get_category (GsCategoryTile *tile)
 {
-       GsCategoryTilePrivate *priv;
-
        g_return_val_if_fail (GS_IS_CATEGORY_TILE (tile), NULL);
 
-       priv = gs_category_tile_get_instance_private (tile);
-       return priv->cat;
+       return tile->cat;
 }
 
 void
 gs_category_tile_set_category (GsCategoryTile *tile, GsCategory *cat)
 {
-       GsCategoryTilePrivate *priv;
-
        g_return_if_fail (GS_IS_CATEGORY_TILE (tile));
        g_return_if_fail (GS_IS_CATEGORY (cat));
 
-       priv = gs_category_tile_get_instance_private (tile);
+       g_clear_object (&tile->cat);
+       tile->cat = g_object_ref (cat);
 
-       g_clear_object (&priv->cat);
-       priv->cat = g_object_ref (cat);
-
-       gtk_label_set_label (GTK_LABEL (priv->label), gs_category_get_name (cat));
+       gtk_label_set_label (GTK_LABEL (tile->label), gs_category_get_name (cat));
 }
 
 static void
 gs_category_tile_destroy (GtkWidget *widget)
 {
        GsCategoryTile *tile = GS_CATEGORY_TILE (widget);
-       GsCategoryTilePrivate *priv;
-
-       priv = gs_category_tile_get_instance_private (tile);
 
-       g_clear_object (&priv->cat);
+       g_clear_object (&tile->cat);
 
        GTK_WIDGET_CLASS (gs_category_tile_parent_class)->destroy (widget);
 }
@@ -90,7 +82,7 @@ gs_category_tile_class_init (GsCategoryTileClass *klass)
 
        gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/Software/category-tile.ui");
 
-       gtk_widget_class_bind_template_child_private (widget_class, GsCategoryTile, label);
+       gtk_widget_class_bind_template_child (widget_class, GsCategoryTile, label);
 }
 
 GtkWidget *
diff --git a/src/gs-category-tile.h b/src/gs-category-tile.h
index a7b6b62..7f33758 100644
--- a/src/gs-category-tile.h
+++ b/src/gs-category-tile.h
@@ -26,31 +26,12 @@
 
 #include "gs-category.h"
 
-#define GS_TYPE_CATEGORY_TILE          (gs_category_tile_get_type())
-#define GS_CATEGORY_TILE(obj)          (G_TYPE_CHECK_INSTANCE_CAST((obj), GS_TYPE_CATEGORY_TILE, 
GsCategoryTile))
-#define GS_CATEGORY_TILE_CLASS(cls)    (G_TYPE_CHECK_CLASS_CAST((cls), GS_TYPE_CATEGORY_TILE, 
GsCategoryTileClass))
-#define GS_IS_CATEGORY_TILE(obj)       (G_TYPE_CHECK_INSTANCE_TYPE((obj), GS_TYPE_CATEGORY_TILE))
-#define GS_IS_CATEGORY_TILE_CLASS(cls) (G_TYPE_CHECK_CLASS_TYPE((cls), GS_TYPE_CATEGORY_TILE))
-#define GS_CATEGORY_TILE_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS((obj), GS_TYPE_CATEGORY_TILE, 
GsCategoryTileClass))
-
 G_BEGIN_DECLS
 
-typedef struct _GsCategoryTile                 GsCategoryTile;
-typedef struct _GsCategoryTileClass            GsCategoryTileClass;
-typedef struct _GsCategoryTilePrivate          GsCategoryTilePrivate;
-
-struct _GsCategoryTile
-{
-       GtkButton                parent;
-       GsCategoryTilePrivate   *priv;
-};
+#define GS_TYPE_CATEGORY_TILE (gs_category_tile_get_type ())
 
-struct _GsCategoryTileClass
-{
-       GtkButtonClass           parent_class;
-};
+G_DECLARE_FINAL_TYPE (GsCategoryTile, gs_category_tile, GS, CATEGORY_TILE, GtkButton)
 
-GType           gs_category_tile_get_type              (void);
 GtkWidget      *gs_category_tile_new                   (GsCategory *cat);
 GsCategory      *gs_category_tile_get_category         (GsCategoryTile *tile);
 void            gs_category_tile_set_category          (GsCategoryTile *tile,


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