aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2009-05-15 00:55:33 +0800
committerMatthew Barnes <mbarnes@redhat.com>2009-05-15 00:55:33 +0800
commit68af3e6898a57080490f860c5076d91a57f6407e (patch)
treef9e9e780cd955044f0e815f99e232b69a7b6ffd7 /widgets
parentbbe6437d089381bb2a3008e98a03aebef53af0e6 (diff)
downloadgsoc2013-evolution-68af3e6898a57080490f860c5076d91a57f6407e.tar
gsoc2013-evolution-68af3e6898a57080490f860c5076d91a57f6407e.tar.gz
gsoc2013-evolution-68af3e6898a57080490f860c5076d91a57f6407e.tar.bz2
gsoc2013-evolution-68af3e6898a57080490f860c5076d91a57f6407e.tar.lz
gsoc2013-evolution-68af3e6898a57080490f860c5076d91a57f6407e.tar.xz
gsoc2013-evolution-68af3e6898a57080490f860c5076d91a57f6407e.tar.zst
gsoc2013-evolution-68af3e6898a57080490f860c5076d91a57f6407e.zip
Add e_attachment_store_get_attachments().
Diffstat (limited to 'widgets')
-rw-r--r--widgets/misc/e-attachment-store.c76
-rw-r--r--widgets/misc/e-attachment-store.h2
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