Index: configure.in
===================================================================
--- configure.in	(revision 34030)
+++ configure.in	(working copy)
@@ -1641,7 +1643,7 @@ plugins_base_always="calendar-file calen
 plugins_base="$plugins_base_always $SA_JUNK_PLUGIN $BF_JUNK_PLUGIN $EXCHANGE_PLUGIN $MONO_PLUGIN" 
 all_plugins_base="$plugins_base_always sa-junk-plugin bogo-junk-plugin exchange-operations mono"
 
-plugins_standard_always="bbdb subject-thread save-calendar select-one-source copy-tool mail-to-task mark-calendar-offline audio-inline mailing-list-actions new-mail-notify default-mailer import-ics-attachments prefer-plain mail-notification attachment-reminder face" 
+plugins_standard_always="bbdb subject-thread thread-default-state save-calendar select-one-source copy-tool mail-to-task mark-calendar-offline audio-inline mailing-list-actions new-mail-notify default-mailer import-ics-attachments prefer-plain mail-notification attachment-reminder face" 
 plugins_standard="$plugins_standard_always"
 all_plugins_standard="$plugins_standard"
 
@@ -1953,6 +1955,7 @@ plugins/mail-remote/Makefile
 plugins/mono/Makefile
 plugins/new-mail-notify/Makefile
 plugins/subject-thread/Makefile
+plugins/thread-default-state/Makefile
 plugins/save-attachments/Makefile
 plugins/save-calendar/Makefile
 plugins/select-one-source/Makefile
Index: plugins/thread-default-state/ChangeLog
===================================================================
--- plugins/thread-default-state/ChangeLog	(revision 0)
+++ plugins/thread-default-state/ChangeLog	(revision 0)
@@ -0,0 +1,4 @@
+2007-08-16  Tobias Mueller <muelli@auftrags-killer.org>
+
+	Plugin for changing the default states of thread. So
+	it's not necessary to run gconf-editor.
Index: plugins/thread-default-state/thread-default-state.c
===================================================================
--- plugins/thread-default-state/thread-default-state.c	(revision 0)
+++ plugins/thread-default-state/thread-default-state.c	(revision 0)
@@ -0,0 +1,80 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ *  Authors: Tobias Mueller <muelli@auftrags-killer.org>
+ *
+ *  Copyright 2007 Tobias Mueller
+ *
+ *  This program is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU General Public
+ *  License as published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <string.h>
+#include <glib.h>
+#include <gtk/gtk.h>
+#include <glib/gi18n.h>
+#include <gconf/gconf-client.h>
+#include <e-util/e-config.h>
+#include <mail/em-config.h>
+
+#define GCONF_KEY "/apps/evolution/mail/display/thread_expand"
+
+GtkWidget *org_gnome_thread_default_state_factory (EPlugin *ep, EConfigHookItemFactoryData *hook_data);
+
+static void
+toggled_cb (GtkWidget *widget, EConfig *config)
+{
+	GError *error = NULL;
+	EMConfigTargetPrefs *target = (EMConfigTargetPrefs *) config->target;
+	
+	/* Save the new setting to gconf */
+	gconf_client_set_bool (target->gconf, GCONF_KEY,
+			       gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)),
+			       &error);
+	
+	if (error != NULL) {
+		g_warning("%s (%s) %s\n", G_STRLOC, G_STRFUNC, error->message);
+		g_error_free(error);
+	}
+	
+	/* TODO: One probably want to save this information in memory as well. 
+	   You could use e_tree_memory_set_expanded_default(E_TREE_MEMORY(ml->model), FALSE);
+	   but I don't know how to achieve this yet.
+	*/
+}
+
+GtkWidget *
+org_gnome_thread_default_state_factory (EPlugin *ep, EConfigHookItemFactoryData *hook_data)
+{
+	GtkWidget *check;
+	EMConfigTargetPrefs *target = (EMConfigTargetPrefs *) hook_data->config->target;
+	
+	/* Create the checkbox we will display, complete with mnemonic that is unique in the dialog */
+	check = gtk_check_button_new_with_mnemonic (_("Ex_pand threads by default"));
+
+	/* Set the toggle button to the current gconf setting */
+	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), gconf_client_get_bool (target->gconf, GCONF_KEY, NULL));
+
+	/* Listen for the item being toggled on and off */
+	g_signal_connect (GTK_TOGGLE_BUTTON (check), "toggled", G_CALLBACK (toggled_cb), hook_data->config);
+	
+	/* Pack the checkbox in the parent widget and show it */
+	gtk_box_pack_start (GTK_BOX (hook_data->parent), check, FALSE, FALSE, 0);
+	gtk_widget_show (check);
+	
+	return check;
+}
Index: plugins/thread-default-state/org-gnome-thread-default-state.eplug.xml
===================================================================
--- plugins/thread-default-state/org-gnome-thread-default-state.eplug.xml	(revision 0)
+++ plugins/thread-default-state/org-gnome-thread-default-state.eplug.xml	(revision 0)
@@ -0,0 +1,14 @@
+<?xml version="1.0"?>
+<e-plugin-list>
+	<e-plugin id="org.gnome.evolution.thread_default_state" type="shlib" _name="Thread Default State" 
+		location="@PLUGINDIR@/liborg-gnome-thread-default-state@SOEXT@">
+		<author name="Tobias Mueller" email="muelli@auftrags-killer.org"/>
+		<_description>Toggles whether to expand threads by default.</_description>
+	
+		<hook class="org.gnome.evolution.mail.config:1.0">
+			<group id="org.gnome.evolution.mail.prefs" target="prefs">
+				<item type="item" path="00.general/10.display/90.thread_default_state" _label="Expand threads by default" factory="org_gnome_thread_default_state_factory"/>
+			</group>
+		</hook>
+	</e-plugin>
+</e-plugin-list>
Index: plugins/thread-default-state/Makefile.am
===================================================================
--- plugins/thread-default-state/Makefile.am	(revision 0)
+++ plugins/thread-default-state/Makefile.am	(revision 0)
@@ -0,0 +1,16 @@
+INCLUDES =						\
+	-I$(top_srcdir)					\
+	$(EVOLUTION_MAIL_CFLAGS)
+
+@EVO_PLUGIN_RULE@
+
+plugin_DATA = org-gnome-thread-default-state.eplug
+plugin_LTLIBRARIES = liborg-gnome-thread-default-state.la
+
+liborg_gnome_thread_default_state_la_SOURCES = thread-default-state.c
+liborg_gnome_thread_default_state_la_LDFLAGS = -module -avoid-version
+
+EXTRA_DIST = org-gnome-thread-default-state.eplug.xml
+
+BUILT_SOURCES = $(plugin_DATA)
+CLEANFILES = $(BUILT_SOURCES)
