diff options
author | Milan Crha <mcrha@redhat.com> | 2008-06-09 18:50:54 +0800 |
---|---|---|
committer | Milan Crha <mcrha@src.gnome.org> | 2008-06-09 18:50:54 +0800 |
commit | f1cfc8c031380ebd6f4c5fcd681ba1cc4e77f967 (patch) | |
tree | efb82364d33cceaa2a990582de1b1c3b4b652fc7 | |
parent | 7d4f83689a512f3af1a4002a1567ffbb2762ebb9 (diff) | |
download | gsoc2013-evolution-f1cfc8c031380ebd6f4c5fcd681ba1cc4e77f967.tar.gz gsoc2013-evolution-f1cfc8c031380ebd6f4c5fcd681ba1cc4e77f967.tar.zst gsoc2013-evolution-f1cfc8c031380ebd6f4c5fcd681ba1cc4e77f967.zip |
** Fix for bug #201011
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.
svn path=/trunk/; revision=35620
-rw-r--r-- | filter/ChangeLog | 14 | ||||
-rw-r--r-- | filter/filter-rule.c | 17 | ||||
-rw-r--r-- | filter/filter-rule.h | 2 | ||||
-rw-r--r-- | filter/rule-editor.c | 47 | ||||
-rw-r--r-- | mail/ChangeLog | 8 | ||||
-rw-r--r-- | mail/em-filter-editor.c | 5 | ||||
-rw-r--r-- | mail/mail-session.c | 4 |
7 files changed, 92 insertions, 5 deletions
diff --git a/filter/ChangeLog b/filter/ChangeLog index 32e27840e1..269362e0d3 100644 --- a/filter/ChangeLog +++ b/filter/ChangeLog @@ -1,3 +1,17 @@ +2008-06-09 Milan Crha <mcrha@redhat.com> + + ** Fix for bug #201011 + + * filter-rule.h: (struct _FilterRule): New property 'enabled' + to be able to disable filter rules. + * filter-rule.c: (filter_rule_init), (rule_eq), (xml_encode), + (xml_decode), (rule_copy): Store/restore/use 'enabled' value. + * rule-editor.c: (add_editor_response), (rule_move), (set_source): + Set the 'enabled' column properly. + * 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. + 2008-06-03 Kjartan Maraas <kmaraas@gnome.org> * filter-part.c: (main): gtk_window_set_policy -> diff --git a/filter/filter-rule.c b/filter/filter-rule.c index 2dfb0b7fd6..4d5d76505c 100644 --- a/filter/filter-rule.c +++ b/filter/filter-rule.c @@ -121,6 +121,7 @@ static void filter_rule_init (FilterRule *fr) { fr->priv = g_malloc0 (sizeof (*fr->priv)); + fr->enabled = TRUE; } static void @@ -258,7 +259,8 @@ list_eq(GList *al, GList *bl) 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 @@ xml_encode (FilterRule *fr) 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 @@ xml_decode (FilterRule *fr, xmlNodePtr node, RuleContext *f) 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 @@ rule_copy (FilterRule *dest, FilterRule *src) { GList *node; + dest->enabled = src->enabled; + g_free (dest->name); dest->name = g_strdup (src->name); diff --git a/filter/filter-rule.h b/filter/filter-rule.h index 19c3f0941a..924bf44459 100644 --- a/filter/filter-rule.h +++ b/filter/filter-rule.h @@ -72,6 +72,8 @@ struct _FilterRule { unsigned int system:1; /* this is a system rule, cannot be edited/deleted */ GList *parts; + + gboolean enabled; }; struct _FilterRuleClass { diff --git a/filter/rule-editor.c b/filter/rule-editor.c index cc60d4fa8a..40f045dbf9 100644 --- a/filter/rule-editor.c +++ b/filter/rule-editor.c @@ -338,7 +338,7 @@ add_editor_response (GtkWidget *dialog, int button, RuleEditor *re) 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 @@ rule_move (RuleEditor *re, int from, int to) 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 @@ set_source (RuleEditor *re, const char *source) 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 @@ set_source (RuleEditor *re, const char *source) 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 @@ rule_editor_treeview_new (char *widget_name, char *string1, char *string2, int i 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, diff --git a/mail/ChangeLog b/mail/ChangeLog index fa13c0f0a4..5a1331c77c 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,5 +1,13 @@ 2008-06-09 Milan Crha <mcrha@redhat.com> + ** Fix for bug #201011 + + * em-filter-editor.c: (em_filter_editor_construct): + Show Enabled column in the editor, because we support it here. + * mail-session.c: (main_get_filter_driver): Skip disabled rules. + +2008-06-09 Milan Crha <mcrha@redhat.com> + ** Fix for bug #536772 * em-folder-browser.c: (EMFolderViewEnable emfb_enable_map): diff --git a/mail/em-filter-editor.c b/mail/em-filter-editor.c index 599d5674e1..20bf0836bc 100644 --- a/mail/em-filter-editor.c +++ b/mail/em-filter-editor.c @@ -137,6 +137,7 @@ em_filter_editor_construct (EMFilterEditor *fe, EMFilterContext *fc, GladeXML *g { 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 @@ em_filter_editor_construct (EMFilterEditor *fe, EMFilterContext *fc, GladeXML *g 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 * diff --git a/mail/mail-session.c b/mail/mail-session.c index 0a8af8e023..a371101946 100644 --- a/mail/mail-session.c +++ b/mail/mail-session.c @@ -548,6 +548,10 @@ main_get_filter_driver (CamelSession *session, const char *type, CamelException 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); |