aboutsummaryrefslogtreecommitdiffstats
path: root/filter
diff options
context:
space:
mode:
Diffstat (limited to 'filter')
-rw-r--r--filter/filter-datespec.c10
-rw-r--r--filter/filter-element.c8
-rw-r--r--filter/filter-element.h4
-rw-r--r--filter/filter-file.c16
-rw-r--r--filter/filter-input.c10
-rw-r--r--filter/filter-part.c4
-rw-r--r--filter/filter-part.h3
-rw-r--r--filter/filter-rule.c18
-rw-r--r--filter/filter-rule.h4
-rw-r--r--filter/rule-context.c4
-rw-r--r--filter/rule-editor.c8
11 files changed, 35 insertions, 54 deletions
diff --git a/filter/filter-datespec.c b/filter/filter-datespec.c
index fcfc877dc0..dcd3078ec1 100644
--- a/filter/filter-datespec.c
+++ b/filter/filter-datespec.c
@@ -45,7 +45,7 @@
#define d(x)
-static gboolean validate (FilterElement *fe);
+static gboolean validate (FilterElement *fe, GtkWindow *error_parent);
static gint date_eq (FilterElement *fe, FilterElement *cm);
static void xml_create (FilterElement *fe, xmlNodePtr node);
static xmlNodePtr xml_encode (FilterElement *fe);
@@ -178,18 +178,14 @@ filter_datespec_new (void)
}
static gboolean
-validate (FilterElement *fe)
+validate (FilterElement *fe, GtkWindow *error_parent)
{
FilterDatespec *fds = (FilterDatespec *) fe;
gboolean valid;
valid = fds->type != FDST_UNKNOWN;
if (!valid) {
- /* FIXME: FilterElement should probably have a
- GtkWidget member pointing to the value gotten with
- ::get_widget() so that we can get the parent window
- here. */
- e_error_run(NULL, "filter:no-date", NULL);
+ e_error_run (error_parent, "filter:no-date", NULL);
}
return valid;
diff --git a/filter/filter-element.c b/filter/filter-element.c
index 7eb898f025..952805e48b 100644
--- a/filter/filter-element.c
+++ b/filter/filter-element.c
@@ -37,7 +37,7 @@ struct _element_type {
gpointer data;
};
-static gboolean validate (FilterElement *fe);
+static gboolean validate (FilterElement *fe, GtkWindow *error_parent);
static gint element_eq(FilterElement *fe, FilterElement *cm);
static void xml_create(FilterElement *fe, xmlNodePtr node);
static FilterElement *clone(FilterElement *fe);
@@ -117,9 +117,9 @@ filter_element_new (void)
}
gboolean
-filter_element_validate (FilterElement *fe)
+filter_element_validate (FilterElement *fe, GtkWindow *error_parent)
{
- return FILTER_ELEMENT_GET_CLASS (fe)->validate (fe);
+ return FILTER_ELEMENT_GET_CLASS (fe)->validate (fe, error_parent);
}
gint
@@ -239,7 +239,7 @@ filter_element_set_data (FilterElement *fe, gpointer data)
/* default implementations */
static gboolean
-validate (FilterElement *fe)
+validate (FilterElement *fe, GtkWindow *error_parent)
{
return TRUE;
}
diff --git a/filter/filter-element.h b/filter/filter-element.h
index 5a78c98980..9bcb3f98df 100644
--- a/filter/filter-element.h
+++ b/filter/filter-element.h
@@ -53,7 +53,7 @@ struct _FilterElementClass {
GObjectClass parent_class;
/* virtual methods */
- gboolean (*validate) (FilterElement *fe);
+ gboolean (*validate) (FilterElement *fe, GtkWindow *error_parent);
gint (*eq) (FilterElement *fe, FilterElement *cm);
void (*xml_create) (FilterElement *, xmlNodePtr);
@@ -76,7 +76,7 @@ FilterElement *filter_element_new (void);
void filter_element_set_data (FilterElement *fe, gpointer data);
/* methods */
-gboolean filter_element_validate (FilterElement *fe);
+gboolean filter_element_validate (FilterElement *fe, GtkWindow *error_parent);
gint filter_element_eq (FilterElement *fe, FilterElement *cm);
void filter_element_xml_create (FilterElement *fe, xmlNodePtr node);
diff --git a/filter/filter-file.c b/filter/filter-file.c
index 72d7bac458..b541022554 100644
--- a/filter/filter-file.c
+++ b/filter/filter-file.c
@@ -37,7 +37,7 @@
#define d(x)
-static gboolean validate (FilterElement *fe);
+static gboolean validate (FilterElement *fe, GtkWindow *error_parent);
static gint file_eq (FilterElement *fe, FilterElement *cm);
static void xml_create (FilterElement *fe, xmlNodePtr node);
static xmlNodePtr xml_encode (FilterElement *fe);
@@ -146,16 +146,12 @@ filter_file_set_path (FilterFile *file, const gchar *path)
}
static gboolean
-validate (FilterElement *fe)
+validate (FilterElement *fe, GtkWindow *error_parent)
{
FilterFile *file = (FilterFile *) fe;
if (!file->path) {
- /* FIXME: FilterElement should probably have a
- GtkWidget member pointing to the value gotten with
- ::get_widget() so that we can get the parent window
- here. */
- e_error_run(NULL, "filter:no-file", NULL);
+ e_error_run (error_parent, "filter:no-file", NULL);
return FALSE;
}
@@ -164,11 +160,7 @@ validate (FilterElement *fe)
if (strcmp (file->type, "file") == 0) {
if (!g_file_test (file->path, G_FILE_TEST_IS_REGULAR)) {
- /* FIXME: FilterElement should probably have a
- GtkWidget member pointing to the value gotten with
- ::get_widget() so that we can get the parent window
- here. */
- e_error_run(NULL, "filter:bad-file", file->path, NULL);
+ e_error_run (error_parent, "filter:bad-file", file->path, NULL);
return FALSE;
}
diff --git a/filter/filter-input.c b/filter/filter-input.c
index ad22dd6846..31f74d991f 100644
--- a/filter/filter-input.c
+++ b/filter/filter-input.c
@@ -38,7 +38,7 @@
#define d(x)
-static gboolean validate (FilterElement *fe);
+static gboolean validate (FilterElement *fe, GtkWindow *error_parent);
static gint input_eq (FilterElement *fe, FilterElement *cm);
static void xml_create (FilterElement *fe, xmlNodePtr node);
static xmlNodePtr xml_encode (FilterElement *fe);
@@ -160,7 +160,7 @@ filter_input_set_value (FilterInput *fi, const gchar *value)
}
static gboolean
-validate (FilterElement *fe)
+validate (FilterElement *fe, GtkWindow *error_parent)
{
FilterInput *fi = (FilterInput *)fe;
gboolean valid = TRUE;
@@ -182,11 +182,7 @@ validate (FilterElement *fe)
regmsg = g_malloc0 (reglen + 1);
regerror (regerr, &regexpat, regmsg, reglen);
- /* FIXME: FilterElement should probably have a
- GtkWidget member pointing to the value gotten with
- ::get_widget() so that we can get the parent window
- here. */
- e_error_run(NULL, "filter:bad-regexp", pattern, regmsg, NULL);
+ e_error_run (error_parent, "filter:bad-regexp", pattern, regmsg, NULL);
g_free (regmsg);
valid = FALSE;
diff --git a/filter/filter-part.c b/filter/filter-part.c
index 2e74f9c926..d59796a2cc 100644
--- a/filter/filter-part.c
+++ b/filter/filter-part.c
@@ -117,7 +117,7 @@ filter_part_new (void)
}
gboolean
-filter_part_validate (FilterPart *fp)
+filter_part_validate (FilterPart *fp, GtkWindow *error_parent)
{
gboolean correct = TRUE;
GList *l;
@@ -126,7 +126,7 @@ filter_part_validate (FilterPart *fp)
while (l && correct) {
FilterElement *fe = l->data;
- correct = filter_element_validate (fe);
+ correct = filter_element_validate (fe, error_parent);
l = l->next;
}
diff --git a/filter/filter-part.h b/filter/filter-part.h
index 10337b95df..10e58979e7 100644
--- a/filter/filter-part.h
+++ b/filter/filter-part.h
@@ -26,6 +26,7 @@
#include <glib.h>
#include <glib-object.h>
+#include <gtk/gtk.h>
#include "filter-input.h"
@@ -63,7 +64,7 @@ GType filter_part_get_type (void);
FilterPart *filter_part_new (void);
/* methods */
-gboolean filter_part_validate (FilterPart *fp);
+gboolean filter_part_validate (FilterPart *fp, GtkWindow *error_parent);
gint filter_part_eq (FilterPart *fp, FilterPart *fc);
gint filter_part_xml_create (FilterPart *ff, xmlNodePtr node, struct _RuleContext *rc);
diff --git a/filter/filter-rule.c b/filter/filter-rule.c
index 8c4d2bbffd..28cf83cb8a 100644
--- a/filter/filter-rule.c
+++ b/filter/filter-rule.c
@@ -36,7 +36,7 @@
#define d(x)
-static gint validate(FilterRule *);
+static gint validate(FilterRule *, GtkWindow *error_parent);
static gint rule_eq(FilterRule *fr, FilterRule *cm);
static xmlNodePtr xml_encode (FilterRule *);
static gint xml_decode (FilterRule *, xmlNodePtr, RuleContext *);
@@ -196,25 +196,21 @@ filter_rule_set_source (FilterRule *fr, const gchar *source)
}
gint
-filter_rule_validate (FilterRule *fr)
+filter_rule_validate (FilterRule *fr, GtkWindow *error_parent)
{
g_return_val_if_fail (IS_FILTER_RULE (fr), 0);
- return FILTER_RULE_GET_CLASS (fr)->validate (fr);
+ return FILTER_RULE_GET_CLASS (fr)->validate (fr, error_parent);
}
static gint
-validate (FilterRule *fr)
+validate (FilterRule *fr, GtkWindow *error_parent)
{
gint valid = TRUE;
GList *parts;
if (!fr->name || !*fr->name) {
- /* FIXME: FilterElement should probably have a
- GtkWidget member pointing to the value gotten with
- ::get_widget() so that we can get the parent window
- here. */
- e_error_run(NULL, "filter:no-name", NULL);
+ e_error_run (error_parent, "filter:no-name", NULL);
return FALSE;
}
@@ -223,7 +219,7 @@ validate (FilterRule *fr)
parts = fr->parts;
valid = parts != NULL;
while (parts && valid) {
- valid = filter_part_validate ((FilterPart *) parts->data);
+ valid = filter_part_validate ((FilterPart *) parts->data, error_parent);
parts = parts->next;
}
@@ -780,7 +776,7 @@ more_parts (GtkWidget *button, struct _rule_data *data)
l = g_list_last (data->fr->parts);
part = l->data;
- if (!filter_part_validate (part))
+ if (!filter_part_validate (part, GTK_WINDOW (gtk_widget_get_toplevel (button))))
return;
}
diff --git a/filter/filter-rule.h b/filter/filter-rule.h
index 94e80695bd..113026fce9 100644
--- a/filter/filter-rule.h
+++ b/filter/filter-rule.h
@@ -81,7 +81,7 @@ struct _FilterRuleClass {
GObjectClass parent_class;
/* virtual methods */
- gint (*validate) (FilterRule *);
+ gint (*validate) (FilterRule *, GtkWindow *error_parent);
gint (*eq) (FilterRule *fr, FilterRule *cm);
xmlNodePtr (*xml_encode) (FilterRule *);
@@ -106,7 +106,7 @@ FilterRule *filter_rule_clone (FilterRule *base);
void filter_rule_set_name (FilterRule *fr, const gchar *name);
void filter_rule_set_source (FilterRule *fr, const gchar *source);
-gint filter_rule_validate (FilterRule *fr);
+gint filter_rule_validate (FilterRule *fr, GtkWindow *error_parent);
gint filter_rule_eq (FilterRule *fr, FilterRule *cm);
xmlNodePtr filter_rule_xml_encode (FilterRule *fr);
diff --git a/filter/rule-context.c b/filter/rule-context.c
index b6e7df47de..45f495e37e 100644
--- a/filter/rule-context.c
+++ b/filter/rule-context.c
@@ -685,13 +685,13 @@ new_rule_response(GtkWidget *dialog, gint button, RuleContext *context)
FilterRule *rule = g_object_get_data((GObject *) dialog, "rule");
gchar *user = g_object_get_data((GObject *) dialog, "path");
- if (!filter_rule_validate(rule)) {
+ if (!filter_rule_validate (rule, GTK_WINDOW (dialog))) {
/* no need to popup a dialog because the validate code does that. */
return;
}
if (rule_context_find_rule (context, rule->name, rule->source)) {
- e_error_run((GtkWindow *)dialog, "filter:bad-name-notunique", rule->name, NULL);
+ e_error_run ((GtkWindow *)dialog, "filter:bad-name-notunique", rule->name, NULL);
return;
}
diff --git a/filter/rule-editor.c b/filter/rule-editor.c
index 7a9335990f..edda65e116 100644
--- a/filter/rule-editor.c
+++ b/filter/rule-editor.c
@@ -326,13 +326,13 @@ add_editor_response (GtkWidget *dialog, gint button, RuleEditor *re)
GtkTreeIter iter;
if (button == GTK_RESPONSE_OK) {
- if (!filter_rule_validate (re->edit)) {
+ if (!filter_rule_validate (re->edit, GTK_WINDOW (dialog))) {
/* no need to popup a dialog because the validate code does that. */
return;
}
if (rule_context_find_rule (re->context, re->edit->name, re->edit->source)) {
- e_error_run((GtkWindow *)dialog, "filter:bad-name-notunique", re->edit->name, NULL);
+ e_error_run ((GtkWindow *)dialog, "filter:bad-name-notunique", re->edit->name, NULL);
return;
}
@@ -408,14 +408,14 @@ edit_editor_response (GtkWidget *dialog, gint button, RuleEditor *re)
gint pos;
if (button == GTK_RESPONSE_OK) {
- if (!filter_rule_validate (re->edit)) {
+ if (!filter_rule_validate (re->edit, GTK_WINDOW (dialog))) {
/* no need to popup a dialog because the validate code does that. */
return;
}
rule = rule_context_find_rule (re->context, re->edit->name, re->edit->source);
if (rule != NULL && rule != re->current) {
- e_error_run((GtkWindow *)dialog, "filter:bad-name-notunique", rule->name, NULL);
+ e_error_run ((GtkWindow *)dialog, "filter:bad-name-notunique", rule->name, NULL);
return;
}