diff options
Diffstat (limited to 'widgets/misc')
-rw-r--r-- | widgets/misc/e-attachment-paned.c | 1 | ||||
-rw-r--r-- | widgets/misc/e-attachment-store.c | 36 | ||||
-rw-r--r-- | widgets/misc/e-attachment-store.h | 1 |
3 files changed, 33 insertions, 5 deletions
diff --git a/widgets/misc/e-attachment-paned.c b/widgets/misc/e-attachment-paned.c index 21d736b50b..73773f25a1 100644 --- a/widgets/misc/e-attachment-paned.c +++ b/widgets/misc/e-attachment-paned.c @@ -221,6 +221,7 @@ attachment_paned_dispose (GObject *object) priv = E_ATTACHMENT_PANED (object)->priv; if (priv->model != NULL) { + e_attachment_store_remove_all (E_ATTACHMENT_STORE (priv->model)); g_object_unref (priv->model); priv->model = NULL; } diff --git a/widgets/misc/e-attachment-store.c b/widgets/misc/e-attachment-store.c index 392dfe6fc7..e1794d653c 100644 --- a/widgets/misc/e-attachment-store.c +++ b/widgets/misc/e-attachment-store.c @@ -108,11 +108,7 @@ attachment_store_get_property (GObject *object, static void attachment_store_dispose (GObject *object) { - EAttachmentStorePrivate *priv; - - priv = E_ATTACHMENT_STORE (object)->priv; - - g_hash_table_remove_all (priv->attachment_index); + e_attachment_store_remove_all (E_ATTACHMENT_STORE (object)); /* Chain up to parent's dispose() method. */ G_OBJECT_CLASS (e_attachment_store_parent_class)->dispose (object); @@ -327,6 +323,36 @@ e_attachment_store_remove_attachment (EAttachmentStore *store, } void +e_attachment_store_remove_all (EAttachmentStore *store) +{ + GList *list, *iter; + + g_return_if_fail (E_IS_ATTACHMENT_STORE (store)); + + if (!g_hash_table_size (store->priv->attachment_index)) + return; + + g_object_freeze_notify (G_OBJECT (store)); + + list = e_attachment_store_get_attachments (store); + for (iter = list; iter; iter = iter->next) { + EAttachment *attachment = iter->data; + + e_attachment_cancel (attachment); + g_hash_table_remove (store->priv->attachment_index, iter->data); + } + + g_list_foreach (list, (GFunc) g_object_unref, NULL); + g_list_free (list); + + gtk_list_store_clear (GTK_LIST_STORE (store)); + + g_object_notify (G_OBJECT (store), "num-attachments"); + g_object_notify (G_OBJECT (store), "total-size"); + g_object_thaw_notify (G_OBJECT (store)); +} + +void e_attachment_store_add_to_multipart (EAttachmentStore *store, CamelMultipart *multipart, const gchar *default_charset) diff --git a/widgets/misc/e-attachment-store.h b/widgets/misc/e-attachment-store.h index 49980ea3b1..a7839aca71 100644 --- a/widgets/misc/e-attachment-store.h +++ b/widgets/misc/e-attachment-store.h @@ -80,6 +80,7 @@ void e_attachment_store_add_attachment gboolean e_attachment_store_remove_attachment (EAttachmentStore *store, EAttachment *attachment); +void e_attachment_store_remove_all (EAttachmentStore *store); void e_attachment_store_add_to_multipart (EAttachmentStore *store, CamelMultipart *multipart, |