[gnome-system-tools/rendering-cleanup: 13/20] e-map: Use G_DEFINE_TYPE



commit 175b7c460d9d87085a25d008575e3fe6d5540f10
Author: Benjamin Otte <otte redhat com>
Date:   Tue Oct 5 14:16:40 2010 +0200

    e-map: Use G_DEFINE_TYPE

 src/time/e-map/e-map.c |   54 ++++++-----------------------------------------
 1 files changed, 7 insertions(+), 47 deletions(-)
---
diff --git a/src/time/e-map/e-map.c b/src/time/e-map/e-map.c
index d379d73..0f96b0a 100644
--- a/src/time/e-map/e-map.c
+++ b/src/time/e-map/e-map.c
@@ -79,8 +79,6 @@ struct _EMapPrivate {
 
 /* Internal prototypes */
 
-static void e_map_class_init (EMapClass *class);
-static void e_map_init (EMap *view);
 static void e_map_finalize (GObject *object);
 static void e_map_destroy (GtkObject *object);
 static void e_map_realize (GtkWidget *widget);
@@ -106,47 +104,11 @@ static void update_and_paint (EMap *map);
 static void update_render_point (EMap *map, EMapPoint *point);
 static void repaint_point (EMap *map, EMapPoint *point);
 
-static GtkWidgetClass *parent_class;
-
 /* ----------------- *
  * Widget management *
  * ----------------- */
 
-/**
- * e_map_get_type:
- * @void:
- *
- * Registers the #EMap class if necessary, and returns the type ID
- * associated to it.
- *
- * Return value: The type ID of the #EMap class.
- **/
-
-GType
-e_map_get_type (void)
-{
-	static GType type = 0;
-
-	if (G_UNLIKELY (type == 0)) {
-		static const GTypeInfo type_info = {
-			sizeof (EMapClass),
-			(GBaseInitFunc) NULL,
-			(GBaseFinalizeFunc) NULL,
-			(GClassInitFunc) e_map_class_init,
-			(GClassFinalizeFunc) NULL,
-			NULL,  /* class_data */
-			sizeof (EMap),
-			0,     /* n_preallocs */
-			(GInstanceInitFunc) e_map_init,
-			NULL   /* value_table */
-		};
-
-		type = g_type_register_static (
-			GTK_TYPE_WIDGET, "EMap", &type_info, 0);
-	}
-
-	return type;
-}
+G_DEFINE_TYPE(EMap, e_map, GTK_TYPE_WIDGET)
 
 /* Class initialization function for the map view */
 
@@ -161,8 +123,6 @@ e_map_class_init (EMapClass *class)
 	object_class = (GtkObjectClass *) class;
 	widget_class = (GtkWidgetClass *) class;
 
-	parent_class = g_type_class_ref(GTK_TYPE_WIDGET);
-
 	gobject_class->finalize = e_map_finalize;
 
 	object_class->destroy = e_map_destroy;
@@ -228,8 +188,8 @@ e_map_destroy (GtkObject *object)
 	g_signal_handlers_disconnect_by_func (priv->hadj, adjustment_changed_cb, view);
 	g_signal_handlers_disconnect_by_func (priv->vadj, adjustment_changed_cb, view);
 
-	if (GTK_OBJECT_CLASS (parent_class)->destroy)
-		(*GTK_OBJECT_CLASS (parent_class)->destroy) (object);
+	if (GTK_OBJECT_CLASS (e_map_parent_class)->destroy)
+		(*GTK_OBJECT_CLASS (e_map_parent_class)->destroy) (object);
 }
 
 /* Finalize handler for the map view */
@@ -264,8 +224,8 @@ e_map_finalize (GObject *object)
 	g_free (priv);
 	view->priv = NULL;
 
-	if (G_OBJECT_CLASS (parent_class)->finalize)
-		(*G_OBJECT_CLASS (parent_class)->finalize) (object);
+	if (G_OBJECT_CLASS (e_map_parent_class)->finalize)
+		(*G_OBJECT_CLASS (e_map_parent_class)->finalize) (object);
 }
 
 /* Realize handler for the map view */
@@ -324,8 +284,8 @@ e_map_unrealize (GtkWidget *widget)
         cairo_surface_destroy (priv->map_render_surface);
         priv->map_render_surface = NULL;
 
-	if (GTK_WIDGET_CLASS (parent_class)->unrealize)
-		(*GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
+	if (GTK_WIDGET_CLASS (e_map_parent_class)->unrealize)
+		(*GTK_WIDGET_CLASS (e_map_parent_class)->unrealize) (widget);
 }
 
 /* Size_request handler for the map view */



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