aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Trowbridge <trow@ximian.com>2001-07-24 10:48:24 +0800
committerJon Trowbridge <trow@src.gnome.org>2001-07-24 10:48:24 +0800
commit19988e2555f80f573fda423f93deddb7b98c79b8 (patch)
treeb02ddf5c1616e5b13005ac1efc6449ffd0e74095
parentb307f4e80d1433022c028aac521e160f5a4a34c4 (diff)
downloadgsoc2013-evolution-19988e2555f80f573fda423f93deddb7b98c79b8.tar.gz
gsoc2013-evolution-19988e2555f80f573fda423f93deddb7b98c79b8.tar.zst
gsoc2013-evolution-19988e2555f80f573fda423f93deddb7b98c79b8.zip
Added a validate function that checks to make sure that vfolders that have
2001-07-23 Jon Trowbridge <trow@ximian.com> * vfolder-rule.c (validate): Added a validate function that checks to make sure that vfolders that have "specific folders" as their source actually have a non-empty list of source folders selected. (Bug #4937) (get_widget): If fr->source is NULL for some reason, bring it into sync with the default in the option menu. svn path=/trunk/; revision=11336
-rw-r--r--filter/ChangeLog9
-rw-r--r--filter/vfolder-rule.c29
-rw-r--r--filter/vfolder-rule.h2
3 files changed, 40 insertions, 0 deletions
diff --git a/filter/ChangeLog b/filter/ChangeLog
index 2a2463717b..57f97dfc0c 100644
--- a/filter/ChangeLog
+++ b/filter/ChangeLog
@@ -1,3 +1,12 @@
+2001-07-23 Jon Trowbridge <trow@ximian.com>
+
+ * vfolder-rule.c (validate): Added a validate function
+ that checks to make sure that vfolders that have "specific
+ folders" as their source actually have a non-empty list of
+ source folders selected. (Bug #4937)
+ (get_widget): If fr->source is NULL for some reason, bring
+ it into sync with the default in the option menu.
+
2001-07-23 Peter Williams <peterw@ximian.com>
* filter-datespec.c (make_span_editor): Change the butt-ugly
diff --git a/filter/vfolder-rule.c b/filter/vfolder-rule.c
index bf1bdc479e..385a751f89 100644
--- a/filter/vfolder-rule.c
+++ b/filter/vfolder-rule.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
/*
* Copyright (C) 2000 Ximian Inc.
*
@@ -26,6 +28,8 @@
#include <gtk/gtkoptionmenu.h>
#include <libgnome/gnome-defs.h>
#include <libgnome/gnome-i18n.h>
+#include <libgnomeui/gnome-dialog.h>
+#include <libgnomeui/gnome-dialog-util.h>
#include <glade/glade.h>
#include <gal/widgets/e-unicode.h>
@@ -35,6 +39,7 @@
#define d(x) x
+static gint validate(FilterRule *);
static xmlNodePtr xml_encode(FilterRule *);
static int xml_decode(FilterRule *, xmlNodePtr, struct _RuleContext *f);
/*static void build_code(FilterRule *, GString *out);*/
@@ -87,6 +92,7 @@ vfolder_rule_class_init (VfolderRuleClass *class)
object_class->finalize = vfolder_rule_finalise;
/* override methods */
+ filter_rule->validate = validate;
filter_rule->xml_encode = xml_encode;
filter_rule->xml_decode = xml_decode;
/*filter_rule->build_code = build_code;*/
@@ -180,6 +186,27 @@ vfolder_rule_next_source (VfolderRule *vr, const char *last)
return NULL;
}
+static gint
+validate (FilterRule *fr)
+{
+ /* We have to have at least one source set in the "specific" case.
+ Do not translate this string! */
+ if (fr && fr->source && !strcmp (fr->source, "specific") && VFOLDER_RULE (fr)->sources == NULL) {
+
+ GtkWidget *gd;
+
+ gd = gnome_ok_dialog (_("Oops. You need to to specify at least one folder as a source."));
+ gnome_dialog_run_and_close (GNOME_DIALOG (gd));
+
+ return 0;
+ }
+
+ if (FILTER_RULE_CLASS (parent_class)->validate)
+ return FILTER_RULE_CLASS (parent_class)->validate (fr);
+
+ return 1;
+}
+
static xmlNodePtr
xml_encode (FilterRule *fr)
{
@@ -409,6 +436,8 @@ get_widget(FilterRule *fr, struct _RuleContext *f)
}
gtk_option_menu_set_history(GTK_OPTION_MENU(w), row);
+ if (fr->source == NULL)
+ filter_rule_set_source (fr, (char *)source_names[row]);
set_sensitive(data);
diff --git a/filter/vfolder-rule.h b/filter/vfolder-rule.h
index 149e6ead76..20dcb6f017 100644
--- a/filter/vfolder-rule.h
+++ b/filter/vfolder-rule.h
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
/*
* Copyright (C) 2000 Ximian Inc.
*