Index: src/validation.c =================================================================== RCS file: /cvs/gnome/gnumeric/src/validation.c,v retrieving revision 1.9 diff -u -p -r1.9 validation.c --- src/validation.c 2002/02/15 20:27:35 1.9 +++ src/validation.c 2002/02/20 22:55:52 @@ -123,7 +123,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; @@ -142,6 +142,9 @@ validation_eval (WorkbookControl *wbc, M Value *val = cell->value; switch (v->type) { + case VALIDATION_TYPE_AS_DATE : /* What the hell does this do */ + case VALIDATION_TYPE_AS_TIME : /* What the hell does this do */ +#warning TODO case VALIDATION_TYPE_ANY : return VALIDATION_STATUS_VALID; @@ -149,35 +152,38 @@ validation_eval (WorkbookControl *wbc, M double dummy; if (val->type == VALUE_FLOAT && fabs (modf (cell->value->v_float.val, &dummy)) > 1e-10) { - msg = g_strdup_printf (_("'%f' is not an integer"), + msg = g_strdup_printf (_("'%f' is not a whole number."), cell->value->v_float.val); break; } } - case VALIDATION_TYPE_AS_DATE : /* What the hell does this do */ - case VALIDATION_TYPE_AS_TIME : /* What the hell does this do */ 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); 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 : @@ -201,7 +207,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); @@ -245,8 +251,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, @@ -260,10 +267,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/workbook-control-gui.c =================================================================== RCS file: /cvs/gnome/gnumeric/src/workbook-control-gui.c,v retrieving revision 1.234 diff -u -p -r1.234 workbook-control-gui.c --- src/workbook-control-gui.c 2002/02/18 05:40:39 1.234 +++ src/workbook-control-gui.c 2002/02/20 22:55:52 @@ -426,6 +426,7 @@ delete_sheet_if_possible (GtkWidget *ign g_free (message); gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_NO); response = gtk_dialog_run (GTK_DIALOG (dialog)); + gtk_widget_destroy (dialog); if (response == GTK_RESPONSE_YES) { workbook_sheet_delete (sc->sheet); workbook_recalc_all (wb); @@ -4373,7 +4374,8 @@ wbcg_validation_msg (WorkbookControl *wb gtk_window_set_title (GTK_WINDOW (dialog), title); gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_NO); response = gtk_dialog_run (GTK_DIALOG (dialog)); - return (response != GTK_RESPONSE_NO) ? res1 : res0; + gtk_widget_destroy (dialog); + return (response != GTK_RESPONSE_NO) ? res0 : res1; } static void Index: src/dialogs/cell-format.glade =================================================================== RCS file: /cvs/gnome/gnumeric/src/dialogs/cell-format.glade,v retrieving revision 1.53 diff -u -p -r1.53 cell-format.glade --- src/dialogs/cell-format.glade 2002/02/17 17:36:53 1.53 +++ src/dialogs/cell-format.glade 2002/02/20 22:55:52 @@ -3646,7 +3646,7 @@ - val <= min || max <= val (not between) + val < min or max < val (not between) 0.0 convertwidget40 yes Index: src/dialogs/dialog-cell-format.c =================================================================== RCS file: /cvs/gnome/gnumeric/src/dialogs/dialog-cell-format.c,v retrieving revision 1.203 diff -u -p -r1.203 dialog-cell-format.c --- src/dialogs/dialog-cell-format.c 2002/02/18 21:45:03 1.203 +++ src/dialogs/dialog-cell-format.c 2002/02/20 22:55:52 @@ -1999,21 +1999,30 @@ fmt_dialog_init_protection_page (FormatS /*****************************************************************************/ static void -validation_entry_from_expr (GnumericExprEntry *entry, +validation_entry_from_expr (GnumericExprEntry *gee, ParsePos const *pp, ExprTree const *expr) { + GtkEntry *entry = GTK_ENTRY(gnm_expr_entry_get_entry(gee)); if (expr != NULL) { char *expr_str = expr_tree_as_string (expr, pp); - gtk_entry_set_text (GTK_ENTRY (entry), expr_str); + gtk_entry_set_text (entry, expr_str); g_free (expr_str); } else - gtk_entry_set_text (GTK_ENTRY (entry), ""); + gtk_entry_set_text (entry, ""); } static ExprTree * validation_entry_to_expr (Sheet *sheet, GnumericExprEntry *gee) { + GnumericExprEntryFlags flags; ParsePos pp; + /* The entry is not guaranteed to be focused upon before this + * function is called, thus cb_fmt_dialog_set_focus may not have + * been called and we need to set the expr_entry flags ourselves + * (in particular clearing GNUM_EE_SINGLE_RANGE). */ + flags = GNUM_EE_ABS_ROW | GNUM_EE_ABS_COL | GNUM_EE_SHEET_OPTIONAL; + gnm_expr_entry_set_flags (gee, flags, flags | GNUM_EE_SINGLE_RANGE); + parse_pos_init (&pp, sheet->workbook, sheet, 0, 0); return gnm_expr_entry_parse (gee, &pp, NULL, FALSE); }