Fix the Gui with NEW_CONFIG

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@8169 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
albeu 2002-11-12 12:39:05 +00:00
parent 66f4e56389
commit 20acd250c5
4 changed files with 36 additions and 4 deletions

View File

@ -156,7 +156,11 @@ int cfg_read( void )
// -- read configuration // -- read configuration
mp_msg( MSGT_GPLAYER,MSGL_STATUS,"[cfg] read config file: %s\n",cfg ); 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 ); m_config_register_options( gui_conf,gui_opts );
if ( m_config_parse_config_file( gui_conf,cfg ) < 0 ) if ( m_config_parse_config_file( gui_conf,cfg ) < 0 )
{ {
@ -221,6 +225,14 @@ int cfg_write( void )
{ {
for ( i=0;gui_opts[i].name;i++ ) 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 ) switch ( gui_opts[i].type )
{ {
case CONF_TYPE_INT: case CONF_TYPE_INT:
@ -239,6 +251,7 @@ int cfg_write( void )
break; break;
} }
} }
#endif
} }
fclose( f ); fclose( f );
} }

View File

@ -55,6 +55,9 @@ m_config_check_option(m_config_t *config, char* arg, char* param);
struct m_option* struct m_option*
m_config_get_option(m_config_t *config, char* arg); m_config_get_option(m_config_t *config, char* arg);
void
m_config_print_option_list(m_config_t *config);
///////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////
/////////////////////////// Backward compat. stuff //////////////////////////////// /////////////////////////// Backward compat. stuff ////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////

View File

@ -315,7 +315,7 @@ static int parse_str(m_option_t* opt,char *name, char *param, void* dst, int src
} }
static char* print_str(m_option_t* opt, void* val) { 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) { static void copy_str(m_option_t* opt,void* dst, void* src) {
@ -559,7 +559,23 @@ static void copy_str_list(m_option_t* opt,void* dst, void* src) {
} }
static char* print_str_list(m_option_t* opt, void* src) { 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 = { m_option_type_t m_option_type_string_list = {

View File

@ -190,7 +190,7 @@ m_option_print(m_option_t* opt, void* val_ptr) {
if(opt->type->print) if(opt->type->print)
return opt->type->print(opt,val_ptr); return opt->type->print(opt,val_ptr);
else else
return NULL; return (char*)-1;
} }
inline static void inline static void