Commit 77ea924c authored by gbazin's avatar gbazin
Browse files

* modules/gui/wxwidgets: fix breakage introduced by changeset 23581 and 23579....

* modules/gui/wxwidgets: fix breakage introduced by changeset 23581 and 23579. Breaking perfectly working modules just because you don't care about them is just rude.
parent 6ed021d3
......@@ -75,6 +75,7 @@ enum vlc_module_properties
};
VLC_EXPORT( vlc_bool_t, module_IsCapable, ( const module_t *m, const char *cap ) );
VLC_EXPORT( vlc_bool_t, module_IsSubModule, ( const module_t *m ) );
VLC_EXPORT( const char *, module_GetObjName, ( const module_t *m ) );
VLC_EXPORT( const char *, module_GetName, ( const module_t *m, vlc_bool_t long_name ) );
#define module_GetLongName( m ) module_GetName( m, VLC_TRUE )
......
......@@ -195,7 +195,9 @@ DialogsProvider::DialogsProvider( intf_thread_t *_p_intf, wxWindow *p_parent )
p_wizard_dialog = NULL;
p_bookmarks_dialog = NULL;
p_dir_dialog = NULL;
#ifdef UPDATE_CHECK
p_updatevlc_dialog = NULL;
#endif
//p_vlm_dialog = NULL;
/* Give our interface a nice little icon */
......@@ -267,7 +269,9 @@ DialogsProvider::~DialogsProvider()
if( p_file_generic_dialog ) delete p_file_generic_dialog;
if( p_wizard_dialog ) delete p_wizard_dialog;
if( p_bookmarks_dialog ) delete p_bookmarks_dialog;
#ifdef UPDATE_CHECK
if( p_updatevlc_dialog ) delete p_updatevlc_dialog;
#endif
//if( p_vlm_dialog ) delete p_vlm_dialog;
......
......@@ -219,17 +219,20 @@ AutoBuiltPanel::AutoBuiltPanel( wxWindow *parent, OpenDialog *dialog,
intf_thread_t *_p_intf,
const module_t *p_module )
: wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize ),
name( wxU( module_GetObjName(p_module) ) ),
name( wxU(module_GetObjName(p_module)) ),
p_advanced_mrl_combo( NULL ),
p_intf( _p_intf ), p_open_dialog( dialog ), p_advanced_dialog( NULL )
{
wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );
bool b_advanced = false;
unsigned int i_confsize;
module_config_t *p_config;
int n;
for( n = 0; n < p_module->confsize; n++ )
p_config = module_GetConfig (p_module, &i_confsize);
for( n = 0; n < i_confsize; n++ )
{
module_config_t *p_item = &p_module->p_config[n];
module_config_t *p_item = p_config + n;
if( !(p_item->i_type & CONFIG_HINT) && p_item->b_advanced )
b_advanced = true;
......@@ -259,8 +262,8 @@ AutoBuiltPanel::AutoBuiltPanel( wxWindow *parent, OpenDialog *dialog,
/* Build the advanced dialog */
p_advanced_dialog =
new wxDialog( this, -1, ((wxString)wxU(_("Advanced options"))) +
wxT(" (") + wxU( module_GetLongName(p_module) ) + wxT(")"),
wxDefaultPosition, wxDefaultSize,
wxT(" (") + wxU( module_GetLongName(p_module) ) +
wxT(")"), wxDefaultPosition, wxDefaultSize,
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER );
wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );
......@@ -283,9 +286,9 @@ AutoBuiltPanel::AutoBuiltPanel( wxWindow *parent, OpenDialog *dialog,
sizer->Add( mrl_sizer_sizer, 0, wxEXPAND | wxALL, 2 );
/* Add advanced options to panel */
for( n = 0; n < p_module->confsize; n++ )
for( n = 0; n < i_confsize; n++ )
{
module_config_t *p_item = &p_module->p_config[n];
module_config_t *p_item = p_config + n;
if( p_item->i_type & CONFIG_HINT || !p_item->b_advanced )
continue;
......@@ -327,6 +330,8 @@ AutoBuiltPanel::AutoBuiltPanel( wxWindow *parent, OpenDialog *dialog,
p_advanced_dialog->SetSizerAndFit( sizer );
}
module_PutConfig (p_config);
this->SetSizerAndFit( sizer );
}
......@@ -508,8 +513,9 @@ OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent,
AutoBuiltPanel *autopanel =
new AutoBuiltPanel( notebook, this, p_intf, p_module );
input_tab_array.Add( autopanel );
notebook->AddPage( autopanel, wxU( module_GetName(p_module, VLC_FALSE) ),
notebook->AddPage( autopanel, wxU( module_GetName(p_module, 0) ),
i_access_method == CAPTURE_ACCESS );
module_Put( p_module );
}
p_module = module_Find( VLC_OBJECT(p_intf), "pvr" );
......@@ -518,8 +524,9 @@ OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent,
AutoBuiltPanel *autopanel =
new AutoBuiltPanel( notebook, this, p_intf, p_module );
input_tab_array.Add( autopanel );
notebook->AddPage( autopanel, wxU( module_GetName(p_module, VLC_FALSE) ),
notebook->AddPage( autopanel, wxU( module_GetName(p_module, 0) ),
i_access_method == CAPTURE_ACCESS );
module_Put( p_module );
}
p_module = module_Find( VLC_OBJECT(p_intf), "dvb" );
......@@ -528,8 +535,9 @@ OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent,
AutoBuiltPanel *autopanel =
new AutoBuiltPanel( notebook, this, p_intf, p_module );
input_tab_array.Add( autopanel );
notebook->AddPage( autopanel, wxU( module_GetName(p_module, VLC_FALSE) ),
notebook->AddPage( autopanel, wxU( module_GetName(p_module, 0) ),
i_access_method == CAPTURE_ACCESS );
module_Put( p_module );
}
p_module = module_Find( VLC_OBJECT(p_intf), "dshow" );
......@@ -538,8 +546,9 @@ OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent,
AutoBuiltPanel *autopanel =
new AutoBuiltPanel( notebook, this, p_intf, p_module );
input_tab_array.Add( autopanel );
notebook->AddPage( autopanel, wxU( module_GetName(p_module, VLC_FALSE) ),
notebook->AddPage( autopanel, wxU( module_GetName(p_module, 0) ),
i_access_method == CAPTURE_ACCESS );
module_Put( p_module );
}
/* Update Disc panel */
......
......@@ -356,27 +356,32 @@ PrefsTreeCtrl::PrefsTreeCtrl( wxWindow *_p_parent, intf_thread_t *_p_intf,
for( i_index = 0; i_index < p_list->i_count; i_index++ )
{
p_module = (module_t *)p_list->p_values[i_index].p_object;
if( !strcmp( p_module->psz_object_name, "main" ) )
if( !strcmp( module_GetObjName(p_module), "main" ) )
break;
}
if( i_index < p_list->i_count )
{
wxTreeItemId current_item;
const char *psz_help;
unsigned int i_confsize;
module_config_t *p_config;
/* We found the main module */
/* Enumerate config categories and store a reference so we can
* generate their config panel them when it is asked by the user. */
for (size_t i = 0; i < p_module->confsize; i++)
p_config = module_GetConfig( p_module, &i_confsize );
for( size_t i = 0; i < i_confsize; i++ )
{
module_config_t *p_item = p_module->p_config + i;
module_config_t *p_item = p_config + i;
ConfigTreeData *config_data;
switch( p_item->i_type )
{
case CONFIG_CATEGORY:
config_data = new ConfigTreeData;
if( p_item->value.i == -1 ) break; // Don't display it
config_data = new ConfigTreeData;
config_data->psz_name = strdup( config_CategoryNameGet(
p_item->value.i ) );
psz_help = config_CategoryHelpGet( p_item->value.i );
......@@ -489,6 +494,7 @@ PrefsTreeCtrl::PrefsTreeCtrl( wxWindow *_p_parent, intf_thread_t *_p_intf,
}
}
module_PutConfig( p_config );
}
......@@ -497,24 +503,25 @@ PrefsTreeCtrl::PrefsTreeCtrl( wxWindow *_p_parent, intf_thread_t *_p_intf,
*/
for( i_index = 0; i_index < p_list->i_count; i_index++ )
{
int i_category = -1;
int i_subcategory = -1;
int i_options = 0;
int i_category = -1, i_subcategory = -1, i_options = 0;
unsigned int i_confsize;
module_config_t *p_config;
p_module = (module_t *)p_list->p_values[i_index].p_object;
/* Exclude the main module */
if( !strcmp( p_module->psz_object_name, "main" ) )
if( !strcmp( module_GetObjName(p_module), "main" ) )
continue;
/* Exclude empty plugins (submodules don't have config options, they
* are stored in the parent module) */
if( p_module->b_submodule )
continue;
// p_item = ((module_t *)p_module->p_parent)->p_config;
else
for (size_t i = 0; i < p_module->confsize; i++)
if( module_IsSubModule(p_module) )
continue;
p_config = module_GetConfig( p_module, &i_confsize );
for( size_t i = 0; i < i_confsize; i++ )
{
module_config_t *p_item = p_module->p_config + i;
module_config_t *p_item = p_config + i;
if( p_item->i_type == CONFIG_CATEGORY )
{
i_category = p_item->value.i;
......@@ -573,11 +580,11 @@ PrefsTreeCtrl::PrefsTreeCtrl( wxWindow *_p_parent, intf_thread_t *_p_intf,
/* Add the plugin to the tree */
ConfigTreeData *config_data = new ConfigTreeData;
config_data->b_submodule = p_module->b_submodule;
config_data->b_submodule = module_IsSubModule(p_module);
config_data->i_type = TYPE_MODULE;
config_data->i_object_id = p_module->b_submodule ?
((module_t *)p_module->p_parent)->i_object_id :
p_module->i_object_id;
config_data->i_object_id = config_data->b_submodule ?
((vlc_object_t *)p_module)->p_parent->i_object_id :
((vlc_object_t *)p_module)->i_object_id;
config_data->psz_help = NULL;
/* WXMSW doesn't know image -1 ... FIXME */
......@@ -602,10 +609,8 @@ PrefsTreeCtrl::PrefsTreeCtrl( wxWindow *_p_parent, intf_thread_t *_p_intf,
#else
i_image = -1;
#endif
AppendItem( subcategory_item, wxU( p_module->psz_shortname ?
p_module->psz_shortname : p_module->psz_object_name )
, i_image, -1,
config_data );
AppendItem( subcategory_item, wxU( module_GetName(p_module, 0) ),
i_image, -1, config_data );
}
/* Sort all this mess */
......@@ -850,7 +855,8 @@ PrefsPanel::PrefsPanel( wxWindow* parent, intf_thread_t *_p_intf,
ConfigTreeData *config_data )
: wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize )
{
module_config_t *p_item, *p_end;
module_config_t *p_item, *p_start, *p_end;
unsigned int i_confsize;
vlc_list_t *p_list = NULL;;
wxStaticText *label;
......@@ -891,8 +897,8 @@ PrefsPanel::PrefsPanel( wxWindow* parent, intf_thread_t *_p_intf,
/* Get a pointer to the module */
if( config_data->i_type == TYPE_MODULE )
{
p_module = (module_t *)vlc_object_get( p_intf,
config_data->i_object_id );
p_module = (module_t *)
vlc_object_get( p_intf, config_data->i_object_id );
}
else
{
......@@ -905,7 +911,7 @@ PrefsPanel::PrefsPanel( wxWindow* parent, intf_thread_t *_p_intf,
for( i_index = 0; i_index < p_list->i_count; i_index++ )
{
p_module = (module_t *)p_list->p_values[i_index].p_object;
if( !strcmp( p_module->psz_object_name, "main" ) )
if( !strcmp( module_GetObjName(p_module), "main" ) )
{
b_found = VLC_TRUE;
break;
......@@ -919,27 +925,22 @@ PrefsPanel::PrefsPanel( wxWindow* parent, intf_thread_t *_p_intf,
}
}
if( p_module->i_object_type != VLC_OBJECT_MODULE )
{
/* 0OOoo something went really bad */
return;
}
/* Enumerate config options and add corresponding config boxes
* (submodules don't have config options, they are stored in the
* parent module) */
if( p_module->b_submodule )
p_item = ((module_t *)p_module->p_parent)->p_config;
if( module_IsSubModule(p_module) )
p_start = module_GetConfig((module_t *)(((vlc_object_t *)p_module)->p_parent), &i_confsize);
else
p_item = p_module->p_config;
p_start = module_GetConfig(p_module, &i_confsize);
p_end = p_item + p_module->confsize;
p_item = p_start;
p_end = p_start + i_confsize;
/* Find the category if it has been specified */
if( config_data->i_type == TYPE_SUBCATEGORY ||
config_data->i_type == TYPE_CATSUBCAT )
{
do
for( ; p_item && p_item < p_end; p_item++ )
{
if( p_item->i_type == CONFIG_SUBCATEGORY &&
( config_data->i_type == TYPE_SUBCATEGORY &&
......@@ -949,7 +950,7 @@ PrefsPanel::PrefsPanel( wxWindow* parent, intf_thread_t *_p_intf,
{
break;
}
} while( p_item++ <= p_end );
}
}
/* Add a head title to the panel */
......@@ -962,7 +963,7 @@ PrefsPanel::PrefsPanel( wxWindow* parent, intf_thread_t *_p_intf,
}
else
{
psz_head = p_module->psz_longname;
psz_head = module_GetLongName(p_module);
}
label = new wxStaticText( this, -1,
......@@ -981,7 +982,7 @@ PrefsPanel::PrefsPanel( wxWindow* parent, intf_thread_t *_p_intf,
config_window->SetAutoLayout( TRUE );
config_window->SetScrollRate( 5, 5 );
if( p_item ) do
for( ; p_item && p_item < p_end; p_item++ )
{
/* If a category has been specified, check we finished the job */
if( ( ( config_data->i_type == TYPE_SUBCATEGORY &&
......@@ -1006,11 +1007,8 @@ PrefsPanel::PrefsPanel( wxWindow* parent, intf_thread_t *_p_intf,
config_sizer->Add( control, 0, wxEXPAND | wxALL, 2 );
}
while( !( ( config_data->i_type == TYPE_SUBCATEGORY ||
config_data->i_type == TYPE_CATSUBCAT ) &&
( p_item->i_type == CONFIG_CATEGORY ||
p_item->i_type == CONFIG_SUBCATEGORY )) && ( ++p_item < p_end) );
module_PutConfig( p_start );
config_sizer->Layout();
config_window->SetSizer( config_sizer );
......@@ -1034,7 +1032,7 @@ PrefsPanel::PrefsPanel( wxWindow* parent, intf_thread_t *_p_intf,
if( config_data->i_type == TYPE_MODULE )
{
vlc_object_release( p_module );
module_Put( p_module );
}
else
{
......
......@@ -278,13 +278,13 @@ ModuleConfigControl::ModuleConfigControl( vlc_object_t *p_this,
{
p_parser = (module_t *)p_list->p_values[i_index].p_object ;
if( !strcmp( p_parser->psz_capability, p_item->psz_type ) )
if( module_IsCapable( p_parser, p_item->psz_type ) )
{
combo->Append( wxU(p_parser->psz_longname),
(char *)p_parser->psz_object_name );
combo->Append( wxU(module_GetLongName(p_parser)),
(char *)module_GetObjName(p_parser) );
if( p_item->value.psz && !strcmp(p_item->value.psz,
p_parser->psz_object_name) )
combo->SetValue( wxU(p_parser->psz_longname) );
module_GetObjName(p_parser)) )
combo->SetValue( wxU(module_GetLongName(p_parser)) );
}
}
vlc_list_release( p_list );
......@@ -331,25 +331,29 @@ ModuleCatConfigControl::ModuleCatConfigControl( vlc_object_t *p_this,
{
p_parser = (module_t *)p_list->p_values[i_index].p_object ;
if( !strcmp( p_parser->psz_object_name, "main" ) )
if( !strcmp( module_GetObjName(p_parser), "main" ) )
continue;
module_config_t *p_config = p_parser->p_config;
module_config_t *p_end = p_config + p_parser->confsize;
unsigned int i_confsize;
module_config_t *p_config, *p_start, *p_end;
p_start = module_GetConfig( p_parser, &i_confsize );
p_end = p_start + i_confsize;
if( p_config ) do
for( p_config = p_start; p_config < p_end; p_config++ )
{
/* Hack: required subcategory is stored in min.i */
if( p_config->i_type == CONFIG_SUBCATEGORY &&
p_config->value.i == p_item->min.i )
{
combo->Append( wxU(p_parser->psz_longname),
(char *)p_parser->psz_object_name );
if( p_item->value.psz && !strcmp(p_item->value.psz,
p_parser->psz_object_name) )
combo->SetValue( wxU(p_parser->psz_longname) );
combo->Append( wxU(module_GetLongName(p_parser)),
(char *)module_GetObjName(p_parser) );
if( p_item->value.psz &&
!strcmp(p_item->value.psz, module_GetObjName(p_parser)) )
combo->SetValue( wxU(module_GetLongName(p_parser)) );
}
} while( p_config < p_end && p_config++ );
}
module_PutConfig( p_start );
}
vlc_list_release( p_list );
......@@ -402,31 +406,27 @@ ModuleListCatConfigControl::ModuleListCatConfigControl( vlc_object_t *p_this,
{
p_parser = (module_t *)p_list->p_values[i_index].p_object ;
if( !strcmp( p_parser->psz_object_name, "main" ) )
if( !strcmp( module_GetObjName(p_parser), "main" ) )
continue;
module_config_t *p_config, *p_end;
if( p_parser->b_submodule )
p_config = ((module_t*)p_parser->p_parent)->p_config;
else
p_config = p_parser->p_config;
p_end = p_config + p_parser->confsize;
unsigned int i_confsize;
module_config_t *p_config, *p_start, *p_end;
if( p_config ) do
p_start = module_GetConfig( p_parser, &i_confsize );
p_end = p_start + i_confsize;
for( p_config = p_start; p_config < p_end; p_config++ )
{
/* Hack: required subcategory is stored in min.i */
if( p_config->i_type == CONFIG_SUBCATEGORY &&
p_config->value.i == p_item->min.i )
{
moduleCheckBox *mc = new moduleCheckBox;
mc->checkbox = new wxCheckBox( this, wxID_HIGHEST,
wxU(p_parser->psz_longname));
/* hack to handle submodules properly */
int i = -1;
while( p_parser->pp_shortcuts[++i] != NULL );
i--;
mc->psz_module = strdup( i>=0?p_parser->pp_shortcuts[i]
:p_parser->psz_object_name );
mc->checkbox =
new wxCheckBox( this, wxID_HIGHEST,
wxU(module_GetLongName(p_parser)) );
mc->psz_module = strdup( module_GetObjName(p_parser) );
pp_checkboxes.push_back( mc );
if( p_item->value.psz &&
......@@ -436,7 +436,9 @@ ModuleListCatConfigControl::ModuleListCatConfigControl( vlc_object_t *p_this,
}
sizer->Add( mc->checkbox );
}
} while( p_config < p_end && p_config++ );
}
module_PutConfig( p_start );
}
vlc_list_release( p_list );
......
......@@ -331,6 +331,14 @@ vlc_bool_t module_IsCapable( const module_t *m, const char *cap )
return !strcmp( m->psz_capability, cap );
}
/*****************************************************************************
* module_IsSubModule: checks whether a module is a sub-module.
*****************************************************************************/
vlc_bool_t module_IsSubModule( const module_t *m )
{
return m->b_submodule;
}
/*****************************************************************************
* module_GetObjName: internal name of a module.
*****************************************************************************/
......@@ -794,11 +802,12 @@ char ** __module_GetModulesNamesForCapability( vlc_object_t *p_this,
module_config_t *module_GetConfig (const module_t *module, unsigned *restrict psize)
{
unsigned size = module->confsize;
module_config_t *config;
assert (psize != NULL);
*psize = size;
module_config_t *config = malloc (size * sizeof (*config));
config = malloc (size * sizeof (*config));
if (config)
memcpy (config, module->p_config, size * sizeof (*config));
......@@ -807,7 +816,7 @@ module_config_t *module_GetConfig (const module_t *module, unsigned *restrict ps
void module_PutConfig (module_config_t *config)
{
free (config);
if(config) free (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