From 24ac71c6a0ba23414aeb76e877fd10949e2181b9 Mon Sep 17 00:00:00 2001
From: Veerapuram Varadhan <vvaradan@src.gnome.org>
Date: Thu, 23 Feb 2006 13:26:41 +0000
Subject:        ** Fixes bug #329733

       * em-folder-properties.c (emfp_dialog_got_folder): Fetch both
       VISIBLE and DELETED count from the folder and adjust it according
       before showing it in the properties dialog w.r.t user preferences.

svn path=/trunk/; revision=31568
---
 mail/ChangeLog              |  8 ++++++++
 mail/em-folder-properties.c | 33 ++++++++++++++++++++++++++++++---
 2 files changed, 38 insertions(+), 3 deletions(-)

(limited to 'mail')

diff --git a/mail/ChangeLog b/mail/ChangeLog
index 8557f84af0..82a9f401f5 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,11 @@
+2006-02-21  Veerapuram Varadhan <vvaradhan@novell.com>
+
+       ** Fixes bug #329733
+
+       * em-folder-properties.c (emfp_dialog_got_folder): Fetch both
+       VISIBLE and DELETED count from the folder and adjust it according
+       before showing it in the properties dialog w.r.t user preferences.
+       
 2006-02-21  Tor Lillqvist  <tml@novell.com>
 
 	* em-composer-utils.c: Use the same Win32 macro for gmtime_r()
diff --git a/mail/em-folder-properties.c b/mail/em-folder-properties.c
index 98ada5a740..3b7fe1244e 100644
--- a/mail/em-folder-properties.c
+++ b/mail/em-folder-properties.c
@@ -38,7 +38,11 @@
 #include <gtk/gtktogglebutton.h>
 #include <gtk/gtkvbox.h>
 
+#include <gconf/gconf-client.h>
+
+#include <camel/camel-store.h>
 #include <camel/camel-folder.h>
+#include <camel/camel-vtrash-folder.h>
 #include <camel/camel-vee-folder.h>
 #include <libgnome/gnome-i18n.h>
 
@@ -49,6 +53,7 @@
 #include "mail-ops.h"
 #include "mail-mt.h"
 #include "mail-vfolder.h"
+#include "mail-config.h"
 
 struct _prop_data {
 	void *object;
@@ -226,23 +231,45 @@ emfp_dialog_got_folder (char *uri, CamelFolder *folder, void *data)
 	GtkWidget *dialog, *w;
 	struct _prop_data *prop_data;
 	GSList *l;
-	gint32 count, i;
+	gint32 count, i,deleted;
 	EMConfig *ec;
 	EMConfigTargetFolder *target;
 	CamelArgGetV *arggetv;
 	CamelArgV *argv;
+	gboolean hide_deleted;
+	GConfClient *gconf;
+	CamelStore *store;
 
 	if (folder == NULL)
 		return;
 
+	store = folder->parent_store;
+
 	prop_data = g_malloc0 (sizeof (*prop_data));
 	prop_data->object = folder;
 	camel_object_ref (folder);
 
+	/*
+	  Get number of VISIBLE and DELETED messages, instead of TOTAL messages.  VISIBLE+DELETED 
+	   gives the correct count that matches the label below the Send & Receive button
+	*/
 	camel_object_get (folder, NULL, CAMEL_FOLDER_PROPERTIES, &prop_data->properties, CAMEL_FOLDER_NAME, &prop_data->name,
-			  CAMEL_FOLDER_TOTAL, &prop_data->total, CAMEL_FOLDER_UNREAD, &prop_data->unread, NULL);
+			  CAMEL_FOLDER_VISIBLE, &prop_data->total, CAMEL_FOLDER_UNREAD, &prop_data->unread, CAMEL_FOLDER_DELETED, &deleted, NULL);
+	
+	gconf = mail_config_get_gconf_client ();
+	hide_deleted = !gconf_client_get_bool(gconf, "/apps/evolution/mail/display/show_deleted", NULL);
+
+	/* 
+	   Do the calculation only for those accounts that support VTRASHes
+	 */
+	if (store->flags & CAMEL_STORE_VTRASH) {
+		if (CAMEL_IS_VTRASH_FOLDER(folder))
+			prop_data->total += deleted;
+		else if (!hide_deleted && deleted > 0)
+			prop_data->total += deleted;
+	}
 
-	if (folder->parent_store == mail_component_peek_local_store(NULL)
+	if (store == mail_component_peek_local_store(NULL)
 	    && (!strcmp(prop_data->name, "Drafts")
 		|| !strcmp(prop_data->name, "Inbox")
 		|| !strcmp(prop_data->name, "Outbox")
-- 
cgit v1.2.3