marlin r1296 - trunk/marlin



Author: iain
Date: Mon Oct  6 00:30:22 2008
New Revision: 1296
URL: http://svn.gnome.org/viewvc/marlin?rev=1296&view=rev

Log:
Fix memory leak in MarlinMarkerModel
Update more code


Modified:
   trunk/marlin/ChangeLog
   trunk/marlin/Makefile.am
   trunk/marlin/marlin-cross-fader.c
   trunk/marlin/marlin-grid-point.c
   trunk/marlin/marlin-grid.c
   trunk/marlin/marlin-load-pipeline.c
   trunk/marlin/marlin-marker-model.c
   trunk/marlin/marlin-marker-view.c
   trunk/marlin/marlin-operation.c
   trunk/marlin/marlin-overview-bar.c
   trunk/marlin/marlin-pipeline.c

Modified: trunk/marlin/Makefile.am
==============================================================================
--- trunk/marlin/Makefile.am	(original)
+++ trunk/marlin/Makefile.am	Mon Oct  6 00:30:22 2008
@@ -97,7 +97,6 @@
 	marlin-marker-view.h			\
 	marlin-msgport.h			\
 	marlin-mt.h				\
-	marlin-object.h				\
 	marlin-operation.h			\
 	marlin-overview-bar.h			\
 	marlin-pipeline.h			\

Modified: trunk/marlin/marlin-cross-fader.c
==============================================================================
--- trunk/marlin/marlin-cross-fader.c	(original)
+++ trunk/marlin/marlin-cross-fader.c	Mon Oct  6 00:30:22 2008
@@ -64,26 +64,22 @@
 	guint ms; /* Length in milliseconds */
 };
 
-static GtkWidgetClass *parent_class = NULL;
+#define GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), MARLIN_CROSS_FADER_TYPE, MarlinCrossFaderPrivate))
+G_DEFINE_TYPE (MarlinCrossFader, marlin_cross_fader, GTK_TYPE_WIDGET);
 
 static void
 finalize (GObject *object)
 {
 	MarlinCrossFader *xfade;
+	MarlinCrossFaderPrivate *priv;
 
 	xfade = MARLIN_CROSS_FADER (object);
+	priv = xfade->priv;
 
-	if (xfade->priv == NULL) {
-		return;
-	}
-
-	g_free (xfade->priv->src_fader);
-	g_free (xfade->priv->dest_fader);
-
-	g_free (xfade->priv);
-	xfade->priv = NULL;
+	g_free (priv->src_fader);
+	g_free (priv->dest_fader);
 
-	G_OBJECT_CLASS (parent_class)->finalize (object);
+	G_OBJECT_CLASS (marlin_cross_fader_parent_class)->finalize (object);
 }
 
 static void
@@ -98,7 +94,6 @@
 	if (priv->src != NULL) {
 		g_object_unref (G_OBJECT (priv->src));
 		priv->src = NULL;
-		
 	}
 
 	if (priv->dest != NULL) {
@@ -106,7 +101,7 @@
 		priv->dest = NULL;
 	}
 
-	G_OBJECT_CLASS (parent_class)->dispose (object);
+	G_OBJECT_CLASS (marlin_cross_fader_parent_class)->dispose (object);
 }
 
 static void
@@ -118,10 +113,10 @@
 	MarlinCrossFader *xfade;
 	MarlinCrossFaderPrivate *priv;
 	MarlinSample *sample;
-	
+
 	xfade = MARLIN_CROSS_FADER (object);
 	priv = xfade->priv;
-	
+
 	switch (prop_id) {
 	case PROP_SRC:
 		sample = g_value_get_object (value);
@@ -169,10 +164,10 @@
 {
 	MarlinCrossFader *xfade;
 	MarlinCrossFaderPrivate *priv;
-	
+
 	xfade = MARLIN_CROSS_FADER (object);
 	priv = xfade->priv;
-	
+
 	switch (prop_id) {
 
 	case PROP_SRC:
@@ -209,7 +204,7 @@
 	if (priv->ms % 1000 == 0) {
 		label = g_strdup_printf (_("%d seconds"), priv->ms / 1000);
 	} else {
-		label = g_strdup_printf (_("%.3f seconds"), 
+		label = g_strdup_printf (_("%.3f seconds"),
 					 (float) priv->ms / 1000.0f);
 	}
 	cairo_text_extents (cr, label, &extents);
@@ -249,43 +244,31 @@
 
 	cairo_restore (cr);
 }
-	
+
 static void
-class_init (MarlinCrossFaderClass *klass)
+marlin_cross_fader_class_init (MarlinCrossFaderClass *klass)
 {
-	GObjectClass *object_class;
-	GtkWidgetClass *widget_class;
-	MarlinGridClass *g_class;
-
-	object_class = G_OBJECT_CLASS (klass);
-	widget_class = GTK_WIDGET_CLASS (klass);
-	g_class = MARLIN_GRID_CLASS (klass);
-
-	object_class->finalize = finalize;
-	object_class->dispose = dispose;
-	object_class->set_property = set_property;
-	object_class->get_property = get_property;
+	GObjectClass *o_class = (GObjectClass *) klass;
+	MarlinGridClass *g_class = (MarlinGridClass *) klass;
 
-	g_class->draw_x_axis = draw_x_axis;
+	o_class->finalize = finalize;
+	o_class->dispose = dispose;
+	o_class->set_property = set_property;
+	o_class->get_property = get_property;
 
-	parent_class = g_type_class_peek_parent (klass);
+	g_class->draw_x_axis = draw_x_axis;
 
-	g_object_class_install_property (object_class,
-					 PROP_SRC,
-					 g_param_spec_object ("src",
-							      "", "",
+	g_type_class_add_private (o_class, sizeof (MarlinCrossFaderPrivate));
+	g_object_class_install_property (o_class, PROP_SRC,
+					 g_param_spec_object ("src", "", "",
 							      MARLIN_SAMPLE_TYPE,
 							      G_PARAM_READWRITE));
-	g_object_class_install_property (object_class,
-					 PROP_DEST,
-					 g_param_spec_object ("dest",
-							      "", "",
+	g_object_class_install_property (o_class, PROP_DEST,
+					 g_param_spec_object ("dest", "", "",
 							      MARLIN_SAMPLE_TYPE,
 							      G_PARAM_READWRITE));
-	g_object_class_install_property (object_class,
-					 PROP_SCALE,
-					 g_param_spec_enum ("scale",
-							    "", "",
+	g_object_class_install_property (o_class, PROP_SCALE,
+					 g_param_spec_enum ("scale", "", "",
 							    MARLIN_TYPE_SCALE,
 							    MARLIN_SCALE_LOG,
 							    G_PARAM_READWRITE));
@@ -307,22 +290,22 @@
 
 	marlin_grid_point_set_slave (in, slave);
 	marlin_grid_curve_add_point (curve, in, MARLIN_GRID_POINT_FREE_Y);
-	
+
 	marlin_grid_curve_add_point (curve, out, MARLIN_GRID_POINT_FREE_Y);
-	
+
 	slave = marlin_grid_point_new (CROSSFADE_WIDTH, 0.0);
 	marlin_grid_point_set_slave (out, slave);
 	marlin_grid_curve_add_point (curve, slave, MARLIN_GRID_POINT_FIXED);
 }
 
 static void
-init (MarlinCrossFader *xfade)
+marlin_cross_fader_init (MarlinCrossFader *xfade)
 {
 	MarlinCrossFaderPrivate *priv;
 	MarlinGridCurve *curve;
 	MarlinRange range;
-	
-	xfade->priv = g_new0 (MarlinCrossFaderPrivate, 1);
+
+	xfade->priv = GET_PRIVATE (xfade);
 	priv = xfade->priv;
 
 	priv->scale = MARLIN_SCALE_LOG;
@@ -337,7 +320,7 @@
 	curve->colour.red = 65535;
 	make_fader_curve (curve, xfade->src_in, xfade->src_out);
 	marlin_grid_add_curve (MARLIN_GRID (xfade), curve);
-	
+
 	xfade->dest_in = marlin_grid_point_new (TENTH_WIDTH, 1.0);
 	xfade->dest_out = marlin_grid_point_new (NINTY_WIDTH, 0.0);
 
@@ -347,26 +330,6 @@
 	marlin_grid_add_curve (MARLIN_GRID (xfade), curve);
 }
 
-GType
-marlin_cross_fader_get_type (void)
-{
-	static GType type = 0;
-
-	if (type == 0) {
-		GTypeInfo info = {
-			sizeof (MarlinCrossFaderClass), NULL, NULL,
-			(GClassInitFunc) class_init, NULL, NULL,
-			sizeof (MarlinCrossFader), 0, (GInstanceInitFunc) init
-		};
-
-		type = g_type_register_static (MARLIN_GRID_TYPE,
-					       "MarlinCrossFader",
-					       &info, 0);
-	}
-
-	return type;
-}
-
 void
 marlin_cross_fader_set_length (MarlinCrossFader *fader,
 			       guint             ms)
@@ -376,7 +339,7 @@
 
 	priv->ms = ms;
 
-	/* Redraw the grid: It'd be nice to be able to force 
+	/* Redraw the grid: It'd be nice to be able to force
 	   a redraw of only the x axis? */
 	if (GTK_WIDGET_DRAWABLE (widget)) {
 		GdkRectangle rect;

Modified: trunk/marlin/marlin-grid-point.c
==============================================================================
--- trunk/marlin/marlin-grid-point.c	(original)
+++ trunk/marlin/marlin-grid-point.c	Mon Oct  6 00:30:22 2008
@@ -2,7 +2,7 @@
 /*
  *  Authors: Iain Holmes <iain gnome org>
  *
- *  Copyright 2003-2007 Iain Holmes
+ *  Copyright 2003-2008 Iain Holmes
  *
  *  This file is free software; you can redistribute it and/or
  *  modify it under the terms of version 2 of the GNU Library General Public
@@ -41,24 +41,23 @@
 	MarlinGridPoint *upper_bound;
 };
 
-static GObjectClass *parent_class = NULL;
+G_DEFINE_TYPE (MarlinGridPoint, marlin_grid_point, G_TYPE_OBJECT);
 static guint32 signals[LAST_SIGNAL] = {0, };
 
 static void
 finalize (GObject *object)
 {
-	parent_class->finalize (object);
+	G_OBJECT_CLASS (marlin_grid_point_parent_class)->finalize (object);
 }
 
 static void
-class_init (MarlinGridPointClass *klass)
+marlin_grid_point_class_init (MarlinGridPointClass *klass)
 {
 	GObjectClass *o_class = (GObjectClass *) klass;
 
 	o_class->finalize = finalize;
 
 	g_type_class_add_private (klass, sizeof (MarlinGridPointPrivate));
-	parent_class = g_type_class_peek_parent (klass);
 
 	signals[MOVED] = g_signal_new ("data-changed",
 				       G_TYPE_FROM_CLASS (klass),
@@ -71,30 +70,11 @@
 }
 
 static void
-init (MarlinGridPoint *point)
+marlin_grid_point_init (MarlinGridPoint *point)
 {
 	point->priv = GET_PRIVATE (point);
 }
 
-GType
-marlin_grid_point_get_type (void)
-{
-	static GType type = 0;
-
-	if (!type) {
-		static const GTypeInfo info = {
-			sizeof (MarlinGridPointClass), NULL, NULL,
-			(GClassInitFunc) class_init, NULL, NULL,
-			sizeof (MarlinGridPoint), 0, (GInstanceInitFunc) init
-		};
-
-		type = g_type_register_static (G_TYPE_OBJECT,
-					       "MarlinGridPoint", &info, 0);
-	}
-
-	return type;
-}
-
 MarlinGridPoint *
 marlin_grid_point_new (guint64 x,
 		       float   level)

Modified: trunk/marlin/marlin-grid.c
==============================================================================
--- trunk/marlin/marlin-grid.c	(original)
+++ trunk/marlin/marlin-grid.c	Mon Oct  6 00:30:22 2008
@@ -48,7 +48,7 @@
 
 typedef struct _MarlinCurvePoint {
 	MarlinListNode list;
-	
+
 	MarlinGridPoint *point;
 	gboolean selected;
 	guint32 movability;
@@ -74,7 +74,7 @@
 	gboolean in_grab;
 };
 
-static GObjectClass *parent_class = NULL;
+G_DEFINE_TYPE (MarlinGrid, marlin_grid, G_TYPE_OBJECT);
 
 static void
 finalize (GObject *object)
@@ -91,13 +91,13 @@
 		g_ptr_array_free (priv->curves, TRUE);
 	}
 
-	parent_class->finalize (object);
+	G_OBJECT_CLASS (marlin_grid_parent_class)->finalize (object);
 }
 
 static void
 dispose (GObject *object)
 {
-	parent_class->dispose (object);
+	G_OBJECT_CLASS (marlin_grid_parent_class)->dispose (object);
 }
 
 static void
@@ -113,7 +113,7 @@
 		rect.y = priv->box_y;
 		rect.width = priv->box_width;
 		rect.height = priv->box_height;
-	
+
 		gdk_window_invalidate_rect (widget->window, &rect, FALSE);
 	}
 }
@@ -135,7 +135,7 @@
 	length = priv->finish - priv->start;
 	priv->frames_per_pixel = ceil (((double)length) / (allocation->width - 38));
 
-	GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation);
+	GTK_WIDGET_CLASS (marlin_grid_parent_class)->size_allocate (widget, allocation);
 }
 
 static void
@@ -146,8 +146,8 @@
 			       GDK_BUTTON_PRESS_MASK |
 			       GDK_BUTTON_RELEASE_MASK |
 			       GDK_POINTER_MOTION_MASK);
-	
-	GTK_WIDGET_CLASS (parent_class)->realize (widget);
+
+	GTK_WIDGET_CLASS (marlin_grid_parent_class)->realize (widget);
 }
 
 static void
@@ -162,7 +162,7 @@
 
 	x1 = x - HALF_POINT_WIDTH;
 	y1 = y - HALF_POINT_WIDTH;
-	
+
 	cairo_save (cr);
 
 	if (selected) {
@@ -193,7 +193,7 @@
 	MarlinListNode *l;
 
 	cairo_save (cr);
-	
+
 	for (l = curve->points->first; l; l = marlin_list_node_next (l)) {
 		MarlinCurvePoint *p1, *p2;
 		MarlinGridPoint *point1, *point2;
@@ -212,10 +212,10 @@
 
 			x2 = FRAME_TO_PIXEL (point2->x);
 			y2 = LEVEL_TO_PIXEL (point2->level);
-			
+
 			cairo_move_to (cr, priv->box_x + x1, priv->box_y + y1);
 			cairo_line_to (cr, priv->box_x + x2, priv->box_y + y2);
-			
+
 			gdk_cairo_set_source_color (cr, &curve->colour);
 			cairo_stroke (cr);
 		}
@@ -242,7 +242,7 @@
 	cairo_text_extents_t extents;
 	float offsetx = 0;
 	float offsety = 0;
-	
+
 	cairo_save (cr);
 
 	cairo_set_font_options (cr, priv->options);
@@ -266,7 +266,7 @@
 			b = priv->box_x + (a * divwidth);
 			value = ((length_x / 10) * a) + priv->start;
 			text = g_strdup_printf ("%d", value);
-			
+
 			cairo_text_extents (cr, text, &extents);
 			if (a == 0) {
 				offsetx = 2;
@@ -275,7 +275,7 @@
 			} else {
 				offsetx = (extents.width / 2.0f);
 			}
-			
+
 			cairo_move_to (cr, b - offsetx,
 				       priv->box_y + priv->box_height + 15);
 			cairo_show_text (cr, text);
@@ -297,16 +297,16 @@
 		cairo_text_extents (cr, "0 dB", &extents);
 		offsetx = extents.width + 5;
 		offsety = extents.height;
-		cairo_move_to (cr, priv->box_x - offsetx - 2, 
+		cairo_move_to (cr, priv->box_x - offsetx - 2,
 			       priv->box_y + offsety);
 		cairo_show_text (cr, "0 dB");
-		
+
 		cairo_text_extents (cr, "-" MARLIN_INFINITY_DB_TEXT, &extents);
 		offsetx = extents.width + 5;
-		cairo_move_to (cr, priv->box_x - offsetx - 2, 
+		cairo_move_to (cr, priv->box_x - offsetx - 2,
 			       priv->box_y + priv->box_height);
 		cairo_show_text (cr, "-" MARLIN_INFINITY_DB_TEXT);
-		
+
 		cairo_restore (cr);
 	}
 }
@@ -598,7 +598,7 @@
 }
 
 static void
-class_init (MarlinGridClass *klass)
+marlin_grid_class_init (MarlinGridClass *klass)
 {
 	GObjectClass *o_class = (GObjectClass *) klass;
 	GtkWidgetClass *w_class = (GtkWidgetClass *) klass;
@@ -615,12 +615,10 @@
 	w_class->button_press_event = button_press_event;
 	w_class->button_release_event = button_release_event;
 	w_class->motion_notify_event = motion_notify_event;
-
-	parent_class = g_type_class_peek_parent (klass);
 }
 
 static void
-init (MarlinGrid *grid)
+marlin_grid_init (MarlinGrid *grid)
 {
 	MarlinGridPrivate *priv;
 
@@ -634,25 +632,6 @@
 	priv->curves = g_ptr_array_new ();
 }
 
-GType
-marlin_grid_get_type (void)
-{
-	static GType type = 0;
-
-	if (!type) {
-		static const GTypeInfo info = {
-			sizeof (MarlinGridClass), NULL, NULL,
-			(GClassInitFunc) class_init, NULL, NULL,
-			sizeof (MarlinGrid), 0, (GInstanceInitFunc) init
-		};
-
-		type = g_type_register_static (GTK_TYPE_DRAWING_AREA,
-					       "MarlinGrid", &info, 0);
-	}
-
-	return type;
-}
-
 void
 marlin_grid_add_curve (MarlinGrid      *grid,
 		       MarlinGridCurve *curve)

Modified: trunk/marlin/marlin-load-pipeline.c
==============================================================================
--- trunk/marlin/marlin-load-pipeline.c	(original)
+++ trunk/marlin/marlin-load-pipeline.c	Mon Oct  6 00:30:22 2008
@@ -2,7 +2,7 @@
 /*
  *  Authors: Iain Holmes <iain gnome org>
  *
- *  Copyright 2002-2006 Iain Holmes
+ *  Copyright 2002-2008 Iain Holmes
  *
  *  This file is free software; you can redistribute it and/or
  *  modify it under the terms of version 2 of the GNU Library General Public

Modified: trunk/marlin/marlin-marker-model.c
==============================================================================
--- trunk/marlin/marlin-marker-model.c	(original)
+++ trunk/marlin/marlin-marker-model.c	Mon Oct  6 00:30:22 2008
@@ -2,7 +2,7 @@
 /*
  *  Authors: Iain Holmes <iain gnome org>
  *
- *  Copyright 2003-2006 Iain Holmes
+ *  Copyright 2003-2008 Iain Holmes
  *
  *  This file is free software; you can redistribute it and/or
  *  modify it under the terms of version 2 of the GNU Library General Public
@@ -46,26 +46,25 @@
 	GList *markers;
 };
 
-static GObjectClass *parent_class = NULL;
+#define GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), MARLIN_MARKER_MODEL_TYPE, MarlinMarkerModelPrivate))
+G_DEFINE_TYPE (MarlinMarkerModel, marlin_marker_model, G_TYPE_OBJECT);
 static guint32 signals[LAST_SIGNAL];
 
 static void
 finalize (GObject *object)
 {
-	MarlinMarkerModel *model;
-	MarlinMarkerModelPrivate *priv;
+	MarlinMarkerModel *model = (MarlinMarkerModel *) object;
+	MarlinMarkerModelPrivate *priv = model->priv;
+	GList *l;
 
-	model = MARLIN_MARKER_MODEL (object);
-	priv = model->priv;
+	for (l = priv->markers; l; l = l->next) {
+		MarlinMarker *marker = l->data;
 
-	if (priv == NULL) {
-		return;
+		g_free (marker);
 	}
+	g_list_free (priv->markers);
 
-	g_free (priv);
-	model->priv = NULL;
-
-	parent_class->finalize (object);
+	G_OBJECT_CLASS (marlin_marker_model_parent_class)->finalize (object);
 }
 
 static void
@@ -99,13 +98,15 @@
 }
 
 static void
-class_init (GObjectClass *klass)
+marlin_marker_model_class_init (MarlinMarkerModelClass *klass)
 {
-	klass->finalize = finalize;
-	klass->set_property = set_property;
-	klass->get_property = get_property;
+	GObjectClass *o_class = (GObjectClass *) klass;
+
+	o_class->finalize = finalize;
+	o_class->set_property = set_property;
+	o_class->get_property = get_property;
 
-	parent_class = g_type_class_peek_parent (klass);
+	g_type_class_add_private (o_class, sizeof (MarlinMarkerModelPrivate));
 
 	signals[MARKER_ADDED] = g_signal_new ("marker-added",
 					      G_TYPE_FROM_CLASS (klass),
@@ -136,37 +137,15 @@
 						G_TYPE_NONE, 1,
 						G_TYPE_POINTER);
 
-	g_object_class_install_property (klass,
-					 PROP_MARKER_LIST,
-					 g_param_spec_pointer ("markers",
-							       "", "",
+	g_object_class_install_property (o_class, PROP_MARKER_LIST,
+					 g_param_spec_pointer ("markers", "", "",
 							       G_PARAM_READABLE));
 }
 
 static void
-init (MarlinMarkerModel *model)
+marlin_marker_model_init (MarlinMarkerModel *model)
 {
-	model->priv = g_new0 (MarlinMarkerModelPrivate, 1);
-}
-
-GType
-marlin_marker_model_get_type (void)
-{
-	static GType type = 0;
-
-	if (type == 0) {
-		GTypeInfo info = {
-			sizeof (MarlinMarkerModelClass), NULL, NULL,
-			(GClassInitFunc) class_init, NULL, NULL,
-			sizeof (MarlinMarkerModel), 0, (GInstanceInitFunc) init
-		};
-		
-		type = g_type_register_static (G_TYPE_OBJECT,
-					       "MarlinMarkerModel",
-					       &info, 0);
-	}
-	
-	return type;
+	model->priv = GET_PRIVATE (model);
 }
 
 /**
@@ -215,7 +194,7 @@
 			return m;
 		}
 	}
-	
+
 	return NULL;
 }
 
@@ -223,13 +202,13 @@
 	MarlinMarkerModel *model;
 	MarlinMarker *marker;
 };
-	
+
 static void
 add_marker_undo (gpointer data)
 {
 	struct _marker_closure *d = data;
 	MarlinMarker *m;
-	
+
 	m = marker_find (d->model, d->marker->position, d->marker->name);
 	if (m) {
 		marlin_marker_model_remove_marker (d->model, m, NULL);
@@ -240,7 +219,7 @@
 add_marker_redo (gpointer data)
 {
 	struct _marker_closure *d = data;
-	
+
 	marlin_marker_model_add_marker (d->model, d->marker->position,
 					d->marker->name, NULL);
 }
@@ -284,14 +263,17 @@
  */
 void
 marlin_marker_model_add_marker (MarlinMarkerModel *model,
-				guint64 position,
-				const char *name,
+				guint64            position,
+				const char        *name,
 				MarlinUndoContext *ctxt)
 {
 	MarlinMarker *marker;
-	
+	MarlinMarkerModelPrivate *priv;
+
 	g_return_if_fail (model != NULL);
 
+	priv = model->priv;
+
 	marker = g_new (MarlinMarker, 1);
 	if (name != NULL) {
 		marker->name = g_strdup (name);
@@ -301,7 +283,7 @@
 	}
 	marker->position = position;
 
-	model->priv->markers = g_list_insert_sorted (model->priv->markers, marker, compare_markers);
+	priv->markers = g_list_insert_sorted (priv->markers, marker, compare_markers);
 
 	g_signal_emit (G_OBJECT (model), signals[MARKER_ADDED], 0, marker);
 

Modified: trunk/marlin/marlin-marker-view.c
==============================================================================
--- trunk/marlin/marlin-marker-view.c	(original)
+++ trunk/marlin/marlin-marker-view.c	Mon Oct  6 00:30:22 2008
@@ -139,7 +139,8 @@
 	gboolean snap; /* Snap to ticks */
 };
 
-static GtkWidgetClass *parent_class = NULL;
+#define GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), MARLIN_MARKER_VIEW_TYPE, MarlinMarkerViewPrivate))
+G_DEFINE_TYPE (MarlinMarkerView, marlin_marker_view, GTK_TYPE_WIDGET);
 static guint32 signals[LAST_SIGNAL] = { 0 };
 
 #define VIEW_HEIGHT 32
@@ -179,46 +180,53 @@
 	view = MARLIN_MARKER_VIEW (object);
 	priv = view->priv;
 
-	if (priv == NULL) {
-		return;
-	}
+	clear_markers (view);
 
-	if (priv->add_id > 0) {
-		g_signal_handler_disconnect (G_OBJECT (priv->model), priv->add_id);
+	if (priv->regions) {
+		marlin_list_free (priv->regions);
 	}
 
-	if (priv->remove_id > 0) {
-		g_signal_handler_disconnect (G_OBJECT (priv->model), priv->remove_id);
-	}
+	G_OBJECT_CLASS (marlin_marker_view_parent_class)->finalize (object);
+}
 
-	if (priv->move_id > 0) {
-		g_signal_handler_disconnect (G_OBJECT (priv->model), priv->move_id);
-	}
+static void
+dispose (GObject *object)
+{
+	MarlinMarkerView *view = (MarlinMarkerView *) object;
+	MarlinMarkerViewPrivate *priv = view->priv;
 
-	if (priv->kb_ctxt) {
-		marlin_undo_manager_context_cancel (priv->undo, priv->kb_ctxt);
+	if (priv->model) {
+		g_signal_handler_disconnect (priv->model, priv->add_id);
+		g_signal_handler_disconnect (priv->model, priv->remove_id);
+		g_signal_handler_disconnect (priv->model, priv->move_id);
+		g_object_unref (G_OBJECT (priv->model));
+
+		priv->model = NULL;
 	}
 
-	g_object_unref (G_OBJECT (priv->model));
-	g_object_unref (G_OBJECT (priv->undo));
+	if (priv->undo) {
+		if (priv->kb_ctxt) {
+			marlin_undo_manager_context_cancel (priv->undo,
+							    priv->kb_ctxt);
+			priv->kb_ctxt = NULL;
+		}
+
+		g_object_unref (G_OBJECT (priv->undo));
+		priv->undo = NULL;
+	}
 
 	if (priv->sample) {
 		g_signal_handler_disconnect (priv->sample, priv->notify_id);
 		g_object_unref (G_OBJECT (priv->sample));
+		priv->sample = NULL;
 	}
 
-	g_object_unref (G_OBJECT (priv->layout));
-
-	clear_markers (view);
-
-	if (priv->regions) {
-		marlin_list_free (priv->regions);
+	if (priv->layout) {
+		g_object_unref (G_OBJECT (priv->layout));
+		priv->layout = NULL;
 	}
 
-	g_free (priv);
-	view->priv = NULL;
-
-	G_OBJECT_CLASS (parent_class)->finalize (object);
+	G_OBJECT_CLASS (marlin_marker_view_parent_class)->dispose (object);
 }
 
 static void
@@ -818,7 +826,7 @@
 	}
 
 	/* Chain up */
-	parent_class->size_allocate (widget, allocation);
+	GTK_WIDGET_CLASS (marlin_marker_view_parent_class)->size_allocate (widget, allocation);
 }
 
 static void
@@ -891,7 +899,7 @@
 	view->priv->backing_store = NULL;
 	view->priv->non_gr_exp_gc = NULL;
 
-	parent_class->unrealize (widget);
+	GTK_WIDGET_CLASS (marlin_marker_view_parent_class)->unrealize (widget);
 }
 
 static int
@@ -2016,12 +2024,13 @@
 }
 
 static void
-class_init (MarlinMarkerViewClass *klass)
+marlin_marker_view_class_init (MarlinMarkerViewClass *klass)
 {
 	GObjectClass *object_class = G_OBJECT_CLASS (klass);
 	GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
 
 	object_class->finalize = finalize;
+	object_class->dispose = dispose;
 	object_class->set_property = set_property;
 	object_class->get_property = get_property;
 
@@ -2040,7 +2049,7 @@
 
 	klass->set_scroll_adjustments = set_scroll_adjustments;
 
-	parent_class = g_type_class_peek_parent (klass);
+	g_type_class_add_private (object_class, sizeof (MarlinMarkerViewPrivate));
 
 	g_object_class_install_property (object_class,
 					 PROP_MODEL,
@@ -2130,13 +2139,13 @@
 }
 
 static void
-init (MarlinMarkerView *view)
+marlin_marker_view_init (MarlinMarkerView *view)
 {
 	MarlinMarkerViewPrivate *priv;
 
 	GTK_WIDGET_SET_FLAGS (view, GTK_CAN_FOCUS);
 
-	priv = g_new0 (MarlinMarkerViewPrivate, 1);
+	priv = GET_PRIVATE (view);
 	view->priv = priv;
 
 	priv->marker_to_view = g_hash_table_new (NULL, NULL);
@@ -2149,26 +2158,6 @@
 	priv->regions = marlin_list_new (region_free);
 }
 
-GType
-marlin_marker_view_get_type (void)
-{
-	static GType type = 0;
-
-	if (type == 0) {
-		GTypeInfo info = {
-			sizeof (MarlinMarkerViewClass), NULL, NULL,
-			(GClassInitFunc) class_init, NULL, NULL,
-			sizeof (MarlinMarkerView), 0, (GInstanceInitFunc) init
-		};
-
-		type = g_type_register_static (GTK_TYPE_WIDGET,
-					       "MarlinMarkerView",
-					       &info, 0);
-	}
-
-	return type;
-}
-
 /**
  * marlin_marker_view_new:
  * @model: The #MarlinMarkerModel that we use.

Modified: trunk/marlin/marlin-operation.c
==============================================================================
--- trunk/marlin/marlin-operation.c	(original)
+++ trunk/marlin/marlin-operation.c	Mon Oct  6 00:30:22 2008
@@ -40,7 +40,8 @@
 	PROP_DESCRIPTION
 };
 
-static GObjectClass *parent_class = NULL;
+#define GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), MARLIN_OPERATION_TYPE, MarlinOperationPrivate))
+G_DEFINE_TYPE (MarlinOperation, marlin_operation, G_TYPE_OBJECT);
 static guint signals[LAST_SIGNAL];
 
 struct _MarlinOperationPrivate {
@@ -56,14 +57,13 @@
 {
 	MarlinOperation *operation;
 	MarlinOperationPrivate *priv;
-	
+
 	operation = MARLIN_OPERATION (object);
 
 	priv = operation->priv;
 	g_free (priv->description);
-	g_free (priv);
-	
-	parent_class->finalize (object);
+
+	G_OBJECT_CLASS (marlin_operation_parent_class)->finalize (object);
 }
 
 static void
@@ -114,18 +114,15 @@
 }
 
 static void
-class_init (MarlinOperationClass *klass)
+marlin_operation_class_init (MarlinOperationClass *klass)
 {
-	GObjectClass *object_class;
-
-	object_class = G_OBJECT_CLASS (klass);
+	GObjectClass *object_class = (GObjectClass *) klass;
 
 	object_class->finalize = finalize;
 	object_class->set_property = set_property;
 	object_class->get_property = get_property;
 
-	parent_class = g_type_class_peek_parent (klass);
-
+	g_type_class_add_private (object_class, sizeof (MarlinOperationPrivate));
 	g_object_class_install_property (object_class,
 					 PROP_DESCRIPTION,
 					 g_param_spec_string ("description",
@@ -188,31 +185,12 @@
 }
 
 static void
-init (MarlinOperation *operation)
+marlin_operation_init (MarlinOperation *operation)
 {
-	operation->priv = g_new0 (MarlinOperationPrivate, 1);
+	operation->priv = GET_PRIVATE (operation);
 	operation->priv->in_op = FALSE;
 }
 
-GType
-marlin_operation_get_type (void)
-{
-	static GType type = 0;
-
-	if (type == 0) {
-		GTypeInfo info = {
-			sizeof (MarlinOperationClass), NULL, NULL,
-			(GClassInitFunc) class_init, NULL, NULL,
-			sizeof (MarlinOperation), 0, (GInstanceInitFunc) init
-		};
-
-		type = g_type_register_static (G_TYPE_OBJECT,
-					       "MarlinOperation", &info, 0);
-	}
-
-	return type;
-}
-
 MarlinOperation *
 marlin_operation_new (void)
 {
@@ -237,8 +215,7 @@
 {
 	operation->priv->progress = progress;
 
-	g_signal_emit (G_OBJECT (operation), signals[PROGRESS], 
-		       0, progress);
+	g_signal_emit (G_OBJECT (operation), signals[PROGRESS], 0, progress);
 }
 
 void

Modified: trunk/marlin/marlin-overview-bar.c
==============================================================================
--- trunk/marlin/marlin-overview-bar.c	(original)
+++ trunk/marlin/marlin-overview-bar.c	Mon Oct  6 00:30:22 2008
@@ -2,7 +2,7 @@
 /*
  *  Authors: Iain Holmes <iain gnome org>
  *
- *  Copyright (C) 2002 - 2006 Iain Holmes 
+ *  Copyright (C) 2002 - 2008 Iain Holmes
  *
  *  This file is free software; you can redistribute it and/or
  *  modify it under the terms of version 2 of the GNU Library General Public
@@ -76,7 +76,7 @@
 	guint frames_per_pixel; /* The number of frames that one pixel
 				    represents */
 	guint num_channels; /* The number of channels in the sample */
-	
+
 	guint64 position; /* The position of the cursor */
 	guint64 start, finish; /* The position of the page */
 
@@ -96,8 +96,9 @@
 
 	MarlinPeak **peaks;
 };
-	
-static GtkWidgetClass *parent_class = NULL;
+
+#define GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), MARLIN_OVERVIEW_BAR_TYPE, MarlinOverviewBarPrivate))
+G_DEFINE_TYPE (MarlinOverviewBar, marlin_overview_bar, GTK_TYPE_DRAWING_AREA);
 static guint signals[LAST_SIGNAL];
 
 #define DEFAULT_FRAMES_PER_PIXEL 64
@@ -151,7 +152,7 @@
 		g_free (bar->priv->peaks[i]);
 	}
  	g_free (bar->priv->peaks);
-}	
+}
 
 static void
 create_peaks (MarlinOverviewBar *bar)
@@ -215,7 +216,7 @@
 
 	overview_bar->priv = NULL;
 
-	G_OBJECT_CLASS (parent_class)->finalize (object);
+	G_OBJECT_CLASS (marlin_overview_bar_parent_class)->finalize (object);
 }
 
 static void
@@ -238,12 +239,12 @@
 {
 	GdkRectangle window;
 
-	if (GTK_WIDGET_REALIZED (widget)) {
+	if (GTK_WIDGET_DRAWABLE (widget)) {
 		window.x = 0;
 		window.y = 0;
 		window.width = widget->allocation.width;
 		window.height = widget->allocation.height;
-		
+
 		gdk_window_invalidate_rect (widget->window,
 					    &window, FALSE);
 	}
@@ -263,7 +264,7 @@
 {
 	GtkWidget *widget = GTK_WIDGET (view);
 	MarlinOverviewBarPrivate *priv = view->priv;
-	
+
 	if (strcmp (pspec->name, "total-frames") == 0) {
 		g_object_get (G_OBJECT (sample),
 			      "total_frames", &priv->number_of_frames,
@@ -329,7 +330,7 @@
 
 	if (GTK_WIDGET_DRAWABLE (widget)) {
 		GdkRectangle area;
-		
+
 		area.x = vm->real_position / priv->frames_per_pixel;
 		area.y = 0;
 		area.width = 1;
@@ -416,11 +417,11 @@
 	int old_start, min_start, max_start;
 	int old_position;
 	GList *marks;
-	
+
 	widget = GTK_WIDGET (object);
 	overview_bar = MARLIN_OVERVIEW_BAR (object);
 	priv = overview_bar->priv;
-	
+
 	switch (prop_id) {
 	case PROP_SAMPLE:
 		new_sample = g_value_get_object (value);
@@ -446,7 +447,7 @@
 			if (GTK_WIDGET_DRAWABLE (widget)) {
 				invalidate_widget (widget);
 			}
-			
+
 			return;
 		}
 
@@ -495,17 +496,15 @@
 		priv->dc->sample = new_sample;
 
 /* 		g_object_ref (priv->sample); */
-		priv->notify_id = g_signal_connect (G_OBJECT (priv->sample), 
+		priv->notify_id = g_signal_connect (G_OBJECT (priv->sample),
 						    "notify",
 						    G_CALLBACK (sample_notify),
 						    overview_bar);
-				
 /* 		g_object_ref (priv->selection); */
 		priv->changed_id = g_signal_connect (G_OBJECT (priv->selection),
 						     "changed",
 						     G_CALLBACK (selection_changed),
 						     overview_bar);
-		
 		g_object_get (G_OBJECT (priv->model),
 			      "markers", &marks,
 			      NULL);
@@ -513,7 +512,7 @@
 		add_markers (overview_bar, marks);
 
 		priv->add_id = g_signal_connect (priv->model, "marker-added",
-						 G_CALLBACK (add_marker), 
+						 G_CALLBACK (add_marker),
 						 overview_bar);
 		priv->remove_id = g_signal_connect (priv->model, "marker-removed",
 						    G_CALLBACK (remove_marker),
@@ -527,17 +526,16 @@
 			priv->frames_per_pixel = 1;
 		}
 		priv->dc->fpp = priv->frames_per_pixel;
-		
+
 		redraw_backing_store (overview_bar);
 		if (GTK_WIDGET_DRAWABLE (widget)) {
 			invalidate_widget (widget);
 		}
-		
 		break;
-		
+
 	case PROP_PER_PAGE:
 		old_finish = priv->finish;
-		
+
 		priv->frames_per_page = g_value_get_uint64 (value);
 
 		if (priv->sample) {
@@ -549,12 +547,12 @@
 			priv->number_of_frames = 0;
 			priv->num_channels = 1;
 		}
-		
+
 		/* Limit the number of frames to the total number of frames */
 		if (priv->frames_per_page > priv->number_of_frames) {
 			priv->frames_per_page = priv->number_of_frames;
 		}
-		
+
 		priv->finish = priv->start + priv->frames_per_page;
 
 		if (GTK_WIDGET_DRAWABLE (widget)) {
@@ -574,7 +572,6 @@
 
 			gdk_window_invalidate_rect (widget->window, &area, FALSE);
 		}
-					    
 		break;
 
 	case PROP_POSITION:
@@ -604,7 +601,7 @@
 		old_start = priv->start;
 		priv->start = g_value_get_uint64 (value);
 		priv->finish = priv->start + priv->frames_per_page;
-		
+
 		if (GTK_WIDGET_DRAWABLE (widget)) {
 			GdkRectangle area;
 
@@ -643,7 +640,7 @@
 	case PROP_SAMPLE:
 		g_value_set_object (value, priv->sample);
 		break;
-		
+
 	case PROP_POSITION:
 		g_value_set_uint64 (value, priv->position);
 		break;
@@ -671,11 +668,11 @@
 {
 	MarlinOverviewBar *overview_bar;
 	MarlinOverviewBarPrivate *priv;
-	
+
 	overview_bar = MARLIN_OVERVIEW_BAR (widget);
 	priv = overview_bar->priv;
 
-	if (GTK_WIDGET_REALIZED (widget)) {
+	if (GTK_WIDGET_DRAWABLE (widget)) {
 		GdkRectangle rect;
 
 		gdk_window_move_resize (widget->window,
@@ -697,7 +694,7 @@
 	priv->dc->fpp = priv->frames_per_pixel;
 
 	/* Chain up */
-	GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation);
+	GTK_WIDGET_CLASS (marlin_overview_bar_parent_class)->size_allocate (widget, allocation);
 
 	if (priv->peaks) {
  		free_peaks (overview_bar);
@@ -716,7 +713,7 @@
 
 	overview_bar = MARLIN_OVERVIEW_BAR (widget);
 	priv = overview_bar->priv;
-	
+
 	requisition->width = (int) (priv->number_of_frames / priv->frames_per_pixel);
 
 	requisition->height = 30;
@@ -734,7 +731,7 @@
 			       GDK_POINTER_MOTION_MASK |
 			       GDK_KEY_PRESS_MASK);
 
-	GTK_WIDGET_CLASS (parent_class)->realize (widget);
+	GTK_WIDGET_CLASS (marlin_overview_bar_parent_class)->realize (widget);
 
 	bar->priv->dc->drawable = widget->window;
 }
@@ -742,7 +739,7 @@
 static void
 unrealize (GtkWidget *widget)
 {
-	GTK_WIDGET_CLASS (parent_class)->unrealize (widget);
+	GTK_WIDGET_CLASS (marlin_overview_bar_parent_class)->unrealize (widget);
 }
 
 static void
@@ -818,7 +815,7 @@
 				    area->width, area->height);
 		return;
 	}
-	
+
 	/* Generate the rectangle for A */
 	rect.x = x;
 	rect.y = y;
@@ -876,17 +873,17 @@
 			rect.y = 0;
 			rect.height = height;
 			break;
-			
+
 		case MARLIN_COVERAGE_LEFT:
 			rect.y = 0;
 			rect.height = (int) (height / 2);
 			break;
-			
+
 		case MARLIN_COVERAGE_RIGHT:
 			rect.y = (int) (height / 2);
 			rect.height = (int) (height / 2);
 			break;
-			
+
 		default:
 			break;
 		}
@@ -896,14 +893,14 @@
 		/* Do the divisions before the subtraction due to
 		   rounding errors that occur the other way round */
 		rect.width = (int) (sel_finish / priv->frames_per_pixel) - (sel_start / priv->frames_per_pixel);
-		
+
 		if (gdk_rectangle_intersect (area, &rect, &inter)) {
 			gdk_draw_rectangle (widget->window, gc,
 					    TRUE, inter.x, inter.y,
 					    inter.width, inter.height);
 		}
 	}
-	
+
 	/* Draw the sample */
 	chan_height = widget->allocation.height / priv->num_channels;
 #if 0
@@ -925,8 +922,8 @@
 	gdk_draw_drawable (widget->window,
 			   priv->non_gr_exp_gc,
 			   priv->backing_store,
-			   0, 0, 0, 0, 
-			   widget->allocation.width, 
+			   0, 0, 0, 0,
+			   widget->allocation.width,
 			   widget->allocation.height);
 #endif
 	inter.x = 0;
@@ -945,7 +942,7 @@
 		       y,
 		       x + (int) (priv->position / priv->frames_per_pixel),
 		       height);
-	
+
 	/* Generate the rectangle for B to draw the decals */
 	rect.x = x + (int) (priv->start / priv->frames_per_pixel);
 	rect.y = y;
@@ -974,7 +971,7 @@
 		points[1].y = (rect.y + height) - 2;
  		points[2].x = (rect.x + rect.width) - 1;
 		points[2].y = rect.y + 1;
-		
+
 		points[3].x = (rect.x + rect.width) - 1;
 		points[3].y = (rect.y + height) - 2;
 
@@ -994,7 +991,7 @@
 		_marlin_overview_bar_paint (overview_bar, &event->area,
 					 GTK_WIDGET_STATE (widget));
 	}
-	
+
 	return FALSE;
 }
 
@@ -1010,7 +1007,7 @@
 	gtk_widget_grab_focus (widget);
 
 	overview_bar = MARLIN_OVERVIEW_BAR (widget);
-	
+
 	x = event->x;
 	position = (guint64) (x * overview_bar->priv->frames_per_pixel);
 
@@ -1230,7 +1227,7 @@
 }
 
 static void
-class_init (MarlinOverviewBarClass *klass)
+marlin_overview_bar_class_init (MarlinOverviewBarClass *klass)
 {
 	GObjectClass *object_class;
 	GtkWidgetClass *widget_class;
@@ -1256,8 +1253,7 @@
 
 	klass->move_page = real_move_page;
 
-	parent_class = g_type_class_peek_parent (klass);
-
+	g_type_class_add_private (object_class, sizeof (MarlinOverviewBarPrivate));
 	g_object_class_install_property (object_class,
 					 PROP_SAMPLE,
 					 g_param_spec_object ("sample",
@@ -1357,7 +1353,7 @@
 			  GTK_MOVEMENT_LOGICAL_POSITIONS, 1);
 	add_move_binding (binding_set, GDK_KP_Left, 0,
 			  GTK_MOVEMENT_LOGICAL_POSITIONS, -1);
-	
+
 	/* PgUp/PgDn - Move page over 1 whole page */
 	add_move_binding (binding_set, GDK_Page_Up, 0,
 			  GTK_MOVEMENT_PAGES, 1);
@@ -1380,37 +1376,19 @@
 }
 
 static void
-init (MarlinOverviewBar *overview_bar)
-{
-	GTK_WIDGET_SET_FLAGS (overview_bar, GTK_CAN_FOCUS);
-
-	overview_bar->priv = g_new0 (MarlinOverviewBarPrivate, 1);
-	overview_bar->priv->frames_per_pixel = DEFAULT_FRAMES_PER_PIXEL;
-	overview_bar->priv->peaks = NULL;
-
-	overview_bar->priv->dc = marlin_sample_draw_context_new (NULL,
-								 DEFAULT_FRAMES_PER_PIXEL,
-								 FALSE);
-}
-
-GType
-marlin_overview_bar_get_type (void)
+marlin_overview_bar_init (MarlinOverviewBar *overview_bar)
 {
-	static GType type = 0;
-
-	if (type == 0) {
-		GTypeInfo info = {
-			sizeof (MarlinOverviewBarClass), NULL, NULL,
-			(GClassInitFunc) class_init, NULL, NULL,
-			sizeof (MarlinOverviewBar), 0, (GInstanceInitFunc) init
-		};
+	MarlinOverviewBarPrivate *priv;
 
-		type = g_type_register_static (GTK_TYPE_DRAWING_AREA,
-					       "MarlinOverviewBar",
-					       &info, 0);
-	}
+	GTK_WIDGET_SET_FLAGS (overview_bar, GTK_CAN_FOCUS);
 
-	return type;
+	priv = overview_bar->priv = GET_PRIVATE (overview_bar);
+	priv->frames_per_pixel = DEFAULT_FRAMES_PER_PIXEL;
+	priv->peaks = NULL;
+
+	priv->dc = marlin_sample_draw_context_new (NULL,
+						   DEFAULT_FRAMES_PER_PIXEL,
+						   FALSE);
 }
 
 GtkWidget *

Modified: trunk/marlin/marlin-pipeline.c
==============================================================================
--- trunk/marlin/marlin-pipeline.c	(original)
+++ trunk/marlin/marlin-pipeline.c	Mon Oct  6 00:30:22 2008
@@ -2,7 +2,7 @@
 /*
  *  Authors: Iain Holmes <iain gnome org>
  *
- *  Copyright 2002 - 2006 Iain Holmes
+ *  Copyright 2002 - 2008 Iain Holmes
  *
  *  This file is free software; you can redistribute it and/or
  *  modify it under the terms of version 2 of the GNU Library General Public



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