evolution r35620 - in trunk: filter mail
- From: mcrha svn gnome org
- To: svn-commits-list gnome org
- Subject: evolution r35620 - in trunk: filter mail
- Date: Mon, 9 Jun 2008 10:50:54 +0000 (UTC)
Author: mcrha
Date: Mon Jun 9 10:50:54 2008
New Revision: 35620
URL: http://svn.gnome.org/viewvc/evolution?rev=35620&view=rev
Log:
2008-06-09 Milan Crha <mcrha redhat com>
** Fix for bug #201011
* filter/filter-rule.h: (struct _FilterRule): New property 'enabled'
to be able to disable filter rules.
* filter/filter-rule.c: (filter_rule_init), (rule_eq), (xml_encode),
(xml_decode), (rule_copy): Store/restore/use 'enabled' value.
* filter/rule-editor.c: (add_editor_response), (rule_move), (set_source):
Set the 'enabled' column properly.
* filter/rule-editor.c: (rule_able_toggled), (rule_editor_treeview_new):
Add column "Enabled" to the tree, but have it hidden by default, only
those whom supports it can show it.
* mail/em-filter-editor.c: (em_filter_editor_construct):
Show Enabled column in the editor, because we support it here.
* mail/mail-session.c: (main_get_filter_driver): Skip disabled rules.
Modified:
trunk/filter/ChangeLog
trunk/filter/filter-rule.c
trunk/filter/filter-rule.h
trunk/filter/rule-editor.c
trunk/mail/ChangeLog
trunk/mail/em-filter-editor.c
trunk/mail/mail-session.c
Modified: trunk/filter/filter-rule.c
==============================================================================
--- trunk/filter/filter-rule.c (original)
+++ trunk/filter/filter-rule.c Mon Jun 9 10:50:54 2008
@@ -121,6 +121,7 @@
filter_rule_init (FilterRule *fr)
{
fr->priv = g_malloc0 (sizeof (*fr->priv));
+ fr->enabled = TRUE;
}
static void
@@ -258,7 +259,8 @@
static int
rule_eq (FilterRule *fr, FilterRule *cm)
{
- return fr->grouping == cm->grouping
+ return fr->enabled == cm->enabled
+ && fr->grouping == cm->grouping
&& fr->threading == fr->threading
&& ((fr->name && cm->name && strcmp (fr->name, cm->name) == 0)
|| (fr->name == NULL && cm->name == NULL))
@@ -282,6 +284,9 @@
GList *l;
node = xmlNewNode (NULL, (const unsigned char *)"rule");
+
+ xmlSetProp (node, (const unsigned char *)"enabled", (const unsigned char *)(fr->enabled ? "true" : "false"));
+
switch (fr->grouping) {
case FILTER_GROUP_ALL:
xmlSetProp (node, (const unsigned char *)"grouping", (const unsigned char *)"all");
@@ -390,6 +395,14 @@
fr->name = NULL;
}
+ grouping = (char *)xmlGetProp (node, (const unsigned char *)"enabled");
+ if (!grouping)
+ fr->enabled = TRUE;
+ else {
+ fr->enabled = strcmp (grouping, "false") != 0;
+ xmlFree (grouping);
+ }
+
grouping = (char *)xmlGetProp (node, (const unsigned char *)"grouping");
if (!strcmp (grouping, "any"))
fr->grouping = FILTER_GROUP_ANY;
@@ -447,6 +460,8 @@
{
GList *node;
+ dest->enabled = src->enabled;
+
g_free (dest->name);
dest->name = g_strdup (src->name);
Modified: trunk/filter/filter-rule.h
==============================================================================
--- trunk/filter/filter-rule.h (original)
+++ trunk/filter/filter-rule.h Mon Jun 9 10:50:54 2008
@@ -72,6 +72,8 @@
unsigned int system:1; /* this is a system rule, cannot be edited/deleted */
GList *parts;
+
+ gboolean enabled;
};
struct _FilterRuleClass {
Modified: trunk/filter/rule-editor.c
==============================================================================
--- trunk/filter/rule-editor.c (original)
+++ trunk/filter/rule-editor.c Mon Jun 9 10:50:54 2008
@@ -338,7 +338,7 @@
g_object_ref (re->edit);
gtk_list_store_append (re->model, &iter);
- gtk_list_store_set (re->model, &iter, 0, re->edit->name, 1, re->edit, -1);
+ gtk_list_store_set (re->model, &iter, 0, re->edit->name, 1, re->edit, 2, re->edit->enabled, -1);
selection = gtk_tree_view_get_selection (re->list);
gtk_tree_selection_select_iter (selection, &iter);
@@ -557,7 +557,7 @@
gtk_list_store_insert (re->model, &iter, to);
/* set the data on the row */
- gtk_list_store_set (re->model, &iter, 0, rule->name, 1, rule, -1);
+ gtk_list_store_set (re->model, &iter, 0, rule->name, 1, rule, 2, rule->enabled, -1);
/* select the row */
selection = gtk_tree_view_get_selection (re->list);
@@ -713,7 +713,7 @@
while ((rule = rule_context_next_rule (re->context, rule, source)) != NULL) {
d(printf("Adding row '%s'\n", rule->name));
gtk_list_store_append (re->model, &iter);
- gtk_list_store_set (re->model, &iter, 0, rule->name, 1, rule, -1);
+ gtk_list_store_set (re->model, &iter, 0, rule->name, 1, rule, 2, rule->enabled, -1);
}
g_free (re->source);
@@ -722,6 +722,33 @@
rule_editor_set_sensitive (re);
}
+static void
+rule_able_toggled (GtkCellRendererToggle *renderer, char *arg1, gpointer user_data)
+{
+ GtkWidget *table = user_data;
+ GtkTreeSelection *selection;
+ GtkTreeModel *model;
+ GtkTreePath *path;
+ GtkTreeIter iter;
+
+ path = gtk_tree_path_new_from_string (arg1);
+ model = gtk_tree_view_get_model (GTK_TREE_VIEW (table));
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (table));
+
+ if (gtk_tree_model_get_iter (model, &iter, path)) {
+ FilterRule *rule = NULL;
+
+ gtk_tree_model_get (model, &iter, 1, &rule, -1);
+
+ if (rule) {
+ rule->enabled = !rule->enabled;
+ gtk_list_store_set (GTK_LIST_STORE (model), &iter, 2, rule->enabled, -1);
+ }
+ }
+
+ gtk_tree_path_free (path);
+}
+
GtkWidget *rule_editor_treeview_new (char *widget_name, char *string1, char *string2,
int int1, int int2);
@@ -732,16 +759,28 @@
GtkTreeSelection *selection;
GtkCellRenderer *renderer;
GtkListStore *model;
+ GtkTreeViewColumn *column;
scrolled = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled), GTK_SHADOW_IN);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- model = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_POINTER);
+ model = gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_BOOLEAN);
table = gtk_tree_view_new_with_model ((GtkTreeModel *) model);
gtk_tree_view_set_headers_visible ((GtkTreeView *) table, FALSE);
+ renderer = gtk_cell_renderer_toggle_new ();
+ g_object_set (G_OBJECT (renderer), "activatable", TRUE, NULL);
+ gtk_tree_view_insert_column_with_attributes ((GtkTreeView *) table, -1,
+ _("Enabled"), renderer,
+ "active", 2, NULL);
+ g_signal_connect (renderer, "toggled", G_CALLBACK (rule_able_toggled), table);
+
+ /* hide enable column by default */
+ column = gtk_tree_view_get_column (GTK_TREE_VIEW (table), 0);
+ gtk_tree_view_column_set_visible (column, FALSE);
+
renderer = gtk_cell_renderer_text_new ();
gtk_tree_view_insert_column_with_attributes ((GtkTreeView *) table, -1,
_("Rule name"), renderer,
Modified: trunk/mail/em-filter-editor.c
==============================================================================
--- trunk/mail/em-filter-editor.c (original)
+++ trunk/mail/em-filter-editor.c Mon Jun 9 10:50:54 2008
@@ -137,6 +137,7 @@
{
GtkWidget *menu, *item, *omenu;
int i;
+ GtkTreeViewColumn *column;
omenu = glade_xml_get_widget (gui, "filter_source");
gtk_option_menu_remove_menu (GTK_OPTION_MENU (omenu));
@@ -153,6 +154,10 @@
gtk_widget_show (omenu);
rule_editor_construct ((RuleEditor *) fe, (RuleContext *) fc, gui, source_names[0].source, _("_Filter Rules"));
+
+ /* Show the Enabled column, we support it here */
+ column = gtk_tree_view_get_column (GTK_TREE_VIEW (RULE_EDITOR (fe)->list), 0);
+ gtk_tree_view_column_set_visible (column, TRUE);
}
static FilterRule *
Modified: trunk/mail/mail-session.c
==============================================================================
--- trunk/mail/mail-session.c (original)
+++ trunk/mail/mail-session.c Mon Jun 9 10:50:54 2008
@@ -548,6 +548,10 @@
g_string_truncate (fsearch, 0);
g_string_truncate (faction, 0);
+ /* skip disabled rules */
+ if (!rule->enabled)
+ continue;
+
filter_rule_build_code (rule, fsearch);
em_filter_rule_build_action ((EMFilterRule *) rule, faction);
camel_filter_driver_add_rule (driver, rule->name, fsearch->str, faction->str);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]