diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2013-06-06 04:35:56 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2013-06-06 04:38:31 +0800 |
commit | 6be4901bae497b2aaf6bde559661f2390adeb9fb (patch) | |
tree | e9c48a6eb12479b21f7529588fb21febcb945878 | |
parent | 900ea24740c39ac60dc1763fedb03cfa3e865b86 (diff) | |
download | gsoc2013-evolution-6be4901bae497b2aaf6bde559661f2390adeb9fb.tar gsoc2013-evolution-6be4901bae497b2aaf6bde559661f2390adeb9fb.tar.gz gsoc2013-evolution-6be4901bae497b2aaf6bde559661f2390adeb9fb.tar.bz2 gsoc2013-evolution-6be4901bae497b2aaf6bde559661f2390adeb9fb.tar.lz gsoc2013-evolution-6be4901bae497b2aaf6bde559661f2390adeb9fb.tar.xz gsoc2013-evolution-6be4901bae497b2aaf6bde559661f2390adeb9fb.tar.zst gsoc2013-evolution-6be4901bae497b2aaf6bde559661f2390adeb9fb.zip |
EMailPart: Add "part-list" property.
This is a weak reference to the EMailPartList to which the EMailPart
has been added. The property is set by e_mail_part_list_add_part().
New functions:
e_mail_part_ref_part_list()
e_mail_part_set_part_list()
-rw-r--r-- | doc/reference/evolution-mail-formatter/evolution-mail-formatter-sections.txt | 2 | ||||
-rw-r--r-- | em-format/e-mail-part-list.c | 4 | ||||
-rw-r--r-- | em-format/e-mail-part.c | 54 | ||||
-rw-r--r-- | em-format/e-mail-part.h | 6 |
4 files changed, 64 insertions, 2 deletions
diff --git a/doc/reference/evolution-mail-formatter/evolution-mail-formatter-sections.txt b/doc/reference/evolution-mail-formatter/evolution-mail-formatter-sections.txt index 0c123bdf33..67cf18e928 100644 --- a/doc/reference/evolution-mail-formatter/evolution-mail-formatter-sections.txt +++ b/doc/reference/evolution-mail-formatter/evolution-mail-formatter-sections.txt @@ -249,6 +249,8 @@ e_mail_part_id_has_substr e_mail_part_ref_mime_part e_mail_part_get_mime_type e_mail_part_set_mime_type +e_mail_part_ref_part_list +e_mail_part_set_part_list e_mail_part_get_is_attachment e_mail_part_set_is_attachment e_mail_part_bind_dom_element diff --git a/em-format/e-mail-part-list.c b/em-format/e-mail-part-list.c index c866e6a559..bcf7490634 100644 --- a/em-format/e-mail-part-list.c +++ b/em-format/e-mail-part-list.c @@ -289,7 +289,7 @@ e_mail_part_list_add_part (EMailPartList *part_list, EMailPart *part) { g_return_if_fail (E_IS_MAIL_PART_LIST (part_list)); - g_return_if_fail (part != NULL); + g_return_if_fail (E_IS_MAIL_PART (part)); g_mutex_lock (&part_list->priv->queue_lock); @@ -298,6 +298,8 @@ e_mail_part_list_add_part (EMailPartList *part_list, g_object_ref (part)); g_mutex_unlock (&part_list->priv->queue_lock); + + e_mail_part_set_part_list (part, part_list); } EMailPart * diff --git a/em-format/e-mail-part.c b/em-format/e-mail-part.c index abd405d677..b4ba2b3eb7 100644 --- a/em-format/e-mail-part.c +++ b/em-format/e-mail-part.c @@ -31,11 +31,14 @@ #include <string.h> +#include "e-mail-part-list.h" + #define E_MAIL_PART_GET_PRIVATE(obj) \ (G_TYPE_INSTANCE_GET_PRIVATE \ ((obj), E_TYPE_MAIL_PART, EMailPartPrivate)) struct _EMailPartPrivate { + GWeakRef part_list; CamelMimePart *mime_part; gchar *id; @@ -51,7 +54,8 @@ enum { PROP_ID, PROP_IS_ATTACHMENT, PROP_MIME_PART, - PROP_MIME_TYPE + PROP_MIME_TYPE, + PROP_PART_LIST }; G_DEFINE_TYPE ( @@ -127,6 +131,12 @@ mail_part_set_property (GObject *object, E_MAIL_PART (object), g_value_get_string (value)); return; + + case PROP_PART_LIST: + e_mail_part_set_part_list ( + E_MAIL_PART (object), + g_value_get_object (value)); + return; } G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -173,6 +183,13 @@ mail_part_get_property (GObject *object, e_mail_part_get_mime_type ( E_MAIL_PART (object))); return; + + case PROP_PART_LIST: + g_value_take_object ( + value, + e_mail_part_ref_part_list ( + E_MAIL_PART (object))); + return; } G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -185,6 +202,8 @@ mail_part_dispose (GObject *object) priv = E_MAIL_PART_GET_PRIVATE (object); + g_weak_ref_set (&priv->part_list, NULL); + g_clear_object (&priv->mime_part); /* Chain up to parent's dispose() method. */ @@ -278,6 +297,17 @@ e_mail_part_class_init (EMailPartClass *class) NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + + g_object_class_install_property ( + object_class, + PROP_PART_LIST, + g_param_spec_object ( + "part-list", + "Part List", + "The part list that owns the part", + E_TYPE_MAIL_PART_LIST, + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS)); } static void @@ -400,6 +430,28 @@ e_mail_part_set_mime_type (EMailPart *part, g_object_notify (G_OBJECT (part), "mime-type"); } +EMailPartList * +e_mail_part_ref_part_list (EMailPart *part) +{ + g_return_val_if_fail (E_IS_MAIL_PART (part), NULL); + + return g_weak_ref_get (&part->priv->part_list); +} + +void +e_mail_part_set_part_list (EMailPart *part, + EMailPartList *part_list) +{ + g_return_if_fail (E_IS_MAIL_PART (part)); + + if (part_list != NULL) + g_return_if_fail (E_IS_MAIL_PART_LIST (part_list)); + + g_weak_ref_set (&part->priv->part_list, part_list); + + g_object_notify (G_OBJECT (part), "part-list"); +} + gboolean e_mail_part_get_is_attachment (EMailPart *part) { diff --git a/em-format/e-mail-part.h b/em-format/e-mail-part.h index f710f4021a..75057c2ee5 100644 --- a/em-format/e-mail-part.h +++ b/em-format/e-mail-part.h @@ -47,6 +47,8 @@ G_BEGIN_DECLS +struct _EMailPartList; + typedef struct _EMailPart EMailPart; typedef struct _EMailPartClass EMailPartClass; typedef struct _EMailPartPrivate EMailPartPrivate; @@ -106,6 +108,10 @@ CamelMimePart * e_mail_part_ref_mime_part (EMailPart *part); const gchar * e_mail_part_get_mime_type (EMailPart *part); void e_mail_part_set_mime_type (EMailPart *part, const gchar *mime_type); +struct _EMailPartList * + e_mail_part_ref_part_list (EMailPart *part); +void e_mail_part_set_part_list (EMailPart *part, + struct _EMailPartList *part_list); gboolean e_mail_part_get_is_attachment (EMailPart *part); void e_mail_part_set_is_attachment (EMailPart *part, gboolean is_attachment); |