Stores the parsed representation in OUTPUT, which the caller must have
initialized with the given WIDTH (0 for a numeric field, otherwise the
string width). If FORMAT is FMT_A, then OUTPUT_ENCODING must specify the
- correct encoding for OUTPUT (normally obtained via dict_get_encoding()). */
+ correct encoding for OUTPUT (normally obtained via dict_get_encoding()).
+
+ If successful NULL is the return value. Otherwise a string describing
+ the problem is returned. The caller must free this string.
+ */
char *
data_in (struct substring input, const char *input_encoding,
enum fmt_type format,
union value v;
- text_to_value__ (val_text, &dialog->format, dialog->encoding, &v);
-
- val_labs_replace (dialog->labs, &v,
- gtk_entry_get_text (GTK_ENTRY (dialog->label_entry)));
+ if (text_to_value__ (val_text, &dialog->format, dialog->encoding, &v))
+ {
+ val_labs_replace (dialog->labs, &v,
+ gtk_entry_get_text (GTK_ENTRY (dialog->label_entry)));
- gtk_widget_set_sensitive (dialog->change_button, FALSE);
+ gtk_widget_set_sensitive (dialog->change_button, FALSE);
- repopulate_dialog (dialog);
- gtk_widget_grab_focus (dialog->value_entry);
+ repopulate_dialog (dialog);
+ gtk_widget_grab_focus (dialog->value_entry);
- value_destroy (&v, val_labs_get_width (dialog->labs));
+ value_destroy (&v, val_labs_get_width (dialog->labs));
+ }
}
/* Callback which occurs when the "Add" button is clicked */
const gchar *text = gtk_entry_get_text (GTK_ENTRY (dialog->value_entry));
- text_to_value__ (text, &dialog->format, dialog->encoding, &v);
-
- if (val_labs_add (dialog->labs, &v,
- gtk_entry_get_text
- ( GTK_ENTRY (dialog->label_entry)) ) )
+ if (text_to_value__ (text, &dialog->format, dialog->encoding, &v))
{
- gtk_widget_set_sensitive (dialog->add_button, FALSE);
+ if (val_labs_add (dialog->labs, &v,
+ gtk_entry_get_text
+ ( GTK_ENTRY (dialog->label_entry)) ) )
+ {
+ gtk_widget_set_sensitive (dialog->add_button, FALSE);
- repopulate_dialog (dialog);
- gtk_widget_grab_focus (dialog->value_entry);
- }
+ repopulate_dialog (dialog);
+ gtk_widget_grab_focus (dialog->value_entry);
+ }
- value_destroy (&v, val_labs_get_width (dialog->labs));
+ value_destroy (&v, val_labs_get_width (dialog->labs));
+ }
}
/* Callback which occurs when the "Remove" button is clicked */