Commit 2b6863df authored by Gildas Bazin's avatar Gildas Bazin

* src/misc/configuration.c, ALL: support for auto-saveable config options...

* src/misc/configuration.c, ALL: support for auto-saveable config options (saved automatically on exit).
parent 7c16ceb6
......@@ -155,6 +155,12 @@ struct module_config_t
char *psz_value_orig;
int i_value_orig;
float f_value_orig;
/* Option values loaded from config file */
char *psz_value_saved;
int i_value_saved;
float f_value_saved;
vlc_bool_t b_autosave; /* Config will be auto-saved at exit time */
};
/*****************************************************************************
......@@ -199,6 +205,7 @@ VLC_EXPORT( void, config_UnsetCallbacks, ( module_config_t * ) );
/* internal only */
int config_CreateDir( vlc_object_t *, char * );
int config_AutoSaveConfigFile( vlc_object_t * );
/*****************************************************************************
* Macros used to build the configuration structure.
......@@ -369,3 +376,6 @@ int config_CreateDir( vlc_object_t *, char * );
p_config[i_config].ppsz_action_text[p_config[i_config].i_action] = \
action_text; \
p_config[i_config].i_action++;
#define change_autosave() \
p_config[i_config].b_autosave = VLC_TRUE;
......@@ -344,8 +344,10 @@ vlc_module_begin();
set_subcategory( SUBCAT_INTERFACE_GENERAL );
add_string( "skins2-last", "", NULL, SKINS2_LAST, SKINS2_LAST_LONG,
VLC_TRUE );
change_autosave();
add_string( "skins2-config", "", NULL, SKINS2_CONFIG, SKINS2_CONFIG_LONG,
VLC_TRUE );
change_autosave();
#ifdef WIN32
add_bool( "skins2-transparency", VLC_FALSE, NULL, SKINS2_TRANSPARENCY,
SKINS2_TRANSPARENCY_LONG, VLC_FALSE );
......
......@@ -110,7 +110,6 @@ void Theme::saveConfig()
// Save config to file
config_PutPsz( getIntf(), "skins2-config", save );
config_SaveConfigFile( getIntf(), "skins2" );
// Free memory
delete[] save;
......
......@@ -131,6 +131,7 @@ vlc_module_begin();
#endif
add_string( "wxwin-config-last", NULL, NULL,
"last config", "last config", VLC_TRUE );
change_autosave();
add_submodule();
set_description( _("wxWindows dialogs provider") );
......@@ -537,7 +538,6 @@ WindowSettings::~WindowSettings( )
}
config_PutPsz( p_intf, "wxwin-config-last", sCfg.mb_str() );
config_SaveConfigFile( p_intf, "wxwindows" );
}
void WindowSettings::SetScreen( int i_screen_w, int i_screen_h )
{
......
This diff is collapsed.
......@@ -245,6 +245,8 @@ void __module_EndBank( vlc_object_t *p_this )
vlc_mutex_unlock( lockval.p_address );
var_Destroy( p_this->p_libvlc, "libvlc" );
config_AutoSaveConfigFile( p_this );
#ifdef HAVE_DYNAMIC_PLUGINS
#define p_bank p_this->p_libvlc->p_module_bank
if( p_bank->b_cache ) CacheSave( p_this );
......@@ -1698,10 +1700,13 @@ static void CacheLoad( vlc_object_t *p_this )
#define LOAD_STRING(a) \
{ if( fread( &i_size, sizeof(char), sizeof(i_size), file ) \
!= sizeof(i_size) ) goto error; \
if( i_size ) { \
if( i_size && i_size > 16384 ) { \
a = malloc( i_size ); \
if( fread( a, sizeof(char), i_size, file ) != (size_t)i_size ) \
goto error; \
if( a[i_size-1] ) { \
free( a ); a = 0; \
goto error; } \
} else a = 0; \
} while(0)
......@@ -1820,6 +1825,10 @@ int CacheLoadConfig( module_t *p_module, FILE *file )
strdup( p_module->p_config[i].psz_value_orig ) : 0;
p_module->p_config[i].i_value = p_module->p_config[i].i_value_orig;
p_module->p_config[i].f_value = p_module->p_config[i].f_value_orig;
p_module->p_config[i].i_value_saved = p_module->p_config[i].i_value;
p_module->p_config[i].f_value_saved = p_module->p_config[i].f_value;
p_module->p_config[i].psz_value_saved = 0;
p_module->p_config[i].b_dirty = VLC_FALSE;
p_module->p_config[i].p_lock = &p_module->object_lock;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment