diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2009-05-15 00:55:33 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2009-05-21 09:58:47 +0800 |
commit | fea524b5292d45a5d02cbfa04bd809cb478fbbcd (patch) | |
tree | 73f46fba10ba6f9a0158c0088d024c2cc1233f04 /widgets | |
parent | 63b66d68529f434d16a12da81a5c611e0df1e7ee (diff) | |
download | gsoc2013-evolution-fea524b5292d45a5d02cbfa04bd809cb478fbbcd.tar gsoc2013-evolution-fea524b5292d45a5d02cbfa04bd809cb478fbbcd.tar.gz gsoc2013-evolution-fea524b5292d45a5d02cbfa04bd809cb478fbbcd.tar.bz2 gsoc2013-evolution-fea524b5292d45a5d02cbfa04bd809cb478fbbcd.tar.lz gsoc2013-evolution-fea524b5292d45a5d02cbfa04bd809cb478fbbcd.tar.xz gsoc2013-evolution-fea524b5292d45a5d02cbfa04bd809cb478fbbcd.tar.zst gsoc2013-evolution-fea524b5292d45a5d02cbfa04bd809cb478fbbcd.zip |
Add e_attachment_store_get_attachments().
Diffstat (limited to 'widgets')
-rw-r--r-- | widgets/misc/e-attachment-store.c | 76 | ||||
-rw-r--r-- | widgets/misc/e-attachment-store.h | 2 |
2 files changed, 44 insertions, 34 deletions
diff --git a/widgets/misc/e-attachment-store.c b/widgets/misc/e-attachment-store.c index 53a1cbe1ff..216a60d32a 100644 --- a/widgets/misc/e-attachment-store.c +++ b/widgets/misc/e-attachment-store.c @@ -360,12 +360,35 @@ e_attachment_store_add_to_multipart (EAttachmentStore *store, CamelMultipart *multipart, const gchar *default_charset) { + GList *list, *iter; + + g_return_if_fail (E_IS_ATTACHMENT_STORE (store)); + g_return_if_fail (CAMEL_MULTIPART (multipart)); + + list = e_attachment_store_get_attachments (store); + + for (iter = list; iter != NULL; iter = iter->next) { + EAttachment *attachment = iter->data; + + /* Skip the attachment if it's still loading. */ + if (!e_attachment_get_loading (attachment)) + e_attachment_add_to_multipart ( + attachment, multipart, default_charset); + } + + g_list_foreach (list, (GFunc) g_object_unref, NULL); + g_list_free (list); +} + +GList * +e_attachment_store_get_attachments (EAttachmentStore *store) +{ + GList *list = NULL; GtkTreeModel *model; GtkTreeIter iter; gboolean valid; - g_return_if_fail (E_IS_ATTACHMENT_STORE (store)); - g_return_if_fail (CAMEL_MULTIPART (multipart)); + g_return_val_if_fail (E_IS_ATTACHMENT_STORE (store), NULL); model = GTK_TREE_MODEL (store); valid = gtk_tree_model_get_iter_first (model, &iter); @@ -377,15 +400,12 @@ e_attachment_store_add_to_multipart (EAttachmentStore *store, column_id = E_ATTACHMENT_STORE_COLUMN_ATTACHMENT; gtk_tree_model_get (model, &iter, column_id, &attachment, -1); - /* Skip the attachment if it's still loading. */ - if (!e_attachment_get_loading (attachment)) - e_attachment_add_to_multipart ( - attachment, multipart, default_charset); - - g_object_unref (attachment); + list = g_list_prepend (list, attachment); valid = gtk_tree_model_iter_next (model, &iter); } + + return g_list_reverse (list); } const gchar * @@ -422,60 +442,48 @@ e_attachment_store_get_num_attachments (EAttachmentStore *store) guint e_attachment_store_get_num_loading (EAttachmentStore *store) { - GtkTreeModel *model; - GtkTreeIter iter; + GList *list, *iter; guint num_loading = 0; - gboolean valid; g_return_val_if_fail (E_IS_ATTACHMENT_STORE (store), 0); - model = GTK_TREE_MODEL (store); - valid = gtk_tree_model_get_iter_first (model, &iter); + list = e_attachment_store_get_attachments (store); - while (valid) { - EAttachment *attachment; - gint column_id; + for (iter = list; iter != NULL; iter = iter->next) { + EAttachment *attachment = iter->data; - column_id = E_ATTACHMENT_STORE_COLUMN_ATTACHMENT; - gtk_tree_model_get (model, &iter, column_id, &attachment, -1); if (e_attachment_get_loading (attachment)) num_loading++; - g_object_unref (attachment); - - valid = gtk_tree_model_iter_next (model, &iter); } + g_list_foreach (list, (GFunc) g_object_unref, NULL); + g_list_free (list); + return num_loading; } goffset e_attachment_store_get_total_size (EAttachmentStore *store) { - GtkTreeModel *model; - GtkTreeIter iter; + GList *list, *iter; goffset total_size = 0; - gboolean valid; g_return_val_if_fail (E_IS_ATTACHMENT_STORE (store), 0); - model = GTK_TREE_MODEL (store); - valid = gtk_tree_model_get_iter_first (model, &iter); + list = e_attachment_store_get_attachments (store); - while (valid) { - EAttachment *attachment; + for (iter = list; iter != NULL; iter = iter->next) { + EAttachment *attachment = iter->data; GFileInfo *file_info; - gint column_id; - column_id = E_ATTACHMENT_STORE_COLUMN_ATTACHMENT; - gtk_tree_model_get (model, &iter, column_id, &attachment, -1); file_info = e_attachment_get_file_info (attachment); if (file_info != NULL) total_size += g_file_info_get_size (file_info); - g_object_unref (attachment); - - valid = gtk_tree_model_iter_next (model, &iter); } + g_list_foreach (list, (GFunc) g_object_unref, NULL); + g_list_free (list); + return total_size; } diff --git a/widgets/misc/e-attachment-store.h b/widgets/misc/e-attachment-store.h index e7f89b7f6c..9fdd74d493 100644 --- a/widgets/misc/e-attachment-store.h +++ b/widgets/misc/e-attachment-store.h @@ -84,6 +84,8 @@ void e_attachment_store_add_to_multipart (EAttachmentStore *store, CamelMultipart *multipart, const gchar *default_charset); +GList * e_attachment_store_get_attachments + (EAttachmentStore *store); const gchar * e_attachment_store_get_current_folder (EAttachmentStore *store); void e_attachment_store_set_current_folder |