aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2010-06-15 22:10:03 +0800
committerMilan Crha <mcrha@redhat.com>2010-06-15 22:10:03 +0800
commit3acb21484e8b93916641dcd0a9b13fed2488a1ef (patch)
tree8bf948e3ba013f66eed7260e914f5744d643300c
parentda4b198ffa205cafc5de986085e77e1b8cc47408 (diff)
downloadgsoc2013-evolution-3acb21484e8b93916641dcd0a9b13fed2488a1ef.tar
gsoc2013-evolution-3acb21484e8b93916641dcd0a9b13fed2488a1ef.tar.gz
gsoc2013-evolution-3acb21484e8b93916641dcd0a9b13fed2488a1ef.tar.bz2
gsoc2013-evolution-3acb21484e8b93916641dcd0a9b13fed2488a1ef.tar.lz
gsoc2013-evolution-3acb21484e8b93916641dcd0a9b13fed2488a1ef.tar.xz
gsoc2013-evolution-3acb21484e8b93916641dcd0a9b13fed2488a1ef.tar.zst
gsoc2013-evolution-3acb21484e8b93916641dcd0a9b13fed2488a1ef.zip
Bug #206061 - Allow normal, non-vFolder, Trash and Junk folder
-rw-r--r--mail/em-account-editor.c191
-rw-r--r--mail/mail-config.ui104
-rw-r--r--mail/message-list.c8
3 files changed, 300 insertions, 3 deletions
diff --git a/mail/em-account-editor.c b/mail/em-account-editor.c
index fb208687b2..772c50a814 100644
--- a/mail/em-account-editor.c
+++ b/mail/em-account-editor.c
@@ -50,6 +50,7 @@
#include "e-util/e-util.h"
#include "e-util/e-alert-dialog.h"
#include "e-util/e-account-utils.h"
+#include "e-util/e-dialog-utils.h"
#include "e-util/e-signature-list.h"
#include "e-util/e-signature-utils.h"
#include "e-util/e-util-private.h"
@@ -171,6 +172,12 @@ struct _EMAccountEditorPrivate {
/* special folders */
GtkButton *drafts_folder_button;
GtkButton *sent_folder_button;
+ GtkToggleButton *trash_folder_check;
+ GtkButton *trash_folder_button;
+ GtkWidget *trash_folder_fixed;
+ GtkToggleButton *junk_folder_check;
+ GtkButton *junk_folder_button;
+ GtkWidget *junk_folder_fixed;
GtkButton *restore_folders_button;
/* Security */
@@ -671,6 +678,9 @@ default_folders_clicked (GtkButton *button, gpointer user_data)
uri = e_mail_local_get_folder_uri (E_MAIL_FOLDER_SENT);
em_folder_selection_button_set_selection ((EMFolderSelectionButton *)emae->priv->sent_folder_button, uri);
emae_account_folder_changed ((EMFolderSelectionButton *)emae->priv->sent_folder_button, emae);
+
+ gtk_toggle_button_set_active (emae->priv->trash_folder_check, FALSE);
+ gtk_toggle_button_set_active (emae->priv->junk_folder_check, FALSE);
}
/* The camel provider auto-detect interface should be deprecated.
@@ -2734,6 +2744,177 @@ emae_send_page (EConfig *ec, EConfigItem *item, GtkWidget *parent, GtkWidget *ol
return w;
}
+static void
+emae_get_checkable_folder_keys_widgets (EMAccountEditor *emae, guint32 flag, GtkWidget **check, GtkWidget **button, const gchar **param_key)
+{
+ g_return_if_fail (emae != NULL);
+ g_return_if_fail (flag == CAMEL_PROVIDER_ALLOW_REAL_TRASH_FOLDER || flag == CAMEL_PROVIDER_ALLOW_REAL_JUNK_FOLDER);
+
+ if (flag == CAMEL_PROVIDER_ALLOW_REAL_TRASH_FOLDER) {
+ if (check) *check = (GtkWidget *) emae->priv->trash_folder_check;
+ if (button) *button = (GtkWidget *) emae->priv->trash_folder_button;
+ if (param_key) *param_key = "real_trash_path";
+ } else {
+ if (check) *check = (GtkWidget *) emae->priv->junk_folder_check;
+ if (button) *button = (GtkWidget *) emae->priv->junk_folder_button;
+ if (param_key) *param_key = "real_junk_path";
+ }
+}
+
+static void
+emae_real_url_toggled (GtkToggleButton *check, EMAccountEditor *emae)
+{
+ guint32 flag;
+ GtkWidget *butt = NULL;
+ gboolean checked;
+ const gchar *param_key;
+
+ g_return_if_fail (check != NULL);
+ g_return_if_fail (emae != NULL);
+
+ if (!gtk_widget_is_sensitive (GTK_WIDGET (check)) || !gtk_widget_get_visible (GTK_WIDGET (check)))
+ return;
+
+ flag = GPOINTER_TO_INT (g_object_get_data ((GObject *)check, "url-flag"));
+ g_return_if_fail (flag == CAMEL_PROVIDER_ALLOW_REAL_TRASH_FOLDER || flag == CAMEL_PROVIDER_ALLOW_REAL_JUNK_FOLDER);
+
+ emae_get_checkable_folder_keys_widgets (emae, flag, NULL, &butt, &param_key);
+
+ checked = gtk_toggle_button_get_active (check);
+ gtk_widget_set_sensitive (butt, checked);
+
+ if (!checked) {
+ CamelURL *url;
+
+ url = emae_account_url (emae, emae_service_info[emae->priv->source.type].account_uri_key);
+ camel_url_set_param (url, param_key, NULL);
+ emae_uri_changed (&emae->priv->source, url);
+ camel_url_free (url);
+
+ /* clear the previous selection */
+ em_folder_selection_button_set_selection ((EMFolderSelectionButton *)butt, "");
+ }
+}
+
+static void
+emae_real_url_folder_changed (EMFolderSelectionButton *folder, EMAccountEditor *emae)
+{
+ CamelURL *url;
+ guint32 flag;
+ GtkWidget *check = NULL;
+ gboolean changed = FALSE;
+ const gchar *param_key = NULL, *curi_selected;
+
+ g_return_if_fail (folder != NULL);
+ g_return_if_fail (emae != NULL);
+
+ if (!gtk_widget_is_sensitive (GTK_WIDGET (folder)) || !gtk_widget_get_visible (GTK_WIDGET (folder)))
+ return;
+
+ flag = GPOINTER_TO_INT (g_object_get_data ((GObject *)folder, "url-flag"));
+ g_return_if_fail (flag == CAMEL_PROVIDER_ALLOW_REAL_TRASH_FOLDER || flag == CAMEL_PROVIDER_ALLOW_REAL_JUNK_FOLDER);
+
+ emae_get_checkable_folder_keys_widgets (emae, flag, &check, NULL, &param_key);
+
+ if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check)))
+ return;
+
+ url = emae_account_url (emae, emae_service_info[emae->priv->source.type].account_uri_key);
+
+ curi_selected = em_folder_selection_button_get_selection (folder);
+ if (!curi_selected || !*curi_selected) {
+ camel_url_set_param (url, param_key, NULL);
+ changed = TRUE;
+ } else {
+ CamelURL *url_selected = camel_url_new (curi_selected, NULL);
+
+ if (url_selected && emae->priv->source.provider && emae->priv->source.provider->url_equal (url, url_selected) && url_selected->path) {
+ camel_url_set_param (url, param_key, (*url_selected->path) == '/' ? url_selected->path + 1 : url_selected->path);
+ changed = TRUE;
+ } else {
+ e_notice (NULL, GTK_MESSAGE_ERROR, "%s", _("Please select a folder from the current account."));
+ em_folder_selection_button_set_selection (folder, "");
+ }
+
+ if (url_selected)
+ camel_url_free (url_selected);
+ }
+
+ if (changed)
+ emae_uri_changed (&emae->priv->source, url);
+ camel_url_free (url);
+}
+
+static void
+setup_checkable_folder (EMAccountEditor *emae, guint32 flag, GtkWidget *check, GtkWidget *button, GtkWidget *fixed)
+{
+ EAccount *account;
+ gboolean available;
+ EMFolderSelectionButton *folderbutt;
+ CamelURL *url;
+ const gchar *value, *param_key = NULL;
+
+ g_return_if_fail (emae != NULL);
+ g_return_if_fail (check != NULL);
+ g_return_if_fail (button != NULL);
+ g_return_if_fail (flag == CAMEL_PROVIDER_ALLOW_REAL_TRASH_FOLDER || flag == CAMEL_PROVIDER_ALLOW_REAL_JUNK_FOLDER);
+
+ account = em_account_editor_get_modified_account (emae);
+ g_return_if_fail (account != NULL);
+
+ folderbutt = (EMFolderSelectionButton *)button;
+ url = emae_account_url (emae, emae_service_info[emae->priv->source.type].account_uri_key);
+
+ emae_get_checkable_folder_keys_widgets (emae, flag, NULL, NULL, &param_key);
+
+ value = camel_url_get_param (url, param_key);
+ available = account->enabled;
+ gtk_widget_set_sensitive (check, available);
+
+ if (value && *value) {
+ gchar *url_string = camel_url_to_string (url, CAMEL_URL_HIDE_ALL);
+ if (!url_string) {
+ em_folder_selection_button_set_selection (folderbutt, "");
+ } else {
+ CamelURL *copy = camel_url_new (url_string, NULL);
+
+ if (copy->path)
+ g_free (copy->path);
+ copy->path = g_strconcat ("/", value, NULL);
+ g_free (url_string);
+
+ url_string = camel_url_to_string (copy, CAMEL_URL_HIDE_ALL);
+ em_folder_selection_button_set_selection (folderbutt, url_string ? url_string : "");
+ g_free (url_string);
+ }
+ } else {
+ em_folder_selection_button_set_selection (folderbutt, "");
+ }
+
+ value = em_folder_selection_button_get_selection (folderbutt);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), value && *value);
+ gtk_widget_set_sensitive (button, available && value && *value);
+
+ g_object_set_data ((GObject *)check, "url-flag", GINT_TO_POINTER(flag));
+ g_object_set_data ((GObject *)folderbutt, "url-flag", GINT_TO_POINTER(flag));
+
+ g_signal_connect (check, "toggled", G_CALLBACK (emae_real_url_toggled), emae);
+ g_signal_connect (folderbutt, "selected", G_CALLBACK (emae_real_url_folder_changed), emae);
+
+ available = emae->priv->source.provider && ((emae->priv->source.provider->flags & flag) == flag);
+ if (available) {
+ gtk_widget_show (check);
+ gtk_widget_show (button);
+ gtk_widget_show (fixed);
+ } else {
+ gtk_widget_hide (check);
+ gtk_widget_hide (button);
+ gtk_widget_hide (fixed);
+ }
+
+ camel_url_free (url);
+}
+
static GtkWidget *
emae_defaults_page (EConfig *ec, EConfigItem *item, GtkWidget *parent, GtkWidget *old, gpointer data)
{
@@ -2757,6 +2938,16 @@ emae_defaults_page (EConfig *ec, EConfigItem *item, GtkWidget *parent, GtkWidget
priv->drafts_folder_button = (GtkButton *)emae_account_folder (emae, "drafts_button", E_ACCOUNT_DRAFTS_FOLDER_URI, E_MAIL_FOLDER_DRAFTS, builder);
priv->sent_folder_button = (GtkButton *)emae_account_folder (emae, "sent_button", E_ACCOUNT_SENT_FOLDER_URI, E_MAIL_FOLDER_SENT, builder);
+ priv->trash_folder_check = GTK_TOGGLE_BUTTON (e_builder_get_widget (builder, "trash_folder_check"));
+ priv->trash_folder_button = GTK_BUTTON (e_builder_get_widget (builder, "trash_folder_butt"));
+ priv->trash_folder_fixed = e_builder_get_widget (builder, "trash_folder_fixed");
+ setup_checkable_folder (emae, CAMEL_PROVIDER_ALLOW_REAL_TRASH_FOLDER, GTK_WIDGET (priv->trash_folder_check), GTK_WIDGET (priv->trash_folder_button), priv->trash_folder_fixed);
+
+ priv->junk_folder_check = GTK_TOGGLE_BUTTON (e_builder_get_widget (builder, "junk_folder_check"));
+ priv->junk_folder_button = GTK_BUTTON (e_builder_get_widget (builder, "junk_folder_butt"));
+ priv->junk_folder_fixed = e_builder_get_widget (builder, "junk_folder_fixed");
+ setup_checkable_folder (emae, CAMEL_PROVIDER_ALLOW_REAL_JUNK_FOLDER, GTK_WIDGET (priv->junk_folder_check), GTK_WIDGET (priv->junk_folder_button), priv->junk_folder_fixed);
+
/* Special Folders "Reset Defaults" button */
priv->restore_folders_button = (GtkButton *)e_builder_get_widget (builder, "default_folders_button");
g_signal_connect (priv->restore_folders_button, "clicked", G_CALLBACK (default_folders_clicked), emae);
diff --git a/mail/mail-config.ui b/mail/mail-config.ui
index cde9f08c03..ce2a19845d 100644
--- a/mail/mail-config.ui
+++ b/mail/mail-config.ui
@@ -1603,7 +1603,7 @@ For example: "Work" or "Personal"</property>
<child>
<object class="GtkTable" id="folders_table">
<property name="visible">True</property>
- <property name="n_rows">3</property>
+ <property name="n_rows">5</property>
<property name="n_columns">3</property>
<property name="column_spacing">12</property>
<property name="row_spacing">6</property>
@@ -1710,8 +1710,110 @@ For example: "Work" or "Personal"</property>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">3</property>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
+ </packing>
+ </child>
+
+ <child>
+ <object class="GtkCheckButton" id="trash_folder_check">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">_Trash Folder:</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="active">False</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="right_attach">1</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
+ <property name="x_options">fill</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+
+ <child>
+ <object class="EMFolderSelectionButton" id="trash_folder_butt">
+ <property name="title" translatable="yes">Select Trash Folder</property>
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options">fill</property>
+ <property name="y_options">fill</property>
+ </packing>
+ </child>
+
+ <child>
+ <object class="GtkCheckButton" id="junk_folder_check">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">_Junk Folder:</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="active">False</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="right_attach">1</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ <property name="x_options">fill</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+
+ <child>
+ <object class="EMFolderSelectionButton" id="junk_folder_butt">
+ <property name="title" translatable="yes">Select Junk Folder</property>
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ <property name="x_options">fill</property>
+ <property name="y_options">fill</property>
+ </packing>
+ </child>
+
+ <child>
+ <object class="GtkFixed" id="trash_folder_fixed">
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options">fill</property>
+ <property name="y_options">fill</property>
+ </packing>
+ </child>
+
+ <child>
+ <object class="GtkFixed" id="junk_folder_fixed">
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ <property name="x_options">fill</property>
+ <property name="y_options">fill</property>
</packing>
</child>
<child>
diff --git a/mail/message-list.c b/mail/message-list.c
index 28cffc1352..29776a221f 100644
--- a/mail/message-list.c
+++ b/mail/message-list.c
@@ -3581,6 +3581,7 @@ message_list_set_folder (MessageList *message_list, CamelFolder *folder, const g
ETreeModel *etm = message_list->model;
gboolean hide_deleted;
GConfClient *gconf;
+ CamelStore *folder_store;
CamelException ex;
g_return_if_fail (IS_MESSAGE_LIST (message_list));
@@ -3645,8 +3646,11 @@ message_list_set_folder (MessageList *message_list, CamelFolder *folder, const g
message_list->folder = folder;
message_list->just_set_folder = TRUE;
+ /* hide deleted messages also when the store has a real trash */
+ folder_store = camel_folder_get_parent_store (folder);
+
/* Setup the strikeout effect for non-trash folders */
- if (!(folder->folder_flags & CAMEL_FOLDER_IS_TRASH))
+ if (!(folder->folder_flags & CAMEL_FOLDER_IS_TRASH) || !(folder_store->flags & CAMEL_STORE_VTRASH))
strikeout_col = COL_DELETED;
cell = e_table_extras_get_cell (message_list->extras, "render_date");
@@ -3673,7 +3677,7 @@ message_list_set_folder (MessageList *message_list, CamelFolder *folder, const g
gconf = mail_config_get_gconf_client ();
hide_deleted = !gconf_client_get_bool (gconf, "/apps/evolution/mail/display/show_deleted", NULL);
- message_list->hidedeleted = hide_deleted && !(folder->folder_flags & CAMEL_FOLDER_IS_TRASH);
+ message_list->hidedeleted = hide_deleted && (!(folder->folder_flags & CAMEL_FOLDER_IS_TRASH) || !(folder_store->flags & CAMEL_STORE_VTRASH));
message_list->hidejunk = folder_store_supports_vjunk_folder (message_list->folder) && !(folder->folder_flags & CAMEL_FOLDER_IS_JUNK) && !(folder->folder_flags & CAMEL_FOLDER_IS_TRASH);
if (message_list->frozen == 0)