]> git.sesse.net Git - vlc/blobdiff - modules/gui/wxwindows/preferences.cpp
Backport [11507] to 0.8.2
[vlc] / modules / gui / wxwindows / preferences.cpp
index 08bd3fd2679deb08f3ed3dc3c66d17bd7b726a1f..1354467ef724230d7c257733de353f658756ee06 100644 (file)
@@ -1,8 +1,8 @@
 /*****************************************************************************
  * preferences.cpp : wxWindows plugin for vlc
  *****************************************************************************
- * Copyright (C) 2000-2001 VideoLAN
- * $Id: preferences.cpp,v 1.30 2003/09/24 21:31:55 gbazin Exp $
+ * Copyright (C) 2000-2004 VideoLAN
+ * $Id$
  *
  * Authors: Gildas Bazin <gbazin@netcourrier.com>
  *
 #include <vlc/vlc.h>
 #include <vlc/intf.h>
 
-#include <vlc_help.h>
+#include <vlc_config_cat.h>
 
 #include "wxwindows.h"
-#include <wx/notebook.h>
-#include <wx/textctrl.h>
+#include "preferences_widgets.h"
+
 #include <wx/combobox.h>
-#include <wx/spinctrl.h>
 #include <wx/statline.h>
-#include <wx/treectrl.h>
 #include <wx/clntdata.h>
 #include <wx/dynarray.h>
+#include <wx/imaglist.h>
+
+#include "bitmaps/type_net.xpm"
+#include "bitmaps/codec.xpm"
+#include "bitmaps/video.xpm"
+#include "bitmaps/type_playlist.xpm"
+#include "bitmaps/advanced.xpm"
+#include "bitmaps/intf.xpm"
+#include "bitmaps/audio.xpm"
 
 #ifndef wxRB_SINGLE
 #   define wxRB_SINGLE 0
 #endif
 
-#define GENERAL_ID 1242
-#define PLUGIN_ID 1243
-#define CAPABILITY_ID 1244
+#define TYPE_CATEGORY 0
+#define TYPE_CATSUBCAT 1  /* Category with embedded subcategory */
+#define TYPE_SUBCATEGORY 2
+#define TYPE_MODULE 3
 
 /*****************************************************************************
  * Classes declarations.
@@ -84,36 +92,10 @@ private:
     vlc_bool_t b_advanced;
 
     wxTreeItemId root_item;
-    wxTreeItemId general_item;
     wxTreeItemId plugins_item;
 };
 
-struct ConfigData
-{
-    ConfigData( wxPanel *_panel, int _i_conf_type,
-                vlc_bool_t _b_advanced, char *psz_name )
-    { panel = _panel; b_advanced = _b_advanced; b_config_list = VLC_FALSE;
-      i_config_type = _i_conf_type; option_name = wxU(psz_name); }
-
-    vlc_bool_t b_advanced;
-    int i_config_type;
-    vlc_bool_t b_config_list;
-
-    union control
-    {
-        wxComboBox *combobox;
-        wxRadioButton *radio;
-        wxSpinCtrl *spinctrl;
-        wxCheckBox *checkbox;
-        wxTextCtrl *textctrl;
-
-    } control;
-
-    wxPanel *panel;
-    wxString option_name;
-};
-
-WX_DEFINE_ARRAY(ConfigData *, ArrayOfConfigData);
+WX_DEFINE_ARRAY(ConfigControl *, ArrayOfConfigControls);
 
 class PrefsPanel : public wxPanel
 {
@@ -121,7 +103,7 @@ public:
 
     PrefsPanel() { }
     PrefsPanel( wxWindow *parent, intf_thread_t *_p_intf,
-                PrefsDialog *, int i_object_id, char *, char * );
+                PrefsDialog *, ConfigTreeData* );
     virtual ~PrefsPanel() {}
 
     void ApplyChanges();
@@ -133,43 +115,35 @@ private:
 
     vlc_bool_t b_advanced;
 
+    wxStaticText *hidden_text;
     wxBoxSizer *config_sizer;
     wxScrolledWindow *config_window;
 
-    ArrayOfConfigData config_array;
+    ArrayOfConfigControls config_array;
 };
 
 class ConfigTreeData : public wxTreeItemData
 {
 public:
 
-    ConfigTreeData() { b_submodule = 0; panel = NULL; psz_section = NULL; }
-    virtual ~ConfigTreeData() { if( panel ) delete panel; }
+    ConfigTreeData() { b_submodule = 0; panel = NULL; psz_name = NULL;
+                       psz_help = NULL; }
+    virtual ~ConfigTreeData() {
+                                 if( panel ) delete panel;
+                                 if( psz_name ) free( psz_name );
+                                 if( psz_help ) free( psz_help );
+                              };
 
     vlc_bool_t b_submodule;
 
-    char *psz_help;
-
     PrefsPanel *panel;
     wxBoxSizer *sizer;
-    int i_object_id;
-    char *psz_section;
-};
-
-class ConfigEvtHandler : public wxEvtHandler
-{
-public:
-    ConfigEvtHandler( intf_thread_t *p_intf, PrefsDialog *p_prefs_dialog );
-    virtual ~ConfigEvtHandler();
-
-    void ConfigEvtHandler::OnCommandEvent( wxCommandEvent& event );
 
-private:
-
-    DECLARE_EVENT_TABLE()
-
-    intf_thread_t *p_intf;
-    PrefsDialog *p_prefs_dialog;
+    int i_object_id;
+    int i_subcat_id;
+    int i_type;
+    char *psz_name;
+    char *psz_help;
 };
 
 /*****************************************************************************
@@ -194,7 +168,7 @@ BEGIN_EVENT_TABLE(PrefsDialog, wxFrame)
     EVT_CHECKBOX(Advanced_Event, PrefsDialog::OnAdvanced)
 
     /* Don't destroy the window when the user closes it */
-    EVT_CLOSE(PrefsDialog::OnCancel)
+    EVT_CLOSE(PrefsDialog::OnClose)
 END_EVENT_TABLE()
 
 // menu and control ids
@@ -208,13 +182,6 @@ BEGIN_EVENT_TABLE(PrefsTreeCtrl, wxTreeCtrl)
     EVT_COMMAND(Advanced_Event, wxEVT_USER_FIRST, PrefsTreeCtrl::OnAdvanced)
 END_EVENT_TABLE()
 
-BEGIN_EVENT_TABLE(ConfigEvtHandler, wxEvtHandler)
-    EVT_BUTTON(-1, ConfigEvtHandler::OnCommandEvent)
-    EVT_TEXT(-1, ConfigEvtHandler::OnCommandEvent)
-    EVT_RADIOBOX(-1, ConfigEvtHandler::OnCommandEvent)
-    EVT_SPINCTRL(-1, ConfigEvtHandler::OnCommandEvent)
-END_EVENT_TABLE()
-
 /*****************************************************************************
  * Constructor.
  *****************************************************************************/
@@ -302,6 +269,12 @@ void PrefsDialog::OnOk( wxCommandEvent& WXUNUSED(event) )
     prefs_tree->CleanChanges();
 }
 
+void PrefsDialog::OnClose( wxCloseEvent& WXUNUSED(event) )
+{
+    wxCommandEvent cevent;
+    OnCancel(cevent);
+}
+
 void PrefsDialog::OnCancel( wxCommandEvent& WXUNUSED(event) )
 {
     this->Hide();
@@ -318,9 +291,9 @@ void PrefsDialog::OnSave( wxCommandEvent& WXUNUSED(event) )
 void PrefsDialog::OnResetAll( wxCommandEvent& WXUNUSED(event) )
 {
     wxMessageDialog dlg( this,
-        wxU(_("Beware this will reset your VLC Media Player config file.\n"
+        wxU(_("Beware this will reset your VLC media player preferences.\n"
               "Are you sure you want to continue?")),
-        wxU(_("Reset config file")), wxYES_NO|wxNO_DEFAULT|wxCENTRE );
+        wxU(_("Reset Preferences")), wxYES_NO|wxNO_DEFAULT|wxCENTRE );
 
     if ( dlg.ShowModal() == wxID_YES )
     {
@@ -339,57 +312,21 @@ void PrefsDialog::OnAdvanced( wxCommandEvent& event )
     prefs_tree->AddPendingEvent( newevent );
 }
 
-/*****************************************************************************
- * GetCapabilityHelp: Display the help for one capability.
- *****************************************************************************/
-static char * GetCapabilityHelp( char *psz_capability)
-{
-    if( psz_capability == NULL)
-        return NULL;
-
-    if( !strcasecmp(psz_capability,"access") )
-        return strdup(ACCESS_HELP);
-    if( !strcasecmp(psz_capability,"audio filter") )
-        return strdup(AUDIO_FILTER_HELP);
-    if( !strcasecmp(psz_capability,"audio output") )
-        return strdup(AOUT_HELP);
-    if( !strcasecmp(psz_capability,"chroma") )
-        return strdup(CHROMA_HELP);
-    if( !strcasecmp(psz_capability,"decoder") )
-        return strdup(DECODER_HELP);
-    if( !strcasecmp(psz_capability,"demux") )
-        return strdup(DEMUX_HELP);
-    if( !strcasecmp(psz_capability,"interface") )
-        return strdup(INTERFACE_HELP);
-    if( !strcasecmp(psz_capability,"sout access") )
-        return strdup(SOUT_HELP);
-    if( !strcasecmp(psz_capability,"subtitle demux") )
-        return strdup(SUBTITLE_DEMUX_HELP);
-    if( !strcasecmp(psz_capability,"text renderer") )
-        return strdup(TEXT_HELP);
-    if( !strcasecmp(psz_capability,"video output") )
-        return strdup(VOUT_HELP);
-    if( !strcasecmp(psz_capability,"video filter") )
-        return strdup(VIDEO_FILTER_HELP);
-
-    return strdup(UNKNOWN_HELP);
-}
-
 /*****************************************************************************
  * PrefsTreeCtrl class definition.
  *****************************************************************************/
 PrefsTreeCtrl::PrefsTreeCtrl( wxWindow *_p_parent, intf_thread_t *_p_intf,
                               PrefsDialog *_p_prefs_dialog,
                               wxBoxSizer *_p_sizer )
-  : wxTreeCtrl( _p_parent, PrefsTree_Ctrl, wxDefaultPosition, wxDefaultSize,
+  : wxTreeCtrl( _p_parent, PrefsTree_Ctrl, wxDefaultPosition, wxSize(200,-1),
                 wxTR_NO_LINES | wxTR_FULL_ROW_HIGHLIGHT |
                 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;
+    int i_index, i_image=0;
 
     /* Initializations */
     p_intf = _p_intf;
@@ -399,21 +336,23 @@ PrefsTreeCtrl::PrefsTreeCtrl( wxWindow *_p_parent, intf_thread_t *_p_intf,
     b_advanced = VLC_FALSE;
 
     root_item = AddRoot( wxT("") );
+    wxASSERT_MSG(root_item.IsOk(), "Could not add root item");
+
+    wxImageList *p_images = new wxImageList( 16,16,TRUE );
+    p_images->Add( wxIcon( audio_xpm ) );
+    p_images->Add( wxIcon( video_xpm ) );
+    p_images->Add( wxIcon( codec_xpm ) );
+    p_images->Add( wxIcon( type_net_xpm ) );
+    p_images->Add( wxIcon( advanced_xpm ) );
+    p_images->Add( wxIcon( type_playlist_xpm ) );
+    p_images->Add( wxIcon( intf_xpm ) );
+    AssignImageList( p_images );
 
     /* List the plugins */
     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->psz_section = NULL;
-    config_data->i_object_id = GENERAL_ID;
-    config_data->psz_help = strdup( GENERAL_HELP );
-    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;
@@ -422,6 +361,8 @@ PrefsTreeCtrl::PrefsTreeCtrl( wxWindow *_p_parent, intf_thread_t *_p_intf,
     }
     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
@@ -430,45 +371,131 @@ PrefsTreeCtrl::PrefsTreeCtrl( wxWindow *_p_parent, intf_thread_t *_p_intf,
 
         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 = strdup( p_item->psz_longtext);
+                    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),
-                            -1, -1, config_data );
+                switch( p_item->i_value )
+                {
+                    case CAT_AUDIO:
+                        i_image = 0; break;
+                    case CAT_VIDEO:
+                        i_image = 1; break;
+                    case CAT_INPUT:
+                        i_image = 2; break;
+                    case CAT_SOUT:
+                        i_image = 3; break;
+                    case CAT_ADVANCED:
+                        i_image = 4; break;
+                    case CAT_PLAYLIST:
+                        i_image = 5; break;
+                    case CAT_INTERFACE:
+                        i_image = 6; break;
+                }
+                current_item = AppendItem( root_item,
+                                           wxU( config_data->psz_name ),
+                                           i_image, -1, config_data );
+
+                break;
+            case CONFIG_SUBCATEGORY:
+                if( p_item->i_value == SUBCAT_VIDEO_GENERAL ||
+                    p_item->i_value == SUBCAT_AUDIO_GENERAL )
+                {
+                    ConfigTreeData *cd = (ConfigTreeData *)
+                                            GetItemData( current_item );
+                    cd->i_type = TYPE_CATSUBCAT;
+                    cd->i_subcat_id = p_item->i_value;
+                    if( cd->psz_name ) free( cd->psz_name );
+                    cd->psz_name = strdup(  config_CategoryNameGet(
+                                                      p_item->i_value ) );
+                    if( cd->psz_help ) free( cd->psz_help );
+                    char *psz_help = config_CategoryHelpGet( p_item->i_value );
+                    if( psz_help )
+                    {
+                        cd->psz_help = wraptext( strdup( psz_help ),72 ,
+                                                 ISUTF8 );
+                    }
+                    else
+                    {
+                        cd->psz_help = NULL;
+                    }
+                    continue;
+                }
+
+                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;
+                /* WXMSW doesn't know image -1 ... FIXME */
+                #ifdef __WXMSW__
+                switch( p_item->i_value / 100 )
+                {
+                    case CAT_AUDIO:
+                        i_image = 0; break;
+                    case CAT_VIDEO:
+                        i_image = 1; break;
+                    case CAT_INPUT:
+                        i_image = 2; break;
+                    case CAT_SOUT:
+                        i_image = 3; break;
+                    case CAT_ADVANCED:
+                        i_image = 4; break;
+                    case CAT_PLAYLIST:
+                        i_image = 5; break;
+                    case CAT_INTERFACE:
+                        i_image = 6; break;
+                }
+                #else
+                i_image = -1;
+                #endif
+                AppendItem( current_item, wxU( config_data->psz_name ),
+                            i_image, -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->psz_section = NULL;
-    config_data->i_object_id = PLUGIN_ID;
-    config_data->psz_help = strdup( PLUGIN_HELP );
-    plugins_item = AppendItem( root_item, wxU(_("Plugins")),
-                        -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 */
@@ -478,69 +505,123 @@ PrefsTreeCtrl::PrefsTreeCtrl( wxWindow *_p_parent, intf_thread_t *_p_intf,
         /* 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 */
+        wxTreeItemIdValue 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 = NULL;
-            config_data->psz_help = 
-                GetCapabilityHelp( p_module->psz_capability );
-            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 = strdup( "" );
-        AppendItem( capability_item, wxU(p_module->psz_object_name), -1, -1,
+        config_data->psz_help = NULL;
+
+        /* WXMSW doesn't know image -1 ... FIXME */
+        #ifdef __WXMSW__
+        switch( i_subcategory / 100 )
+        {
+            case CAT_AUDIO:
+                i_image = 0; break;
+            case CAT_VIDEO:
+                i_image = 1; break;
+            case CAT_INPUT:
+                i_image = 2; break;
+            case CAT_SOUT:
+                i_image = 3; break;
+            case CAT_ADVANCED:
+                i_image = 4; break;
+            case CAT_PLAYLIST:
+                i_image = 5; break;
+            case CAT_INTERFACE:
+                i_image = 6; break;
+        }
+        #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 );
     }
 
     /* Sort all this mess */
-    long cookie; size_t i_child_index;
-    SortChildren( plugins_item );
-    wxTreeItemId capability_item = GetFirstChild( plugins_item, cookie);
+    wxTreeItemIdValue cookie; 
+    size_t i_child_index;
+    wxTreeItemId capability_item = GetFirstChild( root_item, cookie);
     for( i_child_index = 0;
-         i_child_index < GetChildrenCount( plugins_item, FALSE );
+         (capability_item.IsOk() && 
+          //(i_child_index < GetChildrenCount( plugins_item, FALSE )));
+          (i_child_index < GetChildrenCount( root_item, FALSE )));
          i_child_index++ )
     {
-        capability_item = GetNextChild( plugins_item, cookie );
         SortChildren( capability_item );
+        //capability_item = GetNextChild( plugins_item, cookie );
+        capability_item = GetNextChild( root_item, cookie );
     }
 
     /* Clean-up everything */
@@ -554,60 +635,53 @@ PrefsTreeCtrl::PrefsTreeCtrl( wxWindow *_p_parent, intf_thread_t *_p_intf,
     SelectItem( GetFirstChild( root_item, cookie ) );
 #endif
 
-    Expand( general_item );
+    //cannot expand hidden root item
+    //Expand( root_item );
 }
 
-PrefsTreeCtrl::~PrefsTreeCtrl()
-{
+PrefsTreeCtrl::~PrefsTreeCtrl(){
 }
 
 void PrefsTreeCtrl::ApplyChanges()
 {
-    long cookie, cookie2;
+    wxTreeItemIdValue 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 )
-        {
-            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++ )
+        wxTreeItemId subcategory = GetFirstChild( category, cookie2 );
+        while( subcategory.IsOk() )
         {
-            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;
+    wxTreeItemIdValue cookie, cookie2, cookie3;
     ConfigTreeData *config_data;
 
     config_data = !GetSelection() ? NULL :
@@ -615,48 +689,45 @@ void PrefsTreeCtrl::CleanChanges()
     if( config_data  )
     {
         config_data->panel->Hide();
+#if (wxCHECK_VERSION(2,5,0))
+        p_sizer->Detach( config_data->panel );
+#else
         p_sizer->Remove( config_data->panel );
+#endif
     }
 
-    /* Clean changes for 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++ )
-    {
-        config_data = (ConfigTreeData *)GetItemData( item );
-        if( config_data && config_data->panel )
-        {
-            delete config_data->panel;
-            config_data->panel = NULL;
-        }
-
-        item = GetNextChild( general_item, cookie );
-    }
-
-    /* Clean changes for 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 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_data = (ConfigTreeData *)GetItemData( item2 );
-
+            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;
             }
-
-            item2 = GetNextChild( item, cookie2 );
+            subcategory = GetNextChild( category, cookie2 );
         }
-
-        item = GetNextChild( plugins_item, cookie );
+        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( GetSelection() )
@@ -676,29 +747,28 @@ ConfigTreeData *PrefsTreeCtrl::FindModuleConfig( ConfigTreeData *config_data )
         return config_data;
     }
 
-    long cookie, cookie2;
+    wxTreeItemIdValue 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 */
@@ -707,14 +777,19 @@ ConfigTreeData *PrefsTreeCtrl::FindModuleConfig( ConfigTreeData *config_data )
 
 void PrefsTreeCtrl::OnSelectTreeItem( wxTreeEvent& event )
 {
-    ConfigTreeData *config_data;
+    ConfigTreeData *config_data = NULL;
 
-    config_data = FindModuleConfig( (ConfigTreeData *)GetItemData(
-                                    event.GetOldItem() ) );
+    if( event.GetOldItem() )
+        config_data = FindModuleConfig( (ConfigTreeData *)GetItemData(
+                                        event.GetOldItem() ) );
     if( config_data && config_data->panel )
     {
         config_data->panel->Hide();
+#if (wxCHECK_VERSION(2,5,0))
+        p_sizer->Detach( config_data->panel );
+#else
         p_sizer->Remove( config_data->panel );
+#endif
     }
 
     /* Don't use event.GetItem() because we also send fake events */
@@ -727,9 +802,7 @@ void PrefsTreeCtrl::OnSelectTreeItem( wxTreeEvent& event )
             /* 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
@@ -738,7 +811,7 @@ void PrefsTreeCtrl::OnSelectTreeItem( wxTreeEvent& event )
             config_data->panel->Show();
         }
 
-        p_sizer->Add( config_data->panel, 2, wxEXPAND | wxALL, 0 );
+        p_sizer->Add( config_data->panel, 3, wxEXPAND | wxALL, 0 );
         p_sizer->Layout();
     }
 }
@@ -752,7 +825,11 @@ void PrefsTreeCtrl::OnAdvanced( wxCommandEvent& event )
     if( config_data  )
     {
         config_data->panel->Hide();
+#if (wxCHECK_VERSION(2,5,0))
+        p_sizer->Detach( config_data->panel );
+#else
         p_sizer->Remove( config_data->panel );
+#endif
     }
 
     if( GetSelection() )
@@ -767,50 +844,77 @@ void PrefsTreeCtrl::OnAdvanced( wxCommandEvent& event )
  *****************************************************************************/
 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;
-    module_t        *p_parser;
+    vlc_list_t *p_list = NULL;;
 
     wxStaticText *label;
     wxStaticText *help;
-    wxComboBox *combo;
-    wxSpinCtrl *spin;
-    wxCheckBox *checkbox;
-    wxTextCtrl *textctrl;
-    wxButton *button;
     wxArrayString array;
 
-    vlc_bool_t b_has_advanced = VLC_FALSE;
     module_t *p_module = NULL;
-    
+
     /* Initializations */
     p_intf = _p_intf;
     p_prefs_dialog =_p_prefs_dialog,
 
     b_advanced = VLC_TRUE;
     SetAutoLayout( TRUE );
+    Hide();
 
     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 )
     {
-        wxStaticBox *static_box = new wxStaticBox( this, -1, wxT("") );
-        wxStaticBoxSizer *box_sizer = new wxStaticBoxSizer( static_box,
-                                                            wxVERTICAL );
-        label = new wxStaticText( this, -1, wxU(_( psz_help) ) );
-        box_sizer->Add( label, 1,  wxEXPAND | wxLEFT | wxRIGHT, 5 );
-        sizer->Add( box_sizer, 0, wxEXPAND | wxALL , 5 );
+        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( label, 0, wxEXPAND | wxLEFT, 10 );
+        sizer->Add( new wxStaticLine( this, 0 ), 0,
+                    wxEXPAND | wxLEFT | wxRIGHT, 2 );
+
+        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 */
@@ -826,304 +930,149 @@ PrefsPanel::PrefsPanel( wxWindow* parent, intf_thread_t *_p_intf,
             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 ||
+            config_data->i_type == TYPE_CATSUBCAT )
         {
-            while( !p_item->i_type == CONFIG_HINT_CATEGORY ||
-                   strcmp( psz_section, p_item->psz_text ) )
+            do
             {
+                if( p_item->i_type == CONFIG_SUBCATEGORY &&
+                    ( config_data->i_type == TYPE_SUBCATEGORY &&
+                      p_item->i_value == config_data->i_object_id ) ||
+                    ( config_data->i_type == TYPE_CATSUBCAT &&
+                      p_item->i_value == config_data->i_subcat_id ) )
+                {
+                    break;
+                }
                 if( p_item->i_type == CONFIG_HINT_END )
                     break;
-                p_item++;
-            }
+            } while( p_item++ );
         }
 
         /* Add a head title to the panel */
-        wxStaticBox *static_box = new wxStaticBox( this, -1, wxT("") );
-        wxStaticBoxSizer *box_sizer = new wxStaticBoxSizer( static_box,
-                                                            wxVERTICAL );
-
-        wxStaticBox *help_box = NULL;
-        wxStaticBoxSizer *help_sizer = NULL; 
-
-        label = new wxStaticText( this, -1,
-                                  wxU(_(psz_section ? p_item->psz_text :
-                                  p_module->psz_longname )));
-
-        box_sizer->Add( label, 1,  wxEXPAND | wxLEFT | wxRIGHT, 5 );
-
-        sizer->Add( box_sizer, 0, wxEXPAND | wxLEFT | wxRIGHT , 5 );
-
-        /* Check that we have at least something */
-        if( psz_help && psz_help[1] ) 
+        char *psz_head;
+        if( config_data->i_type == TYPE_SUBCATEGORY ||
+            config_data->i_type == TYPE_CATSUBCAT )
         {
-            help_box   = new wxStaticBox( this, -1, wxT("") );
-            help_sizer = new wxStaticBoxSizer( help_box, wxHORIZONTAL ) ;
-            help = new wxStaticText( this, -1, wxU(_(psz_help)),
-                                     wxDefaultPosition, wxDefaultSize,
-                                     wxST_NO_AUTORESIZE | wxALIGN_LEFT,
-                                     wxT("") );
-
-            help_sizer->Add( help, 1,  wxALL | wxEXPAND , 5 );
-            sizer->Add( help_sizer ,0 ,wxEXPAND | wxALL, 5 );
+            psz_head = config_data->psz_name;
+            p_item++;
+        }
+        else
+        {
+            psz_head = p_module->psz_longname;
         }
 
+        label = new wxStaticText( this, -1,
+                      wxU(_( psz_head ? psz_head : _("Unknown") ) ) );
+        wxFont heading_font = label->GetFont();
+        heading_font.SetPointSize( heading_font.GetPointSize() + 5 );
+        label->SetFont( heading_font );
+        sizer->Add( label, 0, wxEXPAND | wxLEFT, 10 );
+        sizer->Add( new wxStaticLine( this, 0 ), 0,
+                    wxEXPAND | wxLEFT | wxRIGHT, 2 );
+
         /* Now put all the config options into a scrolled window */
         config_sizer = new wxBoxSizer( wxVERTICAL );
         config_window = new wxScrolledWindow( this, -1, wxDefaultPosition,
-            wxDefaultSize, wxSTATIC_BORDER | wxHSCROLL | wxVSCROLL );
+            wxDefaultSize, wxBORDER_NONE | wxHSCROLL | wxVSCROLL );
         config_window->SetAutoLayout( TRUE );
         config_window->SetScrollRate( 5, 5 );
 
         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_value != config_data->i_object_id ) ||
+                  ( config_data->i_type == TYPE_CATSUBCAT  &&
+                    p_item->i_value != config_data->i_subcat_id ) ) &&
+                (p_item->i_type == CONFIG_CATEGORY ||
+                  p_item->i_type == CONFIG_SUBCATEGORY ) )
                 break;
 
-            /* put each config option in a separate panel so we can hide
-             * advanced options easily */
-            wxPanel *panel = new wxPanel( config_window, -1, wxDefaultPosition,
-                                          wxDefaultSize );
-            wxBoxSizer *panel_sizer = new wxBoxSizer( wxHORIZONTAL );
-            ConfigData *config_data =
-                new ConfigData( panel, p_item->i_type,
-                                p_item->b_advanced, p_item->psz_name );
+            ConfigControl *control =
+                CreateConfigControl( VLC_OBJECT(p_intf),
+                                     p_item, config_window );
 
-            switch( p_item->i_type )
-            {
-            case CONFIG_ITEM_MODULE:
-                label = new wxStaticText(panel, -1, wxU(p_item->psz_text));
-                combo = new wxComboBox( panel, -1, wxU(p_item->psz_value),
-                                        wxDefaultPosition, wxDefaultSize,
-                                        0, NULL, wxCB_READONLY | wxCB_SORT );
-
-                /* build a list of available modules */
-                p_list = vlc_list_find( p_intf, 
-                                        VLC_OBJECT_MODULE, FIND_ANYWHERE );
-                combo->Append( wxU(_("Default")), (void *)NULL );
-                combo->SetSelection( 0 );
-                for( int i_index = 0; i_index < p_list->i_count; i_index++ )
-                {
-                    p_parser = (module_t *)p_list->p_values[i_index].p_object ;
-
-                    if( !strcmp( p_parser->psz_capability, p_item->psz_type ) )
-                    {
-                        combo->Append( wxU(p_parser->psz_longname),
-                                       p_parser->psz_object_name );
-                        if( p_item->psz_value && !strcmp(p_item->psz_value, 
-                            p_parser->psz_object_name) )
-                            combo->SetValue( wxU(p_parser->psz_longname) );
-                    }
-                }
-                vlc_list_release( p_list );
-
-                combo->SetToolTip( wxU(p_item->psz_longtext) );
-                config_data->control.combobox = combo;
-                panel_sizer->Add( label, 0, wxALIGN_CENTER_VERTICAL
-                                  | wxALL, 5 );
-                panel_sizer->Add( combo, 1, wxALIGN_CENTER_VERTICAL 
-                                  | wxALL, 5 );
-                break;
-
-            case CONFIG_ITEM_STRING:
-            case CONFIG_ITEM_FILE:
-            case CONFIG_ITEM_DIRECTORY:
-                label = new wxStaticText(panel, -1, wxU(p_item->psz_text));
-                panel_sizer->Add( label, 0, wxALIGN_CENTER_VERTICAL 
-                                  | wxALL, 5 );
-
-                if( !p_item->ppsz_list )
-                {
-                    textctrl = new wxTextCtrl( panel, -1, 
-                                               wxU(p_item->psz_value),
-                                               wxDefaultPosition,
-                                               wxDefaultSize,
-                                               wxTE_PROCESS_ENTER);
-                    textctrl->SetToolTip( wxU(p_item->psz_longtext) );
-                    config_data->control.textctrl = textctrl;
-                    panel_sizer->Add( textctrl, 1, wxALL, 5 );
-                }
-                else
-                {
-                    combo = new wxComboBox( panel, -1, wxU(p_item->psz_value),
-                                            wxDefaultPosition, wxDefaultSize,
-                                            0, NULL, wxCB_READONLY|wxCB_SORT );
-
-                    /* build a list of available options */
-                    for( int i_index = 0; p_item->ppsz_list[i_index];
-                         i_index++ )
-                    {
-                        combo->Append( wxU(p_item->ppsz_list[i_index]) );
-                        if( p_item->psz_value && !strcmp( p_item->psz_value,
-                            p_item->ppsz_list[i_index] ) )
-                            combo->SetSelection( i_index );
-                    }
-
-                    if( p_item->psz_value )
-                        combo->SetValue( wxU(p_item->psz_value) );
-                    combo->SetToolTip( wxU(p_item->psz_longtext) );
-                    config_data->control.combobox = combo;
-                    config_data->b_config_list = VLC_TRUE;
-                    panel_sizer->Add( combo, 1, wxALIGN_CENTER_VERTICAL
-                                      |wxALL, 5 );
-                }
-
-                if( p_item->i_type == CONFIG_ITEM_FILE )
-                {
-                    button = new wxButton( panel, -1, wxU(_("Browse...")) );
-                    panel_sizer->Add( button, 0, wxALIGN_CENTER_VERTICAL
-                                      |wxALL, 5);
-                    button->SetClientData((void *)config_data);
-                }
-                if( p_item->b_advanced ) b_has_advanced = VLC_TRUE;
-                break;
-
-            case CONFIG_ITEM_INTEGER:
-                label = new wxStaticText(panel, -1, wxU(p_item->psz_text));
-                spin = new wxSpinCtrl( panel, -1,
-                                       wxString::Format(wxT("%d"),
-                                                        p_item->i_value),
-                                       wxDefaultPosition, wxDefaultSize,
-                                       wxSP_ARROW_KEYS,
-                                       -16000, 16000, p_item->i_value);
-                spin->SetToolTip( wxU(p_item->psz_longtext) );
-                config_data->control.spinctrl = spin;
-                panel_sizer->Add( label, 0, wxALIGN_CENTER_VERTICAL 
-                                  | wxALL, 5 );
-                panel_sizer->Add( spin, 0, wxALIGN_CENTER_VERTICAL 
-                                  | wxALL, 5 );
-
-                spin->SetClientData((void *)config_data);
-                if( p_item->b_advanced ) b_has_advanced = VLC_TRUE;
-                break;
-
-            case CONFIG_ITEM_KEY:
-            {
-                label = new wxStaticText(panel, -1, wxU(p_item->psz_text));
-                wxCheckBox *alt = new wxCheckBox( panel, -1, wxU(_("Alt")) );
-                alt->SetValue( p_item->i_value & KEY_MODIFIER_ALT );
-                wxCheckBox *ctrl = new wxCheckBox( panel, -1, wxU(_("Ctrl")) );
-                ctrl->SetValue( p_item->i_value & KEY_MODIFIER_CTRL );
-                wxCheckBox *shift = new wxCheckBox( panel, -1, 
-                                                    wxU(_("Shift")) );
-                shift->SetValue( p_item->i_value & KEY_MODIFIER_SHIFT );
-                combo = new wxComboBox( panel, -1, wxU("f"), 
-                                        wxDefaultPosition, wxDefaultSize, 0
-                                        , NULL, wxCB_READONLY | wxCB_SORT );
-                for( int i=0; i < sizeof(keys)/sizeof(key_descriptor_s); i++ )
-                {
-                    combo->Append( wxU(_(keys[i].psz_key_string)),
-                                   (void*)&keys[i].i_key_code );
-                }
-                combo->SetValue( wxU( KeyToString( 
-                                 p_item->i_value&~KEY_MODIFIER )));
-                config_data->control.combobox = combo;
-                panel_sizer->Add( label, 0, wxALIGN_CENTER_VERTICAL 
-                                  | wxALL, 5 );
-                panel_sizer->Add( alt, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
-                panel_sizer->Add( ctrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
-                panel_sizer->Add( shift, 0, wxALIGN_CENTER_VERTICAL |wxALL, 5);
-                panel_sizer->Add( combo, 0, wxALIGN_CENTER_VERTICAL |wxALL, 5);
-                break;
-            }
-
-            case CONFIG_ITEM_FLOAT:
-                label = new wxStaticText(panel, -1, wxU(p_item->psz_text));
-                textctrl = new wxTextCtrl( panel, -1,
-                                           wxString::Format(wxT("%f"),
-                                                            p_item->f_value),
-                                           wxDefaultPosition, wxDefaultSize,
-                                           wxTE_PROCESS_ENTER );
-                textctrl->SetToolTip( wxU(p_item->psz_longtext) );
-                config_data->control.textctrl = textctrl;
-                panel_sizer->Add( label, 0, wxALIGN_CENTER_VERTICAL 
-                                  | wxALL, 5 );
-                panel_sizer->Add( textctrl, 0, wxALIGN_CENTER_VERTICAL 
-                                  | wxALL, 5);
-                if( p_item->b_advanced ) b_has_advanced = VLC_TRUE;
-                break;
-
-            case CONFIG_ITEM_BOOL:
-                checkbox = new wxCheckBox( panel, -1, wxU(p_item->psz_text) );
-                if( p_item->i_value ) checkbox->SetValue(TRUE);
-                checkbox->SetToolTip( wxU(p_item->psz_longtext) );
-                config_data->control.checkbox = checkbox;
-                panel_sizer->Add( checkbox, 0, wxALL, 5 );
-                if( p_item->b_advanced ) b_has_advanced = VLC_TRUE;
-                break;
-
-            default:
-                delete panel; panel = NULL;
-                delete panel_sizer;
-                delete config_data;
-                break;
-            }
-
-            /* Don't add items that were not recognized */  
-            if( panel == NULL ) continue;
-  
-            panel_sizer->Layout();
-            panel->SetSizerAndFit( panel_sizer );
+            /* Don't add items that were not recognized */
+            if( control == NULL ) continue;
 
             /* Add the config data to our array so we can keep a trace of it */
-            config_array.Add( config_data );
-            config_sizer->Add( panel, 0, wxEXPAND | wxALL, 2 );
+            config_array.Add( 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 ||
+                   config_data->i_type == TYPE_CATSUBCAT ) &&
+                 ( 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 );
 
-        /* Intercept all menu events in our custom event handler */
-        config_window->PushEventHandler(
-            new ConfigEvtHandler( p_intf, p_prefs_dialog ) );
-    } 
+        /* And at last put a useful help string if available */
+        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(_(config_data->psz_help)),
+                                     wxDefaultPosition, wxDefaultSize,
+                                     wxALIGN_LEFT,
+                                     wxT("") );
+            sizer->Add( help ,0 ,wxEXPAND | wxALL, 5 );
+        }
+
+        if( config_data->i_type == TYPE_MODULE )
+        {
+            vlc_object_release( p_module );
+        }
+        else
+        {
+            vlc_list_release( p_list );
+        }
+    }
     sizer->Layout();
     SetSizer( sizer );
+    Show();
 }
 
 void PrefsPanel::ApplyChanges()
 {
+    vlc_value_t val;
+
     for( size_t i = 0; i < config_array.GetCount(); i++ )
     {
-        ConfigData *config_data = config_array.Item(i);
+        ConfigControl *control = config_array.Item(i);
 
-        switch( config_data->i_config_type )
+        switch( control->GetType() )
         {
-        case CONFIG_ITEM_MODULE:
-            config_PutPsz( p_intf, config_data->option_name.mb_str(), (char *)
-                           config_data->control.combobox->GetClientData(
-                           config_data->control.combobox->GetSelection() ) );
-            break;
         case CONFIG_ITEM_STRING:
         case CONFIG_ITEM_FILE:
         case CONFIG_ITEM_DIRECTORY:
-            if( !config_data->b_config_list )
-                config_PutPsz( p_intf, config_data->option_name.mb_str(),
-                               config_data->control.textctrl->GetValue().mb_str() );
-            else
-                config_PutPsz( p_intf, config_data->option_name.mb_str(),
-                               config_data->control.combobox->GetValue().mb_str() );
-            break;
-        case CONFIG_ITEM_BOOL:
-            config_PutInt( p_intf, config_data->option_name.mb_str(),
-                           config_data->control.checkbox->IsChecked() );
+        case CONFIG_ITEM_MODULE:
+        case CONFIG_ITEM_MODULE_CAT:
+        case CONFIG_ITEM_MODULE_LIST:
+        case CONFIG_ITEM_MODULE_LIST_CAT:
+            config_PutPsz( p_intf, control->GetName().mb_str(),
+                           control->GetPszValue().mb_str() );
             break;
+        case CONFIG_ITEM_KEY:
+            /* So you don't need to restart to have the changes take effect */
+            val.i_int = control->GetIntValue();
+            var_Set( p_intf->p_vlc, control->GetName().mb_str(), val );
         case CONFIG_ITEM_INTEGER:
-            config_PutInt( p_intf, config_data->option_name.mb_str(),
-                           config_data->control.spinctrl->GetValue() );
+        case CONFIG_ITEM_BOOL:
+            config_PutInt( p_intf, control->GetName().mb_str(),
+                           control->GetIntValue() );
             break;
         case CONFIG_ITEM_FLOAT:
-            {
-                float f_value;
-                if( (wxSscanf(config_data->control.textctrl->GetValue(),
-                              wxT("%f"), &f_value) == 1) )
-                    config_PutFloat( p_intf, config_data->option_name.mb_str(),
-                                     f_value );
-            }
+            config_PutFloat( p_intf, control->GetName().mb_str(),
+                             control->GetFloatValue() );
             break;
         }
     }
@@ -1131,7 +1080,12 @@ void PrefsPanel::ApplyChanges()
 
 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 )
     {
@@ -1139,11 +1093,12 @@ void PrefsPanel::SwitchAdvanced( vlc_bool_t b_new_advanced )
 
         for( size_t i = 0; i < config_array.GetCount(); i++ )
         {
-            ConfigData *config_data = config_array.Item(i);
-            if( config_data->b_advanced )
+            ConfigControl *control = config_array.Item(i);
+            if( control->IsAdvanced() )
             {
-                config_data->panel->Show( b_advanced );
-                config_sizer->Show( config_data->panel, b_advanced );
+                if( !b_advanced ) hidden = true;
+                control->Show( b_advanced );
+                config_sizer->Show( control, b_advanced );
             }
         }
 
@@ -1151,72 +1106,16 @@ void PrefsPanel::SwitchAdvanced( vlc_bool_t b_new_advanced )
         config_window->FitInside();
         config_window->Refresh();
     }
-    return;     
-}
-
-/*****************************************************************************
- * A small helper class which intercepts all events
- *****************************************************************************/
-ConfigEvtHandler::ConfigEvtHandler( intf_thread_t *_p_intf,
-                                    PrefsDialog *_p_prefs_dialog )
-{
-    /* Initializations */
-    p_intf = _p_intf;
-    p_prefs_dialog = _p_prefs_dialog;
-}
-
-ConfigEvtHandler::~ConfigEvtHandler()
-{
-}
-
-void ConfigEvtHandler::OnCommandEvent( wxCommandEvent& event )
-{
-    if( !event.GetEventObject() )
-    {
-        event.Skip();
-        return;
-    }
-
-    ConfigData *config_data = (ConfigData *)
-        ((wxEvtHandler *)event.GetEventObject())->GetClientData();
-
-    if( !config_data )
-    {
-        event.Skip();
-        return;
-    }
-
-    if( config_data->i_config_type == CONFIG_ITEM_FILE )
+hide:
+    if( hidden && hidden_text )
     {
-        wxFileDialog dialog( p_prefs_dialog, wxU(_("Open file")),
-                             wxT(""), wxT(""), wxT("*.*"),
-#if defined( __WXMSW__ )
-                             wxOPEN );
-#else
-                             wxOPEN | wxSAVE );
-#endif
-
-        if( dialog.ShowModal() == wxID_OK )
-        {
-            config_data->control.textctrl->SetValue( dialog.GetPath() );      
-        }
+        hidden_text->Show( true );
+        config_sizer->Show( hidden_text, true );
     }
-
-    switch( config_data->i_config_type )
+    else if ( hidden_text )
     {
-    case CONFIG_ITEM_MODULE:
-        break;
-    case CONFIG_ITEM_STRING:
-        break;
-    case CONFIG_ITEM_FILE:
-        break;
-    case CONFIG_ITEM_INTEGER:
-        break;
-    case CONFIG_ITEM_FLOAT:
-        break;
-    case CONFIG_ITEM_BOOL:
-        break;
+        hidden_text->Show( false );
+        config_sizer->Show( hidden_text, false );
     }
-
-    event.Skip();
+    return;
 }