diff options
author | Milan Crha <mcrha@redhat.com> | 2009-12-19 00:56:11 +0800 |
---|---|---|
committer | Milan Crha <mcrha@redhat.com> | 2009-12-19 00:56:11 +0800 |
commit | 10590768038b2f3172040da50533ca4f7802fc34 (patch) | |
tree | 64e23fda77958e0a421d828ccf54c4ee784bacf2 /modules/mail | |
parent | f148a0b0e3aaee26c42c7fc03f7a6359ead71abb (diff) | |
download | gsoc2013-evolution-10590768038b2f3172040da50533ca4f7802fc34.tar gsoc2013-evolution-10590768038b2f3172040da50533ca4f7802fc34.tar.gz gsoc2013-evolution-10590768038b2f3172040da50533ca4f7802fc34.tar.bz2 gsoc2013-evolution-10590768038b2f3172040da50533ca4f7802fc34.tar.lz gsoc2013-evolution-10590768038b2f3172040da50533ca4f7802fc34.tar.xz gsoc2013-evolution-10590768038b2f3172040da50533ca4f7802fc34.tar.zst gsoc2013-evolution-10590768038b2f3172040da50533ca4f7802fc34.zip |
Bug #596967 - Per-folder setting for threading and preview panel
Diffstat (limited to 'modules/mail')
-rw-r--r-- | modules/mail/e-mail-shell-content.h | 3 | ||||
-rw-r--r-- | modules/mail/e-mail-shell-view-actions.c | 39 | ||||
-rw-r--r-- | modules/mail/e-mail-shell-view-private.c | 70 |
3 files changed, 111 insertions, 1 deletions
diff --git a/modules/mail/e-mail-shell-content.h b/modules/mail/e-mail-shell-content.h index 88714f8f95..c11323b5f1 100644 --- a/modules/mail/e-mail-shell-content.h +++ b/modules/mail/e-mail-shell-content.h @@ -46,6 +46,9 @@ (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; diff --git a/modules/mail/e-mail-shell-view-actions.c b/modules/mail/e-mail-shell-view-actions.c index 93a3bf63a1..f300ec0c92 100644 --- a/modules/mail/e-mail-shell-view-actions.c +++ b/modules/mail/e-mail-shell-view-actions.c @@ -483,6 +483,28 @@ 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) { @@ -821,6 +843,7 @@ action_mail_threads_group_by_cb (GtkToggleAction *action, 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; @@ -830,6 +853,20 @@ action_mail_threads_group_by_cb (GtkToggleAction *action, 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 @@ -1281,7 +1318,7 @@ static GtkToggleActionEntry mail_toggle_entries[] = { N_("Show Message _Preview"), "<Control>m", N_("Show message preview pane"), - NULL, /* Handled by property bindings */ + G_CALLBACK (action_mail_preview_cb), /* Also handled by property bindings */ TRUE }, { "mail-threads-group-by", diff --git a/modules/mail/e-mail-shell-view-private.c b/modules/mail/e-mail-shell-view-private.c index 0a38886a6d..c152b84817 100644 --- a/modules/mail/e-mail-shell-view-private.c +++ b/modules/mail/e-mail-shell-view-private.c @@ -23,6 +23,49 @@ #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, @@ -47,6 +90,33 @@ 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 |