[evolution] Bug #309945 - Ability to filter folders other than INBOX too



commit 5483b65b5e2212383b4ecf9a8fe9ef958ef582ad
Author: Milan Crha <mcrha redhat com>
Date:   Tue Feb 7 12:57:29 2012 +0100

    Bug #309945 - Ability to filter folders other than INBOX too

 mail/em-account-editor.c    |   45 ++++++++++++++++++++++---------------------
 mail/em-folder-properties.c |   20 +++++++++++++++++++
 2 files changed, 43 insertions(+), 22 deletions(-)
---
diff --git a/mail/em-account-editor.c b/mail/em-account-editor.c
index 6b54c2a..b2759f3 100644
--- a/mail/em-account-editor.c
+++ b/mail/em-account-editor.c
@@ -3136,6 +3136,26 @@ emae_receive_page (EConfig *ec,
 	return w;
 }
 
+static void
+emae_set_option_dependency (EMAccountEditorService *service,
+			    CamelProviderConfEntry *conf,
+			    GtkWidget *widget)
+{
+	if (conf->depname != NULL) {
+		const gchar *depname = conf->depname;
+
+		if (*depname == '!')
+			depname++;
+
+		g_object_bind_property (
+			service->settings, depname,
+			widget, "sensitive",
+			G_BINDING_SYNC_CREATE |
+			(depname == conf->depname ? 0 : G_BINDING_INVERT_BOOLEAN));
+		gtk_widget_set_margin_left (widget, INDENT_MARGIN);
+	}
+}
+
 static GtkWidget *
 emae_option_toggle (EMAccountEditorService *service,
                     CamelProviderConfEntry *conf)
@@ -3150,13 +3170,7 @@ emae_option_toggle (EMAccountEditorService *service,
 		G_BINDING_BIDIRECTIONAL |
 		G_BINDING_SYNC_CREATE);
 
-	if (conf->depname != NULL) {
-		g_object_bind_property (
-			service->settings, conf->depname,
-			widget, "sensitive",
-			G_BINDING_SYNC_CREATE);
-		gtk_widget_set_margin_left (widget, INDENT_MARGIN);
-	}
+	emae_set_option_dependency (service, conf, widget);
 
 	return widget;
 }
@@ -3177,14 +3191,7 @@ emae_option_entry (EMAccountEditorService *service,
 		G_BINDING_BIDIRECTIONAL |
 		G_BINDING_SYNC_CREATE);
 
-	if (conf->depname != NULL) {
-		g_object_bind_property (
-			service->settings, conf->depname,
-			widget, "sensitive",
-			G_BINDING_SYNC_CREATE);
-		gtk_widget_set_margin_left (
-			GTK_WIDGET (label_for_mnemonic), INDENT_MARGIN);
-	}
+	emae_set_option_dependency (service, conf, widget);
 
 	g_object_bind_property (
 		widget, "sensitive",
@@ -3353,13 +3360,7 @@ emae_option_checkspin (EMAccountEditorService *service,
 		gtk_widget_show (label);
 	}
 
-	if (conf->depname != NULL) {
-		g_object_bind_property (
-			service->settings, conf->depname,
-			hbox, "sensitive",
-			G_BINDING_SYNC_CREATE);
-		gtk_widget_set_margin_left (hbox, INDENT_MARGIN);
-	}
+	emae_set_option_dependency (service, conf, hbox);
 
 	return hbox;
 }
diff --git a/mail/em-folder-properties.c b/mail/em-folder-properties.c
index 2abb1f3..5bd75cf 100644
--- a/mail/em-folder-properties.c
+++ b/mail/em-folder-properties.c
@@ -126,6 +126,7 @@ emfp_get_folder_item (EConfig *ec,
 	AsyncContext *context = data;
 	guint ii, n_properties;
 	gint row = 0;
+	gboolean can_apply_filters = FALSE;
 
 	if (old)
 		return old;
@@ -188,6 +189,21 @@ emfp_get_folder_item (EConfig *ec,
 		}
 	}
 
+	if (context->folder) {
+		CamelStore *store;
+		CamelSession *session;
+		CamelFolderInfoFlags fi_flags = 0;
+		MailFolderCache *folder_cache;
+
+		store = camel_folder_get_parent_store (context->folder);
+		session = camel_service_get_session (CAMEL_SERVICE (store));
+		folder_cache = e_mail_session_get_folder_cache (E_MAIL_SESSION (session));
+
+		can_apply_filters = !CAMEL_IS_VEE_FOLDER (context->folder) &&
+			mail_folder_cache_get_folder_info_flags (folder_cache, context->folder, &fi_flags) &&
+			(fi_flags & CAMEL_FOLDER_TYPE_MASK) != CAMEL_FOLDER_TYPE_INBOX;
+	}
+
 	class = G_OBJECT_GET_CLASS (context->folder);
 	properties = g_object_class_list_properties (class, &n_properties);
 
@@ -197,6 +213,10 @@ emfp_get_folder_item (EConfig *ec,
 		if ((properties[ii]->flags & CAMEL_PARAM_PERSISTENT) == 0)
 			continue;
 
+		if (!can_apply_filters &&
+		    g_strcmp0 (properties[ii]->name, "apply-filters") == 0)
+			continue;
+
 		blurb = g_param_spec_get_blurb (properties[ii]);
 
 		switch (properties[ii]->value_type) {



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