- if (chars_length == 0) {
- /* A blank space is not valid as first character */
- if (strcmp (text, " ")) {
- GtkWidget *ok_button;
- GList *buttons;
-
- /* Show OK button */
- buttons = gtk_container_get_children (GTK_CONTAINER (GTK_DIALOG (data)->action_area));
- ok_button = GTK_WIDGET (buttons->next->data);
+ gboolean is_valid = FALSE;
+
+ if (!text)
+ is_valid = FALSE;
+ else if (strlen(text) == 0 && g_str_has_prefix (chars, " "))
+ is_valid = FALSE;
+ else
+ is_valid = !g_str_has_prefix(text, " ");
+
+ /* A blank space is not valid as first character */
+ if (is_valid) {
+ GtkWidget *ok_button;
+ GList *buttons;
+
+ /* Show OK button */
+ buttons = gtk_container_get_children (GTK_CONTAINER (GTK_DIALOG (data)->action_area));
+ ok_button = GTK_WIDGET (buttons->next->data);