static int GFD_Ok(GGadget *g, GEvent *e) { if ( e->type==et_controlevent && e->u.control.subtype == et_buttonactivate ) { struct gfc_data *d = GDrawGetUserData(GGadgetGetWindow(g)); GGadget *tf; GFileChooserGetChildren(d->gfc,NULL,NULL,&tf); if ( *_GGadgetGetTitle(tf)!='\0' ) { extern int allow_utf8_glyphnames; GTextInfo *ti = GGadgetGetListItemSelected(d->rename); char *nlname = u2utf8_copy(ti->text); force_names_when_opening = NameListByName(nlname); free(nlname); if ( force_names_when_opening!=NULL && force_names_when_opening->uses_unicode && !allow_utf8_glyphnames) { ff_post_error(_("Namelist contains non-ASCII names"),_("Glyph names should be limited to characters in the ASCII character set, but there are names in this namelist which use characters outside that range.")); return(true); } d->done = true; d->ret = GGadgetGetTitle(d->gfc); // Trim trailing '/' if its there and put that string back as // the d->gfc string. int tmplen = u_strlen( d->ret ); if( tmplen > 0 ) { if( d->ret[ tmplen-1 ] == '/' ) { unichar_t* tmp = u_copy( d->ret ); tmp[ tmplen-1 ] = '\0'; GGadgetSetTitle(d->gfc, tmp); free(tmp); d->ret = GGadgetGetTitle(d->gfc); } } } } return( true ); }
static int NOUI_SetPrefs(char *name,Val *val1, Val *val2) { int i,j; for ( i=0; prefs_list[i]!=NULL; ++i ) for ( j=0; prefs_list[i][j].name!=NULL; ++j ) { if ( strcmp(prefs_list[i][j].name,name)==0 ) { struct prefs_list *pf = &prefs_list[i][j]; if ( pf->type == pr_bool || pf->type == pr_int || pf->type == pr_unicode ) { if ( (val1->type!=v_int && val1->type!=v_unicode) || val2!=NULL ) return( -1 ); *((int *) (pf->val)) = val1->u.ival; } else if ( pf->type == pr_real ) { if ( val1->type==v_real && val2==NULL ) *((float *) (pf->val)) = val1->u.fval; else if ( val1->type!=v_int || (val2!=NULL && val2->type!=v_int )) return( -1 ); else *((float *) (pf->val)) = (val2==NULL ? val1->u.ival : val1->u.ival / (double) val2->u.ival); } else if ( pf->type == pr_string || pf->type == pr_file ) { if ( val1->type!=v_str || val2!=NULL ) return( -1 ); if ( pf->set ) { pf->set( val1->u.sval ); } else { free( *((char **) (pf->val))); *((char **) (pf->val)) = copy( val1->u.sval ); } } else if ( pf->type == pr_encoding ) { if ( val2!=NULL ) return( -1 ); else if ( val1->type==v_str && pf->val == &default_encoding) { Encoding *enc = FindOrMakeEncoding(val1->u.sval); if ( enc==NULL ) return( -1 ); *((Encoding **) (pf->val)) = enc; } else return( -1 ); } else if ( pf->type == pr_namelist ) { if ( val2!=NULL ) return( -1 ); else if ( val1->type==v_str ) { NameList *nl = NameListByName(val1->u.sval); if ( strcmp(val1->u.sval,"NULL")==0 && pf->val != &namelist_for_new_fonts ) nl = NULL; else if ( nl==NULL ) return( -1 ); *((NameList **) (pf->val)) = nl; } else return( -1 ); } else return( false ); SavePrefs(true); return( true ); } } return( false ); }