]> git.sesse.net Git - vlc/blobdiff - modules/gui/wxwindows/preferences.cpp
* modules/video_output/opengl.c: forward control queries to opengl provider.
[vlc] / modules / gui / wxwindows / preferences.cpp
index 869826b10cf461d6c771120712fe256f453f3acd..d5c3f878a25489619db1674db389adeef34b0f62 100644 (file)
@@ -1,8 +1,8 @@
 /*****************************************************************************
  * preferences.cpp : wxWindows plugin for vlc
  *****************************************************************************
- * Copyright (C) 2000-2001 VideoLAN
- * $Id: preferences.cpp,v 1.39 2003/10/29 01:33:27 gbazin Exp $
+ * Copyright (C) 2000-2004 VideoLAN
+ * $Id$
  *
  * Authors: Gildas Bazin <gbazin@netcourrier.com>
  *
 
 #include "wxwindows.h"
 #include "preferences_widgets.h"
-#include <wx/notebook.h>
-#include <wx/textctrl.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>
 
@@ -119,17 +116,19 @@ 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_section = NULL;
+                       psz_help = NULL; }
+    virtual ~ConfigTreeData() { if( panel ) delete panel;
+                                if( psz_section) free(psz_section);
+                                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;
+    char *psz_help;
 };
 
 /*****************************************************************************
@@ -271,9 +270,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 )
     {
@@ -292,41 +291,6 @@ void PrefsDialog::OnAdvanced( wxCommandEvent& event )
     prefs_tree->AddPendingEvent( newevent );
 }
 
-/*****************************************************************************
- * GetCapabilityHelp: Display the help for one capability.
- *****************************************************************************/
-static char * GetCapabilityHelp( char *psz_capability, int i_type)
-{
-    if( psz_capability == NULL) return "";
-
-    if( !strcasecmp(psz_capability,"access") )
-        return i_type == 1 ? ACCESS_TITLE : ACCESS_HELP;
-    if( !strcasecmp(psz_capability,"audio filter") )
-        return i_type == 1 ? AUDIO_FILTER_TITLE : AUDIO_FILTER_HELP;
-    if( !strcasecmp(psz_capability,"audio output") )
-        return i_type == 1 ? AOUT_TITLE : AOUT_HELP;
-    if( !strcasecmp(psz_capability,"chroma") )
-        return i_type == 1 ? CHROMA_TITLE : CHROMA_HELP;
-    if( !strcasecmp(psz_capability,"decoder") )
-        return i_type == 1 ? DECODER_TITLE : DECODER_HELP;
-    if( !strcasecmp(psz_capability,"demux") )
-        return i_type == 1 ? DEMUX_TITLE : DEMUX_HELP;
-    if( !strcasecmp(psz_capability,"interface") )
-        return i_type == 1 ? INTERFACE_TITLE : INTERFACE_HELP;
-    if( !strcasecmp(psz_capability,"sout access") )
-        return i_type == 1 ? SOUT_TITLE : SOUT_HELP;
-    if( !strcasecmp(psz_capability,"subtitle demux") )
-        return i_type == 1 ? SUBTITLE_DEMUX_TITLE : SUBTITLE_DEMUX_HELP;
-    if( !strcasecmp(psz_capability,"text renderer") )
-        return i_type == 1 ? TEXT_TITLE : TEXT_HELP;
-    if( !strcasecmp(psz_capability,"video output") )
-        return i_type == 1 ? VOUT__TITLE : VOUT_HELP;
-    if( !strcasecmp(psz_capability,"video filter") )
-        return i_type == 1 ? VIDEO_FILTER_TITLE : VIDEO_FILTER_HELP;
-
-    return "";
-}
-
 /*****************************************************************************
  * PrefsTreeCtrl class definition.
  *****************************************************************************/
@@ -360,11 +324,10 @@ PrefsTreeCtrl::PrefsTreeCtrl( wxWindow *_p_parent, intf_thread_t *_p_intf,
      * 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 = wraptext( GENERAL_HELP, WRAPCOUNT, ISUTF8 );
+    config_data->psz_help = wraptext( GENERAL_HELP, 72 , ISUTF8 );
     config_data->psz_section = strdup( GENERAL_TITLE );
-    general_item = AppendItem( root_item, wxU(_("General Settings")),
+    general_item = AppendItem( root_item, wxU(_("General settings")),
                                 -1, -1, config_data );
 
     for( i_index = 0; i_index < p_list->i_count; i_index++ )
@@ -391,7 +354,7 @@ PrefsTreeCtrl::PrefsTreeCtrl( wxWindow *_p_parent, intf_thread_t *_p_intf,
                 if( p_item->psz_longtext )
                 {
                     config_data->psz_help =
-                        wraptext( p_item->psz_longtext, WRAPCOUNT, ISUTF8 );
+                        wraptext( p_item->psz_longtext, 72 , ISUTF8 );
                 }
                 else
                 {
@@ -415,12 +378,11 @@ PrefsTreeCtrl::PrefsTreeCtrl( wxWindow *_p_parent, intf_thread_t *_p_intf,
      * 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 = wraptext( PLUGIN_HELP, WRAPCOUNT, ISUTF8 );
+    config_data->psz_help = wraptext( PLUGIN_HELP, 72, ISUTF8 );
     config_data->psz_section = strdup( PLUGIN_TITLE );
-    plugins_item = AppendItem( root_item, wxU(_("Plugins")),
-                        -1,-1,config_data );
+    plugins_item = AppendItem( root_item, wxU(_("Modules")),
+                        -1, -1,config_data );
 
     for( i_index = 0; i_index < p_list->i_count; i_index++ )
     {
@@ -468,10 +430,10 @@ PrefsTreeCtrl::PrefsTreeCtrl( wxWindow *_p_parent, intf_thread_t *_p_intf,
             ConfigTreeData *config_data = new ConfigTreeData;
             config_data->psz_section =
                 wraptext( GetCapabilityHelp( p_module->psz_capability , 1 ),
-                          WRAPCOUNT, ISUTF8 );
+                          72, ISUTF8 );
             config_data->psz_help =
                 wraptext( GetCapabilityHelp( p_module->psz_capability , 2 ),
-                          WRAPCOUNT, ISUTF8 );
+                          72, ISUTF8 );
             config_data->i_object_id = CAPABILITY_ID;
             capability_item = AppendItem( plugins_item,
                                           wxU(p_module->psz_capability),
@@ -497,8 +459,8 @@ PrefsTreeCtrl::PrefsTreeCtrl( wxWindow *_p_parent, intf_thread_t *_p_intf,
          i_child_index < GetChildrenCount( plugins_item, FALSE );
          i_child_index++ )
     {
-        capability_item = GetNextChild( plugins_item, cookie );
         SortChildren( capability_item );
+        capability_item = GetNextChild( plugins_item, cookie );
     }
 
     /* Clean-up everything */
@@ -665,10 +627,11 @@ 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();
@@ -735,7 +698,7 @@ PrefsPanel::PrefsPanel( wxWindow* parent, intf_thread_t *_p_intf,
     wxArrayString array;
 
     module_t *p_module = NULL;
-    
+
     /* Initializations */
     p_intf = _p_intf;
     p_prefs_dialog =_p_prefs_dialog,
@@ -806,7 +769,7 @@ PrefsPanel::PrefsPanel( wxWindow* parent, intf_thread_t *_p_intf,
         /* 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 );
 
@@ -847,7 +810,8 @@ PrefsPanel::PrefsPanel( wxWindow* parent, intf_thread_t *_p_intf,
             sizer->Add( help ,0 ,wxEXPAND | wxALL, 5 );
         }
 
-    } 
+        vlc_object_release( p_module );
+    }
     sizer->Layout();
     SetSizer( sizer );
 }
@@ -908,5 +872,5 @@ void PrefsPanel::SwitchAdvanced( vlc_bool_t b_new_advanced )
         config_window->FitInside();
         config_window->Refresh();
     }
-    return;     
+    return;
 }