Index: src/validation.c
===================================================================
RCS file: /cvs/gnome/gnumeric/src/validation.c,v
retrieving revision 1.5.2.2
diff -u -p -r1.5.2.2 validation.c
--- src/validation.c 2002/02/15 20:25:49 1.5.2.2
+++ src/validation.c 2002/02/23 09:03:43
@@ -122,7 +122,7 @@ validation_eval (WorkbookControl *wbc, M
return VALIDATION_STATUS_VALID;
v = mstyle_get_validation (mstyle);
- g_return_val_if_fail (v != NULL, 1);
+ g_return_val_if_fail (v != NULL, VALIDATION_STATUS_VALID);
if (v->style == VALIDATION_TYPE_ANY)
return VALIDATION_STATUS_VALID;
@@ -153,30 +153,38 @@ validation_eval (WorkbookControl *wbc, M
break;
}
}
+ /* fall through to TYPE_AS_NUMBER case */
case VALIDATION_TYPE_AS_DATE : /* What the hell does this do */
case VALIDATION_TYPE_AS_TIME : /* What the hell does this do */
+ /* dates/times are special cases of numbers */
+#warning TODO: check string format, make sure it is a number?
case VALIDATION_TYPE_AS_NUMBER :
- if (val->type == VALUE_ERROR)
+ switch (val->type) {
+ case VALUE_ERROR:
msg = g_strdup_printf (_("'%s' is an error"),
val->v_err.mesg->str);
- else if (cell->value->type == VALUE_STRING) {
+ break;
+ case VALUE_STRING: {
Value *res = format_match_number (val->v_str.val->str, NULL, NULL);
if (res == NULL) {
char const *fmt;
- /* FIXME what else is needed */
- if (v->type == VALIDATION_TYPE_AS_DATE) {
- fmt = N_("'%s' is not a valid date");
- } else if (v->type == VALIDATION_TYPE_AS_TIME) {
- fmt = N_("'%s' is not a valid time");
- } else
- fmt = N_("'%s' is not a number");
+ fmt = N_("'%s' is not a number");
msg = g_strdup_printf (_(fmt), val->v_str.val->str);
} else
val_expr = expr_tree_new_constant (res);
- } else
+ break;
+ }
+ case VALUE_FLOAT:
+ case VALUE_INTEGER:
val_expr = expr_tree_new_constant (
value_duplicate (cell->value));
+ break;
+ default:
+ /* all others are errors */
+ msg = g_strdup_printf (_("Not a number."));
+ break;
+ }
break;
case VALIDATION_TYPE_IN_LIST :
@@ -200,7 +208,7 @@ validation_eval (WorkbookControl *wbc, M
break;
}
- if (msg == NULL && expr == NULL) {
+ if (msg == NULL && expr == NULL/*not custom*/) {
Operation op;
g_return_val_if_fail (val_expr != NULL, VALIDATION_STATUS_VALID);
@@ -244,8 +252,9 @@ validation_eval (WorkbookControl *wbc, M
return VALIDATION_STATUS_VALID;
}
- if (v->op == VALIDATION_OP_BETWEEN || v->op == VALIDATION_OP_NOT_BETWEEN) {
- g_return_val_if_fail (v->expr[1] != NULL, VALIDATION_STATUS_VALID);
+ if ((valid && v->op == VALIDATION_OP_BETWEEN) || v->op == VALIDATION_OP_NOT_BETWEEN) {
+ if (v->expr [1] == NULL)
+ return VALIDATION_STATUS_VALID;
expr_tree_ref (v->expr[1]);
expr = expr_tree_new_binary (val_expr,
@@ -259,10 +268,11 @@ validation_eval (WorkbookControl *wbc, M
return VALIDATION_STATUS_VALID;
}
}
+ /* condition was not valid. */
expr_str = expr_tree_as_string (expr,
parse_pos_init_evalpos (&pp, &ep));
- msg = g_strdup_printf (_("%s is not true."), expr_str);
+ msg = g_strdup_printf (_("The validation condition %s is not satified."), expr_str);
g_free (expr_str);
}
}
Index: src/dialogs/cell-format.glade
===================================================================
RCS file: /cvs/gnome/gnumeric/src/dialogs/cell-format.glade,v
retrieving revision 1.46.2.1
diff -u -p -r1.46.2.1 cell-format.glade
--- src/dialogs/cell-format.glade 2002/02/19 00:27:24 1.46.2.1
+++ src/dialogs/cell-format.glade 2002/02/23 09:03:43
@@ -3454,7 +3453,7 @@ Custom
validation_operator
True
min <= val <= max (between)
-val <= min || max <= val (not between)
+val < min or max < val (not between)
val == bound (equal to)
val != bound (not equal to)
val > bound (greater than)
Index: src/dialogs/dialog-cell-format.c
===================================================================
RCS file: /cvs/gnome/gnumeric/src/dialogs/dialog-cell-format.c,v
retrieving revision 1.195
diff -u -p -r1.195 dialog-cell-format.c
--- src/dialogs/dialog-cell-format.c 2002/01/12 08:07:01 1.195
+++ src/dialogs/dialog-cell-format.c 2002/02/23 09:03:44
@@ -2171,8 +2195,12 @@ static void
fmt_dialog_init_validation_expr_entry (FormatState *state, ExprEntry *entry,
char const *name, int i)
{
+ GnumericExprEntryFlags flags;
entry->name = GTK_LABEL (glade_xml_get_widget (state->gui, name));
entry->entry = GNUMERIC_EXPR_ENTRY (gnumeric_expr_entry_new (state->wbcg));
+ flags = GNUM_EE_ABS_ROW | GNUM_EE_ABS_COL | GNUM_EE_SHEET_OPTIONAL;
+ gnumeric_expr_entry_set_flags (entry->entry,
+ flags, flags | GNUM_EE_SINGLE_RANGE);
gtk_table_attach (state->validation.criteria_table,
GTK_WIDGET (entry->entry),
1, 3, 2+i, 3+i, GTK_EXPAND | GTK_FILL, 0, 0, 0);
@@ -2362,18 +2395,10 @@ cb_fmt_dialog_set_focus (GtkWidget *wind
if (state->validation.changed)
validation_rebuild_validation (state);
- if (IS_GNUMERIC_EXPR_ENTRY (focus_widget)) {
- GnumericExprEntryFlags flags;
-
+ if (IS_GNUMERIC_EXPR_ENTRY (focus_widget))
wbcg_set_entry (state->wbcg,
GNUMERIC_EXPR_ENTRY (focus_widget));
-
- flags = GNUM_EE_ABS_ROW | GNUM_EE_ABS_COL | GNUM_EE_SHEET_OPTIONAL;
- gnumeric_expr_entry_set_flags (state->validation.expr0.entry,
- flags, flags | GNUM_EE_SINGLE_RANGE);
- gnumeric_expr_entry_set_flags (state->validation.expr1.entry,
- flags, flags | GNUM_EE_SINGLE_RANGE);
- } else
+ else
wbcg_set_entry (state->wbcg, NULL);
}