aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
Diffstat (limited to 'mail')
-rw-r--r--mail/ChangeLog16
-rw-r--r--mail/em-folder-selection-button.c2
-rw-r--r--mail/em-folder-selection.c4
-rw-r--r--mail/em-folder-tree-model.c33
-rw-r--r--mail/em-folder-tree-model.h2
-rw-r--r--mail/mail-component.c3
-rw-r--r--mail/mail-component.h3
-rw-r--r--mail/mail-folder-cache.c12
8 files changed, 68 insertions, 7 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 573ddc30d3..81780aa030 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,19 @@
+2003-12-10 Jeffrey Stedfast <fejj@ximian.com>
+
+ * mail-folder-cache.c (real_flush_updates): Update the unread
+ count in the model if the folder got new mail.
+
+ * em-folder-selection.c (em_select_folder): Updated.
+
+ * em-folder-selection-button.c
+ (em_folder_selection_button_clicked): Updated.
+
+ * em-folder-tree-model.c (em_folder_tree_model_set_unread_count):
+ New function to update the unread count for a folder.
+
+ * mail-component.c (mail_component_peek_tree_model): Don't ref the
+ model. Also renamed s/get/peek/
+
2003-12-10 Not Zed <NotZed@Ximian.com>
* em-format-html-display.c (efhd_multipart_signed):
diff --git a/mail/em-folder-selection-button.c b/mail/em-folder-selection-button.c
index 5187e8d324..ce5f38680c 100644
--- a/mail/em-folder-selection-button.c
+++ b/mail/em-folder-selection-button.c
@@ -211,7 +211,7 @@ em_folder_selection_button_clicked (GtkButton *button)
if (GTK_BUTTON_CLASS (parent_class)->clicked != NULL)
(* GTK_BUTTON_CLASS (parent_class)->clicked) (button);
- model = mail_component_get_tree_model (mail_component_peek ());
+ model = mail_component_peek_tree_model (mail_component_peek ());
emft = (EMFolderTree *) em_folder_tree_new_with_model (model);
dialog = em_folder_selector_new (emft, EM_FOLDER_SELECTOR_CAN_CREATE, priv->title, priv->caption);
diff --git a/mail/em-folder-selection.c b/mail/em-folder-selection.c
index 6137e15e88..0534ca99e1 100644
--- a/mail/em-folder-selection.c
+++ b/mail/em-folder-selection.c
@@ -61,8 +61,8 @@ em_select_folder (GtkWindow *parent_window, const char *title, const char *defau
EMFolderTreeModel *model;
GtkWidget *dialog;
EMFolderTree *emft;
-
- model = mail_component_get_tree_model (mail_component_peek ());
+
+ model = mail_component_peek_tree_model (mail_component_peek ());
emft = (EMFolderTree *) em_folder_tree_new_with_model (model);
dialog = em_folder_selector_new(emft, EM_FOLDER_SELECTOR_CAN_CREATE, title, NULL);
diff --git a/mail/em-folder-tree-model.c b/mail/em-folder-tree-model.c
index 1e6df96fbf..e7a766cc61 100644
--- a/mail/em-folder-tree-model.c
+++ b/mail/em-folder-tree-model.c
@@ -1197,3 +1197,36 @@ em_folder_tree_model_save_expanded (EMFolderTreeModel *model)
unlink (tmpname);
g_free (tmpname);
}
+
+
+void
+em_folder_tree_model_set_unread_count (EMFolderTreeModel *model, CamelStore *store, const char *path, int unread)
+{
+ struct _EMFolderTreeModelStoreInfo *si;
+ GtkTreeRowReference *row;
+ GtkTreePath *tree_path;
+ GtkTreeIter iter;
+
+ g_return_if_fail (EM_IS_FOLDER_TREE_MODEL (model));
+ g_return_if_fail (CAMEL_IS_STORE (store));
+ g_return_if_fail (path != NULL);
+
+ if (unread < 0)
+ unread = 0;
+
+ if (!(si = g_hash_table_lookup (model->store_hash, store)))
+ return;
+
+ if (!(row = g_hash_table_lookup (si->path_hash, path)))
+ return;
+
+ tree_path = gtk_tree_row_reference_get_path (row);
+ if (!gtk_tree_model_get_iter ((GtkTreeModel *) model, &iter, tree_path)) {
+ gtk_tree_path_free (tree_path);
+ return;
+ }
+
+ gtk_tree_path_free (tree_path);
+
+ gtk_tree_store_set ((GtkTreeStore *) model, &iter, COL_UINT_UNREAD, unread, -1);
+}
diff --git a/mail/em-folder-tree-model.h b/mail/em-folder-tree-model.h
index 3296af1ed1..fd49bb2f3c 100644
--- a/mail/em-folder-tree-model.h
+++ b/mail/em-folder-tree-model.h
@@ -114,6 +114,8 @@ gboolean em_folder_tree_model_get_expanded (EMFolderTreeModel *model, const char
void em_folder_tree_model_set_expanded (EMFolderTreeModel *model, const char *key, gboolean expanded);
void em_folder_tree_model_save_expanded (EMFolderTreeModel *model);
+void em_folder_tree_model_set_unread_count (EMFolderTreeModel *model, CamelStore *store, const char *path, int unread);
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
diff --git a/mail/mail-component.c b/mail/mail-component.c
index ea3d0e4c73..744ec83ad3 100644
--- a/mail/mail-component.c
+++ b/mail/mail-component.c
@@ -698,9 +698,8 @@ mail_component_remove_folder (MailComponent *component, CamelStore *store, const
EMFolderTreeModel *
-mail_component_get_tree_model (MailComponent *component)
+mail_component_peek_tree_model (MailComponent *component)
{
- g_object_ref (component->priv->model);
return component->priv->model;
}
diff --git a/mail/mail-component.h b/mail/mail-component.h
index 545ddf11d4..afce0a64d4 100644
--- a/mail/mail-component.h
+++ b/mail/mail-component.h
@@ -83,7 +83,8 @@ void mail_component_stores_foreach (MailComponent *component,
void mail_component_remove_folder (MailComponent *component, CamelStore *store, const char *path);
-struct _EMFolderTreeModel *mail_component_get_tree_model (MailComponent *component);
+struct _EMFolderTreeModel *mail_component_peek_tree_model (MailComponent *component);
+
struct _CamelFolder *mail_component_get_local_inbox(MailComponent *mc, struct _CamelException *ex);
char *em_uri_from_camel (const char *curi);
diff --git a/mail/mail-folder-cache.c b/mail/mail-folder-cache.c
index 23f6221544..750f9ab30d 100644
--- a/mail/mail-folder-cache.c
+++ b/mail/mail-folder-cache.c
@@ -45,11 +45,13 @@
#include "mail-folder-cache.h"
#include "mail-ops.h"
#include "mail-session.h"
+#include "mail-component.h"
/* For notifications of changes */
#include "mail-vfolder.h"
#include "mail-autofilter.h"
#include "mail-config.h"
+#include "em-folder-tree-model.h"
#define w(x)
#define d(x) /*(printf("%s(%d):%s: ", __FILE__, __LINE__, __PRETTY_FUNCTION__), (x))*/
@@ -182,10 +184,15 @@ notify_type_changed (GConfClient *client, guint cnxn_id,
static void
real_flush_updates(void *o, void *event_data, void *data)
{
+ struct _MailComponent *component;
+ struct _EMFolderTreeModel *model;
struct _folder_update *up;
struct _store_info *si;
time_t now;
-
+
+ component = mail_component_peek ();
+ model = mail_component_peek_tree_model (component);
+
LOCK(info_lock);
while ((up = (struct _folder_update *)e_dlist_remhead(&updates))) {
si = g_hash_table_lookup(stores, up->store);
@@ -214,6 +221,9 @@ real_flush_updates(void *o, void *event_data, void *data)
mail_vfolder_add_uri(up->store, up->uri, FALSE);
}
+ /* update unread counts */
+ em_folder_tree_model_set_unread_count (model, up->store, up->path, up->unread);
+
/* new mail notification */
if (notify_type == -1) {
/* need to track the user's new-mail-notification settings... */