marlin r1297 - in trunk: marlin src



Author: iain
Date: Tue Oct  7 00:19:18 2008
New Revision: 1297
URL: http://svn.gnome.org/viewvc/marlin?rev=1297&view=rev

Log:
Fix bug where sample tmp files do not get deleted on quit
Fix memory leaks
Update code to proper GObject code style


Modified:
   trunk/marlin/ChangeLog
   trunk/marlin/Makefile.am
   trunk/marlin/marlin-channel-sink.c
   trunk/marlin/marlin-load-pipeline.c
   trunk/marlin/marlin-overview-bar.c
   trunk/marlin/marlin-position-spinner.c
   trunk/marlin/marlin-program.c
   trunk/marlin/marlin-progress-dialog.c
   trunk/src/ChangeLog
   trunk/src/marlin-window.c

Modified: trunk/marlin/Makefile.am
==============================================================================
--- trunk/marlin/Makefile.am	(original)
+++ trunk/marlin/Makefile.am	Tue Oct  7 00:19:18 2008
@@ -157,12 +157,6 @@
 	$(MARLIN_LIBS)
 test_gst_alsa_CFLAGS = $(MARLIN_CFLAGS)
 
-test_play_pipeline_SOURCES = test-play-pipeline.c
-test_play_pipeline_LDADD =			\
-	libmarlin.la libmarlinx.la		\
-	$(MARLIN_LIBS) $(MARLINX_LIBS)
-test_play_pipeline_CFLAGS = $(MARLIN_CFLAGS) $(MARLINX_CFLAGS)
-
 test_sample_view_SOURCES = test-sample-view.c
 test_sample_view_LDADD =			\
 	libmarlin.la libmarlinx.la		\

Modified: trunk/marlin/marlin-channel-sink.c
==============================================================================
--- trunk/marlin/marlin-channel-sink.c	(original)
+++ trunk/marlin/marlin-channel-sink.c	Tue Oct  7 00:19:18 2008
@@ -82,7 +82,7 @@
 
 	gst_element_class_set_details (element_class, &sink_details);
 
-	gst_element_class_add_pad_template 
+	gst_element_class_add_pad_template
 		(element_class,
 		 gst_static_pad_template_get (&sink_factory));
 }
@@ -112,7 +112,7 @@
 
 	sink = MARLIN_CHANNEL_SINK (object);
 	priv = sink->priv;
-	
+
 	if (priv->sample) {
 		g_object_unref (G_OBJECT (priv->sample));
 		priv->sample = NULL;
@@ -161,7 +161,7 @@
 
 		priv->sample = MARLIN_SAMPLE (g_value_dup_object (value));
 		break;
-		
+
 	default:
 		break;
 	}
@@ -238,7 +238,7 @@
 		return;
 	}
 
-	/* Store the new block in the list for linking 
+	/* Store the new block in the list for linking
 	   once the element has finished */
 	if (priv->block_list == NULL) {
 		priv->block_list = block;
@@ -265,14 +265,14 @@
 	if (sink->no_space) {
 		guint64 bytes_needed, bytes_have;
 		char *need, *have;
-		
-		bytes_needed = (sink->frame_count * sizeof (float)) + 
+
+		bytes_needed = (sink->frame_count * sizeof (float)) +
 			((sink->frame_count / 128) * (sizeof (float) * 4));
 		bytes_have = sink->no_space_frames * sizeof (float);
 
 		need = gnome_vfs_format_file_size_for_display (bytes_needed);
 		have = gnome_vfs_format_file_size_for_display (bytes_have);
-		
+
 		GST_ELEMENT_ERROR (GST_ELEMENT (sink), RESOURCE, WRITE,
 				   ("Marlin ran out of temporary space.\n%s of free space is needed on '%s' but only %s is available", need,
 				    marlin_get_tmp_dir (), have),
@@ -316,7 +316,7 @@
 	frames = size / sizeof (float);
 
 	in = (float *) GST_BUFFER_DATA (buffer);
-	
+
 	if (priv->frames_in_data + frames > MARLIN_BLOCK_SIZE) {
 		guint32 needed, remain;
 
@@ -332,7 +332,7 @@
 
 		/* Move the rest of the data across */
 		if (remain > 0) {
-			memmove (priv->data, in + needed, 
+			memmove (priv->data, in + needed,
 				 remain * sizeof (float));
 		}
 
@@ -403,7 +403,7 @@
 	case GST_EVENT_EOS:
 		flush_buffer (sink);
 		break;
-		
+
 	default:
 		break;
 	}

Modified: trunk/marlin/marlin-load-pipeline.c
==============================================================================
--- trunk/marlin/marlin-load-pipeline.c	(original)
+++ trunk/marlin/marlin-load-pipeline.c	Tue Oct  7 00:19:18 2008
@@ -302,7 +302,7 @@
 	}
 
 	name = g_strdup_printf ("load-sink-%d", priv->sinks->len);
- 	sink = gst_element_factory_make ("marlin-channel-sink", name); 
+ 	sink = gst_element_factory_make ("marlin-channel-sink", name);
 	g_free (name);
 
 	if (priv->sample) {
@@ -315,7 +315,7 @@
 
 	if (gst_element_link (q, sink) == FALSE) {
 		g_warning ("Failed to link queue to sink");
-		
+
  		gst_bin_remove (GST_BIN (pipeline), q);
 		gst_bin_remove (GST_BIN (pipeline), sink);
 		return;

Modified: trunk/marlin/marlin-overview-bar.c
==============================================================================
--- trunk/marlin/marlin-overview-bar.c	(original)
+++ trunk/marlin/marlin-overview-bar.c	Tue Oct  7 00:19:18 2008
@@ -174,10 +174,6 @@
 
 	overview_bar = MARLIN_OVERVIEW_BAR (object);
 
-	if (overview_bar->priv == NULL) {
-		return;
-	}
-
 	priv = overview_bar->priv;
 
 	if (priv->selection != NULL) {
@@ -212,10 +208,6 @@
 
 	marlin_sample_draw_context_free (priv->dc);
 
-	g_free (priv);
-
-	overview_bar->priv = NULL;
-
 	G_OBJECT_CLASS (marlin_overview_bar_parent_class)->finalize (object);
 }
 
@@ -1016,21 +1008,21 @@
 		g_object_set (G_OBJECT (widget),
 			      "cursor_position", position,
 			      NULL);
-		
+
 		/* Move the page as well */
 		if (event->type == GDK_2BUTTON_PRESS) {
 			guint64 start, half, end;
-			
+
 			half = (guint) (overview_bar->priv->frames_per_page / 2);
-			
+
 			/* Check it is always >= 0 */
 			start = MAX ((int) (position - half), 0);
-			
+
 			/* Check it's never > end */
 			end = overview_bar->priv->number_of_frames -
 				overview_bar->priv->frames_per_page;
 			start = MIN (start, end);
-			
+
 			g_object_set (G_OBJECT (widget),
 				      "page_start", start,
 				      NULL);
@@ -1038,7 +1030,7 @@
 
 		if (overview_bar->priv->in_page) {
 			GdkCursor *hand = marlin_cursor_get (widget, HAND_CLOSED);
-			
+
 			overview_bar->priv->in_drag = TRUE;
 			overview_bar->priv->drag_offset = position - overview_bar->priv->start;
 			gdk_pointer_grab (widget->window, FALSE,
@@ -1103,13 +1095,13 @@
 	gint64 position;
 
 	position = x * (gint64) overview_bar->priv->frames_per_pixel;
-	
+
 	if (position >= overview_bar->priv->start &&
 	    position <= overview_bar->priv->start + overview_bar->priv->frames_per_page) {
 		if (overview_bar->priv->in_page == FALSE &&
 		    can_page_move (overview_bar)) {
 			GdkCursor *hand = marlin_cursor_get (widget, HAND_OPEN);
-			
+
 			gdk_window_set_cursor (widget->window, hand);
 			gdk_cursor_unref (hand);
 			overview_bar->priv->in_page = TRUE;
@@ -1130,7 +1122,7 @@
 		} else {
 			new_pos = (guint64) pos;
 		}
-		
+
 		g_object_set (G_OBJECT (widget),
 			      "page-start", new_pos,
 			      NULL);
@@ -1208,7 +1200,7 @@
 
 	/* Redraw */
 	invalidate_widget (GTK_WIDGET (bar));
-	
+
 	g_signal_emit (bar, signals[PAGE_START_CHANGED], 0, (guint64) priv->start);
 }
 

Modified: trunk/marlin/marlin-position-spinner.c
==============================================================================
--- trunk/marlin/marlin-position-spinner.c	(original)
+++ trunk/marlin/marlin-position-spinner.c	Tue Oct  7 00:19:18 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
@@ -58,24 +58,18 @@
 	MarlinDisplay display;
 };
 
-static GObjectClass *parent_class = NULL;
+#define GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), MARLIN_POSITION_SPINNER_TYPE, MarlinPositionSpinnerPrivate))
+static void editable_init (GtkEditableClass *iface);
+G_DEFINE_TYPE_EXTENDED (MarlinPositionSpinner, marlin_position_spinner,
+			GTK_TYPE_SPIN_BUTTON, 0,
+			G_IMPLEMENT_INTERFACE (GTK_TYPE_EDITABLE,
+					       editable_init));
 static guint signals[LAST_SIGNAL];
 
 static void
 finalize (GObject *object)
 {
-	MarlinPositionSpinner *spinner;
-
-	spinner = MARLIN_POSITION_SPINNER (object);
-
-	if (spinner->priv == NULL) {
-		return;
-	}
-
-	g_free (spinner->priv);
-	spinner->priv = NULL;
-
-	parent_class->finalize (object);
+	G_OBJECT_CLASS (marlin_position_spinner_parent_class)->finalize (object);
 }
 
 static void
@@ -85,40 +79,41 @@
 	      GParamSpec *pspec)
 {
 	MarlinPositionSpinner *spinner = MARLIN_POSITION_SPINNER (object);
+	MarlinPositionSpinnerPrivate *priv = spinner->priv;
 	guint64 max;
-	
+
 	switch (prop_id) {
 	case PROP_SAMPLE:
 		max = g_value_get_uint64 (value);
 
-		gtk_adjustment_clamp_page (spinner->priv->adj, 0.0, (float) max);
-		spinner->priv->adj->upper = (double) max;
+		gtk_adjustment_clamp_page (priv->adj, 0.0, (float) max);
+		priv->adj->upper = (double) max;
 		break;
 
 	case PROP_RATE:
-		spinner->priv->rate = g_value_get_uint (value);
-		spinner->priv->adj->step_increment = (double) spinner->priv->rate / 10;
-		spinner->priv->adj->page_increment = (double) spinner->priv->rate;;
+		priv->rate = g_value_get_uint (value);
+		priv->adj->step_increment = (double) priv->rate / 10;
+		priv->adj->page_increment = (double) priv->rate;;
 
 		break;
-		
+
 	case PROP_DISPLAY:
-		spinner->priv->display = g_value_get_enum (value);
+		priv->display = g_value_get_enum (value);
 
-		switch (spinner->priv->display) {
+		switch (priv->display) {
 		case MARLIN_DISPLAY_FRAMES:
-			spinner->priv->adj->step_increment = 1.0;
-			spinner->priv->adj->page_increment = 10.0;
+			priv->adj->step_increment = 1.0;
+			priv->adj->page_increment = 10.0;
 			break;
 
 		case MARLIN_DISPLAY_TIME_LONG:
-			spinner->priv->adj->step_increment = (double) spinner->priv->rate / 10;
-			spinner->priv->adj->page_increment = spinner->priv->rate;
+			priv->adj->step_increment = (double) priv->rate / 10;
+			priv->adj->page_increment = priv->rate;
 			break;
 
 		case MARLIN_DISPLAY_SECONDS:
-			spinner->priv->adj->step_increment = (double) spinner->priv->rate;
-			spinner->priv->adj->page_increment = (double) spinner->priv->rate * 10;
+			priv->adj->step_increment = (double) priv->rate;
+			priv->adj->page_increment = (double) priv->rate * 10;
 			break;
 
 		case MARLIN_DISPLAY_BEATS:
@@ -130,7 +125,7 @@
 
 		g_signal_emit (G_OBJECT (spinner), signals[DISPLAY_CHANGED], 0);
 		break;
-		
+
 	default:
 		break;
 	}
@@ -143,18 +138,19 @@
 	      GParamSpec *pspec)
 {
 	MarlinPositionSpinner *spinner = MARLIN_POSITION_SPINNER (object);
-	
+	MarlinPositionSpinnerPrivate *priv = spinner->priv;
+
 	switch (prop_id) {
 	case PROP_ADJUSTMENT:
-		g_value_set_object (value, spinner->priv->adj);
+		g_value_set_object (value, priv->adj);
 		break;
 
 	case PROP_RATE:
-		g_value_set_uint (value, spinner->priv->rate);
+		g_value_set_uint (value, priv->rate);
 		break;
-		
+
 	case PROP_DISPLAY:
-		g_value_set_enum (value, spinner->priv->display);
+		g_value_set_enum (value, priv->display);
 		break;
 
 	default:
@@ -163,7 +159,7 @@
 }
 
 static void
-display_toggled (GtkCheckMenuItem *item,
+display_toggled (GtkCheckMenuItem      *item,
 		 MarlinPositionSpinner *spinner)
 {
 	MarlinDisplay pd;
@@ -171,7 +167,7 @@
 	if (gtk_check_menu_item_get_active (item) == FALSE) {
 		return;
 	}
-	
+
 	pd = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (item), "display"));
 	g_object_set (G_OBJECT (spinner),
 		      "display_as", pd,
@@ -188,12 +184,12 @@
 
 static void
 populate_popup (GtkEntry *entry,
-		GtkMenu *menu)
+		GtkMenu  *menu)
 {
 	MarlinPositionSpinner *spinner = MARLIN_POSITION_SPINNER (entry);
 	int pd;
 	GSList *group = NULL;
-	
+
 	for (pd = MARLIN_DISPLAY_FRAMES; pd < MARLIN_DISPLAY_NULL; pd++) {
 		GtkWidget *item;
 
@@ -204,7 +200,7 @@
 		}
 		g_signal_connect (G_OBJECT (item), "toggled",
 				  G_CALLBACK (display_toggled), entry);
-		
+
 		group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (item));
 		gtk_widget_show (item);
 		gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
@@ -215,30 +211,31 @@
 spin_output (GtkSpinButton *spin)
 {
 	MarlinPositionSpinner *spinner = MARLIN_POSITION_SPINNER (spin);
+	MarlinPositionSpinnerPrivate *priv = spinner->priv;
 	char *buf;
 	guint64 ms;
 
-	switch (spinner->priv->display) {
+	switch (priv->display) {
 	case MARLIN_DISPLAY_FRAMES:
 		buf = g_strdup_printf ("%llu", (guint64) spin->adjustment->value);
 		break;
 
 	case MARLIN_DISPLAY_TIME_LONG:
 		ms = marlin_frames_to_ms ((guint64) spin->adjustment->value,
-					  spinner->priv->rate);
+					  priv->rate);
 		buf = marlin_ms_to_time_string (ms);
 		break;
 
 	case MARLIN_DISPLAY_SECONDS:
 		ms = marlin_frames_to_ms ((guint64) spin->adjustment->value,
-					  spinner->priv->rate);
+					  priv->rate);
 		buf = g_strdup_printf ("%llu", ms / 1000);
 		break;
 
 	case MARLIN_DISPLAY_TIME_FRAMES:
 		ms = marlin_frames_to_ms ((guint64) spin->adjustment->value,
-					  spinner->priv->rate);
-		buf = marlin_ms_to_time_frame_string (ms, spinner->priv->rate);
+					  priv->rate);
+		buf = marlin_ms_to_time_frame_string (ms, priv->rate);
 		break;
 
 	case MARLIN_DISPLAY_BEATS:
@@ -254,20 +251,21 @@
 		gtk_entry_set_text (GTK_ENTRY (spin), buf);
 	}
 	g_free (buf);
-	
+
 	return TRUE;
 }
 
 static int
 spin_input (GtkSpinButton *spin_button,
-	    double *new_val)
+	    double        *new_val)
 {
 	MarlinPositionSpinner *spinner = MARLIN_POSITION_SPINNER (spin_button);
+	MarlinPositionSpinnerPrivate *priv = spinner->priv;
 	guint64 ms;
 	char *err = NULL;
 	const char *text = gtk_entry_get_text (GTK_ENTRY (spinner));
 
-	switch (spinner->priv->display) {
+	switch (priv->display) {
 	case MARLIN_DISPLAY_FRAMES:
 		*new_val = strtod (text, &err);
 		if (*err) {
@@ -278,8 +276,8 @@
 
 	case MARLIN_DISPLAY_TIME_LONG:
 		ms = marlin_time_string_to_ms (text);
-		
-		*new_val = (((double) ms + 0.5) / 1000) * spinner->priv->rate;
+
+		*new_val = (((double) ms + 0.5) / 1000) * priv->rate;
 		break;
 
 	case MARLIN_DISPLAY_SECONDS:
@@ -289,13 +287,13 @@
 		}
 
 		/* Convert seconds into frames */
-		*new_val *= spinner->priv->rate;
+		*new_val *= priv->rate;
 		break;
-		
+
 	case MARLIN_DISPLAY_TIME_FRAMES:
 		ms = marlin_time_frame_string_to_ms (text);
 
-		*new_val = (((double) ms + 0.5) / 1000) * spinner->priv->rate;
+		*new_val = (((double) ms + 0.5) / 1000) * priv->rate;
 		break;
 
 	case MARLIN_DISPLAY_BEATS:
@@ -305,22 +303,22 @@
 	default:
 		return GTK_INPUT_ERROR;
 	}
-	
+
 	/* Return true when this has parsed */
 	return TRUE;
 }
 
 static void
-class_init (MarlinPositionSpinnerClass *klass)
+marlin_position_spinner_class_init (MarlinPositionSpinnerClass *klass)
 {
 	GObjectClass *object_class;
 	GtkEntryClass *entry_class;
 	GtkSpinButtonClass *spin_class;
-	
+
 	object_class = G_OBJECT_CLASS (klass);
 	entry_class = GTK_ENTRY_CLASS (klass);
 	spin_class = GTK_SPIN_BUTTON_CLASS (klass);
-	
+
 	object_class->finalize = finalize;
 	object_class->set_property = set_property;
 	object_class->get_property = get_property;
@@ -329,8 +327,8 @@
 
 	spin_class->input = spin_input;
 	spin_class->output = spin_output;
-	
-	parent_class = g_type_class_peek_parent (klass);
+
+	g_type_class_add_private (object_class, sizeof (MarlinPositionSpinnerPrivate));
 
 	g_object_class_install_property (object_class,
 					 PROP_SAMPLE,
@@ -368,12 +366,16 @@
 }
 
 static void
-init (MarlinPositionSpinner *spinner)
+marlin_position_spinner_init (MarlinPositionSpinner *spinner)
 {
-	spinner->priv = g_new0 (MarlinPositionSpinnerPrivate, 1);
-	spinner->priv->adj = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, (float) G_MAXUINT64, 1.0, 10.0, 1.0));
-	gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON (spinner), spinner->priv->adj);
-	spinner->priv->display = MARLIN_DISPLAY_TIME_LONG;
+	MarlinPositionSpinnerPrivate *priv;
+
+	priv = spinner->priv = GET_PRIVATE (spinner);
+	priv->adj = GTK_ADJUSTMENT (gtk_adjustment_new
+				    (0.0, 0.0, (float) G_MAXUINT64,
+				     1.0, 10.0, 1.0));
+	gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON (spinner), priv->adj);
+	priv->display = MARLIN_DISPLAY_TIME_LONG;
 }
 
 static void
@@ -386,8 +388,9 @@
 	MarlinPositionSpinnerPrivate *priv = spinner->priv;
 	int i = 0;
 	gboolean string_ok = TRUE;
-	GtkEditableClass *parent_iface = g_type_interface_peek (parent_class ,GTK_TYPE_EDITABLE);
-	
+	GtkEditableClass *parent_iface = g_type_interface_peek
+		(marlin_position_spinner_parent_class, GTK_TYPE_EDITABLE);
+
 	while ((i < length) && (string_ok)) {
 		if (g_ascii_isdigit (text[i])) {
 			++i;
@@ -418,33 +421,6 @@
 	iface->insert_text = insert_text;
 }
 
-GType
-marlin_position_spinner_get_type (void)
-{
-	static GType type = 0;
-
-	if (type == 0) {
-		const GTypeInfo info = {
-			sizeof (MarlinPositionSpinnerClass), NULL, NULL,
-			(GClassInitFunc) class_init, NULL, NULL,
-			sizeof (MarlinPositionSpinner), 0, (GInstanceInitFunc) init
-		};
-
-		static const GInterfaceInfo editable_info = {
-			(GInterfaceInitFunc) editable_init,
-			NULL, NULL
-		};
-		
-		type = g_type_register_static (GTK_TYPE_SPIN_BUTTON,
-					       "MarlinPositionSpinner",
-					       &info, 0);
-		g_type_add_interface_static (type, GTK_TYPE_EDITABLE,
-					     &editable_info);
-	}
-
-	return type;
-}
-
 GtkWidget *
 marlin_position_spinner_new (void)
 {
@@ -455,16 +431,16 @@
 get_display_name (MarlinDisplay display)
 {
 	char *text;
-	
+
 	switch (display) {
 	case MARLIN_DISPLAY_FRAMES:
 		text = _("frames");
 		break;
-		
+
 	case MARLIN_DISPLAY_TIME_LONG:
 		text = _("hrs:mins:secs");
 		break;
-		
+
 	case MARLIN_DISPLAY_SECONDS:
 		text = _("seconds");
 		break;
@@ -488,17 +464,20 @@
 display_changed (MarlinPositionSpinner *spinner,
 		 GtkLabel *label)
 {
-	const char *text = get_display_name (spinner->priv->display);
+	MarlinPositionSpinnerPrivate *priv = spinner->priv;
+
+	const char *text = get_display_name (priv->display);
 	gtk_label_set_text (label, text);
 }
 
 GtkWidget *
 marlin_position_spinner_label (MarlinPositionSpinner *spinner)
 {
+	MarlinPositionSpinnerPrivate *priv = spinner->priv;
 	GtkWidget *label;
 	const char *text;
 
-	text = get_display_name (spinner->priv->display);
+	text = get_display_name (priv->display);
 	label = gtk_label_new (text);
 
 	g_signal_connect (G_OBJECT (spinner), "display-changed",
@@ -506,4 +485,3 @@
 
 	return label;
 }
-		

Modified: trunk/marlin/marlin-program.c
==============================================================================
--- trunk/marlin/marlin-program.c	(original)
+++ trunk/marlin/marlin-program.c	Tue Oct  7 00:19:18 2008
@@ -31,7 +31,9 @@
 	LAST_SIGNAL
 };
 
-static GObjectClass *parent_class = NULL;
+#define GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), MARLIN_PROGRAM_TYPE, MarlinProgramPrivate))
+G_DEFINE_TYPE (MarlinProgram, marlin_program, G_TYPE_OBJECT);
+
 static MarlinProgram *main_program = NULL;
 static guint signals[LAST_SIGNAL];
 
@@ -51,10 +53,7 @@
 
 	g_free (priv->clipboard_src);
 
-	g_free (priv);
-	program->priv = NULL;
-
-	parent_class->finalize (object);
+	G_OBJECT_CLASS (marlin_program_parent_class)->finalize (object);
 }
 
 static void
@@ -62,7 +61,7 @@
 {
 	MarlinProgram *program;
 	MarlinProgramPrivate *priv;
-	
+
 	program = MARLIN_PROGRAM (object);
 	priv = program->priv;
 
@@ -71,18 +70,18 @@
 		priv->clipboard = NULL;
 	}
 
-	parent_class->dispose (object);
+	G_OBJECT_CLASS (marlin_program_parent_class)->dispose (object);
 }
 
 static void
-class_init (MarlinProgramClass *klass)
+marlin_program_class_init (MarlinProgramClass *klass)
 {
 	GObjectClass *object_class = (GObjectClass *) klass;
 
 	object_class->finalize = finalize;
 	object_class->dispose = dispose;
 
-	parent_class = g_type_class_peek_parent (klass);
+	g_type_class_add_private (object_class, sizeof (MarlinProgramPrivate));
 
 	signals[NEW_VIEW] = g_signal_new ("new-view",
 					  G_TYPE_FROM_CLASS (klass),
@@ -103,49 +102,15 @@
 						   G_TYPE_NONE, 0);
 }
 
-#if 0
 static void
-pipeline_eos (GstElement *element,
-	      MarlinProgram *program)
+marlin_program_init (MarlinProgram *program)
 {
-	marlin_pipeline_set_state (MARLIN_PIPELINE (program->priv->pipeline), 
-				   GST_STATE_READY);
-}
-#endif
-
-static void
-init (MarlinProgram *program)
-{
-	program->priv = g_new0 (MarlinProgramPrivate, 1);
-#if 0
-	program->priv->pipeline = g_object_new (MARLIN_PLAY_PIPELINE_TYPE, NULL);
-	g_signal_connect (program->priv->pipeline, "eos",
-			  G_CALLBACK (pipeline_eos), program);
-#endif
-}
-
-GType
-marlin_program_get_type (void)
-{
-	static GType type = 0;
-
-	if (type == 0) {
-		GTypeInfo info = {
-			sizeof (MarlinProgramClass), NULL, NULL,
-			(GClassInitFunc) class_init, NULL, NULL,
-			sizeof (MarlinProgram), 0, (GInstanceInitFunc) init
-		};
-
-		type = g_type_register_static (G_TYPE_OBJECT,
-					       "MarlinProgram", &info, 0);
-	}
-
-	return type;
+	program->priv = GET_PRIVATE (program);
 }
 
 /**
  * marlin_program_get_default:
- * 
+ *
  * Obtains the default MarlinProgram for this instance of Marlin.
  *
  * Return value: A pointer to MarlinProgram.

Modified: trunk/marlin/marlin-progress-dialog.c
==============================================================================
--- trunk/marlin/marlin-progress-dialog.c	(original)
+++ trunk/marlin/marlin-progress-dialog.c	Tue Oct  7 00:19:18 2008
@@ -48,7 +48,7 @@
 	MarlinOperation *operation;
 	gulong signal_id;
 	gulong op_id;
-	
+
 	GtkWidget *label;
 	GtkWidget *progress_bar;
 	GtkWidget *parent_window;
@@ -60,7 +60,8 @@
 };
 
 static GdkPixbuf *empty_jar_pixbuf = NULL, *full_jar_pixbuf = NULL;
-static GtkDialogClass *parent_class = NULL;
+#define GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), MARLIN_PROGRESS_DIALOG_TYPE, MarlinProgressDialogPrivate))
+G_DEFINE_TYPE (MarlinProgressDialog, marlin_progress_dialog, GTK_TYPE_DIALOG);
 
 static void
 finalize (GObject *object)
@@ -71,10 +72,6 @@
 	dialog = MARLIN_PROGRESS_DIALOG (object);
 	priv = dialog->priv;
 
-	if (priv == NULL) {
-		return;
-	}
-
 	if (priv->timer) {
 		g_timer_destroy (priv->timer);
 	}
@@ -84,9 +81,7 @@
 					     priv->op_id);
 	}
 
-	g_free (priv);
-
-	G_OBJECT_CLASS (parent_class)->finalize (object);
+	G_OBJECT_CLASS (marlin_progress_dialog_parent_class)->finalize (object);
 }
 
 static void
@@ -103,7 +98,7 @@
 		priv->operation = NULL;
 	}
 
-	G_OBJECT_CLASS (parent_class)->dispose (object);
+	G_OBJECT_CLASS (marlin_progress_dialog_parent_class)->dispose (object);
 }
 
 static char *
@@ -136,7 +131,7 @@
 			      pixbuf,
 			      0, position);
 
- 	gtk_window_set_icon (GTK_WINDOW (dialog), pixbuf); 
+ 	gtk_window_set_icon (GTK_WINDOW (dialog), pixbuf);
 	g_object_unref (pixbuf);
 }
 
@@ -151,13 +146,13 @@
 
 	if (progress != -1) {
 		left = 100 - progress;
-		
+
 		dt = g_timer_elapsed (priv->timer, NULL);
-		
+
 		length = (dt / (double) progress) * left;
-		
+
 		t = marlin_ms_to_pretty_time ((guint64) ((length + 1) * 1000), FALSE);
-		
+
 		text = make_eta_string (t);
 		g_free (t);
 		gtk_progress_bar_set_text (GTK_PROGRESS_BAR (priv->progress_bar),
@@ -204,7 +199,7 @@
 		text = g_value_get_string (value);
 		gtk_label_set_markup (GTK_LABEL (priv->label), text);
 		break;
-		
+
 	case PROP_SECONDARY:
 		text = g_value_get_string (value);
 		gtk_label_set_markup (GTK_LABEL (priv->sub_process), text);
@@ -233,20 +228,18 @@
 	case GTK_RESPONSE_CANCEL:
 		marlin_operation_cancel (pd->priv->operation);
 		break;
-		
+
 	default:
 		break;
 	}
-
-/* 	GTK_DIALOG_CLASS (parent_class)->response (dialog, response_id); */
 }
 
 static void
-class_init (MarlinProgressDialogClass *klass)
+marlin_progress_dialog_class_init (MarlinProgressDialogClass *klass)
 {
 	GObjectClass *object_class = (GObjectClass *) klass;
 	GtkDialogClass *dialog_class = (GtkDialogClass *) klass;
-	
+
 	object_class->finalize = finalize;
 	object_class->dispose = dispose;
 	object_class->set_property = set_property;
@@ -254,8 +247,7 @@
 
 	dialog_class->response = dialog_response;
 
-	parent_class = g_type_class_peek_parent (klass);
-
+	g_type_class_add_private (object_class, sizeof (MarlinProgressDialogPrivate));
 	g_object_class_install_property (object_class,
 					 PROP_OPERATION,
 					 g_param_spec_object ("operation",
@@ -294,20 +286,20 @@
 }
 
 static void
-init (MarlinProgressDialog *dialog)
+marlin_progress_dialog_init (MarlinProgressDialog *dialog)
 {
 	MarlinProgressDialogPrivate *priv;
 	GtkWidget *vbox;
 	GdkCursor *cursor;
 
-	priv = dialog->priv = g_new0 (MarlinProgressDialogPrivate, 1);
+	priv = dialog->priv = GET_PRIVATE (dialog);
 
 	if (empty_jar_pixbuf == NULL) {
 		empty_jar_pixbuf = gdk_pixbuf_new_from_inline (-1, progress_jar_empty_icon, FALSE, NULL);
 		full_jar_pixbuf = gdk_pixbuf_new_from_inline (-1, progress_jar_full_icon, FALSE, NULL);
 	}
 
-	gtk_dialog_add_button (GTK_DIALOG (dialog), 
+	gtk_dialog_add_button (GTK_DIALOG (dialog),
 			       GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
 	gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
 	gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
@@ -317,7 +309,7 @@
 	priv->pause = gtk_toggle_button_new_with_mnemonic (_("_Pause"));
 	GTK_WIDGET_SET_FLAGS (priv->pause, GTK_CAN_DEFAULT);
 	g_signal_connect (priv->pause, "toggled",
-			  G_CALLBACK (pause_toggled), dialog);	
+			  G_CALLBACK (pause_toggled), dialog);
 	gtk_widget_show (priv->pause);
 	gtk_dialog_add_action_widget (GTK_DIALOG (dialog),
 				      priv->pause, GTK_RESPONSE_NONE);
@@ -333,7 +325,7 @@
 	gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
 	gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), vbox, TRUE, TRUE, 0);
 	gtk_widget_show (vbox);
-	
+
 	priv->label = gtk_label_new ("");
 	gtk_misc_set_alignment (GTK_MISC (priv->label), 0.0, 0.5);
 	gtk_label_set_line_wrap (GTK_LABEL (priv->label), TRUE);
@@ -341,7 +333,7 @@
 
 	gtk_box_pack_start (GTK_BOX (vbox), priv->label, FALSE, FALSE, 0);
 	gtk_widget_show (priv->label);
-	
+
 	priv->progress_bar = gtk_progress_bar_new ();
 	gtk_box_pack_start (GTK_BOX (vbox), priv->progress_bar,
 			    FALSE, FALSE, 0);
@@ -350,44 +342,17 @@
 	gtk_misc_set_alignment (GTK_MISC (priv->sub_process), 0.0, 0.5);
 	gtk_label_set_line_wrap (GTK_LABEL (priv->sub_process), FALSE);
 	gtk_label_set_use_markup (GTK_LABEL (priv->sub_process), TRUE);
-	
+
 	gtk_box_pack_start (GTK_BOX (vbox), priv->sub_process,
 			    FALSE, FALSE, 0);
 	/* Hide the sub process label until there is something to display */
 	gtk_widget_hide (priv->sub_process);
-	
+
 	priv->timer = g_timer_new ();
-	
-	gtk_widget_show (priv->progress_bar);
-	
-	/* 	gtk_window_present (GTK_WINDOW (priv->dialog)); */
-	
-	/* Set icon for parent window as the progress is set as being
-	   transient for it, so it shouldn't show up in the taskbar */
-	/* 	gtk_window_set_icon (GTK_WINDOW (window->parent_window), empty_jar_pixbuf); */
-}
-
-GType
-marlin_progress_dialog_get_type (void)
-{
-	static GType type = 0;
-
-	if (type == 0) {
-		static GTypeInfo info = {
-			sizeof (MarlinProgressDialogClass), NULL, NULL,
-			(GClassInitFunc) class_init, NULL, NULL,
-			sizeof (MarlinProgressDialog), 0, 
-			(GInstanceInitFunc) init
-		};
-
-		type = g_type_register_static (GTK_TYPE_DIALOG,
-					       "MarlinProgressDialog",
-					       &info, 0);
-	}
 
-	return type;
+	gtk_widget_show (priv->progress_bar);
 }
-	
+
 /**
  * marlin_progress_dialog_new:
  * @operation:
@@ -407,7 +372,7 @@
 {
 	MarlinProgressDialog *dialog;
 
-	dialog = g_object_new (MARLIN_PROGRESS_DIALOG_TYPE, 
+	dialog = g_object_new (MARLIN_PROGRESS_DIALOG_TYPE,
 			       "operation", operation,
 			       "primary_text", primary,
 			       "secondary_text", secondary,

Modified: trunk/src/marlin-window.c
==============================================================================
--- trunk/src/marlin-window.c	(original)
+++ trunk/src/marlin-window.c	Tue Oct  7 00:19:18 2008
@@ -2762,7 +2762,7 @@
 	MarlinWindow *window = lod->window;
 	MarlinSample *sample = window->priv->sample;
 	char *filename, *text, *tmp;
-	
+
 	marlin_window_set_media_bar_sensitive (window, FALSE);
 	marlin_window_set_plugins_sensitive (window, FALSE);
 
@@ -2800,7 +2800,7 @@
 	window->priv->progress_window = NULL;
 
 	marlin_window_set_title (window, sample);
-	
+
 	marlin_window_set_file_sensitive (window, TRUE);
 	marlin_window_set_media_bar_sensitive (window, TRUE);
 	marlin_window_set_tools_sensitive (window, TRUE);
@@ -2826,6 +2826,8 @@
 
 	/* Kill the pipeline */
   	gst_element_set_state (GST_ELEMENT (lod->pipeline), GST_STATE_NULL);
+	g_object_unref (lod->pipeline);
+	g_free (lod);
 }
 
 static void
@@ -2834,9 +2836,9 @@
 {
 	MarlinWindow *window = lod->window;
 	MarlinSample *sample;
-	
+
 	if (window->priv->progress_window) {
- 		gtk_widget_destroy (GTK_WIDGET (window->priv->progress_window)); 
+ 		gtk_widget_destroy (GTK_WIDGET (window->priv->progress_window));
 		window->priv->progress_window = NULL;
 	}
 
@@ -2854,6 +2856,8 @@
 	g_object_unref (G_OBJECT (sample));
 
 	gst_element_set_state (GST_ELEMENT (lod->pipeline), GST_STATE_NULL);
+	g_object_unref (lod->pipeline);
+	g_free (lod);
 }
 
 static void
@@ -2868,14 +2872,14 @@
 	char *markup, *message, *filename;
 
 	if (window->priv->progress_window) {
- 		gtk_widget_destroy (GTK_WIDGET (window->priv->progress_window)); 
+ 		gtk_widget_destroy (GTK_WIDGET (window->priv->progress_window));
 		window->priv->progress_window = NULL;
 	}
-	
+
 	g_object_get (G_OBJECT (window->priv->sample),
 		      "filename", &filename,
 		      NULL);
-	
+
 	markup = g_strdup_printf ("<span weight=\"bold\" size=\"larger\">%s</span>\n%s",
 				  _("Could not load '%s'"),
 				  error->message);
@@ -2887,7 +2891,7 @@
 						     GTK_MESSAGE_ERROR,
 						     GTK_BUTTONS_OK,
 						     message);
-	
+
 	gtk_label_set_use_markup (GTK_LABEL (GTK_MESSAGE_DIALOG (dialog)->label), TRUE);
 	gtk_label_set_line_wrap (GTK_LABEL (GTK_MESSAGE_DIALOG (dialog)->label), FALSE);
 
@@ -2910,6 +2914,8 @@
 	g_object_unref (G_OBJECT (sample));
 
 	gst_element_set_state (GST_ELEMENT (lod->pipeline), GST_STATE_NULL);
+	g_object_unref (lod->pipeline);
+	g_free (lod);
 }
 
 static void
@@ -2921,16 +2927,6 @@
 			       paused ? GST_STATE_PAUSED : GST_STATE_PLAYING);
 }
 
-#if 0
-static void
-load_pipeline_shutdown (MarlinPipeline *pipeline,
-			struct _load_op_data *lod)
-{
-	g_object_unref (G_OBJECT (lod->pipeline));
-	g_free (lod);
-}
-#endif
-
 void
 marlin_window_load_file (MarlinWindow *window,
 			 const char *filename)
@@ -2954,7 +2950,7 @@
 			  G_CALLBACK (load_op_error), lod);
 	g_signal_connect (G_OBJECT (operation), "paused",
 			  G_CALLBACK (load_op_paused), lod);
-	
+
 	pipeline = marlin_load_pipeline_new (operation);
 	lod->pipeline = (MarlinPipeline *) pipeline;
 #if 0



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