From 494cc008639cfbaef55113d98da76c791770a987 Mon Sep 17 00:00:00 2001 From: Srinivasa Ragavan Date: Mon, 18 Jun 2007 04:54:07 +0000 Subject: ** Fix for bug #263207 svn path=/trunk/; revision=33689 --- filter/ChangeLog | 12 ++++++++++++ filter/filter-rule.c | 5 +++-- filter/rule-editor.c | 19 +++++++++++++++++-- 3 files changed, 32 insertions(+), 4 deletions(-) (limited to 'filter') diff --git a/filter/ChangeLog b/filter/ChangeLog index 1efa3d9345..a1debaee1e 100644 --- a/filter/ChangeLog +++ b/filter/ChangeLog @@ -1,3 +1,15 @@ +2007-06-15 Milan Crha + + ** Fix for bug #263207 + + * filter-rule.c: (validate): No part is not valid. + * filter-rule.c: (less_parts): Can remove all parts. + * rule-editor.c: (dialog_rule_changed): New callback + for disabling OK button in dialog when rule isn't valid. + * rule-editor.c: (rule_add), (rule_edit): + Connecting dialog_rule_changed on "changed" signal of + actual rule. + 2007-06-04 Chenthill Palanisamy * rule-context.c: (new_element): Added a percentage diff --git a/filter/filter-rule.c b/filter/filter-rule.c index 3c0b9be9f6..11fb881472 100644 --- a/filter/filter-rule.c +++ b/filter/filter-rule.c @@ -198,7 +198,7 @@ int filter_rule_validate (FilterRule *fr) { g_assert (IS_FILTER_RULE (fr)); - + return FILTER_RULE_GET_CLASS (fr)->validate (fr); } @@ -220,6 +220,7 @@ validate (FilterRule *fr) /* validate rule parts */ parts = fr->parts; + valid = parts != NULL; while (parts && valid) { valid = filter_part_validate ((FilterPart *) parts->data); parts = parts->next; @@ -693,7 +694,7 @@ less_parts (GtkWidget *button, struct _rule_data *data) FilterPart *part; GtkWidget *rule; - if (g_list_length (data->fr->parts) < 2) + if (g_list_length (data->fr->parts) < 1) return; rule = g_object_get_data ((GObject *) button, "rule"); diff --git a/filter/rule-editor.c b/filter/rule-editor.c index 28e44f862a..cb0cb358c2 100644 --- a/filter/rule-editor.c +++ b/filter/rule-editor.c @@ -50,6 +50,8 @@ static void rule_editor_init (RuleEditor *re); static void rule_editor_finalise (GObject *obj); static void rule_editor_destroy (GtkObject *obj); +static void dialog_rule_changed (FilterRule *fr, GtkWidget *dialog); + #define _PRIVATE(x)(((RuleEditor *)(x))->priv) enum { @@ -385,7 +387,10 @@ rule_add (GtkWidget *widget, RuleEditor *re) g_signal_connect (re->dialog, "response", G_CALLBACK (add_editor_response), re); g_object_weak_ref ((GObject *) re->dialog, (GWeakNotify) editor_destroy, re); - + + g_signal_connect (re->edit, "changed", G_CALLBACK (dialog_rule_changed), re->dialog); + dialog_rule_changed (re->edit, re->dialog); + gtk_widget_set_sensitive (GTK_WIDGET (re), FALSE); gtk_widget_show (re->dialog); @@ -461,7 +466,10 @@ rule_edit (GtkWidget *widget, RuleEditor *re) g_signal_connect (re->dialog, "response", G_CALLBACK (edit_editor_response), re); g_object_weak_ref ((GObject *) re->dialog, (GWeakNotify) editor_destroy, re); - + + g_signal_connect (re->edit, "changed", G_CALLBACK (dialog_rule_changed), re->dialog); + dialog_rule_changed (re->edit, re->dialog); + gtk_widget_set_sensitive (GTK_WIDGET (re), FALSE); gtk_widget_show (re->dialog); @@ -653,6 +661,13 @@ set_sensitive (RuleEditor *re) gtk_widget_set_sensitive (GTK_WIDGET (re->priv->buttons[BUTTON_BOTTOM]), index >= 0 && index < count); } +static void +dialog_rule_changed (FilterRule *fr, GtkWidget *dialog) +{ + g_return_if_fail (dialog != NULL); + + gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, fr && fr->parts); +} static void cursor_changed (GtkTreeView *treeview, RuleEditor *re) -- cgit