Commit 93de8cf8 authored by Gildas Bazin's avatar Gildas Bazin

* modules/gui/wxwindows/preferences_widgets.*: added a refresh button for...

* modules/gui/wxwindows/preferences_widgets.*: added a refresh button for config vars with choices lists which have a pf_list_update callback.
* modules/access/dshow/dshow.cpp: provide a callback to update the devices lists.
parent b380a994
......@@ -2,7 +2,7 @@
* dshow.cpp : DirectShow access module for vlc
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: dshow.cpp,v 1.12 2003/11/03 20:22:21 gbazin Exp $
* $Id: dshow.cpp,v 1.13 2003/11/05 02:43:55 gbazin Exp $
*
* Author: Gildas Bazin <gbazin@netcourrier.com>
*
......@@ -53,6 +53,8 @@ static AM_MEDIA_TYPE EnumDeviceCaps( vlc_object_t *, IBaseFilter *,
int, int, int, int, int, int );
static bool ConnectFilters( IFilterGraph *, IBaseFilter *, IPin * );
static int FindDevicesCallback( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * );
#if 0
/* Debug only, use this to find out GUIDs */
unsigned char p_st[];
......@@ -61,8 +63,13 @@ static bool ConnectFilters( IFilterGraph *, IBaseFilter *, IPin * );
#endif
/*****************************************************************************
* Module descriptior
* Module descriptor
*****************************************************************************/
static char *ppsz_vdev[] = { "", "none" };
static char *ppsz_vdev_text[] = { N_("Default"), N_("None") };
static char *ppsz_adev[] = { "", "none" };
static char *ppsz_adev_text[] = { N_("Default"), N_("None") };
#define CACHING_TEXT N_("Caching value in ms")
#define CACHING_LONGTEXT N_( \
"Allows you to modify the default caching value for directshow streams. " \
......@@ -92,9 +99,15 @@ vlc_module_begin();
add_category_hint( N_("dshow"), NULL, VLC_TRUE );
add_integer( "dshow-caching", (mtime_t)(0.2*CLOCK_FREQ) / 1000, NULL,
CACHING_TEXT, CACHING_LONGTEXT, VLC_TRUE );
add_string( "dshow-vdev", NULL, NULL, VDEV_TEXT, VDEV_LONGTEXT, VLC_FALSE);
change_string_list( ppsz_vdev, ppsz_vdev_text, FindDevicesCallback );
add_string( "dshow-adev", NULL, NULL, ADEV_TEXT, ADEV_LONGTEXT, VLC_FALSE);
change_string_list( ppsz_adev, ppsz_adev_text, FindDevicesCallback );
add_string( "dshow-size", NULL, NULL, SIZE_TEXT, SIZE_LONGTEXT, VLC_FALSE);
add_string( "dshow-chroma", NULL, NULL, CHROMA_TEXT, CHROMA_LONGTEXT,
VLC_TRUE );
add_shortcut( "dshow" );
......@@ -1337,3 +1350,62 @@ static int Demux( input_thread_t *p_input )
return 1;
}
/*****************************************************************************
* config variable callback
*****************************************************************************/
static int FindDevicesCallback( vlc_object_t *p_this, char const *psz_name,
vlc_value_t newval, vlc_value_t oldval, void * )
{
module_t *p_module;
module_config_t *p_item;
vlc_bool_t b_audio = VLC_FALSE;
int i;
p_item = config_FindConfig( p_this, psz_name );
if( !p_item ) return VLC_SUCCESS;
if( !strcmp( psz_name, "dshow-adev" ) ) b_audio = VLC_TRUE;
/* Clear-up the current list */
if( p_item->i_list )
{
/* Keep the 2 first entries */
for( i = 2; i < p_item->i_list; i++ )
{
free( p_item->ppsz_list[i] );
free( p_item->ppsz_list_text[i] );
}
/* TODO: Remove when no more needed */
p_item->ppsz_list[i] = NULL;
p_item->ppsz_list_text[i] = NULL;
}
p_item->i_list = 2;
/* Find list of devices */
list<string> list_devices;
FindCaptureDevice( p_this, NULL, &list_devices, b_audio );
if( !list_devices.size() ) return VLC_SUCCESS;
p_item->ppsz_list =
(char **)realloc( p_item->ppsz_list,
(list_devices.size()+3) * sizeof(char *) );
p_item->ppsz_list_text =
(char **)realloc( p_item->ppsz_list_text,
(list_devices.size()+3) * sizeof(char *) );
list<string>::iterator iter;
for( iter = list_devices.begin(), i = 2; iter != list_devices.end();
iter++, i++ )
{
p_item->ppsz_list[i] = strdup( iter->c_str() );
p_item->ppsz_list_text[i] = strdup( iter->c_str() );
p_item->i_list++;
}
p_item->ppsz_list[i] = NULL;
p_item->ppsz_list_text[i] = NULL;
return VLC_SUCCESS;
}
......@@ -2,7 +2,7 @@
* preferences_widgets.cpp : wxWindows plugin for vlc
*****************************************************************************
* Copyright (C) 2000-2001 VideoLAN
* $Id: preferences_widgets.cpp,v 1.10 2003/11/05 00:39:16 gbazin Exp $
* $Id: preferences_widgets.cpp,v 1.11 2003/11/05 02:43:55 gbazin Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
* Sigmund Augdal <sigmunau@idi.ntnu.no>
......@@ -55,44 +55,44 @@ ConfigControl *CreateConfigControl( vlc_object_t *p_this,
case CONFIG_ITEM_STRING:
if( !p_item->i_list )
{
p_control = new StringConfigControl( p_item, parent );
p_control = new StringConfigControl( p_this, p_item, parent );
}
else
{
p_control = new StringListConfigControl( p_item, parent );
p_control = new StringListConfigControl( p_this, p_item, parent );
}
break;
case CONFIG_ITEM_FILE:
case CONFIG_ITEM_DIRECTORY:
p_control = new FileConfigControl( p_item, parent );
p_control = new FileConfigControl( p_this, p_item, parent );
break;
case CONFIG_ITEM_INTEGER:
if( p_item->i_list )
{
p_control = new IntegerListConfigControl( p_item, parent );
p_control = new IntegerListConfigControl( p_this, p_item, parent );
}
else if( p_item->i_min != 0 || p_item->i_max != 0 )
{
p_control = new RangedIntConfigControl( p_item, parent );
p_control = new RangedIntConfigControl( p_this, p_item, parent );
}
else
{
p_control = new IntegerConfigControl( p_item, parent );
p_control = new IntegerConfigControl( p_this, p_item, parent );
}
break;
case CONFIG_ITEM_KEY:
p_control = new KeyConfigControl( p_item, parent );
p_control = new KeyConfigControl( p_this, p_item, parent );
break;
case CONFIG_ITEM_FLOAT:
p_control = new FloatConfigControl( p_item, parent );
p_control = new FloatConfigControl( p_this, p_item, parent );
break;
case CONFIG_ITEM_BOOL:
p_control = new BoolConfigControl( p_item, parent );
p_control = new BoolConfigControl( p_this, p_item, parent );
break;
default:
......@@ -105,17 +105,21 @@ ConfigControl *CreateConfigControl( vlc_object_t *p_this,
/*****************************************************************************
* ConfigControl implementation
*****************************************************************************/
ConfigControl::ConfigControl( module_config_t *p_item, wxWindow *parent )
: wxPanel( parent ), name( wxU(p_item->psz_name) ),
ConfigControl::ConfigControl( vlc_object_t *_p_this,
module_config_t *p_item, wxWindow *parent )
: wxPanel( parent ), p_this( _p_this ), name( wxU(p_item->psz_name) ),
i_type( p_item->i_type ), b_advanced( p_item->b_advanced )
{
sizer = new wxBoxSizer( wxHORIZONTAL );
i_counter++;
}
ConfigControl::~ConfigControl()
{
}
int ConfigControl::i_counter = 0;
wxSizer *ConfigControl::Sizer()
{
return sizer;
......@@ -211,8 +215,9 @@ static wxString KeysList[] =
wxT("*")
};
KeyConfigControl::KeyConfigControl( module_config_t *p_item, wxWindow *parent )
: ConfigControl( p_item, parent )
KeyConfigControl::KeyConfigControl( vlc_object_t *p_this,
module_config_t *p_item, wxWindow *parent )
: ConfigControl( p_this, p_item, parent )
{
label = new wxStaticText(this, -1, wxU(p_item->psz_text));
alt = new wxCheckBox( this, -1, wxU(_("Alt")) );
......@@ -278,7 +283,7 @@ int KeyConfigControl::GetIntValue()
ModuleConfigControl::ModuleConfigControl( vlc_object_t *p_this,
module_config_t *p_item,
wxWindow *parent )
: ConfigControl( p_item, parent )
: ConfigControl( p_this, p_item, parent )
{
vlc_list_t *p_list;
module_t *p_parser;
......@@ -327,9 +332,10 @@ wxString ModuleConfigControl::GetPszValue()
/*****************************************************************************
* StringConfigControl implementation
*****************************************************************************/
StringConfigControl::StringConfigControl( module_config_t *p_item,
StringConfigControl::StringConfigControl( vlc_object_t *p_this,
module_config_t *p_item,
wxWindow *parent )
: ConfigControl( p_item, parent )
: ConfigControl( p_this, p_item, parent )
{
label = new wxStaticText(this, -1, wxU(p_item->psz_text));
sizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
......@@ -357,16 +363,42 @@ wxString StringConfigControl::GetPszValue()
/*****************************************************************************
* StringListConfigControl implementation
*****************************************************************************/
StringListConfigControl::StringListConfigControl( module_config_t *p_item,
StringListConfigControl::StringListConfigControl( vlc_object_t *p_this,
module_config_t *p_item,
wxWindow *parent )
: ConfigControl( p_item, parent )
: ConfigControl( p_this, p_item, parent ), psz_name( NULL )
{
label = new wxStaticText(this, -1, wxU(p_item->psz_text));
sizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
combo = new wxComboBox( this, -1, wxT(""),
wxDefaultPosition, wxDefaultSize,
0, NULL, wxCB_READONLY );
UpdateCombo( p_item );
combo->SetToolTip( wxU(p_item->psz_longtext) );
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();
this->SetSizerAndFit( sizer );
}
StringListConfigControl::~StringListConfigControl()
{
if( psz_name ) free( psz_name );
}
void StringListConfigControl::UpdateCombo( module_config_t *p_item )
{
/* build a list of available options */
for( int i_index = 0; i_index < p_item->i_list; i_index++ )
{
......@@ -375,8 +407,9 @@ StringListConfigControl::StringListConfigControl( module_config_t *p_item,
wxU(p_item->ppsz_list_text[i_index]) :
wxU(p_item->ppsz_list[i_index]) );
combo->SetClientData( i_index, (void *)p_item->ppsz_list[i_index] );
if( p_item->psz_value && !strcmp( p_item->psz_value,
p_item->ppsz_list[i_index] ) )
if( ( p_item->psz_value &&
!strcmp( p_item->psz_value, p_item->ppsz_list[i_index] ) ) ||
( !p_item->psz_value && !*p_item->ppsz_list[i_index] ) )
{
combo->SetSelection( i_index );
combo->SetValue( ( p_item->ppsz_list_text &&
......@@ -385,16 +418,26 @@ StringListConfigControl::StringListConfigControl( module_config_t *p_item,
wxU(p_item->ppsz_list[i_index]) );
}
}
combo->SetToolTip( wxU(p_item->psz_longtext) );
sizer->Add( combo, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
sizer->Layout();
this->SetSizerAndFit( sizer );
}
StringListConfigControl::~StringListConfigControl()
BEGIN_EVENT_TABLE(StringListConfigControl, wxPanel)
/* Button events */
EVT_BUTTON(wxID_HIGHEST+i_counter%100, StringListConfigControl::OnRefresh)
END_EVENT_TABLE()
void StringListConfigControl::OnRefresh( wxCommandEvent& event )
{
;
if( pf_list_update )
{
vlc_value_t val;
module_config_t *p_item;
pf_list_update( p_this, psz_name, val, val, 0 );
p_item = config_FindConfig( p_this, psz_name );
combo->Clear();
UpdateCombo( p_item );
}
}
wxString StringListConfigControl::GetPszValue()
......@@ -410,9 +453,10 @@ wxString StringListConfigControl::GetPszValue()
/*****************************************************************************
* FileConfigControl implementation
*****************************************************************************/
FileConfigControl::FileConfigControl( module_config_t *p_item,
FileConfigControl::FileConfigControl( vlc_object_t *p_this,
module_config_t *p_item,
wxWindow *parent )
: ConfigControl( p_item, parent )
: ConfigControl( p_this, p_item, parent )
{
directory = p_item->i_type == CONFIG_ITEM_DIRECTORY;
label = new wxStaticText(this, -1, wxU(p_item->psz_text));
......@@ -432,7 +476,7 @@ FileConfigControl::FileConfigControl( module_config_t *p_item,
BEGIN_EVENT_TABLE(FileConfigControl, wxPanel)
/* Button events */
EVT_BUTTON(wxID_HIGHEST, FileConfigControl::OnBrowse)
EVT_BUTTON(wxID_HIGHEST+i_counter%100, FileConfigControl::OnBrowse)
END_EVENT_TABLE()
void FileConfigControl::OnBrowse( wxCommandEvent& event )
......@@ -472,9 +516,10 @@ wxString FileConfigControl::GetPszValue()
/*****************************************************************************
* IntegerConfigControl implementation
*****************************************************************************/
IntegerConfigControl::IntegerConfigControl( module_config_t *p_item,
IntegerConfigControl::IntegerConfigControl( vlc_object_t *p_this,
module_config_t *p_item,
wxWindow *parent )
: ConfigControl( p_item, parent )
: ConfigControl( p_this, p_item, parent )
{
label = new wxStaticText(this, -1, wxU(p_item->psz_text));
spin = new wxSpinCtrl( this, -1,
......@@ -503,9 +548,10 @@ int IntegerConfigControl::GetIntValue()
/*****************************************************************************
* IntegerListConfigControl implementation
*****************************************************************************/
IntegerListConfigControl::IntegerListConfigControl( module_config_t *p_item,
IntegerListConfigControl::IntegerListConfigControl( vlc_object_t *p_this,
module_config_t *p_item,
wxWindow *parent )
: ConfigControl( p_item, parent )
: ConfigControl( p_this, p_item, parent )
{
label = new wxStaticText(this, -1, wxU(p_item->psz_text));
sizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
......@@ -513,6 +559,32 @@ IntegerListConfigControl::IntegerListConfigControl( module_config_t *p_item,
wxDefaultPosition, wxDefaultSize,
0, NULL, wxCB_READONLY );
UpdateCombo( p_item );
combo->SetToolTip( wxU(p_item->psz_longtext) );
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();
this->SetSizerAndFit( sizer );
}
IntegerListConfigControl::~IntegerListConfigControl()
{
if( psz_name ) free( psz_name );
}
void IntegerListConfigControl::UpdateCombo( module_config_t *p_item )
{
/* build a list of available options */
for( int i_index = 0; i_index < p_item->i_list; i_index++ )
{
......@@ -532,16 +604,26 @@ IntegerListConfigControl::IntegerListConfigControl( module_config_t *p_item,
p_item->pi_list[i_index]) );
}
}
combo->SetToolTip( wxU(p_item->psz_longtext) );
sizer->Add( combo, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
sizer->Layout();
this->SetSizerAndFit( sizer );
}
IntegerListConfigControl::~IntegerListConfigControl()
BEGIN_EVENT_TABLE(IntegerListConfigControl, wxPanel)
/* Button events */
EVT_BUTTON(wxID_HIGHEST+i_counter%100, IntegerListConfigControl::OnRefresh)
END_EVENT_TABLE()
void IntegerListConfigControl::OnRefresh( wxCommandEvent& event )
{
;
if( pf_list_update )
{
vlc_value_t val;
module_config_t *p_item;
pf_list_update( p_this, psz_name, val, val, 0 );
p_item = config_FindConfig( p_this, psz_name );
combo->Clear();
UpdateCombo( p_item );
}
}
int IntegerListConfigControl::GetIntValue()
......@@ -557,9 +639,10 @@ int IntegerListConfigControl::GetIntValue()
/*****************************************************************************
* RangedIntConfigControl implementation
*****************************************************************************/
RangedIntConfigControl::RangedIntConfigControl( module_config_t *p_item,
RangedIntConfigControl::RangedIntConfigControl( vlc_object_t *p_this,
module_config_t *p_item,
wxWindow *parent )
: ConfigControl( p_item, parent )
: ConfigControl( p_this, p_item, parent )
{
label = new wxStaticText(this, -1, wxU(p_item->psz_text));
slider = new wxSlider( this, -1, p_item->i_value, p_item->i_min,
......@@ -585,9 +668,10 @@ int RangedIntConfigControl::GetIntValue()
/*****************************************************************************
* FloatConfigControl implementation
*****************************************************************************/
FloatConfigControl::FloatConfigControl( module_config_t *p_item,
FloatConfigControl::FloatConfigControl( vlc_object_t *p_this,
module_config_t *p_item,
wxWindow *parent )
: ConfigControl( p_item, parent )
: ConfigControl( p_this, p_item, parent )
{
label = new wxStaticText(this, -1, wxU(p_item->psz_text));
textctrl = new wxTextCtrl( this, -1,
......@@ -618,9 +702,10 @@ float FloatConfigControl::GetFloatValue()
/*****************************************************************************
* BoolConfigControl implementation
*****************************************************************************/
BoolConfigControl::BoolConfigControl( module_config_t *p_item,
BoolConfigControl::BoolConfigControl( vlc_object_t *p_this,
module_config_t *p_item,
wxWindow *parent )
: ConfigControl( p_item, parent )
: ConfigControl( p_this, p_item, parent )
{
checkbox = new wxCheckBox( this, -1, wxU(p_item->psz_text) );
if( p_item->i_value ) checkbox->SetValue(TRUE);
......
......@@ -2,7 +2,7 @@
* preferences_widgets.h : wxWindows plugin for vlc
*****************************************************************************
* Copyright (C) 2000-2003 VideoLAN
* $Id: preferences_widgets.h,v 1.4 2003/11/05 00:39:16 gbazin Exp $
* $Id: preferences_widgets.h,v 1.5 2003/11/05 02:43:55 gbazin Exp $
*
* Authors: Sigmund Augdal <sigmunau@idi.ntnu.no>
*
......@@ -24,7 +24,7 @@
class ConfigControl: public wxPanel
{
public:
ConfigControl( module_config_t *, wxWindow *parent );
ConfigControl( vlc_object_t *, module_config_t *, wxWindow * );
~ConfigControl();
wxSizer *Sizer();
......@@ -39,6 +39,8 @@ public:
protected:
wxBoxSizer *sizer;
wxStaticText *label;
vlc_object_t *p_this;
static int i_counter;
private:
wxString name;
......@@ -52,7 +54,7 @@ ConfigControl *CreateConfigControl( vlc_object_t *,
class KeyConfigControl: public ConfigControl
{
public:
KeyConfigControl( module_config_t *p_item, wxWindow *parent );
KeyConfigControl( vlc_object_t *, module_config_t *, wxWindow * );
~KeyConfigControl();
virtual int GetIntValue();
private:
......@@ -65,8 +67,7 @@ private:
class ModuleConfigControl: public ConfigControl
{
public:
ModuleConfigControl( vlc_object_t *p_this, module_config_t *p_item,
wxWindow *parent );
ModuleConfigControl( vlc_object_t *, module_config_t *, wxWindow * );
~ModuleConfigControl();
virtual wxString GetPszValue();
private:
......@@ -76,7 +77,7 @@ private:
class StringConfigControl: public ConfigControl
{
public:
StringConfigControl( module_config_t *p_item, wxWindow *parent );
StringConfigControl( vlc_object_t *, module_config_t *, wxWindow * );
~StringConfigControl();
virtual wxString GetPszValue();
private:
......@@ -86,19 +87,28 @@ private:
class StringListConfigControl: public ConfigControl
{
public:
StringListConfigControl( module_config_t *p_item, wxWindow *parent );
StringListConfigControl( vlc_object_t *, module_config_t *, wxWindow * );
~StringListConfigControl();
virtual wxString GetPszValue();
private:
wxComboBox *combo;
void OnRefresh( wxCommandEvent& );
char *psz_name;
vlc_object_t *p_this;
vlc_callback_t pf_list_update;
void UpdateCombo( module_config_t *p_item );
DECLARE_EVENT_TABLE()
};
class FileConfigControl: public ConfigControl
{
public:
FileConfigControl( module_config_t *p_item, wxWindow *parent );
FileConfigControl( vlc_object_t *, module_config_t *, wxWindow * );
~FileConfigControl();
void FileConfigControl::OnBrowse( wxCommandEvent& );
void OnBrowse( wxCommandEvent& );
virtual wxString GetPszValue();
private:
DECLARE_EVENT_TABLE()
......@@ -110,7 +120,7 @@ private:
class IntegerConfigControl: public ConfigControl
{
public:
IntegerConfigControl( module_config_t *p_item, wxWindow *parent );
IntegerConfigControl( vlc_object_t *, module_config_t *, wxWindow * );
~IntegerConfigControl();
virtual int GetIntValue();
private:
......@@ -120,17 +130,26 @@ private:
class IntegerListConfigControl: public ConfigControl
{
public:
IntegerListConfigControl( module_config_t *p_item, wxWindow *parent );
IntegerListConfigControl( vlc_object_t *, module_config_t *, wxWindow * );
~IntegerListConfigControl();
virtual int GetIntValue();
private:
wxComboBox *combo;
void OnRefresh( wxCommandEvent& );
char *psz_name;
vlc_object_t *p_this;
vlc_callback_t pf_list_update;
void UpdateCombo( module_config_t *p_item );
DECLARE_EVENT_TABLE()
};
class RangedIntConfigControl: public ConfigControl
{
public:
RangedIntConfigControl( module_config_t *p_item, wxWindow *parent );
RangedIntConfigControl( vlc_object_t *, module_config_t *, wxWindow * );
~RangedIntConfigControl();
virtual int GetIntValue();
private:
......@@ -140,7 +159,7 @@ private:
class FloatConfigControl: public ConfigControl
{
public:
FloatConfigControl( module_config_t *p_item, wxWindow *parent );
FloatConfigControl( vlc_object_t *, module_config_t *, wxWindow * );
~FloatConfigControl();
virtual float GetFloatValue();
private:
......@@ -150,7 +169,7 @@ private:
class BoolConfigControl: public ConfigControl
{
public:
BoolConfigControl( module_config_t *p_item, wxWindow *parent );
BoolConfigControl( vlc_object_t *, module_config_t *, wxWindow * );
~BoolConfigControl();
virtual int GetIntValue();
private:
......
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