# HG changeset patch # User albeu # Date 1037104745 0 # Node ID ff6a98628e6c3a7d7e158ea5b325b4494e70b752 # Parent e8832e66babd923284aadd0e30ff479376cf3dc0 Fix the Gui with NEW_CONFIG diff -r e8832e66babd -r ff6a98628e6c Gui/cfg.c --- a/Gui/cfg.c Tue Nov 12 12:33:56 2002 +0000 +++ b/Gui/cfg.c Tue Nov 12 12:39:05 2002 +0000 @@ -156,7 +156,11 @@ // -- read configuration mp_msg( MSGT_GPLAYER,MSGL_STATUS,"[cfg] read config file: %s\n",cfg ); - gui_conf=m_config_new( play_tree_new() ); + gui_conf=m_config_new( +#ifndef NEW_CONFIG + play_tree_new() +#endif + ); m_config_register_options( gui_conf,gui_opts ); if ( m_config_parse_config_file( gui_conf,cfg ) < 0 ) { @@ -221,6 +225,14 @@ { for ( i=0;gui_opts[i].name;i++ ) { +#ifdef NEW_CONFIG + char* v = m_option_print(&gui_opts[i],gui_opts[i].p); + if(v) { + fprintf( f,"%s = \"%s\"\n",gui_opts[i].name, v); + free(v); + } else if((int)v == -1) + mp_msg(MSGT_GPLAYER,MSGL_WARN,"Unable to save the %s option\n"); +#else switch ( gui_opts[i].type ) { case CONF_TYPE_INT: @@ -239,6 +251,7 @@ break; } } +#endif } fclose( f ); } diff -r e8832e66babd -r ff6a98628e6c m_config.h --- a/m_config.h Tue Nov 12 12:33:56 2002 +0000 +++ b/m_config.h Tue Nov 12 12:39:05 2002 +0000 @@ -55,6 +55,9 @@ struct m_option* m_config_get_option(m_config_t *config, char* arg); +void +m_config_print_option_list(m_config_t *config); + ///////////////////////////////////////////////////////////////////////////////////// /////////////////////////// Backward compat. stuff //////////////////////////////// //////////////////////////////////////////////////////////////////////////////////// diff -r e8832e66babd -r ff6a98628e6c m_option.c --- a/m_option.c Tue Nov 12 12:33:56 2002 +0000 +++ b/m_option.c Tue Nov 12 12:39:05 2002 +0000 @@ -315,7 +315,7 @@ } static char* print_str(m_option_t* opt, void* val) { - return (val && VAL(val) && strlen(VAL(val)) > 0) ? strdup(VAL(val)) : strdup("(empty)"); + return (val && VAL(val) && strlen(VAL(val)) > 0) ? strdup(VAL(val)) : NULL; } static void copy_str(m_option_t* opt,void* dst, void* src) { @@ -559,7 +559,23 @@ } static char* print_str_list(m_option_t* opt, void* src) { - return strdup("TODO ;)"); + char **lst = NULL; + char *ret = NULL,*last = NULL; + int i; + + if(!(src && VAL(src))) return NULL; + lst = VAL(src); + + for(i = 0 ; lst[i] ; i++) { + if(last) { + ret = dup_printf("%s,%s",last,lst[i]); + free(last); + } else + ret = strdup(lst[i]); + last = ret; + } + if(last && last != ret) free(last); + return ret; } m_option_type_t m_option_type_string_list = { diff -r e8832e66babd -r ff6a98628e6c m_option.h --- a/m_option.h Tue Nov 12 12:33:56 2002 +0000 +++ b/m_option.h Tue Nov 12 12:39:05 2002 +0000 @@ -190,7 +190,7 @@ if(opt->type->print) return opt->type->print(opt,val_ptr); else - return NULL; + return (char*)-1; } inline static void