From 3814bb179fb3e0f3f0e862b2390e317bff0c80bb Mon Sep 17 00:00:00 2001
From: Jeffrey Stedfast <fejj@ximian.com>
Date: Tue, 27 Aug 2002 22:09:41 +0000
Subject: Pass mail_config_get_thread_subject() as the third argument to

2002-08-27  Jeffrey Stedfast  <fejj@ximian.com>

	* message-list.c (regen_list_regen): Pass
	mail_config_get_thread_subject() as the third argument to
	camel_folder_thread_messages_new().

	* mail-config.c (config_read): Read in the thread_by_subject
	config option.
	(mail_config_write_on_exit): Save the thread_by_subject config
	option.
	(mail_config_get_thread_subject): New function to get the
	thread_subject value.
	(mail_config_set_thread_subject): New function to set the
	thread_subject value.

svn path=/trunk/; revision=17881
---
 mail/ChangeLog      | 15 ++++++++++
 mail/mail-config.c  | 79 +++++++++++++++++++++++++++++++++--------------------
 mail/mail-config.h  |  3 ++
 mail/message-list.c |  3 +-
 4 files changed, 70 insertions(+), 30 deletions(-)

(limited to 'mail')

diff --git a/mail/ChangeLog b/mail/ChangeLog
index 7088dbcb68..74a633aa00 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,18 @@
+2002-08-27  Jeffrey Stedfast  <fejj@ximian.com>
+
+	* message-list.c (regen_list_regen): Pass
+	mail_config_get_thread_subject() as the third argument to
+	camel_folder_thread_messages_new().
+
+	* mail-config.c (config_read): Read in the thread_by_subject
+	config option.
+	(mail_config_write_on_exit): Save the thread_by_subject config
+	option.
+	(mail_config_get_thread_subject): New function to get the
+	thread_subject value.
+	(mail_config_set_thread_subject): New function to set the
+	thread_subject value.
+
 2002-08-27  Radek Doulik  <rodo@ximian.com>
 
 	* mail-signature-editor.c: removed tip frame
diff --git a/mail/mail-config.c b/mail/mail-config.c
index ad09ec03c8..b9aed3b1f4 100644
--- a/mail/mail-config.c
+++ b/mail/mail-config.c
@@ -27,6 +27,7 @@
 #endif
 
 /* this group of headers is for pgp detection */
+#include <stdlib.h>
 #include <signal.h>
 #include <sys/ioctl.h>
 #include <sys/time.h>
@@ -101,6 +102,8 @@ typedef struct {
 	int seen_timeout;
 	gboolean empty_trash_on_exit;
 	
+	gboolean thread_subject;
+	
 	GSList *accounts;
 	int default_account;
 	
@@ -517,32 +520,31 @@ config_write_imported_signature (gchar *filename, gint i, gboolean html)
 static void
 config_import_old_signatures ()
 {
-	gint num;
-
+	int num;
+	
 	num = bonobo_config_get_long_with_default (config->db, "/Mail/Signatures/num", -1, NULL);
-
+	
 	if (num == -1) {
 		/* there are no signatures defined
 		 * look for old config to create new ones from old ones
 		 */
-
 		GHashTable *cache;
-		gint i, accounts;
-
+		int i, accounts;
+		
 		cache = g_hash_table_new (g_str_hash, g_str_equal);
 		accounts = bonobo_config_get_long_with_default (config->db, "/Mail/Accounts/num", 0, NULL);
 		num = 0;
 		for (i = 0; i < accounts; i ++) {
-			gchar *path, *val;
-
+			char *path, *val;
+			
 			/* read text signature file */
 			path = g_strdup_printf ("/Mail/Accounts/identity_signature_%d", i);
 			val = bonobo_config_get_string (config->db, path, NULL);
 			g_free (path);
 			if (val && *val) {
-				gint id;
 				gpointer orig_key, node_val;
-
+				int id;
+				
 				if (g_hash_table_lookup_extended (cache, val, &orig_key, &node_val)) {
 					id = GPOINTER_TO_INT (node_val);
 				} else {
@@ -551,23 +553,23 @@ config_import_old_signatures ()
 					id = num;
 					num ++;
 				}
-
+				
 				/* set new text signature to this identity */
 				path = g_strdup_printf ("/Mail/Accounts/identity_signature_text_%d", i);
 				bonobo_config_set_long (config->db, path, id, NULL);
 				g_free (path);
 			} else
 				g_free (val);
-
+			
 			path = g_strdup_printf ("/Mail/Accounts/identity_has_html_signature_%d", i);
 			if (bonobo_config_get_boolean_with_default (config->db, path, FALSE, NULL)) {
 				g_free (path);
 				path = g_strdup_printf ("/Mail/Accounts/identity_html_signature_%d", i);
 				val = bonobo_config_get_string (config->db, path, NULL);
 				if (val && *val) {
-					gint id;
 					gpointer orig_key, node_val;
-
+					int id;
+					
 					if (g_hash_table_lookup_extended (cache, val, &orig_key, &node_val)) {
 						id = GPOINTER_TO_INT (node_val);
 					} else {
@@ -576,7 +578,7 @@ config_import_old_signatures ()
 						id = num;
 						num ++;
 					}
-
+					
 					/* set new html signature to this identity */
 					g_free (path);
 					path = g_strdup_printf ("/Mail/Accounts/identity_signature_html_%d", i);
@@ -597,7 +599,7 @@ locale_supports_12_hour_format(void)
 {
 	char s[16];
 	time_t t = 0;
-
+	
 	strftime(s, sizeof s, "%p", gmtime (&t));
 	return s[0] != '\0';
 }
@@ -609,7 +611,7 @@ config_read (void)
 	char *path, *val, *p;
 	
 	mail_config_clear ();
-
+	
 	config_import_old_signatures ();
 	config_read_signatures ();
 	
@@ -746,12 +748,12 @@ config_read (void)
 		path = g_strdup_printf ("/Mail/Accounts/identity_def_signature_%d", i);
 		id->def_signature = lookup_signature (bonobo_config_get_long_with_default (config->db, path, -1, NULL));
 		g_free (path);
-
+		
 		/* autogenerated signature */
 		path = g_strdup_printf ("/Mail/Accounts/identity_autogenerated_signature_%d", i);
 		id->auto_signature = bonobo_config_get_boolean_with_default (config->db, path, TRUE, NULL);
 		g_free (path);
-
+		
 		/* get the source */
 		source = g_new0 (MailConfigService, 1);
 		
@@ -823,7 +825,7 @@ config_read (void)
 	/* Format */
 	config->send_html = bonobo_config_get_boolean_with_default (config->db,
 	        "/Mail/Format/send_html", FALSE, NULL);
-
+	
 	/* Confirm Sending Unwanted HTML */
 	config->confirm_unwanted_html = bonobo_config_get_boolean_with_default (config->db,
 	        "/Mail/Format/confirm_unwanted_html", TRUE, NULL);
@@ -847,6 +849,10 @@ config_read (void)
 	config->thread_list = bonobo_config_get_boolean_with_default (
                 config->db, "/Mail/Display/thread_list", FALSE, NULL);
 	
+	p = getenv ("USER");
+	config->thread_subject = bonobo_config_get_boolean_with_default (
+                config->db, "/Mail/Display/thread_subject", p && (!strcmp (p, "fejj") || !strcmp (p, "notzed")) ? TRUE : FALSE, NULL);
+	
 	config->show_preview = bonobo_config_get_boolean_with_default (
 		config->db, "/Mail/Display/preview_pane", TRUE, NULL);
 	
@@ -946,7 +952,7 @@ config_read (void)
 	config->x_mailer_display_style = bonobo_config_get_long_with_default (
 		config->db, "/Mail/Display/x_mailer_display_style", 
 		MAIL_CONFIG_XMAILER_NONE, NULL);
-
+	
 	/* last filesel dir */
 	config->last_filesel_dir = bonobo_config_get_string (
 		config->db, "/Mail/Filesel/last_filesel_dir", NULL);
@@ -973,7 +979,7 @@ config_read (void)
 									       label_defaults[i].color, NULL);
 	}
 	g_free (path);
-
+	
 	config->week_start_day = bonobo_config_get_long_with_default(config->db, "/Calendar/Display/WeekStartDay", 1, NULL);
 	if (locale_supports_12_hour_format()) {
 		config->time_24hour = bonobo_config_get_boolean_with_default(config->db, "/Calendar/Display/Use24HourFormat", FALSE, NULL);
@@ -988,12 +994,12 @@ void
 mail_config_write_account_sig (MailConfigAccount *account, gint i)
 {
 	char *path;
-
+	
 	mail_config_init ();
-
+	
 	if (i == -1) {
 		GSList *link;
-
+		
 		link = g_slist_find (config->accounts, account);
 		if (!link) {
 			g_warning ("Can't find account in accounts list");
@@ -1001,13 +1007,13 @@ mail_config_write_account_sig (MailConfigAccount *account, gint i)
 		}
 		i = g_slist_position (config->accounts, link);
 	}
-
+	
 	/* id signatures */
 	path = g_strdup_printf ("/Mail/Accounts/identity_def_signature_%d", i);
 	bonobo_config_set_long (config->db, path, account->id->def_signature
 				? account->id->def_signature->id : -1, NULL);
 	g_free (path);
-
+	
 	path = g_strdup_printf ("/Mail/Accounts/identity_autogenerated_signature_%d", i);
 	bonobo_config_set_boolean (config->db, path, account->id->auto_signature, NULL);
 	g_free (path);
@@ -1032,7 +1038,7 @@ mail_config_write (void)
 	Bonobo_ConfigDatabase_sync (config->db, &ev);
 	
 	config_write_signatures ();
-
+	
 	len = g_slist_length (config->accounts);
 	bonobo_config_set_long (config->db,
 				"/Mail/Accounts/num", len, NULL);
@@ -1133,7 +1139,7 @@ mail_config_write (void)
 		g_free (path);
 		
 		mail_config_write_account_sig (account, i);
-
+		
 		path = g_strdup_printf ("/Mail/Accounts/identity_autogenerated_signature_%d", i);
 		bonobo_config_set_boolean (config->db, path, account->id->auto_signature, NULL);
 		g_free (path);
@@ -1206,6 +1212,9 @@ mail_config_write_on_exit (void)
 	bonobo_config_set_boolean (config->db, "/Mail/Display/thread_list", 
 				   config->thread_list, NULL);
 	
+	bonobo_config_set_boolean (config->db, "/Mail/Display/thread_subject", 
+				   config->thread_subject, NULL);
+	
 	/* Show Message Preview */
 	bonobo_config_set_boolean (config->db, "/Mail/Display/preview_pane",
 				   config->show_preview, NULL);
@@ -1418,6 +1427,18 @@ uri_to_key (const char *uri)
 	return rval;
 }
 
+gboolean
+mail_config_get_thread_subject (void)
+{
+	return config->thread_subject;
+}
+
+void
+mail_config_set_thread_subject (gboolean thread_subject)
+{
+	config->thread_subject = thread_subject;
+}
+
 gboolean
 mail_config_get_empty_trash_on_exit (void)
 {
diff --git a/mail/mail-config.h b/mail/mail-config.h
index bcf45e9ca8..95159faafe 100644
--- a/mail/mail-config.h
+++ b/mail/mail-config.h
@@ -179,6 +179,9 @@ void     mail_config_set_empty_trash_on_exit  (gboolean value);
 gboolean mail_config_get_thread_list          (const char *uri);
 void     mail_config_set_thread_list          (const char *uri, gboolean value);
 
+gboolean mail_config_get_thread_subject       (void);
+void     mail_config_set_thread_subject       (gboolean thread_subject);
+
 gboolean mail_config_get_show_preview         (const char *uri);
 void     mail_config_set_show_preview         (const char *uri, gboolean value);
 
diff --git a/mail/message-list.c b/mail/message-list.c
index 14624f57f2..a719983588 100644
--- a/mail/message-list.c
+++ b/mail/message-list.c
@@ -2673,7 +2673,8 @@ regen_list_regen (struct _mail_msg *mm)
 			if (m->tree)
 				camel_folder_thread_messages_apply(m->tree, showuids);
 			else
-				m->tree = camel_folder_thread_messages_new(m->folder, showuids);
+				m->tree = camel_folder_thread_messages_new (m->folder, showuids,
+									    mail_config_get_thread_subject ());
 		} else {
 			m->summary = g_ptr_array_new ();
 			for (i = 0; i < showuids->len; i++) {
-- 
cgit v1.2.3