[evolution] Bug 616724 - Initialize message window with threaded state of main window



commit 0439c01a9ab20875796c8ecae855627424742bf4
Author: Matthew Barnes <mbarnes redhat com>
Date:   Sat Jun 19 11:39:49 2010 -0400

    Bug 616724 - Initialize message window with threaded state of main window

 mail/e-mail-browser.c                    |   19 ++++++++
 mail/e-mail-reader-utils.c               |    3 +
 mail/e-mail-reader.c                     |   47 +++++++++++++++++++
 mail/e-mail-reader.h                     |    5 ++
 modules/mail/e-mail-shell-content.c      |   75 ++++++++++--------------------
 modules/mail/e-mail-shell-content.h      |    5 --
 modules/mail/e-mail-shell-view-private.c |    2 +-
 7 files changed, 100 insertions(+), 56 deletions(-)
---
diff --git a/mail/e-mail-browser.c b/mail/e-mail-browser.c
index e076585..0626231 100644
--- a/mail/e-mail-browser.c
+++ b/mail/e-mail-browser.c
@@ -63,6 +63,7 @@ struct _EMailBrowserPrivate {
 enum {
 	PROP_0,
 	PROP_FOCUS_TRACKER,
+	PROP_GROUP_BY_THREADS,
 	PROP_SHELL_BACKEND,
 	PROP_SHOW_DELETED,
 	PROP_UI_MANAGER
@@ -348,6 +349,12 @@ mail_browser_set_property (GObject *object,
                            GParamSpec *pspec)
 {
 	switch (property_id) {
+		case PROP_GROUP_BY_THREADS:
+			e_mail_reader_set_group_by_threads (
+				E_MAIL_READER (object),
+				g_value_get_boolean (value));
+			return;
+
 		case PROP_SHELL_BACKEND:
 			mail_browser_set_shell_backend (
 				E_MAIL_BROWSER (object),
@@ -377,6 +384,12 @@ mail_browser_get_property (GObject *object,
 				E_MAIL_BROWSER (object)));
 			return;
 
+		case PROP_GROUP_BY_THREADS:
+			g_value_set_boolean (
+				value, e_mail_reader_get_group_by_threads (
+				E_MAIL_READER (object)));
+			return;
+
 		case PROP_SHELL_BACKEND:
 			g_value_set_object (
 				value, e_mail_reader_get_shell_backend (
@@ -770,6 +783,12 @@ mail_browser_class_init (EMailBrowserClass *class)
 			E_TYPE_FOCUS_TRACKER,
 			G_PARAM_READABLE));
 
+	/* Inherited from EMailReader */
+	g_object_class_override_property (
+		object_class,
+		PROP_GROUP_BY_THREADS,
+		"group-by-threads");
+
 	g_object_class_install_property (
 		object_class,
 		PROP_SHELL_BACKEND,
diff --git a/mail/e-mail-reader-utils.c b/mail/e-mail-reader-utils.c
index 566d2e7..539f927 100644
--- a/mail/e-mail-reader-utils.c
+++ b/mail/e-mail-reader-utils.c
@@ -264,6 +264,9 @@ e_mail_reader_open_selected (EMailReader *reader)
 		e_mail_reader_set_folder (
 			E_MAIL_READER (browser), folder, folder_uri);
 		e_mail_reader_set_message (E_MAIL_READER (browser), uid);
+		e_mail_reader_set_group_by_threads (
+			E_MAIL_READER (browser),
+			e_mail_reader_get_group_by_threads (reader));
 		gtk_widget_show (browser);
 	}
 
diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c
index 502ee0d..abfbf3b 100644
--- a/mail/e-mail-reader.c
+++ b/mail/e-mail-reader.c
@@ -76,6 +76,8 @@ struct _EMailReaderPrivate {
 	 * happen when the -user- selects a message. */
 	guint folder_was_just_selected    : 1;
 	guint restoring_message_selection : 1;
+
+	guint group_by_threads : 1;
 };
 
 enum {
@@ -2487,6 +2489,15 @@ mail_reader_class_init (EMailReaderIface *iface)
 	iface->set_message = mail_reader_set_message;
 	iface->update_actions = mail_reader_update_actions;
 
+	g_object_interface_install_property (
+		iface,
+		g_param_spec_boolean (
+			"group-by-threads",
+			"Group by Threads",
+			"Whether to group messages by threads",
+			FALSE,
+			G_PARAM_READWRITE));
+
 	signals[CHANGED] = g_signal_new (
 		"changed",
 		G_OBJECT_CLASS_TYPE (iface),
@@ -3100,6 +3111,42 @@ e_mail_reader_set_message (EMailReader *reader,
 	iface->set_message (reader, uid);
 }
 
+gboolean
+e_mail_reader_get_group_by_threads (EMailReader *reader)
+{
+	EMailReaderPrivate *priv;
+
+	g_return_val_if_fail (E_IS_MAIL_READER (reader), FALSE);
+
+	priv = E_MAIL_READER_GET_PRIVATE (reader);
+
+	return priv->group_by_threads;
+}
+
+void
+e_mail_reader_set_group_by_threads (EMailReader *reader,
+                                    gboolean group_by_threads)
+{
+	EMailReaderPrivate *priv;
+	GtkWidget *message_list;
+
+	g_return_if_fail (E_IS_MAIL_READER (reader));
+
+	priv = E_MAIL_READER_GET_PRIVATE (reader);
+
+	if (group_by_threads == priv->group_by_threads)
+		return;
+
+	priv->group_by_threads = group_by_threads;
+
+	/* XXX MessageList should define a property for this. */
+	message_list = e_mail_reader_get_message_list (reader);
+	message_list_set_threaded (
+		MESSAGE_LIST (message_list), group_by_threads);
+
+	g_object_notify (G_OBJECT (reader), "group-by-threads");
+}
+
 void
 e_mail_reader_create_charset_menu (EMailReader *reader,
                                    GtkUIManager *ui_manager,
diff --git a/mail/e-mail-reader.h b/mail/e-mail-reader.h
index b493cff..53fcd09 100644
--- a/mail/e-mail-reader.h
+++ b/mail/e-mail-reader.h
@@ -130,6 +130,11 @@ void		e_mail_reader_set_folder_uri	(EMailReader *reader,
 						 const gchar *folder_uri);
 void		e_mail_reader_set_message	(EMailReader *reader,
 						 const gchar *uid);
+gboolean	e_mail_reader_get_group_by_threads
+						(EMailReader *reader);
+void		e_mail_reader_set_group_by_threads
+						(EMailReader *reader,
+						 gboolean group_by_threads);
 void		e_mail_reader_create_charset_menu
 						(EMailReader *reader,
 						 GtkUIManager *ui_manager,
diff --git a/modules/mail/e-mail-shell-content.c b/modules/mail/e-mail-shell-content.c
index 340e323..75787ce 100644
--- a/modules/mail/e-mail-shell-content.c
+++ b/modules/mail/e-mail-shell-content.c
@@ -69,7 +69,6 @@ struct _EMailShellContentPrivate {
 	/* Signal handler IDs */
 	guint message_list_built_id;
 
-	guint group_by_threads	: 1;
 	guint preview_visible	: 1;
 	guint show_deleted	: 1;
 };
@@ -239,6 +238,18 @@ mail_shell_content_restore_state_cb (EShellWindow *shell_window,
 	gconf_bridge_bind_property (bridge, key, object, "vposition");
 }
 
+static void
+mail_shell_content_notify_group_by_threads_cb (EMailReader *reader)
+{
+	gboolean group_by_threads;
+
+	group_by_threads = e_mail_reader_get_group_by_threads (reader);
+
+	mail_shell_content_save_boolean (
+		E_MAIL_SHELL_CONTENT (reader),
+		STATE_KEY_GROUP_BY_THREADS, group_by_threads);
+}
+
 static GtkOrientation
 mail_shell_content_get_orientation (EMailShellContent *mail_shell_content)
 {
@@ -264,8 +275,8 @@ mail_shell_content_set_property (GObject *object,
 {
 	switch (property_id) {
 		case PROP_GROUP_BY_THREADS:
-			e_mail_shell_content_set_group_by_threads (
-				E_MAIL_SHELL_CONTENT (object),
+			e_mail_reader_set_group_by_threads (
+				E_MAIL_READER (object),
 				g_value_get_boolean (value));
 			return;
 
@@ -301,8 +312,8 @@ mail_shell_content_get_property (GObject *object,
 		case PROP_GROUP_BY_THREADS:
 			g_value_set_boolean (
 				value,
-				e_mail_shell_content_get_group_by_threads (
-				E_MAIL_SHELL_CONTENT (object)));
+				e_mail_reader_get_group_by_threads (
+				E_MAIL_READER (object)));
 			return;
 
 		case PROP_ORIENTATION:
@@ -628,8 +639,7 @@ mail_shell_content_set_folder (EMailReader *reader,
 		g_clear_error (&error);
 	}
 
-	e_mail_shell_content_set_group_by_threads (
-		E_MAIL_SHELL_CONTENT (shell_content), value);
+	e_mail_reader_set_group_by_threads (reader, value);
 
 	key = STATE_KEY_PREVIEW_VISIBLE;
 	value = g_key_file_get_boolean (key_file, group_name, key, &error);
@@ -686,15 +696,11 @@ mail_shell_content_class_init (EMailShellContentClass *class)
 	shell_content_class = E_SHELL_CONTENT_CLASS (class);
 	shell_content_class->check_state = mail_shell_content_check_state;
 
-	g_object_class_install_property (
+	/* Inherited from EMailReader */
+	g_object_class_override_property (
 		object_class,
 		PROP_GROUP_BY_THREADS,
-		g_param_spec_boolean (
-			"group-by-threads",
-			"Group by Threads",
-			"Whether to group messages by threads",
-			FALSE,
-			G_PARAM_READWRITE));
+		"group-by-threads");
 
 	g_object_class_install_property (
 		object_class,
@@ -742,6 +748,11 @@ mail_shell_content_init (EMailShellContent *mail_shell_content)
 
 	mail_shell_content->priv->preview_visible = TRUE;
 
+	g_signal_connect (
+		mail_shell_content, "notify::group-by-threads",
+		G_CALLBACK (mail_shell_content_notify_group_by_threads_cb),
+		NULL);
+
 	/* Postpone widget construction until we have a shell view. */
 }
 
@@ -803,42 +814,6 @@ e_mail_shell_content_new (EShellView *shell_view)
 }
 
 gboolean
-e_mail_shell_content_get_group_by_threads (EMailShellContent *mail_shell_content)
-{
-	g_return_val_if_fail (
-		E_IS_MAIL_SHELL_CONTENT (mail_shell_content), FALSE);
-
-	return mail_shell_content->priv->group_by_threads;
-}
-
-void
-e_mail_shell_content_set_group_by_threads (EMailShellContent *mail_shell_content,
-                                           gboolean group_by_threads)
-{
-	EMailReader *reader;
-	GtkWidget *message_list;
-
-	g_return_if_fail (E_IS_MAIL_SHELL_CONTENT (mail_shell_content));
-
-	if (group_by_threads == mail_shell_content->priv->group_by_threads)
-		return;
-
-	mail_shell_content->priv->group_by_threads = group_by_threads;
-
-	mail_shell_content_save_boolean (
-		mail_shell_content,
-		STATE_KEY_GROUP_BY_THREADS, group_by_threads);
-
-	/* XXX MessageList should define a property for this. */
-	reader = E_MAIL_READER (mail_shell_content);
-	message_list = e_mail_reader_get_message_list (reader);
-	message_list_set_threaded (
-		MESSAGE_LIST (message_list), group_by_threads);
-
-	g_object_notify (G_OBJECT (mail_shell_content), "group-by-threads");
-}
-
-gboolean
 e_mail_shell_content_get_preview_visible (EMailShellContent *mail_shell_content)
 {
 	g_return_val_if_fail (
diff --git a/modules/mail/e-mail-shell-content.h b/modules/mail/e-mail-shell-content.h
index 4be7be2..a5263bc 100644
--- a/modules/mail/e-mail-shell-content.h
+++ b/modules/mail/e-mail-shell-content.h
@@ -66,11 +66,6 @@ GType		e_mail_shell_content_get_type	(void);
 void		e_mail_shell_content_register_type
 					(GTypeModule *type_module);
 GtkWidget *	e_mail_shell_content_new(EShellView *shell_view);
-gboolean	e_mail_shell_content_get_group_by_threads
-					(EMailShellContent *mail_shell_content);
-void		e_mail_shell_content_set_group_by_threads
-					(EMailShellContent *mail_shell_content,
-					 gboolean group_by_threads);
 gboolean	e_mail_shell_content_get_preview_visible
 					(EMailShellContent *mail_shell_content);
 void		e_mail_shell_content_set_preview_visible
diff --git a/modules/mail/e-mail-shell-view-private.c b/modules/mail/e-mail-shell-view-private.c
index 4cef432..4aac007 100644
--- a/modules/mail/e-mail-shell-view-private.c
+++ b/modules/mail/e-mail-shell-view-private.c
@@ -575,9 +575,9 @@ e_mail_shell_view_private_constructed (EMailShellView *mail_shell_view)
 			G_CALLBACK (mail_shell_view_prepare_for_quit_cb),
 			mail_shell_view);
 
+	e_mail_reader_init (reader);
 	e_mail_shell_view_actions_init (mail_shell_view);
 	e_mail_shell_view_update_search_filter (mail_shell_view);
-	e_mail_reader_init (reader);
 
 	/* Populate built-in rules for search entry popup menu.
 	 * Keep the assertions, please.  If the conditions aren't



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]