Commit f5c7fd83 authored by Gildas Bazin's avatar Gildas Bazin

* src/misc/configuration.c, include/configuration.h: added a...

* src/misc/configuration.c, include/configuration.h: added a change_action_add()method to associate an action (that can be triggered through a gui) to a config var.
* modules/gui/wxwindows/preferences_widgets.*: implemented partial support for change_action_add().
* modules/access/dshow/dshow.cpp: use change_action_add() to refresh the list of devices and to add an option to configure a device.
parent 0b1ccd3e
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* It includes functions allowing to declare, get or set configuration options. * It includes functions allowing to declare, get or set configuration options.
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * Copyright (C) 1999, 2000 VideoLAN
* $Id: configuration.h,v 1.34 2004/01/25 18:17:08 zorglub Exp $ * $Id: configuration.h,v 1.35 2004/01/29 17:04:01 gbazin Exp $
* *
* Authors: Gildas Bazin <gbazin@netcourrier.com> * Authors: Gildas Bazin <gbazin@netcourrier.com>
* *
...@@ -68,12 +68,18 @@ struct module_config_t ...@@ -68,12 +68,18 @@ struct module_config_t
vlc_callback_t pf_callback; vlc_callback_t pf_callback;
void *p_callback_data; void *p_callback_data;
/* Values list */
char **ppsz_list; /* List of possible values for the option */ char **ppsz_list; /* List of possible values for the option */
int *pi_list; /* Idem for integers */ int *pi_list; /* Idem for integers */
char **ppsz_list_text; /* Friendly names for list values */ char **ppsz_list_text; /* Friendly names for list values */
int i_list; /* Options list size */ int i_list; /* Options list size */
vlc_callback_t pf_list_update; /* Callback that updates the list */
/* Actions list */
vlc_callback_t *ppf_action; /* List of possible actions for a config */
char **ppsz_action_text; /* Friendly names for actions */
int i_action; /* actions list size */
/* Misc */
vlc_mutex_t *p_lock; /* Lock to use when modifying the config */ vlc_mutex_t *p_lock; /* Lock to use when modifying the config */
vlc_bool_t b_dirty; /* Dirty flag to indicate a config change */ vlc_bool_t b_dirty; /* Dirty flag to indicate a config change */
vlc_bool_t b_advanced; /* Flag to indicate an advanced option */ vlc_bool_t b_advanced; /* Flag to indicate an advanced option */
...@@ -216,11 +222,24 @@ VLC_EXPORT( void, config_UnsetCallbacks, ( module_config_t * ) ); ...@@ -216,11 +222,24 @@ VLC_EXPORT( void, config_UnsetCallbacks, ( module_config_t * ) );
#define change_string_list( list, list_text, list_update_func ) \ #define change_string_list( list, list_text, list_update_func ) \
p_config[i_config].i_list = sizeof(list)/sizeof(char *); \ p_config[i_config].i_list = sizeof(list)/sizeof(char *); \
p_config[i_config].ppsz_list = list; \ p_config[i_config].ppsz_list = list; \
p_config[i_config].ppsz_list_text = list_text; \ p_config[i_config].ppsz_list_text = list_text;
p_config[i_config].pf_list_update = list_update_func;
#define change_integer_list( list, list_text, list_update_func ) \ #define change_integer_list( list, list_text, list_update_func ) \
p_config[i_config].i_list = sizeof(list)/sizeof(int); \ p_config[i_config].i_list = sizeof(list)/sizeof(int); \
p_config[i_config].pi_list = list; \ p_config[i_config].pi_list = list; \
p_config[i_config].ppsz_list_text = list_text; \ p_config[i_config].ppsz_list_text = list_text;
p_config[i_config].pf_list_update = list_update_func;
#define change_action_add( pf_action, action_text ) \
if( !p_config[i_config].i_action ) \
{ p_config[i_config].ppsz_action_text = 0; \
p_config[i_config].ppf_action = 0; } \
p_config[i_config].ppf_action = (vlc_callback_t *) \
realloc( p_config[i_config].ppf_action, \
(p_config[i_config].i_action + 1) * sizeof(void *) ); \
p_config[i_config].ppsz_action_text = (char **)\
realloc( p_config[i_config].ppsz_action_text, \
(p_config[i_config].i_action + 1) * sizeof(void *) ); \
p_config[i_config].ppf_action[p_config[i_config].i_action] = pf_action; \
p_config[i_config].ppsz_action_text[p_config[i_config].i_action] = \
action_text; \
p_config[i_config].i_action++;
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* dshow.cpp : DirectShow access module for vlc * dshow.cpp : DirectShow access module for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2002, 2003 VideoLAN * Copyright (C) 2002, 2003 VideoLAN
* $Id: dshow.cpp,v 1.26 2004/01/28 16:46:52 gbazin Exp $ * $Id: dshow.cpp,v 1.27 2004/01/29 17:04:01 gbazin Exp $
* *
* Author: Gildas Bazin <gbazin@netcourrier.com> * Author: Gildas Bazin <gbazin@netcourrier.com>
* *
...@@ -45,12 +45,15 @@ static IBaseFilter *FindCaptureDevice( vlc_object_t *, string *, ...@@ -45,12 +45,15 @@ static IBaseFilter *FindCaptureDevice( vlc_object_t *, string *,
list<string> *, vlc_bool_t ); list<string> *, vlc_bool_t );
static AM_MEDIA_TYPE EnumDeviceCaps( vlc_object_t *, IBaseFilter *, static AM_MEDIA_TYPE EnumDeviceCaps( vlc_object_t *, IBaseFilter *,
int, int, int, int, int, int ); int, int, int, int, int, int );
static bool ConnectFilters( IFilterGraph *, IBaseFilter *, IPin * ); static bool ConnectFilters( vlc_object_t *, IFilterGraph *,
IBaseFilter *, IPin * );
static int FindDevicesCallback( vlc_object_t *, char const *, static int FindDevicesCallback( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * ); vlc_value_t, vlc_value_t, void * );
static int ConfigDevicesCallback( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * );
static void PropertiesPage( input_thread_t *, IBaseFilter * ); static void PropertiesPage( vlc_object_t *, IBaseFilter * );
#if 0 #if 0
/* Debug only, use this to find out GUIDs */ /* Debug only, use this to find out GUIDs */
...@@ -142,9 +145,13 @@ vlc_module_begin(); ...@@ -142,9 +145,13 @@ vlc_module_begin();
add_string( "dshow-vdev", NULL, NULL, VDEV_TEXT, VDEV_LONGTEXT, VLC_FALSE); add_string( "dshow-vdev", NULL, NULL, VDEV_TEXT, VDEV_LONGTEXT, VLC_FALSE);
change_string_list( ppsz_vdev, ppsz_vdev_text, FindDevicesCallback ); change_string_list( ppsz_vdev, ppsz_vdev_text, FindDevicesCallback );
change_action_add( FindDevicesCallback, N_("Refresh list") );
change_action_add( ConfigDevicesCallback, N_("Configure") );
add_string( "dshow-adev", NULL, NULL, ADEV_TEXT, ADEV_LONGTEXT, VLC_FALSE); add_string( "dshow-adev", NULL, NULL, ADEV_TEXT, ADEV_LONGTEXT, VLC_FALSE);
change_string_list( ppsz_adev, ppsz_adev_text, FindDevicesCallback ); change_string_list( ppsz_adev, ppsz_adev_text, FindDevicesCallback );
change_action_add( FindDevicesCallback, N_("Refresh list") );
change_action_add( ConfigDevicesCallback, N_("Configure") );
add_string( "dshow-size", NULL, NULL, SIZE_TEXT, SIZE_LONGTEXT, VLC_FALSE); add_string( "dshow-size", NULL, NULL, SIZE_TEXT, SIZE_LONGTEXT, VLC_FALSE);
...@@ -409,23 +416,27 @@ static void AccessClose( vlc_object_t *p_this ) ...@@ -409,23 +416,27 @@ static void AccessClose( vlc_object_t *p_this )
/**************************************************************************** /****************************************************************************
* ConnectFilters * ConnectFilters
****************************************************************************/ ****************************************************************************/
static bool ConnectFilters( IFilterGraph *p_graph, IBaseFilter *p_filter, static bool ConnectFilters( vlc_object_t *p_this, IFilterGraph *p_graph,
IPin *p_input_pin ) IBaseFilter *p_filter, IPin *p_input_pin )
{ {
IEnumPins *p_enumpins; IEnumPins *p_enumpins;
IPin *p_output_pin; IPin *p_pin;
if( S_OK != p_filter->EnumPins( &p_enumpins ) ) return false; if( S_OK != p_filter->EnumPins( &p_enumpins ) ) return false;
while( S_OK == p_enumpins->Next( 1, &p_output_pin, NULL ) ) while( S_OK == p_enumpins->Next( 1, &p_pin, NULL ) )
{ {
if( S_OK == p_graph->ConnectDirect( p_output_pin, p_input_pin, 0 ) ) PIN_DIRECTION pin_dir;
p_pin->QueryDirection( &pin_dir );
if( pin_dir == PINDIR_OUTPUT &&
S_OK == p_graph->ConnectDirect( p_pin, p_input_pin, 0 ) )
{ {
p_output_pin->Release(); p_pin->Release();
p_enumpins->Release(); p_enumpins->Release();
return true; return true;
} }
p_output_pin->Release(); p_pin->Release();
} }
p_enumpins->Release(); p_enumpins->Release();
...@@ -482,7 +493,7 @@ static int OpenDevice( input_thread_t *p_input, string devicename, ...@@ -482,7 +493,7 @@ static int OpenDevice( input_thread_t *p_input, string devicename,
/* Attempt to connect one of this device's capture output pins */ /* Attempt to connect one of this device's capture output pins */
msg_Dbg( p_input, "connecting filters" ); msg_Dbg( p_input, "connecting filters" );
if( ConnectFilters( p_sys->p_graph, p_device_filter, if( ConnectFilters( VLC_OBJECT(p_input), p_sys->p_graph, p_device_filter,
p_capture_filter->CustomGetPin() ) ) p_capture_filter->CustomGetPin() ) )
{ {
/* Success */ /* Success */
...@@ -702,7 +713,7 @@ static int OpenDevice( input_thread_t *p_input, string devicename, ...@@ -702,7 +713,7 @@ static int OpenDevice( input_thread_t *p_input, string devicename,
VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Get( p_input, "dshow-config", &val ); var_Get( p_input, "dshow-config", &val );
if(val.i_int) PropertiesPage( p_input, p_device_filter ); if(val.i_int) PropertiesPage( VLC_OBJECT(p_input), p_device_filter );
/* Add directshow elementary stream to our list */ /* Add directshow elementary stream to our list */
dshow_stream.p_device_filter = p_device_filter; dshow_stream.p_device_filter = p_device_filter;
...@@ -770,7 +781,7 @@ FindCaptureDevice( vlc_object_t *p_this, string *p_devicename, ...@@ -770,7 +781,7 @@ FindCaptureDevice( vlc_object_t *p_this, string *p_devicename,
* CreateClassEnumerator will succeed, but p_class_enum will be NULL */ * CreateClassEnumerator will succeed, but p_class_enum will be NULL */
if( p_class_enum == NULL ) if( p_class_enum == NULL )
{ {
msg_Err( p_this, "no capture device was detected." ); msg_Err( p_this, "no capture device was detected" );
return NULL; return NULL;
} }
...@@ -851,14 +862,35 @@ static AM_MEDIA_TYPE EnumDeviceCaps( vlc_object_t *p_this, ...@@ -851,14 +862,35 @@ static AM_MEDIA_TYPE EnumDeviceCaps( vlc_object_t *p_this,
if( S_OK != p_filter->EnumPins( &p_enumpins ) ) return media_type; if( S_OK != p_filter->EnumPins( &p_enumpins ) ) return media_type;
while( S_OK == p_enumpins->Next( 1, &p_output_pin, NULL ) )
{
PIN_INFO info;
if( S_OK == p_output_pin->QueryPinInfo( &info ) )
{
msg_Dbg( p_this, "EnumDeviceCaps: %s pin: %S",
info.dir == PINDIR_INPUT ? "input" : "output",
info.achName );
if( info.pFilter ) info.pFilter->Release();
}
p_output_pin->Release();
}
p_enumpins->Reset();
while( !b_found && p_enumpins->Next( 1, &p_output_pin, NULL ) == S_OK ) while( !b_found && p_enumpins->Next( 1, &p_output_pin, NULL ) == S_OK )
{ {
PIN_INFO info; PIN_INFO info;
if( S_OK == p_output_pin->QueryPinInfo( &info ) ) if( S_OK == p_output_pin->QueryPinInfo( &info ) )
{ {
msg_Dbg( p_this, "EnumDeviceCaps: pin %S", info.achName );
if( info.pFilter ) info.pFilter->Release(); if( info.pFilter ) info.pFilter->Release();
if( info.dir == PINDIR_INPUT )
{
p_output_pin->Release();
continue;
}
msg_Dbg( p_this, "EnumDeviceCaps: trying pin %S", info.achName );
} }
/* Probe pin */ /* Probe pin */
...@@ -1464,10 +1496,54 @@ static int FindDevicesCallback( vlc_object_t *p_this, char const *psz_name, ...@@ -1464,10 +1496,54 @@ static int FindDevicesCallback( vlc_object_t *p_this, char const *psz_name,
p_item->ppsz_list[i] = NULL; p_item->ppsz_list[i] = NULL;
p_item->ppsz_list_text[i] = NULL; p_item->ppsz_list_text[i] = NULL;
/* Signal change to the interface */
p_item->b_dirty = VLC_TRUE;
return VLC_SUCCESS; return VLC_SUCCESS;
} }
static void PropertiesPage( input_thread_t *p_input, static int ConfigDevicesCallback( vlc_object_t *p_this, char const *psz_name,
vlc_value_t newval, vlc_value_t oldval, void * )
{
module_config_t *p_item;
vlc_bool_t b_audio = VLC_FALSE;
p_item = config_FindConfig( p_this, psz_name );
if( !p_item ) return VLC_SUCCESS;
if( !strcmp( psz_name, "dshow-adev" ) ) b_audio = VLC_TRUE;
string devicename;
if( newval.psz_string && *newval.psz_string )
{
devicename = newval.psz_string;
}
else
{
/* If no device name was specified, pick the 1st one */
list<string> list_devices;
/* Enumerate devices */
FindCaptureDevice( p_this, NULL, &list_devices, b_audio );
if( !list_devices.size() ) return VLC_EGENERIC;
devicename = *list_devices.begin();
}
IBaseFilter *p_device_filter =
FindCaptureDevice( p_this, &devicename, NULL, b_audio );
if( p_device_filter )
PropertiesPage( p_this, p_device_filter );
else
{
msg_Err( p_this, "didn't find device: %s", devicename.c_str() );
return VLC_EGENERIC;
}
return VLC_SUCCESS;
}
static void PropertiesPage( vlc_object_t *p_this,
IBaseFilter *p_device_filter ) IBaseFilter *p_device_filter )
{ {
ISpecifyPropertyPages *p_spec; ISpecifyPropertyPages *p_spec;
...@@ -1486,14 +1562,8 @@ static void PropertiesPage( input_thread_t *p_input, ...@@ -1486,14 +1562,8 @@ static void PropertiesPage( input_thread_t *p_input,
(IUnknown **)&p_device_filter, (IUnknown **)&p_device_filter,
cauuid.cElems, cauuid.cElems,
(GUID *)cauuid.pElems, 0, 0, NULL ); (GUID *)cauuid.pElems, 0, 0, NULL );
if( hr == S_OK )
{
msg_Dbg( p_input, "made OleCreatePropertyFrame");
}
CoTaskMemFree( cauuid.pElems ); CoTaskMemFree( cauuid.pElems );
} }
p_spec->Release(); p_spec->Release();
} }
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* preferences_widgets.cpp : wxWindows plugin for vlc * preferences_widgets.cpp : wxWindows plugin for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2000-2004 VideoLAN * Copyright (C) 2000-2004 VideoLAN
* $Id: preferences_widgets.cpp,v 1.22 2004/01/25 03:29:01 hartman Exp $ * $Id: preferences_widgets.cpp,v 1.23 2004/01/29 17:04:01 gbazin Exp $
* *
* Authors: Gildas Bazin <gbazin@netcourrier.com> * Authors: Gildas Bazin <gbazin@netcourrier.com>
* Sigmund Augdal <sigmunau@idi.ntnu.no> * Sigmund Augdal <sigmunau@idi.ntnu.no>
...@@ -386,7 +386,7 @@ END_EVENT_TABLE() ...@@ -386,7 +386,7 @@ END_EVENT_TABLE()
StringListConfigControl::StringListConfigControl( vlc_object_t *p_this, StringListConfigControl::StringListConfigControl( vlc_object_t *p_this,
module_config_t *p_item, module_config_t *p_item,
wxWindow *parent ) wxWindow *parent )
: ConfigControl( p_this, p_item, parent ), psz_name( NULL ) : ConfigControl( p_this, p_item, parent )
{ {
label = new wxStaticText(this, -1, wxU(p_item->psz_text)); label = new wxStaticText(this, -1, wxU(p_item->psz_text));
sizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); sizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
...@@ -398,14 +398,12 @@ StringListConfigControl::StringListConfigControl( vlc_object_t *p_this, ...@@ -398,14 +398,12 @@ StringListConfigControl::StringListConfigControl( vlc_object_t *p_this,
combo->SetToolTip( wxU(p_item->psz_longtext) ); combo->SetToolTip( wxU(p_item->psz_longtext) );
sizer->Add( combo, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); sizer->Add( combo, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
if( p_item->pf_list_update ) for( int i = 0; i < p_item->i_action; i++ )
{ {
wxButton *refresh = wxButton *button =
new wxButton( this, wxID_HIGHEST, wxU(_("Refresh")) ); new wxButton( this, wxID_HIGHEST+i,
sizer->Add( refresh, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); wxU(p_item->ppsz_action_text[i]) );
sizer->Add( button, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
psz_name = strdup( p_item->psz_name );
pf_list_update = p_item->pf_list_update;
} }
sizer->Layout(); sizer->Layout();
...@@ -414,7 +412,6 @@ StringListConfigControl::StringListConfigControl( vlc_object_t *p_this, ...@@ -414,7 +412,6 @@ StringListConfigControl::StringListConfigControl( vlc_object_t *p_this,
StringListConfigControl::~StringListConfigControl() StringListConfigControl::~StringListConfigControl()
{ {
if( psz_name ) free( psz_name );
} }
void StringListConfigControl::UpdateCombo( module_config_t *p_item ) void StringListConfigControl::UpdateCombo( module_config_t *p_item )
...@@ -442,24 +439,31 @@ void StringListConfigControl::UpdateCombo( module_config_t *p_item ) ...@@ -442,24 +439,31 @@ void StringListConfigControl::UpdateCombo( module_config_t *p_item )
BEGIN_EVENT_TABLE(StringListConfigControl, wxPanel) BEGIN_EVENT_TABLE(StringListConfigControl, wxPanel)
/* Button events */ /* Button events */
EVT_BUTTON(wxID_HIGHEST, StringListConfigControl::OnRefresh) EVT_BUTTON(-1, StringListConfigControl::OnAction)
/* Text events */ /* Text events */
EVT_TEXT(-1, StringListConfigControl::OnUpdate) EVT_TEXT(-1, StringListConfigControl::OnUpdate)
END_EVENT_TABLE() END_EVENT_TABLE()
void StringListConfigControl::OnRefresh( wxCommandEvent& event ) void StringListConfigControl::OnAction( wxCommandEvent& event )
{ {
if( pf_list_update ) int i_action = event.GetId() - wxID_HIGHEST;
{
vlc_value_t val; module_config_t *p_item = config_FindConfig( p_this, GetName().mb_str() );
module_config_t *p_item; if( !p_item ) return;
pf_list_update( p_this, psz_name, val, val, 0 ); if( i_action < 0 || i_action >= p_item->i_action ) return;
p_item = config_FindConfig( p_this, psz_name );
vlc_value_t val;
wxString value = GetPszValue();
(const char *)val.psz_string = value.mb_str();
p_item->ppf_action[i_action]( p_this, GetName().mb_str(), val, val, 0 );
if( p_item->b_dirty )
{
combo->Clear(); combo->Clear();
UpdateCombo( p_item ); UpdateCombo( p_item );
p_item->b_dirty = VLC_FALSE;
} }
} }
...@@ -578,7 +582,7 @@ int IntegerConfigControl::GetIntValue() ...@@ -578,7 +582,7 @@ int IntegerConfigControl::GetIntValue()
IntegerListConfigControl::IntegerListConfigControl( vlc_object_t *p_this, IntegerListConfigControl::IntegerListConfigControl( vlc_object_t *p_this,
module_config_t *p_item, module_config_t *p_item,
wxWindow *parent ) wxWindow *parent )
: ConfigControl( p_this, p_item, parent ), psz_name( NULL ) : ConfigControl( p_this, p_item, parent )
{ {
label = new wxStaticText(this, -1, wxU(p_item->psz_text)); label = new wxStaticText(this, -1, wxU(p_item->psz_text));
sizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); sizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
...@@ -591,23 +595,12 @@ IntegerListConfigControl::IntegerListConfigControl( vlc_object_t *p_this, ...@@ -591,23 +595,12 @@ IntegerListConfigControl::IntegerListConfigControl( vlc_object_t *p_this,
combo->SetToolTip( wxU(p_item->psz_longtext) ); combo->SetToolTip( wxU(p_item->psz_longtext) );
sizer->Add( combo, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); sizer->Add( combo, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
if( p_item->pf_list_update )
{
wxButton *refresh =
new wxButton( this, wxID_HIGHEST, wxU(_("Refresh")) );
sizer->Add( refresh, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
psz_name = strdup( p_item->psz_name );
pf_list_update = p_item->pf_list_update;
}
sizer->Layout(); sizer->Layout();
this->SetSizerAndFit( sizer ); this->SetSizerAndFit( sizer );
} }
IntegerListConfigControl::~IntegerListConfigControl() IntegerListConfigControl::~IntegerListConfigControl()
{ {
if( psz_name ) free( psz_name );
} }
void IntegerListConfigControl::UpdateCombo( module_config_t *p_item ) void IntegerListConfigControl::UpdateCombo( module_config_t *p_item )
...@@ -643,21 +636,28 @@ void IntegerListConfigControl::UpdateCombo( module_config_t *p_item ) ...@@ -643,21 +636,28 @@ void IntegerListConfigControl::UpdateCombo( module_config_t *p_item )
BEGIN_EVENT_TABLE(IntegerListConfigControl, wxPanel) BEGIN_EVENT_TABLE(IntegerListConfigControl, wxPanel)
/* Button events */ /* Button events */
EVT_BUTTON(wxID_HIGHEST, IntegerListConfigControl::OnRefresh) EVT_BUTTON(-1, IntegerListConfigControl::OnAction)
END_EVENT_TABLE() END_EVENT_TABLE()
void IntegerListConfigControl::OnRefresh( wxCommandEvent& event ) void IntegerListConfigControl::OnAction( wxCommandEvent& event )
{ {
if( pf_list_update ) int i_action = event.GetId() - wxID_HIGHEST;
{
vlc_value_t val;
module_config_t *p_item;
pf_list_update( p_this, psz_name, val, val, 0 ); module_config_t *p_item;
p_item = config_FindConfig( p_this, psz_name ); p_item = config_FindConfig( p_this, GetName().mb_str() );
if( !p_item ) return;
if( i_action < 0 || i_action >= p_item->i_action ) return;
vlc_value_t val;
val.i_int = GetIntValue();
p_item->ppf_action[i_action]( p_this, GetName().mb_str(), val, val, 0 );
if( p_item->b_dirty )
{
combo->Clear(); combo->Clear();
UpdateCombo( p_item ); UpdateCombo( p_item );
p_item->b_dirty = VLC_FALSE;
} }
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* preferences_widgets.h : wxWindows plugin for vlc * preferences_widgets.h : wxWindows plugin for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2000-2003 VideoLAN * Copyright (C) 2000-2003 VideoLAN
* $Id: preferences_widgets.h,v 1.7 2003/11/10 00:14:05 gbazin Exp $ * $Id: preferences_widgets.h,v 1.8 2004/01/29 17:04:01 gbazin Exp $
* *
* Authors: Sigmund Augdal <sigmunau@idi.ntnu.no> * Authors: Sigmund Augdal <sigmunau@idi.ntnu.no>
* *
...@@ -100,13 +100,10 @@ public: ...@@ -100,13 +100,10 @@ public:
virtual wxString GetPszValue(); virtual wxString GetPszValue();
private: private:
wxComboBox *combo; wxComboBox *combo;
void OnRefresh( wxCommandEvent& );
char *psz_name;
vlc_callback_t pf_list_update;
void UpdateCombo( module_config_t *p_item ); void UpdateCombo( module_config_t *p_item );
void OnAction( wxCommandEvent& );
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
...@@ -142,13 +139,10 @@ public: ...@@ -142,13 +139,10 @@ public:
virtual int GetIntValue(); virtual int GetIntValue();
private: private:
wxComboBox *combo; wxComboBox *combo;
void OnRefresh( wxCommandEvent& );
char *psz_name;
vlc_callback_t pf_list_update;
void UpdateCombo( module_config_t *p_item ); void UpdateCombo( module_config_t *p_item );
void OnAction( wxCommandEvent& );
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* configuration.c management of the modules configuration * configuration.c management of the modules configuration
***************************************************************************** *****************************************************************************
* Copyright (C) 2001-2004 VideoLAN * Copyright (C) 2001-2004 VideoLAN
* $Id: configuration.c,v 1.75 2004/01/25 17:16:06 zorglub Exp $ * $Id: configuration.c,v 1.76 2004/01/29 17:04:01 gbazin Exp $
* *
* Authors: Gildas Bazin <gbazin@netcourrier.com> * Authors: Gildas Bazin <gbazin@netcourrier.com>
* *
...@@ -560,6 +560,26 @@ void config_Duplicate( module_t *p_module, module_config_t *p_orig ) ...@@ -560,6 +560,26 @@ void config_Duplicate( module_t *p_module, module_config_t *p_orig )
} }
} }
/* duplicate the actions list */
if( p_orig[i].i_action )
{
int j;
p_module->p_config[i].ppf_action =
malloc( p_orig[i].i_action * sizeof(void *) );
p_module->p_config[i].ppsz_action_text =
malloc( p_orig[i].i_action * sizeof(char *) );
for( j = 0; j < p_orig[i].i_action; j++ )
{
p_module->p_config[i].ppf_action[j] =
p_orig[i].ppf_action[j];
p_module->p_config[i].ppsz_action_text[j] =
p_orig[i].ppsz_action_text[j] ?
strdup( p_orig[i].ppsz_action_text[j] ) : NULL;
}
}
p_module->p_config[i].pf_callback = p_orig[i].pf_callback; p_module->p_config[i].pf_callback = p_orig[i].pf_callback;
} }
} }
...@@ -612,6 +632,17 @@ void config_Free( module_t *p_module ) ...@@ -612,6 +632,17 @@ void config_Free( module_t *p_module )
if( p_item->ppsz_list_text ) free( p_item->ppsz_list_text ); if( p_item->ppsz_list_text ) free( p_item->ppsz_list_text );
if( p_item->pi_list ) free( p_item->pi_list ); if( p_item->pi_list ) free( p_item->pi_list );
} }
if( p_item->i_action )
{
for( i = 0; i < p_item->i_action; i++ )
{
if( p_item->ppsz_action_text[i] )
free( p_item->ppsz_action_text[i] );
}
if( p_item->ppf_action ) free( p_item->ppf_action );
if( p_item->ppsz_action_text ) free( p_item->ppsz_action_text );
}
} }
free( p_module->p_config ); free( p_module->p_config );
......
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