From b96154a2673604c3550a0ff0296a48d16420800a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20Weber?= Date: Mon, 3 Mar 2008 19:57:43 +0100 Subject: [PATCH] Enable the last parameter of the macros change_integer_list, change_string_list to supply a method to initialize update dynamic selectionlists inside the settings GUI allready on showing the gui. (f.e. the audio device list) --- include/vlc_configuration.h | 10 +++-- include/vlc_modules_macros.h | 4 +- .../qt4/components/preferences_widgets.cpp | 42 ++++++++++++++++++- .../wxwidgets/dialogs/preferences_widgets.cpp | 37 +++++++++++++++- src/modules/entry.c | 1 + 5 files changed, 85 insertions(+), 9 deletions(-) diff --git a/include/vlc_configuration.h b/include/vlc_configuration.h index 43258e0a51..4bcadf4ba9 100644 --- a/include/vlc_configuration.h +++ b/include/vlc_configuration.h @@ -169,6 +169,7 @@ struct module_config_t int *pi_list; /* Idem for integers */ char **ppsz_list_text; /* Friendly names for list values */ int i_list; /* Options list size */ + vlc_callback_t pf_update_list; /*callback to initialize dropdownlists */ /* Actions list */ vlc_callback_t *ppf_action; /* List of possible actions for a config */ @@ -435,19 +436,22 @@ VLC_EXPORT( int, vlc_config_set, (module_config_t *, int, ...) ); vlc_config_set (p_config, VLC_CONFIG_LIST, \ (size_t)(sizeof (list) / sizeof (char *)), \ (const char *const *)(list), \ - (const char *const *)(list_text)) + (const char *const *)(list_text), \ + list_update_func) #define change_integer_list( list, list_text, list_update_func ) \ vlc_config_set (p_config, VLC_CONFIG_LIST, \ (size_t)(sizeof (list) / sizeof (int)), \ (const int *)(list), \ - (const char *const *)(list_text)) + (const char *const *)(list_text), \ + list_update_func) #define change_float_list( list, list_text, list_update_func ) \ vlc_config_set (p_config, VLC_CONFIG_LIST, \ (size_t)(sizeof (list) / sizeof (float)), \ (const float *)(list), \ - (const char *const *)(list_text)) + (const char *const *)(list_text), \ + list_update_func) #define change_integer_range( minv, maxv ) \ vlc_config_set (p_config, VLC_CONFIG_RANGE, (int)(minv), (int)(maxv)) diff --git a/include/vlc_modules_macros.h b/include/vlc_modules_macros.h index 0e544fddf8..426352f0a3 100644 --- a/include/vlc_modules_macros.h +++ b/include/vlc_modules_macros.h @@ -35,8 +35,8 @@ /** * Current plugin ABI version */ -# define MODULE_SYMBOL 0_9_0g -# define MODULE_SUFFIX "__0_9_0g" +# define MODULE_SYMBOL 0_9_0h +# define MODULE_SUFFIX "__0_9_0h" /***************************************************************************** * Add a few defines. You do not want to read this section. Really. diff --git a/modules/gui/qt4/components/preferences_widgets.cpp b/modules/gui/qt4/components/preferences_widgets.cpp index ba0220c7b6..d64b207c60 100644 --- a/modules/gui/qt4/components/preferences_widgets.cpp +++ b/modules/gui/qt4/components/preferences_widgets.cpp @@ -373,7 +373,21 @@ StringListConfigControl::StringListConfigControl( vlc_object_t *_p_this, combo->setMinimumWidth( MINWIDTH_BOX ); combo->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Preferred ); - module_config_t *p_module_config = config_FindConfig( p_this, getName() ); + module_config_t *p_module_config = config_FindConfig( p_this, p_item->psz_name ); + if(p_module_config && p_module_config->pf_update_list) + { + vlc_value_t val; + val.psz_string = strdup(p_module_config->value.psz); + + p_module_config->pf_update_list(p_this, p_item->psz_name, val, val, NULL); + + // assume in a×y case that dirty was set to VLC_TRUE + // because lazy programmes will use the same callback for + // this, like the one behind the refresh push button? + p_module_config->b_dirty = VLC_FALSE; + + if(val.psz_string) free(val.psz_string); + } finish( p_module_config, bycat ); if( !l ) @@ -473,6 +487,17 @@ void setfillVLCConfigCombo( const char *configname, intf_thread_t *p_intf, config_FindConfig( VLC_OBJECT(p_intf), configname ); if( p_config ) { + if(p_config->pf_update_list) + { + vlc_value_t val; + val.i_int = p_config->value.i; + p_config->pf_update_list(VLC_OBJECT(p_intf), configname, val, val, NULL); + // assume in any case that dirty was set to VLC_TRUE + // because lazy programmes will use the same callback for + // this, like the one behind the refresh push button? + p_config->b_dirty = VLC_FALSE; + } + for ( int i_index = 0; i_index < p_config->i_list; i_index++ ) { combo->addItem( qfu( p_config->ppsz_list_text[i_index] ), @@ -837,7 +862,20 @@ IntegerListConfigControl::IntegerListConfigControl( vlc_object_t *_p_this, combo = new QComboBox(); combo->setMinimumWidth( MINWIDTH_BOX ); - module_config_t *p_module_config = config_FindConfig( p_this, getName() ); + module_config_t *p_module_config = config_FindConfig( p_this, p_item->psz_name ); + if(p_module_config && p_module_config->pf_update_list) + { + vlc_value_t val; + val.i_int = p_module_config->value.i; + + p_module_config->pf_update_list(p_this, p_item->psz_name, val, val, NULL); + + // assume in any case that dirty was set to VLC_TRUE + // because lazy programmes will use the same callback for + // this, like the one behind the refresh push button? + p_module_config->b_dirty = VLC_FALSE; + } + finish( p_module_config, bycat ); if( !l ) diff --git a/modules/gui/wxwidgets/dialogs/preferences_widgets.cpp b/modules/gui/wxwidgets/dialogs/preferences_widgets.cpp index 1d3974195c..692c5896f6 100644 --- a/modules/gui/wxwidgets/dialogs/preferences_widgets.cpp +++ b/modules/gui/wxwidgets/dialogs/preferences_widgets.cpp @@ -563,7 +563,26 @@ StringListConfigControl::StringListConfigControl( vlc_object_t *p_this, combo = new wxComboBox( this, -1, wxT(""), wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY ); - UpdateCombo( p_item ); + + // was required to do so - because local p_item is a memcpy of + // this one, so it won't see the change done by pf_updat_list + module_config_t *p_module_config = config_FindConfig( p_this, p_item->psz_name ); + if(p_module_config && p_module_config->pf_update_list) + { + vlc_value_t val; + val.psz_string = strdup(p_module_config->value.psz); + + p_module_config->pf_update_list(p_this, p_item->psz_name, val, val, NULL); + + // assume in a×y case that dirty was set to VLC_TRUE + // because lazy programmes will use the same callback for + // this, like the one behind the refresh push button? + p_module_config->b_dirty = VLC_FALSE; + + if(val.psz_string) free(val.psz_string); + } + + UpdateCombo( p_module_config ); combo->SetToolTip( wxU(p_item->psz_longtext) ); sizer->Add( combo, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); @@ -793,7 +812,21 @@ IntegerListConfigControl::IntegerListConfigControl( vlc_object_t *p_this, wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY ); - UpdateCombo( p_item ); + module_config_t *p_module_config = config_FindConfig( p_this, p_item->psz_name ); + if(p_module_config && p_module_config->pf_update_list) + { + vlc_value_t val; + val.i_int = p_module_config->value.i; + + p_module_config->pf_update_list(p_this, p_item->psz_name, val, val, NULL); + + // assume in any case that dirty was set to VLC_TRUE + // because lazy programmes will use the same callback for + // this, like the one behind the refresh push button? + p_module_config->b_dirty = VLC_FALSE; + } + + UpdateCombo( p_module_config ); combo->SetToolTip( wxU(p_item->psz_longtext) ); sizer->Add( combo, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); diff --git a/src/modules/entry.c b/src/modules/entry.c index 52ca2e6f78..8a87a1a057 100644 --- a/src/modules/entry.c +++ b/src/modules/entry.c @@ -368,6 +368,7 @@ int vlc_config_set (module_config_t *restrict item, int id, ...) } item->i_list = len; + item->pf_update_list = va_arg (ap, vlc_callback_t); ret = 0; break; } -- 2.39.2