aboutsummaryrefslogtreecommitdiffstats
path: root/modules/mail
diff options
context:
space:
mode:
Diffstat (limited to 'modules/mail')
-rw-r--r--modules/mail/e-mail-shell-content.c133
-rw-r--r--modules/mail/e-mail-shell-content.h8
-rw-r--r--modules/mail/e-mail-shell-view-actions.c71
-rw-r--r--modules/mail/e-mail-shell-view-private.c70
4 files changed, 144 insertions, 138 deletions
diff --git a/modules/mail/e-mail-shell-content.c b/modules/mail/e-mail-shell-content.c
index a1d8a40d82..992660ccc6 100644
--- a/modules/mail/e-mail-shell-content.c
+++ b/modules/mail/e-mail-shell-content.c
@@ -45,7 +45,9 @@
(G_TYPE_INSTANCE_GET_PRIVATE \
((obj), E_TYPE_MAIL_SHELL_CONTENT, EMailShellContentPrivate))
+#define STATE_KEY_GROUP_BY_THREADS "GroupByThreads"
#define STATE_KEY_SELECTED_MESSAGE "SelectedMessage"
+#define STATE_KEY_PREVIEW_VISIBLE "PreviewVisible"
struct _EMailShellContentPrivate {
GtkWidget *paned;
@@ -65,6 +67,7 @@ struct _EMailShellContentPrivate {
/* Signal handler IDs */
guint message_list_built_id;
+ guint group_by_threads : 1;
guint preview_visible : 1;
guint suppress_message_selection : 1;
guint show_deleted : 1;
@@ -72,6 +75,7 @@ struct _EMailShellContentPrivate {
enum {
PROP_0,
+ PROP_GROUP_BY_THREADS,
PROP_ORIENTATION,
PROP_PREVIEW_VISIBLE,
PROP_SHOW_DELETED
@@ -81,6 +85,35 @@ static gpointer parent_class;
static GType mail_shell_content_type;
static void
+mail_shell_content_save_boolean (EMailShellContent *mail_shell_content,
+ const gchar *key,
+ gboolean value)
+{
+ EShellView *shell_view;
+ EShellContent *shell_content;
+ EMailReader *reader;
+ GKeyFile *key_file;
+ const gchar *folder_uri;
+ gchar *group_name;
+
+ shell_content = E_SHELL_CONTENT (mail_shell_content);
+ shell_view = e_shell_content_get_shell_view (shell_content);
+ key_file = e_shell_view_get_state_key_file (shell_view);
+
+ reader = E_MAIL_READER (mail_shell_content);
+ folder_uri = e_mail_reader_get_folder_uri (reader);
+
+ if (folder_uri == NULL)
+ return;
+
+ group_name = g_strdup_printf ("Folder %s", folder_uri);
+ g_key_file_set_boolean (key_file, group_name, key, value);
+ g_free (group_name);
+
+ e_shell_view_set_state_dirty (shell_view);
+}
+
+static void
mail_shell_content_message_list_built_cb (EMailShellContent *mail_shell_content,
MessageList *message_list)
{
@@ -218,6 +251,12 @@ mail_shell_content_set_property (GObject *object,
GParamSpec *pspec)
{
switch (property_id) {
+ case PROP_GROUP_BY_THREADS:
+ e_mail_shell_content_set_group_by_threads (
+ E_MAIL_SHELL_CONTENT (object),
+ g_value_get_boolean (value));
+ return;
+
case PROP_ORIENTATION:
mail_shell_content_set_orientation (
E_MAIL_SHELL_CONTENT (object),
@@ -247,6 +286,13 @@ mail_shell_content_get_property (GObject *object,
GParamSpec *pspec)
{
switch (property_id) {
+ case PROP_GROUP_BY_THREADS:
+ g_value_set_boolean (
+ value,
+ e_mail_shell_content_get_group_by_threads (
+ E_MAIL_SHELL_CONTENT (object)));
+ return;
+
case PROP_ORIENTATION:
g_value_set_enum (
value,
@@ -540,11 +586,18 @@ mail_shell_content_set_folder (EMailReader *reader,
CamelFolder *folder,
const gchar *folder_uri)
{
+ EShellView *shell_view;
+ EShellContent *shell_content;
EMailShellContentPrivate *priv;
EMailReaderIface *default_iface;
GtkWidget *message_list;
CamelFolder *old_folder;
+ GKeyFile *key_file;
+ gchar *group_name;
+ const gchar *key;
gboolean different_folder;
+ gboolean value;
+ GError *error = NULL;
priv = E_MAIL_SHELL_CONTENT_GET_PRIVATE (reader);
@@ -579,6 +632,36 @@ mail_shell_content_set_folder (EMailReader *reader,
G_CALLBACK (mail_shell_content_message_list_built_cb),
reader);
+ /* Restore the folder's preview and threaded state. */
+
+ shell_content = E_SHELL_CONTENT (reader);
+ shell_view = e_shell_content_get_shell_view (shell_content);
+
+ key_file = e_shell_view_get_state_key_file (shell_view);
+ group_name = g_strdup_printf ("Folder %s", folder_uri);
+
+ key = STATE_KEY_GROUP_BY_THREADS;
+ value = g_key_file_get_boolean (key_file, group_name, key, &error);
+ if (error != NULL) {
+ value = FALSE;
+ g_clear_error (&error);
+ }
+
+ e_mail_shell_content_set_group_by_threads (
+ E_MAIL_SHELL_CONTENT (shell_content), value);
+
+ key = STATE_KEY_PREVIEW_VISIBLE;
+ value = g_key_file_get_boolean (key_file, group_name, key, &error);
+ if (error != NULL) {
+ value = TRUE;
+ g_clear_error (&error);
+ }
+
+ e_mail_shell_content_set_preview_visible (
+ E_MAIL_SHELL_CONTENT (shell_content), value);
+
+ g_free (group_name);
+
exit:
message_list_thaw (MESSAGE_LIST (message_list));
}
@@ -613,6 +696,16 @@ mail_shell_content_class_init (EMailShellContentClass *class)
g_object_class_install_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));
+
+ g_object_class_install_property (
+ object_class,
PROP_PREVIEW_VISIBLE,
g_param_spec_boolean (
"preview-visible",
@@ -718,6 +811,42 @@ 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 (
@@ -753,6 +882,10 @@ e_mail_shell_content_set_preview_visible (EMailShellContent *mail_shell_content,
mail_shell_content->priv->preview_visible = preview_visible;
+ mail_shell_content_save_boolean (
+ mail_shell_content,
+ STATE_KEY_PREVIEW_VISIBLE, preview_visible);
+
g_object_notify (G_OBJECT (mail_shell_content), "preview-visible");
}
diff --git a/modules/mail/e-mail-shell-content.h b/modules/mail/e-mail-shell-content.h
index 69a1fdc397..4be7be206f 100644
--- a/modules/mail/e-mail-shell-content.h
+++ b/modules/mail/e-mail-shell-content.h
@@ -47,9 +47,6 @@
(G_TYPE_INSTANCE_GET_CLASS \
((obj), E_TYPE_MAIL_SHELL_CONTENT, EMailShellContentClass))
-#define STATE_KEY_PREVIEW "Preview"
-#define STATE_KEY_THREAD_LIST "ThreadList"
-
G_BEGIN_DECLS
typedef struct _EMailShellContent EMailShellContent;
@@ -69,6 +66,11 @@ 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-actions.c b/modules/mail/e-mail-shell-view-actions.c
index 103463b586..2ab36d46fb 100644
--- a/modules/mail/e-mail-shell-view-actions.c
+++ b/modules/mail/e-mail-shell-view-actions.c
@@ -485,28 +485,6 @@ action_mail_hide_selected_cb (GtkAction *action,
}
static void
-action_mail_preview_cb (GtkToggleAction *action, EMailShellView *mail_shell_view)
-{
- const gchar *folder_uri;
- EMailReader *reader;
-
- reader = E_MAIL_READER (mail_shell_view->priv->mail_shell_content);
- folder_uri = e_mail_reader_get_folder_uri (reader);
-
- if (folder_uri) {
- GKeyFile *key_file;
- const gchar *key;
- gchar *group_name;
-
- key_file = e_shell_view_get_state_key_file (E_SHELL_VIEW (mail_shell_view));
- key = STATE_KEY_PREVIEW;
- group_name = g_strdup_printf ("Folder %s", folder_uri);
- g_key_file_set_boolean (key_file, group_name, key, gtk_toggle_action_get_active (action));
- g_free (group_name);
- }
-}
-
-static void
action_mail_label_cb (GtkToggleAction *action,
EMailShellView *mail_shell_view)
{
@@ -839,39 +817,6 @@ action_mail_threads_expand_all_cb (GtkAction *action,
}
static void
-action_mail_threads_group_by_cb (GtkToggleAction *action,
- EMailShellView *mail_shell_view)
-{
- EMailShellContent *mail_shell_content;
- GtkWidget *message_list;
- EMailReader *reader;
- const gchar *folder_uri;
- gboolean active;
-
- mail_shell_content = mail_shell_view->priv->mail_shell_content;
- active = gtk_toggle_action_get_active (action);
-
- reader = E_MAIL_READER (mail_shell_content);
- message_list = e_mail_reader_get_message_list (reader);
-
- message_list_set_threaded (MESSAGE_LIST (message_list), active);
-
- folder_uri = e_mail_reader_get_folder_uri (reader);
-
- if (folder_uri) {
- GKeyFile *key_file;
- const gchar *key;
- gchar *group_name;
-
- key_file = e_shell_view_get_state_key_file (E_SHELL_VIEW (mail_shell_view));
- key = STATE_KEY_THREAD_LIST;
- group_name = g_strdup_printf ("Folder %s", folder_uri);
- g_key_file_set_boolean (key_file, group_name, key, active);
- g_free (group_name);
- }
-}
-
-static void
action_mail_tools_filters_cb (GtkAction *action,
EMailShellView *mail_shell_view)
{
@@ -1320,7 +1265,7 @@ static GtkToggleActionEntry mail_toggle_entries[] = {
N_("Show Message _Preview"),
"<Control>m",
N_("Show message preview pane"),
- G_CALLBACK (action_mail_preview_cb), /* Also handled by property bindings */
+ NULL, /* Handled by property bindings */
TRUE },
{ "mail-threads-group-by",
@@ -1328,7 +1273,7 @@ static GtkToggleActionEntry mail_toggle_entries[] = {
N_("_Group By Threads"),
"<Control>t",
N_("Threaded message list"),
- G_CALLBACK (action_mail_threads_group_by_cb),
+ NULL, /* Handled by property bindings */
FALSE }
};
@@ -1566,14 +1511,6 @@ e_mail_shell_view_actions_init (EMailShellView *mail_shell_view)
bridge = gconf_bridge_get ();
- object = G_OBJECT (ACTION (MAIL_PREVIEW));
- key = "/apps/evolution/mail/display/show_preview";
- gconf_bridge_bind_property (bridge, key, object, "active");
-
- object = G_OBJECT (ACTION (MAIL_THREADS_GROUP_BY));
- key = "/apps/evolution/mail/display/thread_list";
- gconf_bridge_bind_property (bridge, key, object, "active");
-
object = G_OBJECT (ACTION (MAIL_VIEW_VERTICAL));
key = "/apps/evolution/mail/display/layout";
gconf_bridge_bind_property (bridge, key, object, "current-value");
@@ -1600,6 +1537,10 @@ e_mail_shell_view_actions_init (EMailShellView *mail_shell_view)
ACTION (MAIL_PREVIEW), "active",
mail_shell_content, "preview-visible");
+ e_mutual_binding_new (
+ ACTION (MAIL_THREADS_GROUP_BY), "active",
+ mail_shell_content, "group-by-threads");
+
e_binding_new (
ACTION (MAIL_PREVIEW), "active",
ACTION (MAIL_VIEW_CLASSIC), "sensitive");
diff --git a/modules/mail/e-mail-shell-view-private.c b/modules/mail/e-mail-shell-view-private.c
index f1e9805752..b198b69cd1 100644
--- a/modules/mail/e-mail-shell-view-private.c
+++ b/modules/mail/e-mail-shell-view-private.c
@@ -23,49 +23,6 @@
#include "widgets/menus/gal-view-factory-etable.h"
-static gboolean
-restore_action_bool_state (gpointer view, GtkToggleAction *action, GKeyFile *key_file, const gchar *group_name, const gchar *key, const gchar *gconf_key)
-{
- gboolean value;
- GConfBridge *bridge;
-
- g_return_val_if_fail (action != NULL, FALSE);
- g_return_val_if_fail (GTK_IS_TOGGLE_ACTION (action), FALSE);
- g_return_val_if_fail (key_file != NULL, FALSE);
- g_return_val_if_fail (group_name != NULL, FALSE);
- g_return_val_if_fail (key != NULL, FALSE);
- g_return_val_if_fail (gconf_key != NULL, FALSE);
-
- bridge = gconf_bridge_get ();
-
- if (g_key_file_has_key (key_file, group_name, key, NULL)) {
- value = g_key_file_get_boolean (key_file, group_name, key, NULL);
- } else {
- GError *error = NULL;
-
- value = gconf_client_get_bool (gconf_bridge_get_client (bridge), gconf_key, &error);
-
- if (error) {
- g_error_free (error);
- value = gtk_toggle_action_get_active (action);
- }
- }
-
- if (value != gtk_toggle_action_get_active (action)) {
- /* block bindings to not store this change to gconf */
- gconf_bridge_block_property_bindings (bridge, gconf_key);
- /* block action to not store to key file for the previous folder */
- g_signal_handlers_block_matched (action, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, view);
-
- gtk_toggle_action_set_active (action, value);
-
- g_signal_handlers_unblock_matched (action, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, view);
- gconf_bridge_unblock_property_bindings (bridge, gconf_key);
- }
-
- return value;
-}
-
static void
mail_shell_view_folder_tree_selected_cb (EMailShellView *mail_shell_view,
const gchar *full_name,
@@ -90,33 +47,6 @@ mail_shell_view_folder_tree_selected_cb (EMailShellView *mail_shell_view,
e_mail_reader_set_folder (reader, NULL, NULL);
e_shell_view_update_actions (shell_view);
-
- if (folder_selected && uri) {
- EShellWindow *shell_window;
- GtkToggleAction *action;
- GKeyFile *key_file;
- gchar *group_name;
- gboolean value;
-
- shell_window = e_shell_view_get_shell_window (shell_view);
- key_file = e_shell_view_get_state_key_file (shell_view);
- group_name = g_strdup_printf ("Folder %s", uri);
-
- action = GTK_TOGGLE_ACTION (ACTION (MAIL_PREVIEW));
- restore_action_bool_state (mail_shell_view, action,
- key_file, group_name, STATE_KEY_PREVIEW,
- "/apps/evolution/mail/display/show_preview");
-
- action = GTK_TOGGLE_ACTION (ACTION (MAIL_THREADS_GROUP_BY));
- value = restore_action_bool_state (mail_shell_view, action,
- key_file, group_name, STATE_KEY_THREAD_LIST,
- "/apps/evolution/mail/display/thread_list");
-
- /* because the change is not propagated due to blocking the action signal */
- message_list_set_threaded (MESSAGE_LIST (e_mail_reader_get_message_list (reader)), value);
-
- g_free (group_name);
- }
}
static gboolean