aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSrinivasa Ragavan <sragavan@src.gnome.org>2007-06-18 12:54:07 +0800
committerSrinivasa Ragavan <sragavan@src.gnome.org>2007-06-18 12:54:07 +0800
commit494cc008639cfbaef55113d98da76c791770a987 (patch)
treee5470f3b3e1c102dd0608437d3ec68a4a84e8486
parent20f692fb88bfcad5557c2732c41e5b7977ffce21 (diff)
downloadgsoc2013-evolution-494cc008639cfbaef55113d98da76c791770a987.tar.gz
gsoc2013-evolution-494cc008639cfbaef55113d98da76c791770a987.tar.zst
gsoc2013-evolution-494cc008639cfbaef55113d98da76c791770a987.zip
** Fix for bug #263207
svn path=/trunk/; revision=33689
-rw-r--r--filter/ChangeLog12
-rw-r--r--filter/filter-rule.c5
-rw-r--r--filter/rule-editor.c19
-rw-r--r--widgets/misc/ChangeLog10
-rw-r--r--widgets/misc/e-filter-bar.c30
5 files changed, 66 insertions, 10 deletions
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 <mcrha@redhat.com>
+
+ ** 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 <pchenthill@novell.com>
* 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)
diff --git a/widgets/misc/ChangeLog b/widgets/misc/ChangeLog
index 706a3abad2..a3335297e3 100644
--- a/widgets/misc/ChangeLog
+++ b/widgets/misc/ChangeLog
@@ -1,3 +1,13 @@
+2007-06-15 Milan Crha <mcrha@redhat.com>
+
+ ** Fix for bug #263207
+
+ * e-filter-bar.c: (dialog_rule_changed): New callback
+ for disabling OK button in dialog when rule isn't valid.
+ * e-filter-bar.c: (do_advanced), (save_search_dialog):
+ Connecting dialog_rule_changed on "changed" signal of
+ actual rule.
+
2007-06-15 Matthew Barnes <mbarnes@redhat.com>
** Fixes part of bug #447727
diff --git a/widgets/misc/e-filter-bar.c b/widgets/misc/e-filter-bar.c
index e8e0a1d6e3..4e94c27c14 100644
--- a/widgets/misc/e-filter-bar.c
+++ b/widgets/misc/e-filter-bar.c
@@ -145,6 +145,18 @@ rule_advanced_response (GtkWidget *dialog, int response, void *data)
}
static void
+dialog_rule_changed (FilterRule *fr, GtkWidget *dialog)
+{
+ gboolean sensitive;
+
+ g_return_if_fail (dialog != NULL);
+
+ sensitive = fr && fr->parts;
+ gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, sensitive);
+ gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_APPLY, sensitive);
+}
+
+static void
do_advanced (ESearchBar *esb)
{
EFilterBar *efb = (EFilterBar *)esb;
@@ -184,7 +196,10 @@ do_advanced (ESearchBar *esb)
g_object_ref (rule);
g_object_set_data_full ((GObject *) dialog, "rule", rule, (GDestroyNotify) g_object_unref);
-
+
+ g_signal_connect (rule, "changed", G_CALLBACK (dialog_rule_changed), dialog);
+ dialog_rule_changed (rule, dialog);
+
g_signal_connect (dialog, "response", G_CALLBACK (rule_advanced_response), efb);
g_object_weak_ref ((GObject *) dialog, (GWeakNotify) rule_editor_destroyed, efb);
@@ -222,18 +237,21 @@ save_search_dialog (ESearchBar *esb)
gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), 0);
gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->action_area), 12);
-
+
gtk_window_set_default_size (GTK_WINDOW (dialog), 500, 300);
-
+
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), w, TRUE, TRUE, 0);
-
+
g_object_ref (rule);
g_object_set_data_full ((GObject *) dialog, "rule", rule, (GDestroyNotify) g_object_unref);
g_signal_connect (dialog, "response", G_CALLBACK (rule_editor_response), efb);
g_object_weak_ref ((GObject *) dialog, (GWeakNotify) rule_editor_destroyed, efb);
-
+
+ g_signal_connect (rule, "changed", G_CALLBACK (dialog_rule_changed), dialog);
+ dialog_rule_changed (rule, dialog);
+
e_search_bar_set_menu_sensitive (esb, E_FILTERBAR_SAVE_ID, FALSE);
-
+
gtk_widget_show (dialog);
}