#include <vlc/vlc.h>
#include <vlc/intf.h>
-#include <vlc_help.h>
+#include <vlc_config_cat.h>
#include "wxwindows.h"
#include "preferences_widgets.h"
# define wxRB_SINGLE 0
#endif
-#define GENERAL_ID 1242
-#define PLUGIN_ID 1243
-#define CAPABILITY_ID 1244
+#define TYPE_CATEGORY 0
+#define TYPE_SUBCATEGORY 1
+#define TYPE_MODULE 2
/*****************************************************************************
* Classes declarations.
vlc_bool_t b_advanced;
wxTreeItemId root_item;
- wxTreeItemId general_item;
wxTreeItemId plugins_item;
};
PrefsPanel() { }
PrefsPanel( wxWindow *parent, intf_thread_t *_p_intf,
- PrefsDialog *, int i_object_id, char *, char * );
+ PrefsDialog *, ConfigTreeData* );
virtual ~PrefsPanel() {}
void ApplyChanges();
vlc_bool_t b_advanced;
+ wxStaticText *hidden_text;
wxBoxSizer *config_sizer;
wxScrolledWindow *config_window;
{
public:
- ConfigTreeData() { b_submodule = 0; panel = NULL; psz_section = NULL;
+ ConfigTreeData() { b_submodule = 0; panel = NULL; psz_name = NULL;
psz_help = NULL; }
- virtual ~ConfigTreeData() { if( panel ) delete panel;
- if( psz_section) free(psz_section);
- if( psz_help) free(psz_help); }
+ virtual ~ConfigTreeData() {
+ if( panel ) delete panel;
+ if( psz_name ) free( psz_name );
+ if( psz_help ) free( psz_help );
+ };
vlc_bool_t b_submodule;
PrefsPanel *panel;
wxBoxSizer *sizer;
+
int i_object_id;
- char *psz_section;
+ int i_type;
+ char *psz_name;
char *psz_help;
};
wxTR_LINES_AT_ROOT | wxTR_HIDE_ROOT |
wxTR_HAS_BUTTONS | wxTR_TWIST_BUTTONS | wxSUNKEN_BORDER )
{
- vlc_list_t *p_list;
+ vlc_list_t *p_list = NULL;;
module_t *p_module;
module_config_t *p_item;
int i_index;
p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
if( !p_list ) return;
- /*
- * Build a tree of the main options
- */
- ConfigTreeData *config_data = new ConfigTreeData;
- config_data->i_object_id = GENERAL_ID;
- config_data->psz_help = wraptext( GENERAL_HELP, 72 , ISUTF8 );
- config_data->psz_section = strdup( GENERAL_TITLE );
- general_item = AppendItem( root_item, wxU(_("General settings")),
- -1, -1, config_data );
-
+ /* Build the categories list */
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( i_index < p_list->i_count )
{
+ wxTreeItemId current_item;
+ char *psz_help;
/* We found the main module */
/* Enumerate config categories and store a reference so we can
if( p_item ) do
{
+ ConfigTreeData *config_data;
switch( p_item->i_type )
{
- case CONFIG_HINT_CATEGORY:
- ConfigTreeData *config_data = new ConfigTreeData;
- config_data->psz_section = strdup(p_item->psz_text);
- if( p_item->psz_longtext )
+ case CONFIG_CATEGORY:
+ config_data = new ConfigTreeData;
+ config_data->psz_name = strdup( config_CategoryNameGet(
+ p_item->i_value ) );
+ psz_help = config_CategoryHelpGet( p_item->i_value );
+ if( psz_help )
{
- config_data->psz_help =
- wraptext( p_item->psz_longtext, 72 , ISUTF8 );
+ config_data->psz_help = wraptext( strdup( psz_help ),
+ 72 , ISUTF8 );
}
else
{
config_data->psz_help = NULL;
}
- config_data->i_object_id = p_module->i_object_id;
+ config_data->i_type = TYPE_CATEGORY;
+ config_data->i_object_id = p_item->i_value;
/* Add the category to the tree */
- AppendItem( general_item, wxU(p_item->psz_text),
+ current_item = AppendItem( root_item,
+ wxU( config_data->psz_name ),
+ -1, -1, config_data );
+ break;
+ case CONFIG_SUBCATEGORY:
+ config_data = new ConfigTreeData;
+ config_data->psz_name = strdup( config_CategoryNameGet(
+ p_item->i_value ) );
+ psz_help = config_CategoryHelpGet( p_item->i_value );
+ if( psz_help )
+ {
+ config_data->psz_help = wraptext( strdup( psz_help ) ,
+ 72 , ISUTF8 );
+ }
+ else
+ {
+ config_data->psz_help = NULL;
+ }
+ config_data->i_type = TYPE_SUBCATEGORY;
+ config_data->i_object_id = p_item->i_value;
+ AppendItem( current_item, wxU( config_data->psz_name ),
-1, -1, config_data );
break;
}
}
while( p_item->i_type != CONFIG_HINT_END && p_item++ );
- SortChildren( general_item );
}
/*
* Build a tree of all the plugins
*/
- config_data = new ConfigTreeData;
- config_data->i_object_id = PLUGIN_ID;
- config_data->psz_help = wraptext( PLUGIN_HELP, 72, ISUTF8 );
- config_data->psz_section = strdup( PLUGIN_TITLE );
- plugins_item = AppendItem( root_item, wxU(_("Modules")),
- -1, -1,config_data );
-
for( i_index = 0; i_index < p_list->i_count; i_index++ )
{
+ int i_category = -1;
+ int i_subcategory = -1;
+ int i_options = 0;
+
p_module = (module_t *)p_list->p_values[i_index].p_object;
/* Exclude the main module */
/* Exclude empty plugins (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;
+ continue;
+// p_item = ((module_t *)p_module->p_parent)->p_config;
else
p_item = p_module->p_config;
if( !p_item ) continue;
do
{
+ if( p_item->i_type == CONFIG_CATEGORY )
+ {
+ i_category = p_item->i_value;
+ }
+ else if( p_item->i_type == CONFIG_SUBCATEGORY )
+ {
+ i_subcategory = p_item->i_value;
+ }
if( p_item->i_type & CONFIG_ITEM )
+ i_options ++;
+ if( i_options > 0 && i_category >= 0 && i_subcategory >= 0 )
+ {
break;
+ }
}
while( p_item->i_type != CONFIG_HINT_END && p_item++ );
- if( p_item->i_type == CONFIG_HINT_END ) continue;
- /* Find the capability child item */
- long cookie; size_t i_child_index;
- wxTreeItemId capability_item = GetFirstChild( plugins_item, cookie);
- for( i_child_index = 0;
- i_child_index < GetChildrenCount( plugins_item, FALSE );
- i_child_index++ )
+ if( !i_options ) continue;
+
+ /* Find the right category item */
+ long cookie;
+ vlc_bool_t b_found = VLC_FALSE;
+ wxTreeItemId category_item = GetFirstChild( root_item , cookie);
+ while( category_item.IsOk() )
{
- if( !GetItemText(capability_item).Cmp(
- wxU(p_module->psz_capability ) ) )
+ ConfigTreeData *config_data =
+ (ConfigTreeData *)GetItemData( category_item );
+ if( config_data->i_object_id == i_category )
{
+ b_found = VLC_TRUE;
break;
}
- capability_item = GetNextChild( plugins_item, cookie );
+ category_item = GetNextChild( root_item, cookie );
}
- if( i_child_index == GetChildrenCount( plugins_item, FALSE ) &&
- p_module->psz_capability && *p_module->psz_capability )
+ if( !b_found ) continue;
+
+ /* Find subcategory item */
+ b_found = VLC_FALSE;
+ cookie = -1;
+ wxTreeItemId subcategory_item = GetFirstChild( category_item, cookie );
+ while( subcategory_item.IsOk() )
{
- /* We didn't find it, add it */
- ConfigTreeData *config_data = new ConfigTreeData;
- config_data->psz_section =
- wraptext( GetCapabilityHelp( p_module->psz_capability , 1 ),
- 72, ISUTF8 );
- config_data->psz_help =
- wraptext( GetCapabilityHelp( p_module->psz_capability , 2 ),
- 72, ISUTF8 );
- config_data->i_object_id = CAPABILITY_ID;
- capability_item = AppendItem( plugins_item,
- wxU(p_module->psz_capability),
- -1,-1,config_data );
+ ConfigTreeData *config_data =
+ (ConfigTreeData *)GetItemData( subcategory_item );
+ if( config_data->i_object_id == i_subcategory )
+ {
+ b_found = VLC_TRUE;
+ break;
+ }
+ subcategory_item = GetNextChild( category_item, cookie );
+ }
+ if( !b_found )
+ {
+ subcategory_item = category_item;
}
/* Add the plugin to the tree */
ConfigTreeData *config_data = new ConfigTreeData;
config_data->b_submodule = p_module->b_submodule;
+ 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->psz_help = NULL;
- AppendItem( capability_item, wxU(p_module->psz_object_name), -1, -1,
+
+ AppendItem( subcategory_item, wxU( p_module->psz_name ?
+ p_module->psz_name : p_module->psz_object_name)
+ , -1, -1,
config_data );
}
/* Sort all this mess */
long cookie; size_t i_child_index;
- SortChildren( plugins_item );
- wxTreeItemId capability_item = GetFirstChild( plugins_item, cookie);
+ wxTreeItemId capability_item = GetFirstChild( root_item, cookie);
for( i_child_index = 0;
i_child_index < GetChildrenCount( plugins_item, FALSE );
i_child_index++ )
SelectItem( GetFirstChild( root_item, cookie ) );
#endif
- Expand( general_item );
+ Expand( root_item );
}
PrefsTreeCtrl::~PrefsTreeCtrl()
void PrefsTreeCtrl::ApplyChanges()
{
- long cookie, cookie2;
+ long cookie, cookie2, cookie3;
ConfigTreeData *config_data;
- /* Apply changes to the main module */
- wxTreeItemId item = GetFirstChild( general_item, cookie );
- for( size_t i_child_index = 0;
- i_child_index < GetChildrenCount( general_item, FALSE );
- i_child_index++ )
+ wxTreeItemId category = GetFirstChild( root_item, cookie );
+ while( category.IsOk() )
{
- config_data = (ConfigTreeData *)GetItemData( item );
- if( config_data && config_data->panel )
+ wxTreeItemId subcategory = GetFirstChild( category, cookie2 );
+ while( subcategory.IsOk() )
{
- config_data->panel->ApplyChanges();
- }
-
- item = GetNextChild( general_item, cookie );
- }
-
- /* Apply changes to the plugins */
- item = GetFirstChild( plugins_item, cookie );
- for( size_t i_child_index = 0;
- i_child_index < GetChildrenCount( plugins_item, FALSE );
- i_child_index++ )
- {
- wxTreeItemId item2 = GetFirstChild( item, cookie2 );
- for( size_t i_child_index = 0;
- i_child_index < GetChildrenCount( item, FALSE );
- i_child_index++ )
- {
- config_data = (ConfigTreeData *)GetItemData( item2 );
+ wxTreeItemId module = GetFirstChild( subcategory, cookie3 );
+ while( module.IsOk() )
+ {
+ config_data = (ConfigTreeData *)GetItemData( module );
+ if( config_data && config_data->panel )
+ {
+ config_data->panel->ApplyChanges();
+ }
+ module = GetNextChild( subcategory, cookie3 );
+ }
+ config_data = (ConfigTreeData *)GetItemData( subcategory );
if( config_data && config_data->panel )
{
config_data->panel->ApplyChanges();
}
-
- item2 = GetNextChild( item, cookie2 );
+ subcategory = GetNextChild( category, cookie2 );
}
-
- item = GetNextChild( plugins_item, cookie );
+ config_data = (ConfigTreeData *)GetItemData( category );
+ if( config_data && config_data->panel )
+ {
+ config_data->panel->ApplyChanges();
+ }
+ category = GetNextChild( root_item, cookie );
}
}
void PrefsTreeCtrl::CleanChanges()
{
- long cookie, cookie2;
+ long cookie, cookie2, cookie3;
ConfigTreeData *config_data;
config_data = !GetSelection() ? NULL :
p_sizer->Remove( config_data->panel );
}
+ wxTreeItemId category = GetFirstChild( root_item, cookie );
+ while( category.IsOk() )
+ {
+ wxTreeItemId subcategory = GetFirstChild( category, cookie2 );
+ while( subcategory.IsOk() )
+ {
+ wxTreeItemId module = GetFirstChild( subcategory, cookie3 );
+ while( module.IsOk() )
+ {
+ config_data = (ConfigTreeData *)GetItemData( module );
+ if( config_data && config_data->panel )
+ {
+ delete config_data->panel;
+ config_data->panel = NULL;
+ }
+ module = GetNextChild( subcategory, cookie3 );
+ }
+ config_data = (ConfigTreeData *)GetItemData( subcategory );
+ if( config_data && config_data->panel )
+ {
+ delete config_data->panel;
+ config_data->panel = NULL;
+ }
+ subcategory = GetNextChild( category, cookie2 );
+ }
+ config_data = (ConfigTreeData *)GetItemData( category );
+ if( config_data && config_data->panel )
+ {
+ delete config_data->panel;
+ config_data->panel = NULL;
+ }
+ category = GetNextChild( root_item, cookie );
+ }
+
+#if 0
/* Clean changes for the main module */
- wxTreeItemId item = GetFirstChild( general_item, cookie );
+ wxTreeItemId item = GetFirstChild( root_item, cookie );
for( size_t i_child_index = 0;
- i_child_index < GetChildrenCount( general_item, FALSE );
+ i_child_index < GetChildrenCount( root_item, FALSE );
i_child_index++ )
{
config_data = (ConfigTreeData *)GetItemData( item );
config_data->panel = NULL;
}
- item = GetNextChild( general_item, cookie );
+ item = GetNextChild( root_item, cookie );
}
-
/* Clean changes for the plugins */
item = GetFirstChild( plugins_item, cookie );
for( size_t i_child_index = 0;
item = GetNextChild( plugins_item, cookie );
}
-
+#endif
if( GetSelection() )
{
wxTreeEvent event;
return config_data;
}
- long cookie, cookie2;
+ long cookie, cookie2, cookie3;
ConfigTreeData *config_new;
- wxTreeItemId item = GetFirstChild( plugins_item, cookie );
- for( size_t i_child_index = 0;
- i_child_index < GetChildrenCount( plugins_item, FALSE );
- i_child_index++ )
+ wxTreeItemId category = GetFirstChild( root_item, cookie );
+ while( category.IsOk() )
{
- wxTreeItemId item2 = GetFirstChild( item, cookie2 );
- for( size_t i_child_index = 0;
- i_child_index < GetChildrenCount( item, FALSE );
- i_child_index++ )
+ wxTreeItemId subcategory = GetFirstChild( category, cookie2 );
+ while( subcategory.IsOk() )
{
- config_new = (ConfigTreeData *)GetItemData( item2 );
- if( config_new && !config_new->b_submodule &&
- config_new->i_object_id == config_data->i_object_id )
+ wxTreeItemId module = GetFirstChild( subcategory, cookie3 );
+ while( module.IsOk() )
{
- return config_new;
+ config_new = (ConfigTreeData *)GetItemData( module );
+ if( config_new && !config_new->b_submodule &&
+ config_new->i_object_id == config_data->i_object_id )
+ {
+ return config_new;
+ }
+ module = GetNextChild( subcategory, cookie3 );
}
-
- item2 = GetNextChild( item, cookie2 );
+ subcategory = GetNextChild( category, cookie2 );
}
-
- item = GetNextChild( plugins_item, cookie );
+ category = GetNextChild( root_item, cookie );
}
/* Found nothing */
/* The panel hasn't been created yet. Let's do it. */
config_data->panel =
new PrefsPanel( p_parent, p_intf, p_prefs_dialog,
- config_data->i_object_id,
- config_data->psz_section,
- config_data->psz_help );
+ config_data );
config_data->panel->SwitchAdvanced( b_advanced );
}
else
*****************************************************************************/
PrefsPanel::PrefsPanel( wxWindow* parent, intf_thread_t *_p_intf,
PrefsDialog *_p_prefs_dialog,
- int i_object_id, char *psz_section, char *psz_help )
+ ConfigTreeData *config_data )
: wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize )
{
module_config_t *p_item;
+ vlc_list_t *p_list = NULL;;
wxStaticText *label;
wxStaticText *help;
wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );
- if( i_object_id == PLUGIN_ID || i_object_id == GENERAL_ID ||
- i_object_id == CAPABILITY_ID )
+ if( config_data->i_type == TYPE_CATEGORY )
{
- label = new wxStaticText( this, -1,wxU(_( psz_section )));
+ label = new wxStaticText( this, -1,wxU(_( config_data->psz_name )));
wxFont heading_font = label->GetFont();
heading_font.SetPointSize( heading_font.GetPointSize() + 5 );
label->SetFont( heading_font );
sizer->Add( new wxStaticLine( this, 0 ), 0,
wxEXPAND | wxLEFT | wxRIGHT, 2 );
- help = new wxStaticText( this, -1, wxU(_( psz_help ) ) );
+ hidden_text = NULL;
+ help = new wxStaticText( this, -1, wxU(_( config_data->psz_help ) ) );
sizer->Add( help ,0 ,wxEXPAND | wxALL, 5 );
config_sizer = NULL; config_window = NULL;
else
{
/* Get a pointer to the module */
- p_module = (module_t *)vlc_object_get( p_intf, i_object_id );
+ if( config_data->i_type == TYPE_MODULE )
+ {
+ p_module = (module_t *)vlc_object_get( p_intf,
+ config_data->i_object_id );
+ }
+ else
+ {
+ /* List the plugins */
+ int i_index;
+ vlc_bool_t b_found = VLC_FALSE;
+ p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
+ if( !p_list ) return;
+
+ 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" ) )
+ {
+ b_found = VLC_TRUE;
+ break;
+ }
+ }
+ if( !p_module && !b_found )
+ {
+ msg_Warn( p_intf, "ohoh, unable to find main module");
+ return;
+ }
+ }
+
if( p_module->i_object_type != VLC_OBJECT_MODULE )
{
/* 0OOoo something went really bad */
p_item = p_module->p_config;
/* Find the category if it has been specified */
- if( psz_section && p_item->i_type == CONFIG_HINT_CATEGORY )
+ if( config_data->i_type == TYPE_SUBCATEGORY )
{
- while( !p_item->i_type == CONFIG_HINT_CATEGORY ||
- strcmp( psz_section, p_item->psz_text ) )
+ do
{
+ if( p_item->i_type == CONFIG_SUBCATEGORY &&
+ p_item->i_value == config_data->i_object_id )
+ {
+ break;
+ }
if( p_item->i_type == CONFIG_HINT_END )
break;
- p_item++;
- }
+ } while( p_item++ );
}
/* Add a head title to the panel */
+ char *psz_head;
+ if( config_data->i_type == TYPE_SUBCATEGORY )
+ {
+ psz_head = config_data->psz_name;
+ p_item++;
+ }
+ else
+ {
+ psz_head = p_module->psz_longname;
+ }
+
label = new wxStaticText( this, -1,
- wxU(_(psz_section ? p_item->psz_text :
- p_module->psz_longname )));
+ wxU(_( psz_head ? psz_head : _("Unknown") ) ) );
wxFont heading_font = label->GetFont();
heading_font.SetPointSize( heading_font.GetPointSize() + 5 );
label->SetFont( heading_font );
if( p_item ) do
{
/* If a category has been specified, check we finished the job */
- if( psz_section && p_item->i_type == CONFIG_HINT_CATEGORY &&
- strcmp( psz_section, p_item->psz_text ) )
+ if( config_data->i_type == TYPE_SUBCATEGORY &&
+ (p_item->i_type == CONFIG_CATEGORY ||
+ p_item->i_type == CONFIG_SUBCATEGORY ) &&
+ p_item->i_value != config_data->i_object_id )
break;
ConfigControl *control =
config_sizer->Add( control, 0, wxEXPAND | wxALL, 2 );
}
- while( p_item->i_type != CONFIG_HINT_END && p_item++ );
+ while( !( p_item->i_type == CONFIG_HINT_END ||
+ ( config_data->i_type == TYPE_SUBCATEGORY &&
+ ( p_item->i_type == CONFIG_CATEGORY ||
+ p_item->i_type == CONFIG_SUBCATEGORY ) ) ) && p_item++ );
+
config_sizer->Layout();
config_window->SetSizer( config_sizer );
sizer->Add( config_window, 1, wxEXPAND | wxALL, 5 );
+ hidden_text = new wxStaticText( this, -1,
+ wxU( _( "Some options are available but hidden. " \
+ "Check \"Advanced options\" to see them." ) ) );
+ sizer->Add( hidden_text );
/* And at last put a useful help string if available */
- if( psz_help && *psz_help )
+ if( config_data->psz_help && *config_data->psz_help )
{
sizer->Add( new wxStaticLine( this, 0 ), 0,
wxEXPAND | wxLEFT | wxRIGHT, 2 );
- help = new wxStaticText( this, -1, wxU(_(psz_help)),
+ help = new wxStaticText( this, -1, wxU(_(config_data->psz_help)),
wxDefaultPosition, wxDefaultSize,
wxALIGN_LEFT,
wxT("") );
sizer->Add( help ,0 ,wxEXPAND | wxALL, 5 );
}
- vlc_object_release( p_module );
+ if( config_data->i_type == TYPE_MODULE )
+ {
+ vlc_object_release( p_module );
+ }
+ else
+ {
+ vlc_list_release( p_list );
+ }
}
sizer->Layout();
SetSizer( sizer );
case CONFIG_ITEM_FILE:
case CONFIG_ITEM_DIRECTORY:
case CONFIG_ITEM_MODULE:
+ case CONFIG_ITEM_MODULE_LIST:
+ case CONFIG_ITEM_MODULE_LIST_CAT:
config_PutPsz( p_intf, control->GetName().mb_str(),
control->GetPszValue().mb_str() );
break;
void PrefsPanel::SwitchAdvanced( vlc_bool_t b_new_advanced )
{
- if( b_advanced == b_new_advanced ) return;
+ bool hidden = false;
+
+ if( b_advanced == b_new_advanced )
+ {
+ goto hide;
+ }
if( config_sizer && config_window )
{
ConfigControl *control = config_array.Item(i);
if( control->IsAdvanced() )
{
+ if( !b_advanced ) hidden = true;
control->Show( b_advanced );
config_sizer->Show( control, b_advanced );
}
config_window->FitInside();
config_window->Refresh();
}
+hide:
+ if( hidden && hidden_text )
+ {
+ hidden_text->Show( true );
+ config_sizer->Show( hidden_text, true );
+ }
+ else if ( hidden_text )
+ {
+ hidden_text->Show( false );
+ config_sizer->Show( hidden_text, false );
+ }
return;
}