[evolution/webkit: 139/171] Revert "Use a single mutex located in EMPartClass"



commit c684223b669b098fe97473b566d765b9ce49e0ac
Author: Dan VrÃtil <dvratil redhat com>
Date:   Wed Feb 8 14:48:55 2012 +0100

    Revert "Use a single mutex located in EMPartClass"
    
    This reverts commit 9cff4862c66187fbd2e598fed008a7048396842f.

 em-format/em-part.c                  |  136 +++++++++++++--------------------
 em-format/em-part.h                  |    8 +--
 mail/em-format-html-display-parts.c  |  133 ++++++++++++++++++---------------
 plugins/audio-inline/em-part-audio.c |   70 +++++++++--------
 plugins/audio-inline/em-part-audio.h |    3 +-
 5 files changed, 168 insertions(+), 182 deletions(-)
---
diff --git a/em-format/em-part.c b/em-format/em-part.c
index c2ede26..26c4c4b 100644
--- a/em-format/em-part.c
+++ b/em-format/em-part.c
@@ -41,6 +41,8 @@ struct _EMPartPrivate {
 	CamelCipherValidity *validity_parent;
 
 	gboolean is_attachment;
+
+	GMutex *mutex;
 };
 
 static void
@@ -48,7 +50,7 @@ em_part_finalize (GObject *object)
 {
 	EMPartPrivate *priv = EM_PART (object)->priv;
 
-	em_part_mutex_lock (EM_PART (object));
+	g_mutex_lock (priv->mutex);
 
 	if (priv->cid) {
 		g_free (priv->cid);
@@ -85,21 +87,8 @@ em_part_finalize (GObject *object)
 		priv->validity_parent = NULL;
 	}
 
-	em_part_mutex_unlock (EM_PART (object));
-}
-
-static void
-em_part_dispose (GObject *object)
-{
-	EMPartClass *klass;
-
-	klass = EM_PART_GET_CLASS (EM_PART (object));
-
-	/* Make sure the mutex is unlocked */
-	g_mutex_lock (klass->mutex);
-	g_mutex_unlock (klass->mutex);
-
-	g_mutex_free (klass->mutex);
+	g_mutex_unlock (priv->mutex);
+	g_mutex_free (priv->mutex);
 }
 
 static void
@@ -107,12 +96,9 @@ em_part_class_init (EMPartClass *klass)
 {
 	GObjectClass *object_class;
 
-	klass->mutex = g_mutex_new ();
-
 	g_type_class_add_private (klass, sizeof (EMPartPrivate));
 
 	object_class = G_OBJECT_CLASS (klass);
-	object_class->dispose = em_part_dispose;
 	object_class->finalize = em_part_finalize;
 
 }
@@ -123,6 +109,7 @@ em_part_init (EMPart *emp)
 	emp->priv = G_TYPE_INSTANCE_GET_PRIVATE (emp,
 			EM_TYPE_PART, EMPartPrivate);
 
+	emp->priv->mutex = g_mutex_new ();
 	emp->priv->cid = NULL;
 	emp->priv->formatter = NULL;
 	emp->priv->is_attachment = FALSE;
@@ -179,7 +166,7 @@ em_part_set_formatter (EMPart *emp,
 	g_return_if_fail (EM_IS_PART (emp));
 	g_return_if_fail (EM_IS_FORMAT (emf));
 
-	em_part_mutex_lock (emp);
+	g_mutex_lock (emp->priv->mutex);
 
 	g_object_ref (emf);
 
@@ -188,7 +175,7 @@ em_part_set_formatter (EMPart *emp,
 
 	emp->priv->formatter = emf;
 
-	em_part_mutex_unlock (emp);
+	g_mutex_unlock (emp->priv->mutex);
 }
 
 /**
@@ -205,12 +192,12 @@ em_part_get_formatter (EMPart *emp)
 
 	g_return_val_if_fail (EM_IS_PART (emp), NULL);
 
-	em_part_mutex_lock (emp);
+	g_mutex_lock (emp->priv->mutex);
 
 	if (emp->priv->formatter)
 		formatter = g_object_ref (emp->priv->formatter);
 
-	em_part_mutex_unlock (emp);
+	g_mutex_unlock (emp->priv->mutex);
 
 	return formatter;
 }
@@ -229,7 +216,7 @@ em_part_set_mime_part (EMPart *emp,
 	g_return_if_fail (EM_IS_PART (emp));
 	g_return_if_fail ((part == NULL) || CAMEL_IS_MIME_PART (part));
 
-	em_part_mutex_lock (emp);
+	g_mutex_lock (emp->priv->mutex);
 
 	if (part)
 		g_object_ref (part);
@@ -239,7 +226,7 @@ em_part_set_mime_part (EMPart *emp,
 
 	emp->priv->part = part;
 
-	em_part_mutex_unlock (emp);
+	g_mutex_unlock (emp->priv->mutex);
 }
 
 /**
@@ -256,12 +243,12 @@ em_part_get_mime_part (EMPart *emp)
 
 	g_return_val_if_fail (EM_IS_PART (emp), NULL);
 
-	em_part_mutex_lock (emp);
+	g_mutex_lock (emp->priv->mutex);
 
 	if (emp->priv->part)
 		part = g_object_ref (emp->priv->part);
 
-	em_part_mutex_unlock (emp);
+	g_mutex_unlock (emp->priv->mutex);
 
 	return part;
 }
@@ -278,9 +265,9 @@ em_part_set_write_func (EMPart *emp,
 {
 	g_return_if_fail (EM_IS_PART (emp));
 
-	em_part_mutex_lock (emp);
+	g_mutex_lock (emp->priv->mutex);
 	emp->priv->write_func = write_func;
-	em_part_mutex_unlock (emp);
+	g_mutex_unlock (emp->priv->mutex);
 }
 
 EMPartWriteFunc
@@ -290,9 +277,9 @@ em_part_get_write_func (EMPart *emp)
 
 	g_return_val_if_fail (EM_IS_PART (emp), NULL);
 
-	em_part_mutex_lock (emp);
+	g_mutex_lock (emp->priv->mutex);
 	write_func = emp->priv->write_func;
-	em_part_mutex_unlock (emp);
+	g_mutex_unlock (emp->priv->mutex);
 
 	return write_func;
 }
@@ -309,9 +296,9 @@ em_part_set_widget_func (EMPart *emp,
 {
 	g_return_if_fail (EM_IS_PART (emp));
 
-	em_part_mutex_lock (emp);
+	g_mutex_lock (emp->priv->mutex);
 	emp->priv->widget_func = widget_func;
-	em_part_mutex_unlock (emp);
+	g_mutex_unlock (emp->priv->mutex);
 }
 
 EMPartWidgetFunc
@@ -321,9 +308,9 @@ em_part_get_widget_func (EMPart *emp)
 
 	g_return_val_if_fail (EM_IS_PART (emp), NULL);
 
-	em_part_mutex_lock (emp);
+	g_mutex_lock (emp->priv->mutex);
 	widget_func = emp->priv->widget_func;
-	em_part_mutex_unlock (emp);
+	g_mutex_unlock (emp->priv->mutex);
 
 	return widget_func;
 }
@@ -335,14 +322,14 @@ em_part_set_uri (EMPart *emp,
 	g_return_if_fail (EM_IS_PART (emp));
 	g_return_if_fail (uri && *uri);
 
-	em_part_mutex_lock (emp);
+	g_mutex_lock (emp->priv->mutex);
 
 	if (emp->priv->uri)
 		g_free (emp->priv->uri);
 
 	emp->priv->uri = g_strdup (uri);
 
-	em_part_mutex_unlock (emp);
+	g_mutex_unlock (emp->priv->mutex);
 }
 
 gchar *
@@ -352,12 +339,12 @@ em_part_get_uri (EMPart *emp)
 
 	g_return_val_if_fail (EM_IS_PART (emp), NULL);
 
-	em_part_mutex_lock (emp);
+	g_mutex_lock (emp->priv->mutex);
 
 	if (emp->priv->uri)
 		uri = g_strdup (emp->priv->uri);
 
-	em_part_mutex_unlock (emp);
+	g_mutex_unlock (emp->priv->mutex);
 
 	return uri;
 }
@@ -374,7 +361,7 @@ em_part_set_cid (EMPart *emp,
 {
 	g_return_if_fail (EM_IS_PART (emp));
 
-	em_part_mutex_lock (emp);
+	g_mutex_lock (emp->priv->mutex);
 
 	if (emp->priv->cid)
 		g_free (emp->priv->cid);
@@ -384,7 +371,7 @@ em_part_set_cid (EMPart *emp,
 	else
 		emp->priv->cid = NULL;
 
-	em_part_mutex_unlock (emp);
+	g_mutex_unlock (emp->priv->mutex);
 }
 
 gchar *
@@ -394,12 +381,12 @@ em_part_get_cid (EMPart *emp)
 
 	g_return_val_if_fail (EM_IS_PART (emp), NULL);
 
-	em_part_mutex_lock (emp);
+	g_mutex_lock (emp->priv->mutex);
 
 	if (cid)
 		cid = g_strdup (emp->priv->cid);
 
-	em_part_mutex_unlock (emp);
+	g_mutex_unlock (emp->priv->mutex);
 
 	return cid;
 }
@@ -411,14 +398,14 @@ em_part_set_mime_type (EMPart *emp,
 	g_return_if_fail (EM_IS_PART (emp));
 	g_return_if_fail (mime_type && *mime_type);
 
-	em_part_mutex_lock (emp);
+	g_mutex_lock (emp->priv->mutex);
 
 	if (emp->priv->mime_type)
 		g_free (emp->priv->mime_type);
 
 	emp->priv->mime_type = g_strdup (mime_type);
 
-	em_part_mutex_unlock (emp);
+	g_mutex_unlock (emp->priv->mutex);
 }
 
 gchar *
@@ -428,12 +415,12 @@ em_part_get_mime_type (EMPart *emp)
 
 	g_return_val_if_fail (EM_IS_PART (emp), NULL);
 
-	em_part_mutex_lock (emp);
+	g_mutex_lock (emp->priv->mutex);
 
 	if (mime_type)
 		mime_type = g_strdup (emp->priv->mime_type);
 
-	em_part_mutex_unlock (emp);
+	g_mutex_unlock (emp->priv->mutex);
 
 	return mime_type;
 }
@@ -446,9 +433,9 @@ em_part_set_validity_type (EMPart *emp,
 {
 	g_return_if_fail (EM_IS_PART (emp));
 
-	em_part_mutex_lock (emp);
+	g_mutex_lock (emp->priv->mutex);
 	emp->priv->validity_type = validity_type;
-	em_part_mutex_unlock (emp);
+	g_mutex_unlock (emp->priv->mutex);
 }
 
 guint32
@@ -458,9 +445,9 @@ em_part_get_validity_type (EMPart *emp)
 
 	g_return_val_if_fail (EM_IS_PART (emp), 0);
 
-	em_part_mutex_lock (emp);
+	g_mutex_lock (emp->priv->mutex);
 	validity_type = emp->priv->validity_type;
-	em_part_mutex_unlock (emp);
+	g_mutex_unlock (emp->priv->mutex);
 
 	return validity_type;
 }
@@ -477,7 +464,7 @@ em_part_set_validity (EMPart *emp,
 {
 	g_return_if_fail (EM_IS_PART (emp));
 
-	em_part_mutex_lock (emp);
+	g_mutex_lock (emp->priv->mutex);
 
 	if (emp->priv->validity)
 		camel_cipher_validity_free (emp->priv->validity);
@@ -487,7 +474,7 @@ em_part_set_validity (EMPart *emp,
 	else
 		emp->priv->validity = NULL;
 
-	em_part_mutex_unlock (emp);
+	g_mutex_unlock (emp->priv->mutex);
 }
 
 /**
@@ -504,12 +491,12 @@ em_part_get_validity (EMPart *emp)
 
 	g_return_val_if_fail (EM_IS_PART (emp), NULL);
 
-	em_part_mutex_lock (emp);
+	g_mutex_lock (emp->priv->mutex);
 
 	if (emp->priv->validity)
 		validity = camel_cipher_validity_clone (emp->priv->validity);
 
-	em_part_mutex_unlock (emp);
+	g_mutex_unlock (emp->priv->mutex);
 
 	return validity;
 }
@@ -526,7 +513,7 @@ em_part_set_validity_parent (EMPart *emp,
 {
 	g_return_if_fail (EM_IS_PART (emp));
 
-	em_part_mutex_lock (emp);
+	g_mutex_lock (emp->priv->mutex);
 
 	if (emp->priv->validity_parent)
 		camel_cipher_validity_free (emp->priv->validity_parent);
@@ -536,7 +523,7 @@ em_part_set_validity_parent (EMPart *emp,
 	else
 		emp->priv->validity_parent = NULL;
 
-	em_part_mutex_unlock (emp);
+	g_mutex_unlock (emp->priv->mutex);
 }
 
 /**
@@ -553,12 +540,12 @@ em_part_get_validity_parent (EMPart *emp)
 
 	g_return_val_if_fail (EM_IS_PART (emp), NULL);
 
-	em_part_mutex_lock (emp);
+	g_mutex_lock (emp->priv->mutex);
 
 	if (emp->priv->validity_parent)
 		validity = camel_cipher_validity_clone (emp->priv->validity_parent);
 
-	em_part_mutex_unlock (emp);
+	g_mutex_unlock (emp->priv->mutex);
 
 	return validity;
 }
@@ -569,9 +556,9 @@ em_part_set_is_attachment (EMPart *emp,
 {
 	g_return_if_fail (EM_IS_PART (emp));
 
-	em_part_mutex_lock (emp);
+	g_mutex_lock (emp->priv->mutex);
 	emp->priv->is_attachment = is_attachment;
-	em_part_mutex_unlock (emp);
+	g_mutex_unlock (emp->priv->mutex);
 }
 
 gboolean
@@ -581,9 +568,9 @@ em_part_get_is_attachment (EMPart *emp)
 
 	g_return_val_if_fail (EM_IS_PART (emp), FALSE);
 
-	em_part_mutex_lock (emp);
+	g_mutex_lock (emp->priv->mutex);
 	is_attachment = emp->priv->is_attachment;
-	em_part_mutex_unlock (emp);
+	g_mutex_unlock (emp->priv->mutex);
 
 	return is_attachment;
 }
@@ -609,10 +596,10 @@ em_part_get_widget (EMPart *emp,
 
 	g_return_val_if_fail (EM_IS_PART (emp), NULL);
 
-	em_part_mutex_lock (emp);
+	g_mutex_lock (emp->priv->mutex);
 	widget_func = emp->priv->widget_func;
 	formatter = g_object_ref (emp->priv->formatter);
-	em_part_mutex_unlock (emp);
+	g_mutex_unlock (emp->priv->mutex);
 
 	if (!widget_func)
 		return NULL;
@@ -648,14 +635,14 @@ em_part_write (EMPart *emp,
 	g_return_if_fail (EM_IS_PART (emp));
 	g_return_if_fail (CAMEL_IS_STREAM (stream));
 
-	em_part_mutex_lock (emp);
+	g_mutex_lock (emp->priv->mutex);
 	write_func = emp->priv->write_func;
 	formatter = g_object_ref (emp->priv->formatter);
 
 	if (emp->priv->mime_type)
 		mime_type = g_strdup (emp->priv->mime_type);
 
-	em_part_mutex_unlock (emp);
+	g_mutex_unlock (emp->priv->mutex);
 
 	g_object_ref (emp);
 
@@ -689,18 +676,3 @@ em_part_write (EMPart *emp,
 	if (mime_type)
 		g_free (mime_type);
 }
-
-void
-em_part_mutex_lock (EMPart *emp)
-{
-        g_return_if_fail (EM_IS_PART (emp));
-
-        g_mutex_lock (EM_PART_GET_CLASS (emp)->mutex);
-}
-
-void em_part_mutex_unlock (EMPart *emp)
-{
-        g_return_if_fail (EM_IS_PART (emp));
-
-        g_mutex_unlock (EM_PART_GET_CLASS (emp)->mutex);
-}
diff --git a/em-format/em-part.h b/em-format/em-part.h
index 1dcf527..2b20be5 100644
--- a/em-format/em-part.h
+++ b/em-format/em-part.h
@@ -20,7 +20,7 @@
 #include <camel/camel.h>
 #include <glib-object.h>
 
-#include <em-format/em-format.h>
+#include <em-format.h>
 
 /* Standard GObject macros */
 #define EM_TYPE_PART \
@@ -66,7 +66,6 @@ struct _EMPart {
 struct _EMPartClass {
         GObjectClass parent_class;
 
-        GMutex *mutex;
 };
 
 EMPart*			em_part_new      	(EMFormat *emf,
@@ -136,11 +135,6 @@ void                    em_part_write		(EMPart *emp,
                                                  EMFormatWriterInfo *info,
                                                  GCancellable *cancellable);
 
-void                    em_part_mutex_lock	(EMPart *emp);
-
-void                    em_part_mutex_unlock    (EMPart *emp);
-
-
 G_END_DECLS
 
 #endif /* EM_PART_H */
\ No newline at end of file
diff --git a/mail/em-format-html-display-parts.c b/mail/em-format-html-display-parts.c
index 9c24650..d7c7965 100644
--- a/mail/em-format-html-display-parts.c
+++ b/mail/em-format-html-display-parts.c
@@ -20,6 +20,8 @@
 
 struct _EMPartAttachmentBarPrivate {
 	EAttachmentStore *store;
+	
+	GMutex *mutex;
 };
 
 G_DEFINE_TYPE (EMPartAttachmentBar, em_part_attachment_bar, EM_TYPE_PART);
@@ -30,14 +32,15 @@ em_part_attachment_bar_finalize (GObject *object)
 	EMPartAttachmentBarPrivate *priv =
 		EM_PART_ATTACHMENT_BAR (object)->priv;
 
-	em_part_mutex_lock (EM_PART (object));
+	g_mutex_lock (priv->mutex);
 
 	if (priv->store) {
 		g_object_unref (priv->store);
 		priv->store = NULL;
 	}
 
-	em_part_mutex_unlock (EM_PART (object));
+	g_mutex_unlock (priv->mutex);
+	g_mutex_free (priv->mutex);
 }
 
 static void
@@ -60,6 +63,8 @@ em_part_attachment_bar_init (EMPartAttachmentBar *empab)
 			EM_TYPE_PART_ATTACHMENT_BAR, EMPartAttachmentBarPrivate);
 
 	empab->priv->store = NULL;
+
+	empab->priv->mutex = g_mutex_new ();
 }
 
 EMPart*
@@ -90,7 +95,7 @@ em_part_attachment_bar_set_store (EMPartAttachmentBar *empab,
 	g_return_if_fail (EM_IS_PART_ATTACHMENT_BAR (empab));
 	g_return_if_fail ((store == NULL) || E_IS_ATTACHMENT_STORE (store));
 
-	em_part_mutex_lock ((EMPart *) empab);
+	g_mutex_lock (empab->priv->mutex);
 
 	if (store)
 		g_object_ref (store);
@@ -100,7 +105,7 @@ em_part_attachment_bar_set_store (EMPartAttachmentBar *empab,
 
 	empab->priv->store = store;
 
-	em_part_mutex_unlock ((EMPart *) empab);
+	g_mutex_unlock (empab->priv->mutex);
 }
 
 
@@ -111,10 +116,10 @@ em_part_attachment_bar_get_store (EMPartAttachmentBar *empab)
 
 	g_return_val_if_fail (EM_IS_PART_ATTACHMENT_BAR (empab), NULL);
 
-	em_part_mutex_lock ((EMPart *) empab);
+	g_mutex_lock (empab->priv->mutex);
 	if (empab->priv->store)
 		store = g_object_ref (empab->priv->store);
-	em_part_mutex_unlock ((EMPart *) empab);
+	g_mutex_unlock (empab->priv->mutex);
 
 	return store;
 }
@@ -137,6 +142,8 @@ struct _EMPartAttachmentPrivate {
 	CamelStream *mstream;
 
 	const EMFormatHandler *handler;
+
+	GMutex *mutex;
 };
 
 G_DEFINE_TYPE (EMPartAttachment, em_part_attachment, EM_TYPE_PART);
@@ -146,7 +153,7 @@ em_part_attachment_finalize (GObject *object)
 {
 	EMPartAttachmentPrivate *priv = EM_PART_ATTACHMENT (object)->priv;
 
-	em_part_mutex_lock (EM_PART (object));
+	g_mutex_lock (priv->mutex);
 
 	if (priv->attachment) {
 		g_object_unref (priv->attachment);
@@ -183,7 +190,8 @@ em_part_attachment_finalize (GObject *object)
 		priv->view_part_id = NULL;
 	}
 
-	em_part_mutex_unlock (EM_PART (object));
+	g_mutex_unlock (priv->mutex);
+	g_mutex_free (priv->mutex);
 }
 
 static void
@@ -212,6 +220,8 @@ em_part_attachment_init (EMPartAttachment *empa)
 	empa->priv->snoop_mime_type = NULL;
 	empa->priv->view_part_id = NULL;
 	empa->priv->handler = NULL;
+	
+	empa->priv->mutex = g_mutex_new ();	
 }
 
 EMPart*
@@ -241,7 +251,7 @@ em_part_attachment_set_snoop_mime_type (EMPartAttachment *empa,
 {
 	g_return_if_fail (EM_IS_PART_ATTACHMENT (empa));
 
-	em_part_mutex_lock ((EMPart *) empa);
+	g_mutex_lock (empa->priv->mutex);
 
 	if (empa->priv->snoop_mime_type)
 		g_free (empa->priv->snoop_mime_type);
@@ -251,7 +261,7 @@ em_part_attachment_set_snoop_mime_type (EMPartAttachment *empa,
 	else
 		empa->priv->snoop_mime_type = NULL;
 
-	em_part_mutex_unlock ((EMPart *) empa);
+	g_mutex_unlock (empa->priv->mutex);
 }
 
 gchar*
@@ -261,10 +271,10 @@ em_part_attachment_get_snoop_mime_part (EMPartAttachment *empa)
 
 	g_return_val_if_fail (EM_IS_PART_ATTACHMENT (empa), NULL);
 
-	em_part_mutex_lock ((EMPart *) empa);
+	g_mutex_lock (empa->priv->mutex);
 	if (empa->priv->snoop_mime_type)
 		mime_type = g_strdup (empa->priv->snoop_mime_type);
-	em_part_mutex_unlock ((EMPart *) empa);
+	g_mutex_unlock (empa->priv->mutex);
 
 	return mime_type;
 }
@@ -276,7 +286,7 @@ em_part_attachment_set_forward_widget (EMPartAttachment *empa,
 	g_return_if_fail (EM_IS_PART_ATTACHMENT (empa));
 	g_return_if_fail ((forward == NULL) || GTK_IS_WIDGET (forward));
 
-	em_part_mutex_lock ((EMPart *) empa);
+	g_mutex_lock (empa->priv->mutex);
 	
 	if (forward)
 		g_object_ref (forward);
@@ -289,7 +299,7 @@ em_part_attachment_set_forward_widget (EMPartAttachment *empa,
 	else
 		empa->priv->forward = NULL;
 
-	em_part_mutex_unlock ((EMPart *) empa);
+	g_mutex_unlock (empa->priv->mutex);
 }
 
 GtkWidget*
@@ -299,10 +309,10 @@ em_part_attachment_get_forward_widget (EMPartAttachment *empa)
 
 	g_return_val_if_fail (EM_IS_PART_ATTACHMENT (empa), NULL);
 
-	em_part_mutex_lock ((EMPart *) empa);
+	g_mutex_lock (empa->priv->mutex);
 	if (empa->priv->down)
 		widget = g_object_ref (empa->priv->down);
-	em_part_mutex_unlock ((EMPart *) empa);
+	g_mutex_unlock (empa->priv->mutex);
 
 	return widget;
 }
@@ -315,7 +325,7 @@ em_part_attachment_set_down_widget (EMPartAttachment *empa,
 	g_return_if_fail (EM_IS_PART_ATTACHMENT (empa));
 	g_return_if_fail ((down == NULL) || GTK_IS_WIDGET (down));
 
-	em_part_mutex_lock ((EMPart *) empa);
+	g_mutex_lock (empa->priv->mutex);
 
 	if (down)
 		g_object_ref (down);
@@ -328,7 +338,7 @@ em_part_attachment_set_down_widget (EMPartAttachment *empa,
 	else
 		empa->priv->down = NULL;
 
-	em_part_mutex_unlock ((EMPart *) empa);
+	g_mutex_unlock (empa->priv->mutex);
 }
 
 GtkWidget*
@@ -338,10 +348,10 @@ em_part_attachment_get_down_widget (EMPartAttachment *empa)
 
 	g_return_val_if_fail (EM_IS_PART_ATTACHMENT (empa), NULL);
 
-	em_part_mutex_lock ((EMPart *) empa);
+	g_mutex_lock (empa->priv->mutex);
 	if (empa->priv->down)
 		widget = g_object_ref (empa->priv->down);
-	em_part_mutex_unlock ((EMPart *) empa);
+	g_mutex_unlock (empa->priv->mutex);
 
 	return widget;
 }
@@ -352,9 +362,9 @@ em_part_attachment_set_is_shown (EMPartAttachment *empa,
 {
 	g_return_if_fail (EM_IS_PART_ATTACHMENT (empa));
 
-	em_part_mutex_lock ((EMPart *) empa);
+	g_mutex_lock (empa->priv->mutex);
 	empa->priv->shown = is_shown;
-	em_part_mutex_unlock ((EMPart *) empa);
+	g_mutex_unlock (empa->priv->mutex);
 }
 
 gboolean
@@ -364,9 +374,9 @@ em_part_attachment_get_is_shown (EMPartAttachment *empa)
 
 	g_return_val_if_fail (EM_IS_PART_ATTACHMENT (empa), FALSE);
 
-	em_part_mutex_lock ((EMPart *) empa);
+	g_mutex_lock (empa->priv->mutex);
 	is_shown = empa->priv->shown;
-	em_part_mutex_unlock ((EMPart *) empa);
+	g_mutex_unlock (empa->priv->mutex);
 
 	return is_shown;
 }
@@ -381,7 +391,7 @@ em_part_attachment_set_attachment (EMPartAttachment *empa,
 	if (attachment)
 		g_object_ref (attachment);
 
-	em_part_mutex_lock ((EMPart *) empa);
+	g_mutex_lock (empa->priv->mutex);
 
 	if (empa->priv->attachment)
 		g_object_unref (empa->priv->attachment);
@@ -391,7 +401,7 @@ em_part_attachment_set_attachment (EMPartAttachment *empa,
 	else
 		empa->priv->attachment = NULL;
 
-	em_part_mutex_unlock ((EMPart *) empa);
+	g_mutex_unlock (empa->priv->mutex);
 }
 
 EAttachment*
@@ -401,10 +411,10 @@ em_part_attachment_get_attachment (EMPartAttachment *empa)
 
 	g_return_val_if_fail (EM_IS_PART_ATTACHMENT (empa), NULL);
 
-	em_part_mutex_lock ((EMPart *) empa);
-	if (empa->priv->attachment)
+	g_mutex_lock (empa->priv->mutex);
+	if (empa->priv->mutex)
 		attachment = g_object_ref (empa->priv->attachment);
-	em_part_mutex_unlock ((EMPart *) empa);
+	g_mutex_unlock (empa->priv->mutex);
 
 	return attachment;
 }
@@ -415,7 +425,7 @@ em_part_attachment_set_view_part_id (EMPartAttachment *empa,
 {
 	g_return_if_fail (EM_IS_PART_ATTACHMENT (empa));
 
-	em_part_mutex_lock ((EMPart *) empa);
+	g_mutex_lock (empa->priv->mutex);
 
 	if (empa->priv->view_part_id)
 		g_free (empa->priv->view_part_id);
@@ -425,7 +435,7 @@ em_part_attachment_set_view_part_id (EMPartAttachment *empa,
 	else
 		empa->priv->view_part_id = NULL;
 
-	em_part_mutex_unlock ((EMPart *) empa);
+	g_mutex_unlock (empa->priv->mutex);
 }
 
 gchar*
@@ -435,10 +445,10 @@ em_part_attachment_get_view_part_id (EMPartAttachment *empa)
 
 	g_return_val_if_fail (EM_IS_PART_ATTACHMENT (empa), NULL);
 	
-	em_part_mutex_lock ((EMPart *) empa);
+	g_mutex_lock (empa->priv->mutex);
 	if (empa->priv->view_part_id)
 		view_part_id = g_strdup (view_part_id);
-	em_part_mutex_unlock ((EMPart *) empa);
+	g_mutex_unlock (empa->priv->mutex);
 
 	return view_part_id;	
 }
@@ -449,7 +459,7 @@ em_part_attachment_set_description (EMPartAttachment *empa,
 {
 	g_return_if_fail (EM_IS_PART_ATTACHMENT (empa));
 
-	em_part_mutex_lock ((EMPart *) empa);
+	g_mutex_lock (empa->priv->mutex);
 
 	if (empa->priv->description)
 		g_free (empa->priv->description);
@@ -459,7 +469,7 @@ em_part_attachment_set_description (EMPartAttachment *empa,
 	else
 		empa->priv->description = NULL;
 
-	em_part_mutex_unlock ((EMPart *) empa);
+	g_mutex_unlock (empa->priv->mutex);
 }
 
 gchar*
@@ -469,10 +479,10 @@ em_part_attachment_get_description (EMPartAttachment *empa)
 
 	g_return_val_if_fail (EM_IS_PART_ATTACHMENT (empa), NULL);
 
-	em_part_mutex_lock ((EMPart *) empa);
+	g_mutex_lock (empa->priv->mutex);
 	if (empa->priv->description)
 		description = g_strdup (empa->priv->description);
-	em_part_mutex_unlock ((EMPart *) empa);
+	g_mutex_unlock (empa->priv->mutex);
 
 	return description;
 }
@@ -484,7 +494,7 @@ em_part_attachment_set_mstream (EMPartAttachment *empa,
 	g_return_if_fail (EM_IS_PART_ATTACHMENT (empa));
 	g_return_if_fail ((mstream == NULL) || CAMEL_IS_STREAM (mstream));
 
-	em_part_mutex_lock ((EMPart *) empa);
+	g_mutex_lock (empa->priv->mutex);
 	if (mstream)
 		g_object_ref (mstream);
 
@@ -493,7 +503,7 @@ em_part_attachment_set_mstream (EMPartAttachment *empa,
 
 	empa->priv->mstream = mstream;
 		
-	em_part_mutex_unlock ((EMPart *) empa);
+	g_mutex_unlock (empa->priv->mutex);
 }
 
 CamelStream*
@@ -503,10 +513,10 @@ em_part_attachment_get_mstream (EMPartAttachment *empa)
 
 	g_return_val_if_fail (EM_IS_PART_ATTACHMENT (empa), NULL);
 
-	em_part_mutex_lock ((EMPart *) empa);
+	g_mutex_lock (empa->priv->mutex);
 	if (empa->priv->mstream)
 		stream = g_object_ref (empa->priv->mstream);
-	em_part_mutex_unlock ((EMPart *) empa);
+	g_mutex_unlock (empa->priv->mutex);
 
 	return stream;
 }
@@ -517,9 +527,9 @@ em_part_attachment_set_handler (EMPartAttachment *empa,
 {
 	g_return_if_fail (EM_IS_PART_ATTACHMENT (empa));
 
-	em_part_mutex_lock ((EMPart *) empa);
+	g_mutex_lock (empa->priv->mutex);
 	empa->priv->handler = handler;
-	em_part_mutex_unlock ((EMPart *) empa);
+	g_mutex_unlock (empa->priv->mutex);
 }
 
 const EMFormatHandler*
@@ -529,9 +539,9 @@ em_part_attachment_get_handler (EMPartAttachment *empa)
 
 	g_return_val_if_fail (EM_IS_PART_ATTACHMENT (empa), NULL);
 
-	em_part_mutex_lock ((EMPart *) empa);
+	g_mutex_lock (empa->priv->mutex);
 	handler = empa->priv->handler;
-	em_part_mutex_unlock ((EMPart *) empa);
+	g_mutex_unlock (empa->priv->mutex);
 
 	return handler;
 }
@@ -544,6 +554,8 @@ struct _EMPartSMIMEPrivate {
 	gchar *description;
 	gint signature;
 	GtkWidget *widget;
+
+	GMutex *mutex;
 };
 
 G_DEFINE_TYPE (EMPartSMIME, em_part_smime, EM_TYPE_PART);
@@ -554,7 +566,7 @@ em_part_smime_finalize (GObject *object)
 {
 	EMPartSMIMEPrivate *priv = EM_PART_SMIME (object)->priv;
 	
-	em_part_mutex_lock (EM_PART (object));
+	g_mutex_lock (priv->mutex);
 	
 	if (priv->description) {
 		g_free (priv->description);
@@ -566,7 +578,8 @@ em_part_smime_finalize (GObject *object)
 		priv->widget = NULL;
 	}
 	
-	em_part_mutex_lock (EM_PART (object));
+	g_mutex_unlock (priv->mutex);
+	g_mutex_free (priv->mutex);
 }
 
 static void
@@ -589,6 +602,8 @@ em_part_smime_init (EMPartSMIME *emps)
 	emps->priv->description = NULL;
 	emps->priv->signature = 0;
 	emps->priv->widget = NULL;
+	
+	emps->priv->mutex = g_mutex_new ();	
 }
 
 EMPart*
@@ -618,7 +633,7 @@ em_part_smime_set_description (EMPartSMIME *emps,
 {
 	g_return_if_fail (EM_IS_PART_SMIME (emps));
 
-	em_part_mutex_lock ((EMPart *) emps);
+	g_mutex_lock (emps->priv->mutex);
 
 	if (emps->priv->description)
 		g_free (emps->priv->description);
@@ -628,7 +643,7 @@ em_part_smime_set_description (EMPartSMIME *emps,
 	else
 		emps->priv->description = NULL;
 
-	em_part_mutex_unlock ((EMPart *) emps);
+	g_mutex_unlock (emps->priv->mutex);
 }
 
 gchar*
@@ -638,10 +653,10 @@ em_part_smime_get_description (EMPartSMIME *emps)
 
 	g_return_val_if_fail (EM_IS_PART_SMIME (emps), NULL);
 
-	em_part_mutex_lock ((EMPart *) emps);
+	g_mutex_lock (emps->priv->mutex);
 	if (emps->priv->description)
 		description = g_strdup (emps->priv->description);
-	em_part_mutex_unlock ((EMPart *) emps);
+	g_mutex_unlock (emps->priv->mutex);
 
 	return description;
 }
@@ -652,9 +667,9 @@ em_part_smime_set_signature (EMPartSMIME *emps,
 {
 	g_return_if_fail (EM_IS_PART_SMIME (emps));
 
-	em_part_mutex_lock ((EMPart *) emps);
+	g_mutex_lock (emps->priv->mutex);
 	emps->priv->signature = signature;
-	em_part_mutex_unlock ((EMPart *) emps);
+	g_mutex_unlock (emps->priv->mutex);
 }
 
 gint
@@ -664,9 +679,9 @@ em_part_smime_get_signature (EMPartSMIME *emps)
 
 	g_return_val_if_fail (EM_IS_PART_SMIME (emps), 0);
 
-	em_part_mutex_lock ((EMPart *) emps);
+	g_mutex_lock (emps->priv->mutex);
 	signature = emps->priv->signature;
-	em_part_mutex_unlock ((EMPart *) emps);
+	g_mutex_unlock (emps->priv->mutex);
 
 	return signature;
 }
@@ -681,14 +696,14 @@ em_part_smime_set_widget (EMPartSMIME *emps,
 	if (widget)
 		g_object_ref (widget);
 
-	em_part_mutex_lock ((EMPart *) emps);
+	g_mutex_lock (emps->priv->mutex);
 
 	if (emps->priv->widget)
 		g_object_unref (emps->priv->widget);
 
 	emps->priv->widget = widget;
 
-	em_part_mutex_unlock ((EMPart *) emps);
+	g_mutex_unlock (emps->priv->mutex);
 }
 
 GtkWidget*
@@ -698,10 +713,10 @@ em_part_smime_get_widget (EMPartSMIME *emps)
 
 	g_return_val_if_fail (EM_IS_PART_SMIME (emps), NULL);
 
-	em_part_mutex_lock ((EMPart *) emps);
+	g_mutex_lock (emps->priv->mutex);
 	if (emps->priv->widget)
 		widget = g_object_ref (emps->priv->widget);
-	em_part_mutex_unlock ((EMPart *) emps);
+	g_mutex_unlock (emps->priv->mutex);
 
 	return widget;
 }
diff --git a/plugins/audio-inline/em-part-audio.c b/plugins/audio-inline/em-part-audio.c
index 2b2c4a2..749cd83 100644
--- a/plugins/audio-inline/em-part-audio.c
+++ b/plugins/audio-inline/em-part-audio.c
@@ -34,6 +34,8 @@ struct _EMPartAudioPrivate {
 	GtkWidget *play_button;
 	GtkWidget *pause_button;
 	GtkWidget *stop_button;
+
+	GMutex *mutex;
 };
 
 static void
@@ -41,7 +43,7 @@ em_part_audio_finalize (GObject *object)
 {
 	EMPartAudioPrivate *priv = EM_PART_AUDIO (object)->priv;
 
-	em_part_mutex_lock (EM_PART (object));
+	g_mutex_lock (priv->mutex);
 
 	if (priv->filename) {
 		g_free (priv->filename);
@@ -68,7 +70,8 @@ em_part_audio_finalize (GObject *object)
 		priv->stop_button = NULL;
 	}
 
-	em_part_mutex_unlock (EM_PART (object));
+	g_mutex_unlock (priv->mutex);
+	g_mutex_free (priv->mutex);
 }
 
 static void
@@ -88,6 +91,7 @@ em_part_audio_init (EMPartAudio *empa)
 	empa->priv = G_TYPE_INSTANCE_GET_PRIVATE (empa,
 			EM_TYPE_PART_AUDIO, EMPartAudioPrivate);
 	
+	empa->priv->mutex = g_mutex_new ();
 	empa->priv->filename = NULL;
 	empa->priv->pause_button = NULL;
 	empa->priv->play_button = NULL;
@@ -101,7 +105,7 @@ EMPart *
 em_part_audio_new (EMFormat *emf,
 		   CamelMimePart *part,
 		   const gchar *uri,
-		   EMPartWriteFunc write_func)
+		   EMPartWidgetFunc widget_func)
 {
 	EMPart *emp;
 	
@@ -114,8 +118,8 @@ em_part_audio_new (EMFormat *emf,
 	em_part_set_formatter (emp, emf);
 	em_part_set_uri (emp, uri);
 	
-	if (write_func)
-		em_part_set_write_func (emp, write_func);
+	if (widget_func)
+		em_part_set_widget_func (emp, widget_func);
 	
 	return emp;
 }
@@ -126,7 +130,7 @@ em_part_audio_set_filename (EMPartAudio *empa,
 {
 	g_return_if_fail (EM_IS_PART_AUDIO (empa));
 
-	em_part_mutex_lock ((EMPart *) empa);
+	g_mutex_lock (empa->priv->mutex);
 	if (empa->priv->filename)
 		g_free (empa->priv->filename);
 
@@ -135,7 +139,7 @@ em_part_audio_set_filename (EMPartAudio *empa,
 	else
 		empa->priv->filename = NULL;
 
-	em_part_mutex_unlock ((EMPart *) empa);
+	g_mutex_unlock (empa->priv->mutex);
 }
 
 gchar*
@@ -145,10 +149,10 @@ em_part_audio_get_filename (EMPartAudio *empa)
 
 	g_return_val_if_fail (EM_IS_PART_AUDIO (empa), NULL);
 
-	em_part_mutex_lock ((EMPart *) empa);
+	g_mutex_lock (empa->priv->mutex);
 	if (empa->priv->filename)
 		filename = g_strdup (empa->priv->filename);
-	em_part_mutex_unlock ((EMPart *) empa);
+	g_mutex_unlock (empa->priv->mutex);
 
 	return filename;
 }
@@ -159,7 +163,7 @@ void em_part_audio_set_playbin (EMPartAudio *empa,
 	g_return_if_fail (EM_IS_PART_AUDIO (empa));
 	g_return_if_fail (playbin == NULL || GST_IS_ELEMENT (playbin));
 
-	em_part_mutex_lock ((EMPart *) empa);
+	g_mutex_lock (empa->priv->mutex);
 
 	if (playbin)
 		g_object_ref (playbin);
@@ -169,7 +173,7 @@ void em_part_audio_set_playbin (EMPartAudio *empa,
 
 	empa->priv->playbin = playbin;
 
-	em_part_mutex_unlock ((EMPart *) empa);
+	g_mutex_unlock (empa->priv->mutex);
 }
 
 GstElement*
@@ -179,10 +183,10 @@ em_part_audio_get_playbin (EMPartAudio *empa)
 
 	g_return_val_if_fail (EM_IS_PART_AUDIO (empa), NULL);
 
-	em_part_mutex_lock ((EMPart *) empa);
+	g_mutex_lock (empa->priv->mutex);
 	if (empa->priv->playbin)
 		element = g_object_ref (empa->priv->playbin);
-	em_part_mutex_unlock ((EMPart *) empa);
+	g_mutex_unlock (empa->priv->mutex);
 
 	return element;	
 }
@@ -192,9 +196,9 @@ void em_part_audio_set_bus_id (EMPartAudio *empa,
 {
 	g_return_if_fail (EM_IS_PART_AUDIO (empa));
 
-	em_part_mutex_lock ((EMPart *) empa);
+	g_mutex_lock (empa->priv->mutex);
 	empa->priv->bus_id = bus_id;
-	em_part_mutex_unlock ((EMPart *) empa);
+	g_mutex_unlock (empa->priv->mutex);
 }
 
 gulong
@@ -204,9 +208,9 @@ em_part_audio_get_bus_id (EMPartAudio *empa)
 
 	g_return_val_if_fail (EM_IS_PART_AUDIO (empa), 0);
 
-	em_part_mutex_lock ((EMPart *) empa);
+	g_mutex_lock (empa->priv->mutex);
 	bus_id = empa->priv->bus_id;
-	em_part_mutex_unlock ((EMPart *) empa);
+	g_mutex_unlock (empa->priv->mutex);
 
 	return bus_id;
 }
@@ -217,9 +221,9 @@ em_part_audio_set_target_state (EMPartAudio *empa,
 {
 	g_return_if_fail (EM_IS_PART_AUDIO (empa));
 
-	em_part_mutex_lock ((EMPart *) empa);
+	g_mutex_lock (empa->priv->mutex);
 	empa->priv->target_state = state;
-	em_part_mutex_unlock ((EMPart *) empa);
+	g_mutex_unlock (empa->priv->mutex);
 }
 
 GstState
@@ -229,9 +233,9 @@ em_part_audio_get_target_state (EMPartAudio *empa)
 
 	g_return_val_if_fail (EM_IS_PART_AUDIO (empa), GST_STATE_NULL);
 
-	em_part_mutex_lock ((EMPart *) empa);
+	g_mutex_lock (empa->priv->mutex);
 	state = empa->priv->target_state;
-	em_part_mutex_unlock ((EMPart *) empa);
+	g_mutex_unlock (empa->priv->mutex);
 
 	return state;	
 }
@@ -243,7 +247,7 @@ em_part_audio_set_play_button (EMPartAudio *empa,
 	g_return_if_fail (EM_IS_PART_AUDIO (empa));
 	g_return_if_fail (button == NULL || GTK_IS_WIDGET (button));
 
-	em_part_mutex_lock ((EMPart *) empa);
+	g_mutex_lock (empa->priv->mutex);
 
 	if (button)
 		g_object_ref (button);
@@ -253,7 +257,7 @@ em_part_audio_set_play_button (EMPartAudio *empa,
 
 	empa->priv->play_button = button;
 
-	em_part_mutex_unlock ((EMPart *) empa);
+	g_mutex_unlock (empa->priv->mutex);
 }
 
 GtkWidget*
@@ -263,10 +267,10 @@ em_part_audio_get_play_button (EMPartAudio *empa)
 
 	g_return_val_if_fail (EM_IS_PART_AUDIO (empa), NULL);
 
-	em_part_mutex_lock ((EMPart *) empa);
+	g_mutex_lock (empa->priv->mutex);
 	if (empa->priv->play_button)
 		widget = g_object_ref (empa->priv->play_button);
-	em_part_mutex_unlock ((EMPart *) empa);
+	g_mutex_unlock (empa->priv->mutex);
 
 	return widget;
 }
@@ -278,7 +282,7 @@ em_part_audio_set_pause_button (EMPartAudio *empa,
 	g_return_if_fail (EM_IS_PART_AUDIO (empa));
 	g_return_if_fail (button == NULL || GTK_IS_WIDGET (button));
 
-	em_part_mutex_lock ((EMPart *) empa);
+	g_mutex_lock (empa->priv->mutex);
 
 	if (button)
 		g_object_ref (button);
@@ -288,7 +292,7 @@ em_part_audio_set_pause_button (EMPartAudio *empa,
 
 	empa->priv->pause_button = button;
 
-	em_part_mutex_unlock ((EMPart *) empa);
+	g_mutex_unlock (empa->priv->mutex);
 }
 
 GtkWidget*
@@ -298,10 +302,10 @@ em_part_audio_get_pause_button (EMPartAudio *empa)
 
 	g_return_val_if_fail (EM_IS_PART_AUDIO (empa), NULL);
 
-	em_part_mutex_lock ((EMPart *) empa);
+	g_mutex_lock (empa->priv->mutex);
 	if (empa->priv->pause_button)
 		widget = g_object_ref (empa->priv->pause_button);
-	em_part_mutex_unlock ((EMPart *) empa);
+	g_mutex_unlock (empa->priv->mutex);
 
 	return widget;
 }
@@ -313,7 +317,7 @@ em_part_audio_set_stop_button (EMPartAudio *empa,
 	g_return_if_fail (EM_IS_PART_AUDIO (empa));
 	g_return_if_fail (button == NULL || GTK_IS_WIDGET (button));
 
-	em_part_mutex_lock ((EMPart *) empa);
+	g_mutex_lock (empa->priv->mutex);
 
 	if (button)
 		g_object_ref (button);
@@ -323,7 +327,7 @@ em_part_audio_set_stop_button (EMPartAudio *empa,
 
 	empa->priv->stop_button = button;
 
-	em_part_mutex_unlock ((EMPart *) empa);
+	g_mutex_unlock (empa->priv->mutex);
 }
 
 GtkWidget*
@@ -333,10 +337,10 @@ em_part_audio_get_stop_button (EMPartAudio *empa)
 
 	g_return_val_if_fail (EM_IS_PART_AUDIO (empa), NULL);
 
-	em_part_mutex_lock ((EMPart *) empa);
+	g_mutex_lock (empa->priv->mutex);
 	if (empa->priv->stop_button)
 		widget = g_object_ref (empa->priv->stop_button);
-	em_part_mutex_unlock ((EMPart *) empa);
+	g_mutex_unlock (empa->priv->stop_button);
 
 	return widget;
 }
diff --git a/plugins/audio-inline/em-part-audio.h b/plugins/audio-inline/em-part-audio.h
index ff51678..e8d7853 100644
--- a/plugins/audio-inline/em-part-audio.h
+++ b/plugins/audio-inline/em-part-audio.h
@@ -53,7 +53,8 @@ struct _EMPartAudio {
 };
 
 struct _EMPartAudioClass {
-	EMPartClass parent_class;
+	GObjectClass parent_class;
+	
 };
 
 EMPart*			em_part_audio_new      	(EMFormat *emf,



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