+ int apply_sensitive = 1;
+ if(users_mode == MODE_NONE)
+ apply_sensitive = 0;
+ else {
+ const char *name = gtk_entry_get_text(GTK_ENTRY(users_details_name));
+ const char *email = gtk_entry_get_text(GTK_ENTRY(users_details_email));
+ const char *pw = gtk_entry_get_text(GTK_ENTRY(users_details_password));
+ const char *pw2 = gtk_entry_get_text(GTK_ENTRY(users_details_password2));
+ /* Username must be filled in */
+ if(!*name) {
+ apply_sensitive = 0;
+ if(!report)
+ report = "Must fill in username";
+ }
+ /* Passwords must be nontrivial and match */
+ if(!*pw) {
+ apply_sensitive = 0;
+ if(!report)
+ report = "Must fill in password";
+ }
+ if(strcmp(pw, pw2)) {
+ apply_sensitive = 0;
+ if(!report)
+ report = "Passwords must match";
+ }
+ /* Email address must be somewhat valid */
+ if(*email) {
+ if(!email_valid(email)) {
+ apply_sensitive = 0;
+ report = "Invalid email address";
+ }
+ }
+ }
+ gtk_widget_set_sensitive(users_apply_button, apply_sensitive);