]> git.sesse.net Git - vlc/commitdiff
beos/* : New Preferences window that lets you configure everything.
authorEric Petit <titer@videolan.org>
Sat, 3 May 2003 13:37:21 +0000 (13:37 +0000)
committerEric Petit <titer@videolan.org>
Sat, 3 May 2003 13:37:21 +0000 (13:37 +0000)
          It is not complete yet (see the TODO in PreferencesWindow.cpp)

modules/gui/beos/BeOS.cpp
modules/gui/beos/Interface.cpp
modules/gui/beos/InterfaceWindow.cpp
modules/gui/beos/PreferencesWindow.cpp
modules/gui/beos/PreferencesWindow.h

index a9c514b7fddfb6742bdb78f47d9edd9b97523890..26817a5566604de8f047525a49f7bb7b79a8a0d0 100644 (file)
@@ -2,7 +2,7 @@
  * beos.cpp : BeOS plugin for vlc
  *****************************************************************************
  * Copyright (C) 2000, 2001 VideoLAN
- * $Id: BeOS.cpp,v 1.8 2003/03/30 18:14:37 gbazin Exp $
+ * $Id: BeOS.cpp,v 1.9 2003/05/03 13:37:21 titer Exp $
  *
  * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
  *          Samuel Hocevar <sam@zoy.org>
@@ -51,28 +51,6 @@ vlc_module_begin();
     add_submodule();
         set_capability( "interface", 100 );
         set_callbacks( E_(OpenIntf), E_(CloseIntf) );
-        add_integer( "beos-intf-width", 0, NULL, "", "", VLC_TRUE );
-        add_integer( "beos-intf-height", 0, NULL, "", "", VLC_TRUE );
-        add_integer( "beos-intf-xpos", 0, NULL, "", "", VLC_TRUE );
-        add_integer( "beos-intf-ypos", 0, NULL, "", "", VLC_TRUE );
-        add_integer( "beos-playlist-width", 0, NULL, "", "", VLC_TRUE );
-        add_integer( "beos-playlist-height", 0, NULL, "", "", VLC_TRUE );
-        add_integer( "beos-playlist-xpos", 0, NULL, "", "", VLC_TRUE );
-        add_integer( "beos-playlist-ypos", 0, NULL, "", "", VLC_TRUE );
-        add_bool( "beos-playlist-show", 0, NULL, "", "", VLC_TRUE );
-        add_integer( "beos-messages-width", 0, NULL, "", "", VLC_TRUE );
-        add_integer( "beos-messages-height", 0, NULL, "", "", VLC_TRUE );
-        add_integer( "beos-messages-xpos", 0, NULL, "", "", VLC_TRUE );
-        add_integer( "beos-messages-ypos", 0, NULL, "", "", VLC_TRUE );
-        add_bool( "beos-messages-show", 0, NULL, "", "", VLC_TRUE );
-        add_integer( "beos-settings-width", 0, NULL, "", "", VLC_TRUE );
-        add_integer( "beos-settings-height", 0, NULL, "", "", VLC_TRUE );
-        add_integer( "beos-settings-xpos", 0, NULL, "", "", VLC_TRUE );
-        add_integer( "beos-settings-ypos", 0, NULL, "", "", VLC_TRUE );
-        add_bool( "beos-settings-show", 0, NULL, "", "", VLC_TRUE );
-        add_integer( "beos-screenshot-format", 0, NULL, "", "", VLC_TRUE );
-        add_string( "beos-screenshot-path", 0, NULL, "", "", VLC_TRUE );
-        add_bool( "beos-use-dvd-menus", 0, NULL, "", "", VLC_TRUE );
     add_submodule();                                     
         set_capability( "video output", 100 );
         set_callbacks( E_(OpenVideo), E_(CloseVideo) );
index 2a307fd29f1ae140c07cde6b78c0832f06f15023..548ebe1122bc700c151fe88c3e311e80011d6783 100644 (file)
@@ -2,7 +2,7 @@
  * intf_beos.cpp: beos interface
  *****************************************************************************
  * Copyright (C) 1999, 2000, 2001 VideoLAN
- * $Id: Interface.cpp,v 1.11 2003/03/12 23:15:03 titer Exp $
+ * $Id: Interface.cpp,v 1.12 2003/05/03 13:37:21 titer Exp $
  *
  * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
  *          Samuel Hocevar <sam@zoy.org>
@@ -85,7 +85,10 @@ int E_(OpenIntf) ( vlc_object_t *p_this )
         free( p_intf->p_sys );
         msg_Err( p_intf, "cannot allocate InterfaceWindow" );
         return( 1 );
-    } else {
+    }
+    else
+    {
+        /* Make the be_app aware the interface has been created */
         BMessage message(INTERFACE_CREATED);
         message.AddPointer("window", p_intf->p_sys->p_window);
         be_app->PostMessage(&message);
index 092d36df5657313c29f1f46b5ac8b9603ac9665f..61e1ea663113f7f9d1c2bcd6efd192328ebf6562 100644 (file)
@@ -2,7 +2,7 @@
  * InterfaceWindow.cpp: beos interface
  *****************************************************************************
  * Copyright (C) 1999, 2000, 2001 VideoLAN
- * $Id: InterfaceWindow.cpp,v 1.34 2003/04/22 16:36:16 titer Exp $
+ * $Id: InterfaceWindow.cpp,v 1.35 2003/05/03 13:37:21 titer Exp $
  *
  * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
  *          Samuel Hocevar <sam@zoy.org>
@@ -53,7 +53,6 @@
 
 #define INTERFACE_UPDATE_TIMEOUT 80000 // 2 frames if at 25 fps
 #define INTERFACE_LOCKING_TIMEOUT 5000
-#define USE_VLC_CONFIG_FILE 0
 
 // make_sure_frame_is_on_screen
 bool
@@ -202,7 +201,7 @@ InterfaceWindow::InterfaceWindow( BRect frame, const char* name,
                      ( screen_rect.bottom - PREFS_WINDOW_HEIGHT ) / 2,
                      ( screen_rect.right + PREFS_WINDOW_WIDTH ) / 2,
                      ( screen_rect.bottom + PREFS_WINDOW_HEIGHT ) / 2 );
-    fPreferencesWindow = new PreferencesWindow( p_intf, window_rect, _("Settings") );
+    fPreferencesWindow = new PreferencesWindow( p_intf, window_rect, _("Preferences") );
     window_rect.Set( screen_rect.right - 500,
                      screen_rect.top + 50,
                      screen_rect.right - 150,
@@ -241,7 +240,7 @@ InterfaceWindow::InterfaceWindow( BRect frame, const char* name,
     // Add the file Menu
     BMenu* fileMenu = new BMenu( _("File") );
     fMenuBar->AddItem( fileMenu );
-    fileMenu->AddItem( new BMenuItem( _AddEllipsis(_("Open Subtitles")),
+    fileMenu->AddItem( new BMenuItem( _AddEllipsis(_("Open File")),
                                       new BMessage( OPEN_FILE ), 'O') );
     
     fileMenu->AddItem( new CDMenu( _("Open Disc") ) );
@@ -301,7 +300,7 @@ InterfaceWindow::InterfaceWindow( BRect frame, const char* name,
                                        new BMessage( OPEN_PLAYLIST ), 'P') );
     fShowMenu->AddItem( new BMenuItem( _AddEllipsis(_("Messages")),
                                        new BMessage( OPEN_MESSAGES ), 'M' ) );
-    fShowMenu->AddItem( new BMenuItem( _AddEllipsis(_("Settings")),
+    fShowMenu->AddItem( new BMenuItem( _AddEllipsis(_("Preferences")),
                                        new BMessage( OPEN_PREFERENCES ), 'S' ) );
     fMenuBar->AddItem( fShowMenu );                            
 
@@ -957,82 +956,29 @@ launch_window( BWindow* window, bool showing )
 void
 InterfaceWindow::_RestoreSettings()
 {
-       if ( USE_VLC_CONFIG_FILE )
-       {
-               // main window size and position
-           int i_width = config_GetInt( p_intf, "beos-intf-width" ),
-               i_height = config_GetInt( p_intf, "beos-intf-height" ),
-               i_xpos = config_GetInt( p_intf, "beos-intf-xpos" ),
-               i_ypos = config_GetInt( p_intf, "beos-intf-ypos" );
-           if( i_width > 20 && i_height > 20 && i_xpos >= 0 && i_ypos >= 0 )
-           {
-               BRect r( i_xpos, i_ypos, i_xpos + i_width, i_ypos + i_height );
-               set_window_pos( this, r );
-           }
-               // playlist window size and position
-           i_width = config_GetInt( p_intf, "beos-playlist-width" ),
-           i_height = config_GetInt( p_intf, "beos-playlist-height" ),
-           i_xpos = config_GetInt( p_intf, "beos-playlist-xpos" ),
-           i_ypos = config_GetInt( p_intf, "beos-playlist-ypos" );
-           if( i_width > 20 && i_height > 20 && i_xpos >= 0 && i_ypos >= 0 )
-           {
-               BRect r( i_xpos, i_ypos, i_xpos + i_width, i_ypos + i_height );
-               set_window_pos( fPlaylistWindow, r );
-           }
-           // playlist showing
-           launch_window( fPlaylistWindow, config_GetInt( p_intf, "beos-playlist-show" ) );
-           // messages window size and position
-           i_width = config_GetInt( p_intf, "beos-messages-width" ),
-           i_height = config_GetInt( p_intf, "beos-messages-height" ),
-           i_xpos = config_GetInt( p_intf, "beos-messages-xpos" ),
-           i_ypos = config_GetInt( p_intf, "beos-messages-ypos" );
-           if( i_width > 20 && i_height > 20 && i_xpos >= 0 && i_ypos >= 0 )
-           {
-               BRect r( i_xpos, i_ypos, i_xpos + i_width, i_ypos + i_height );
-               set_window_pos( fMessagesWindow, r );
-           }
-           // messages showing
-           launch_window( fMessagesWindow, config_GetInt( p_intf, "beos-messages-show" ) );
-
-               // messages window size and position
-           i_width = config_GetInt( p_intf, "beos-settings-width" ),
-           i_height = config_GetInt( p_intf, "beos-settings-height" ),
-           i_xpos = config_GetInt( p_intf, "beos-settings-xpos" ),
-           i_ypos = config_GetInt( p_intf, "beos-settings-ypos" );
-           if( i_width > 20 && i_height > 20 && i_xpos >= 0 && i_ypos >= 0 )
-           {
-               BRect r( i_xpos, i_ypos, i_xpos + i_width, i_ypos + i_height );
-               set_window_pos( fPreferencesWindow, r );
-           }
-           // settings showing
-           launch_window( fPreferencesWindow, config_GetInt( p_intf, "beos-settings-show" ) );
-       }
-       else
+       if ( load_settings( fSettings, "interface_settings", "VideoLAN Client" ) == B_OK )
        {
-               if ( load_settings( fSettings, "interface_settings", "VideoLAN Client" ) == B_OK )
-               {
-                       BRect frame;
-                       if ( fSettings->FindRect( "main frame", &frame ) == B_OK )
-                               set_window_pos( this, frame );
-                       if (fSettings->FindRect( "playlist frame", &frame ) == B_OK )
-                               set_window_pos( fPlaylistWindow, frame );
-                       if (fSettings->FindRect( "messages frame", &frame ) == B_OK )
-                               set_window_pos( fMessagesWindow, frame );
-                       if (fSettings->FindRect( "settings frame", &frame ) == B_OK )
-                               set_window_pos( fPreferencesWindow, frame );
-                       
-                       bool showing;
-                       if ( fSettings->FindBool( "playlist showing", &showing ) == B_OK )
-                               launch_window( fPlaylistWindow, showing );
-                       if ( fSettings->FindBool( "messages showing", &showing ) == B_OK )
-                               launch_window( fMessagesWindow, showing );
-                       if ( fSettings->FindBool( "settings showing", &showing ) == B_OK )
-                               launch_window( fPreferencesWindow, showing );
-       
-                       uint32 displayMode;
-                       if ( fSettings->FindInt32( "playlist display mode", (int32*)&displayMode ) == B_OK )
-                               fPlaylistWindow->SetDisplayMode( displayMode );
-               }
+               BRect frame;
+               if ( fSettings->FindRect( "main frame", &frame ) == B_OK )
+                       set_window_pos( this, frame );
+               if (fSettings->FindRect( "playlist frame", &frame ) == B_OK )
+                       set_window_pos( fPlaylistWindow, frame );
+               if (fSettings->FindRect( "messages frame", &frame ) == B_OK )
+                       set_window_pos( fMessagesWindow, frame );
+               if (fSettings->FindRect( "settings frame", &frame ) == B_OK )
+                       set_window_pos( fPreferencesWindow, frame );
+               
+               bool showing;
+               if ( fSettings->FindBool( "playlist showing", &showing ) == B_OK )
+                       launch_window( fPlaylistWindow, showing );
+               if ( fSettings->FindBool( "messages showing", &showing ) == B_OK )
+                       launch_window( fMessagesWindow, showing );
+               if ( fSettings->FindBool( "settings showing", &showing ) == B_OK )
+                       launch_window( fPreferencesWindow, showing );
+
+               uint32 displayMode;
+               if ( fSettings->FindInt32( "playlist display mode", (int32*)&displayMode ) == B_OK )
+                       fPlaylistWindow->SetDisplayMode( displayMode );
        }
 }
 
@@ -1042,92 +988,40 @@ InterfaceWindow::_RestoreSettings()
 void
 InterfaceWindow::_StoreSettings()
 {
-       if ( USE_VLC_CONFIG_FILE )
+       if ( fSettings->ReplaceRect( "main frame", Frame() ) != B_OK )
+               fSettings->AddRect( "main frame", Frame() );
+       if ( fPlaylistWindow->Lock() )
        {
-           // save interface settings in vlc config file
-           BRect frame = Frame();
-           config_PutInt( p_intf, "beos-intf-width", (int)frame.Width() );
-           config_PutInt( p_intf, "beos-intf-height", (int)frame.Height() );
-           config_PutInt( p_intf, "beos-intf-xpos", (int)frame.left );
-           config_PutInt( p_intf, "beos-intf-ypos", (int)frame.top );
-           if( fPlaylistWindow->Lock() )
-           {
-               frame = fPlaylistWindow->Frame();
-               config_PutInt( p_intf, "beos-playlist-width", (int)frame.Width() );
-               config_PutInt( p_intf, "beos-playlist-height", (int)frame.Height() );
-               config_PutInt( p_intf, "beos-playlist-xpos", (int)frame.left );
-               config_PutInt( p_intf, "beos-playlist-ypos", (int)frame.top );
-               config_PutInt( p_intf, "beos-playlist-show", !fPlaylistWindow->IsHidden() );
-               fPlaylistWindow->Unlock();
-           }
-           if( fMessagesWindow->Lock() )
-           {
-               frame = fMessagesWindow->Frame();
-               config_PutInt( p_intf, "beos-messages-width", (int)frame.Width() );
-               config_PutInt( p_intf, "beos-messages-height", (int)frame.Height() );
-               config_PutInt( p_intf, "beos-messages-xpos", (int)frame.left );
-               config_PutInt( p_intf, "beos-messages-ypos", (int)frame.top );
-               config_PutInt( p_intf, "beos-messages-show", !fMessagesWindow->IsHidden() );
-               fMessagesWindow->Unlock();
-           }
-           if( fPreferencesWindow->Lock() )
-           {
-               frame = fPreferencesWindow->Frame();
-               config_PutInt( p_intf, "beos-messages-width", (int)frame.Width() );
-               config_PutInt( p_intf, "beos-messages-height", (int)frame.Height() );
-               config_PutInt( p_intf, "beos-messages-xpos", (int)frame.left );
-               config_PutInt( p_intf, "beos-messages-ypos", (int)frame.top );
-               config_PutInt( p_intf, "beos-messages-show", !fPreferencesWindow->IsHidden() );
-               fPreferencesWindow->Unlock();
-           }
+               if (fSettings->ReplaceRect( "playlist frame", fPlaylistWindow->Frame() ) != B_OK)
+                       fSettings->AddRect( "playlist frame", fPlaylistWindow->Frame() );
+               if (fSettings->ReplaceBool( "playlist showing", !fPlaylistWindow->IsHidden() ) != B_OK)
+                       fSettings->AddBool( "playlist showing", !fPlaylistWindow->IsHidden() );
+               fPlaylistWindow->Unlock();
        }
-    else
-    {
-               if ( fSettings->ReplaceRect( "main frame", Frame() ) != B_OK )
-                       fSettings->AddRect( "main frame", Frame() );
-               if ( fPlaylistWindow->Lock() )
-               {
-                       if (fSettings->ReplaceRect( "playlist frame", fPlaylistWindow->Frame() ) != B_OK)
-                               fSettings->AddRect( "playlist frame", fPlaylistWindow->Frame() );
-                       if (fSettings->ReplaceBool( "playlist showing", !fPlaylistWindow->IsHidden() ) != B_OK)
-                               fSettings->AddBool( "playlist showing", !fPlaylistWindow->IsHidden() );
-                       fPlaylistWindow->Unlock();
-               }
-               if ( fMessagesWindow->Lock() )
-               {
-                       if (fSettings->ReplaceRect( "messages frame", fMessagesWindow->Frame() ) != B_OK)
-                               fSettings->AddRect( "messages frame", fMessagesWindow->Frame() );
-                       if (fSettings->ReplaceBool( "messages showing", !fMessagesWindow->IsHidden() ) != B_OK)
-                               fSettings->AddBool( "messages showing", !fMessagesWindow->IsHidden() );
-                       fMessagesWindow->Unlock();
-               }
-               if ( fPreferencesWindow->Lock() )
-               {
-                       if (fSettings->ReplaceRect( "settings frame", fPreferencesWindow->Frame() ) != B_OK)
-                               fSettings->AddRect( "settings frame", fPreferencesWindow->Frame() );
-                       if (fSettings->ReplaceBool( "settings showing", !fPreferencesWindow->IsHidden() ) != B_OK)
-                               fSettings->AddBool( "settings showing", !fPreferencesWindow->IsHidden() );
-                       fPreferencesWindow->Unlock();
-               }
-               uint32 displayMode = fPlaylistWindow->DisplayMode();
-               if (fSettings->ReplaceInt32( "playlist display mode", displayMode ) != B_OK )
-                       fSettings->AddInt32( "playlist display mode", displayMode );
-       
-               save_settings( fSettings, "interface_settings", "VideoLAN Client" );
-    }
+       if ( fMessagesWindow->Lock() )
+       {
+               if (fSettings->ReplaceRect( "messages frame", fMessagesWindow->Frame() ) != B_OK)
+                       fSettings->AddRect( "messages frame", fMessagesWindow->Frame() );
+               if (fSettings->ReplaceBool( "messages showing", !fMessagesWindow->IsHidden() ) != B_OK)
+                       fSettings->AddBool( "messages showing", !fMessagesWindow->IsHidden() );
+               fMessagesWindow->Unlock();
+       }
+       if ( fPreferencesWindow->Lock() )
+       {
+               if (fSettings->ReplaceRect( "settings frame", fPreferencesWindow->Frame() ) != B_OK)
+                       fSettings->AddRect( "settings frame", fPreferencesWindow->Frame() );
+               if (fSettings->ReplaceBool( "settings showing", !fPreferencesWindow->IsHidden() ) != B_OK)
+                       fSettings->AddBool( "settings showing", !fPreferencesWindow->IsHidden() );
+               fPreferencesWindow->Unlock();
+       }
+       uint32 displayMode = fPlaylistWindow->DisplayMode();
+       if (fSettings->ReplaceInt32( "playlist display mode", displayMode ) != B_OK )
+               fSettings->AddInt32( "playlist display mode", displayMode );
 
-       // save VLC internal settings
-       config_SaveConfigFile( p_intf, "beos" );
-       config_SaveConfigFile( p_intf, "main" );
-       config_SaveConfigFile( p_intf, "adjust" );
-       config_SaveConfigFile( p_intf, "ffmpeg" );
+       save_settings( fSettings, "interface_settings", "VideoLAN Client" );
 }
 
 
-
-
-
-
 /*****************************************************************************
  * CDMenu::CDMenu
  *****************************************************************************/
index c9e0f04904a61061d5e4e1755164def8fceb3370..f85f941edb4f5c2ad3f68604feecf5245847626f 100644 (file)
@@ -2,7 +2,7 @@
  * PreferencesWindow.cpp: beos interface
  *****************************************************************************
  * Copyright (C) 1999, 2000, 2001 VideoLAN
- * $Id: PreferencesWindow.cpp,v 1.14 2003/04/22 16:36:16 titer Exp $
+ * $Id: PreferencesWindow.cpp,v 1.15 2003/05/03 13:37:21 titer Exp $
  *
  * Authors: Eric Petit <titer@videolan.org>
  *
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
-/* system headers */
-#include <malloc.h>
-#include <string.h>
+#include <stdlib.h> /* atoi(), strtod() */
 
-/* BeOS headers */
 #include <InterfaceKit.h>
-#include <Entry.h>
-#include <Path.h>
-#include <TranslatorRoster.h>
+#include <SupportKit.h>
 
-/* VLC headers */
 #include <vlc/vlc.h>
 #include <vlc/intf.h>
 
-/* BeOS module headers */
-#include "VlcWrapper.h"
-#include "MsgVals.h"
 #include "PreferencesWindow.h"
 
-static const char* kTranslatorField = "be:translator";
-static const char* kTypeField = "be:type";
-static const char* kDefaultScreenShotPath = "/boot/home/vlc screenshot";
-static const uint32 kDefaultScreenShotFormat = 'PNG ';
-
-// add_translator_items
-status_t
-add_translator_items( BMenu* intoMenu, uint32 fromType, uint32 command )
-{ 
-       BTranslatorRoster* roster = BTranslatorRoster::Default();
-       translator_id* ids = NULL;
-       int32 count = 0;
-       
-       status_t err = B_NO_INIT;
-       if ( roster )
-               err = roster->GetAllTranslators( &ids, &count );
-       if ( err < B_OK )
-               return err;
-       for ( int32 tix = 0; tix < count; tix++ )
-       { 
-               const translation_format* formats = NULL;
-               int32 num_formats = 0;
-               bool checkOutFormats = false; 
-               err = roster->GetInputFormats( ids[tix], &formats, &num_formats );
-               if ( err == B_OK )
-               {
-                       for ( int iix = 0; iix < num_formats; iix++ )
-                       {
-                               if ( formats[iix].type == fromType )
-                               { 
-                                       checkOutFormats = true;
-                                       break;
-                               }
-                       }
-               }
-               if ( !checkOutFormats )
-                       continue;
-               err = roster->GetOutputFormats(ids[tix], &formats, &num_formats);
-               if ( err == B_OK )
-               {
-                       for ( int32 oix = 0; oix < num_formats; oix++ )
-                       {
-                               if ( formats[oix].type != fromType )
-                               {
-                                       BMessage* message = new BMessage( command );
-                                       message->AddInt32( kTranslatorField, ids[tix] );
-                                       message->AddInt32( kTypeField, formats[oix].type );
-                                       intoMenu->AddItem( new BMenuItem( formats[oix].name, message ) );
-                               }
-                       }
-               } 
-       }
-       delete[] ids;
-       return B_OK; 
-}
-
-// get_config_string
-char*
-get_config_string( intf_thread_t* intf, const char* field, const char* defaultString )
-{
-       char* string = config_GetPsz( intf, field );
-       if ( !string )
-       {
-               string = strdup( defaultString );
-               config_PutPsz( intf, field, string );
-       }
-       return string;
-}
-
-// get_config_int
-int32
-get_config_int( intf_thread_t* intf, const char* field, int32 defaultValue )
-{
-       int32 value = config_GetInt( intf, field );
-       if ( value < 0 )
-       {
-               value = defaultValue;
-               config_PutInt( intf, field, value );
-       }
-       return value;
-}
-
-// get_config_float
-float
-get_config_float( intf_thread_t* intf, const char* field, float defaultValue )
-{
-       float value = config_GetFloat( intf, field );
-       if ( value < 0 )
-       {
-               value = defaultValue;
-               config_PutFloat( intf, field, value );
-       }
-       return value;
-}
-
-
 /*****************************************************************************
- * DirectoryTextControl class
+ * StringItemWithView::StringItemWithView
  *****************************************************************************/
-class DirectoryTextControl : public BTextControl
-{
- public:
-       DirectoryTextControl( BRect frame, const char* name, 
-                                                 const char* label, const char* text,
-                                                 BMessage* message,
-                                                 uint32 resizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP,
-                                                 uint32 flags = B_WILL_DRAW | B_NAVIGABLE );
-       virtual                         ~DirectoryTextControl();
-
-       virtual void            MessageReceived(BMessage *msg);
-};
-
-DirectoryTextControl::DirectoryTextControl( BRect frame, const char* name, 
-                                                                                       const char* label, const char* text,
-                                                                                       BMessage* message,
-                                                                                       uint32 resizingMode, uint32 flags)
-       : BTextControl( frame, name, label, text, message, resizingMode, flags )
-{
-}
-
-DirectoryTextControl::~DirectoryTextControl()
+StringItemWithView::StringItemWithView( const char * text )
+    : BStringItem( text )
 {
+    /* We use the default constructor */
 }
 
 /*****************************************************************************
- * DirectoryTextControl::MessageReceived
+ * ConfigView::ConfigView
  *****************************************************************************/
-void
-DirectoryTextControl::MessageReceived( BMessage* message )
+ConfigView::ConfigView( BRect frame, const char * name,
+                        uint32 resizingMode, uint32 flags )
+    : BView( frame, name, resizingMode, flags )
 {
-       switch ( message->what )
-       {
-               case B_SIMPLE_DATA:
-               {
-                       entry_ref ref;
-                       if ( message->FindRef( "refs", &ref ) == B_OK ) {
-                               BString directory;
-                               BEntry entry;
-                               BPath path;
-                               if ( entry.SetTo( &ref, true ) == B_OK
-                                        && entry.IsDirectory()
-                                        && path.SetTo( &entry ) == B_OK )
-                               {
-                                       SetText( path.Path() );
-                               }
-                       }
-                       break;
-               }
-               default:
-                       BTextControl::MessageReceived( message );
-                       break;
-       }
+    /* We use the default constructor */
 }
 
-
-
 /*****************************************************************************
- * Preferences::PreferencesWindow
+ * PreferencesWindow::PreferencesWindow
  *****************************************************************************/
 PreferencesWindow::PreferencesWindow( intf_thread_t * p_interface,
                                       BRect frame, const char * name )
     : BWindow( frame, name, B_FLOATING_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
-               B_NOT_ZOOMABLE | B_NOT_RESIZABLE ),
-         fDVDMenusBackup( false ),
-         fPostProcessingBackup( 0 ),
-         fBrightnessBackup( 100.0 ),
-         fContrastBackup( 100.0 ),
-         fHueBackup( 0 ),
-         fSaturationBackup( 100.0 ),
-         fScreenShotPathBackup( kDefaultScreenShotPath ),
-         fScreenShotFormatBackup( kDefaultScreenShotFormat ),
-         p_intf( p_interface )
+               B_NOT_ZOOMABLE ),
+      fConfigScroll( NULL ),
+      p_intf( p_interface )
 {
     BRect rect;
 
-    /* "background" view */
+    /* The "background" view */
     rgb_color background = ui_color( B_PANEL_BACKGROUND_COLOR );
     fPrefsView = new BView( Bounds(), NULL, B_FOLLOW_ALL, B_WILL_DRAW );
     fPrefsView->SetViewColor( background );
     AddChild( fPrefsView );
-
-    /* add the tabs */
-    rect = Bounds();
-    rect.top += 10.0;
-    rect.bottom -= 45.0;
-    fTabView = new BTabView( rect, "preferences view" );
-    fTabView->SetViewColor( background );
     
-    fGeneralView = new BView( fTabView->Bounds(), NULL, B_FOLLOW_ALL, B_WILL_DRAW );
-    fGeneralView->SetViewColor( background );
-    fAdjustView = new BView( fTabView->Bounds(), NULL, B_FOLLOW_ALL, B_WILL_DRAW );
-    fAdjustView->SetViewColor( background );
+    /* Create the preferences tree */
+    rect = Bounds();
+    rect.InsetBy( 10, 10 );
+    rect.right = rect.left + 150;
+    fOutline = new BOutlineListView( rect, "preferences tree",
+                                     B_SINGLE_SELECTION_LIST,
+                                     B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM );
+
+    rect.right += B_V_SCROLL_BAR_WIDTH;
+    BScrollView * scrollview = new BScrollView( "scrollview", fOutline,
+                                                B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM,
+                                                0, false, true );
+    fPrefsView->AddChild( scrollview );
     
-    fGeneralTab = new BTab();
-    fTabView->AddTab( fGeneralView, fGeneralTab );
-    fGeneralTab->SetLabel( _("General") );
+    /* We need to be informed if the user selects an item */
+    fOutline->SetSelectionMessage( new BMessage( PREFS_ITEM_SELECTED ) );
+
+    /* Create a dummy view so we can correctly place the real config views later */
+    rect.bottom -= 40;
+    rect.left = rect.right + 15;
+    rect.right = Bounds().right - 15;
+    fDummyView = new BView( rect, "", B_FOLLOW_ALL_SIDES, B_WILL_DRAW );
+    fPrefsView->AddChild( fDummyView );
+   
+    /* Fill the tree */
+    /* TODO:
+        - manage CONFIG_HINT_SUBCATEGORY
+        - use a pop-up for CONFIG_HINT_MODULE
+        - use BSliders for integer_with_range and float_with_range
+        - add a tab for BeOS specific configution (screenshot path, etc)
+        - add the needed LockLooper()s
+        - fix window resizing
+        - make this intuitive ! */
+    vlc_list_t * p_list;
+    p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
+    if( !p_list )
+    {
+        msg_Warn( p_intf, "couldn't find any module !" );
+        return;
+    }
+
+    module_t * p_module;
+    for( int i = 0; i < p_list->i_count; i++ )
+    {
+        p_module = (module_t*) p_list->p_values[i].p_object;
+        
+        /* If the module has no config option, ignore it */
+        module_config_t * p_item;
+        p_item = p_module->p_config;
+        if( !p_item )
+            continue;
+        do
+        {
+            if( p_item->i_type & CONFIG_ITEM )
+                break;
+        } while( p_item->i_type != CONFIG_HINT_END && p_item++ );
+        if( p_item->i_type == CONFIG_HINT_END )
+            continue;
+        
+        /* Build the config view for this module */
+        rect = fDummyView->Bounds();
+        rect.right -= B_V_SCROLL_BAR_WIDTH;
+        ConfigView * configView;
+        configView = new ConfigView( rect, "config view",
+                                     B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP, B_WILL_DRAW );
+        configView->SetViewColor( background );
+        
+        rect = configView->Bounds();
+        rect.InsetBy( 10, 10 );
+        rect.bottom = rect.top + TEXT_HEIGHT;
+        BTextControl * textControl;
+        BCheckBox * checkBox;
+
+        /* FIXME: we use the BControl name to store the VLC variable name.
+           To know what variable type it is, I add one character at the beginning
+           of the name (see ApplyChanges()); it's not pretty, but it works. To
+           be cleaned later. */    
+        char name[128];
+        p_item = p_module->p_config;
+        bool firstItem = true;
+        do
+        {
+            switch( p_item->i_type )
+            {
+                case CONFIG_ITEM_STRING:
+                case CONFIG_ITEM_FILE:
+                case CONFIG_ITEM_MODULE:
+                case CONFIG_ITEM_DIRECTORY:
+                    if( !firstItem )
+                        rect.OffsetBy( 0, 25 );
+                    else
+                        firstItem = false;
+                    
+                    memset( name, 0, 128 );
+                    sprintf( name, "s%s", p_item->psz_name );
+                    textControl = new BTextControl( rect, name, p_item->psz_text,
+                                                    "", new BMessage(),
+                                                    B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP );
+                    configView->AddChild( textControl );
+                    break;
+
+                case CONFIG_ITEM_INTEGER:
+                    if( !firstItem )
+                        rect.OffsetBy( 0, 25 );
+                    else
+                        firstItem = false;
+                        
+                    memset( name, 0, 128 );
+                    sprintf( name, "i%s", p_item->psz_name );
+                    textControl = new BTextControl( rect, name, p_item->psz_text,
+                                                    "", new BMessage(),
+                                                    B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP );
+                    configView->AddChild( textControl );
+                    break;
+
+                case CONFIG_ITEM_FLOAT:
+                    if( !firstItem )
+                        rect.OffsetBy( 0, 25 );
+                    else
+                        firstItem = false;
+                        
+                    memset( name, 0, 128 );
+                    sprintf( name, "f%s", p_item->psz_name );
+                    textControl = new BTextControl( rect, name, p_item->psz_text,
+                                                    "", new BMessage(),
+                                                    B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP );
+                    configView->AddChild( textControl );
+                    break;
+            
+                case CONFIG_ITEM_BOOL:
+                    if( !firstItem )
+                        rect.OffsetBy( 0,25 );
+                    else
+                       firstItem = false;
+                       
+                    memset( name, 0, 128 );
+                    sprintf( name, "b%s", p_item->psz_name );
+                    checkBox = new BCheckBox( rect, name, p_item->psz_text,
+                                              new BMessage(), B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP );
+                    configView->AddChild( checkBox );
+                    break;
+            }
+
+        } while( p_item->i_type != CONFIG_HINT_END && p_item++ );
     
-    fAdjustTab = new BTab();
-    fTabView->AddTab( fAdjustView, fAdjustTab );
-    fAdjustTab->SetLabel( _("Picture") );
+        /* Adjust the configView size */
+        rect.bottom += 10;
+        configView->fRealBounds = BRect( 0, 0, configView->Bounds().Width(), rect.bottom );
+        configView->ResizeTo( configView->Bounds().Width(), configView->Bounds().Height() );
+
+        /* Add the item to the tree */
+        StringItemWithView * stringItem;
+        stringItem = new StringItemWithView( p_module->psz_object_name );
+        stringItem->fConfigView = configView;
+        fOutline->AddItem( stringItem );
+    }
     
-    /* fills the tabs */
-    /* general tab */
-    rect = fGeneralView->Bounds();
-    rect.InsetBy( 10, 10 );
-    rect.bottom = rect.top + 10;
-    fDvdMenusCheck = new BCheckBox( rect, "dvdmenus", _("Use DVD menus"),
-                                  new BMessage( DVDMENUS_CHECK ) );
-    fGeneralView->AddChild( fDvdMenusCheck );
+    vlc_list_release( p_list );
     
-    rect.top = rect.bottom + 20;
-    rect.bottom = rect.top + 30;
-    fPpSlider = new BSlider( rect, "post-processing", _("MPEG4 post-processing level"),
-                               new BMessage( FFMPEG_UPDATE ),
-                               0, 6, B_TRIANGLE_THUMB,
-                               B_FOLLOW_LEFT, B_WILL_DRAW ); 
-    fPpSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
-    fPpSlider->SetHashMarkCount( 7 );
-    fPpSlider->SetLimitLabels( _("None"), _("Maximum") );
-    fGeneralView->AddChild( fPpSlider );
-
-
-       rect.top = fPpSlider->Frame().bottom + 5.0;
-       rect.bottom = rect.top + 15.0;
-       fScreenShotPathTC = new DirectoryTextControl( rect, "screenshot path",
-                                                                                                 _("Screenshot Path:"),
-                                                                                                 fScreenShotPathBackup.String(),
-                                                                                                 new BMessage( SET_FOLDER ) );
-//     fScreenShotPathTC->ResizeToPreferred();
-
-       rect.top = fScreenShotPathTC->Frame().bottom + 5.0;
-       rect.bottom = rect.top + 15.0;  // TODO: this will be so tricky to get right!
-       BMenu* translatorMenu = new BMenu( "translators" );
-       add_translator_items( translatorMenu, B_TRANSLATOR_BITMAP, SET_TRANSLATOR );
-       fScreenShotFormatMF = new BMenuField( rect, "translators field",
-                                                                                 _("Screenshot Format:"), translatorMenu );
-       fScreenShotFormatMF->Menu()->SetRadioMode( true );
-       fScreenShotFormatMF->Menu()->SetLabelFromMarked( true );
-       // this will most likely not work for BMenuFields
-//     fScreenShotFormatMF->ResizeToPreferred();
-
-       fGeneralView->AddChild( fScreenShotPathTC );
-       fGeneralView->AddChild( fScreenShotFormatMF );
-
-       // make sure the controls labels are aligned nicely
-       float labelWidthM = fScreenShotFormatMF->StringWidth( fScreenShotFormatMF->Label() ) + 5.0;
-       float labelWidthP = fScreenShotPathTC->StringWidth( fScreenShotPathTC->Label() ) + 5.0;
-       if ( labelWidthM > labelWidthP )
-       {
-               fScreenShotPathTC->SetDivider( labelWidthM );
-               fScreenShotFormatMF->SetDivider( labelWidthM );
-       }
-       else
-       {
-               fScreenShotPathTC->SetDivider( labelWidthP );
-               fScreenShotFormatMF->SetDivider( labelWidthP );
-       }
-
-    /* restart message */
-    rect = fGeneralView->Bounds();
-    rect.bottom -= 40.0;
-    font_height fh;
-    be_plain_font->GetHeight( &fh );
-    rect.top = rect.bottom - ceilf( fh.ascent + fh.descent ) - 2.0;
-    fRestartString = new BStringView( rect, NULL,
-        _("DVD-menu and MPEG4 settings take effect after playback is restarted.") );
-    fRestartString->SetAlignment( B_ALIGN_CENTER );
-    fGeneralView->AddChild( fRestartString );
-
+    /* Set the correct values */
+    ApplyChanges( false );
     
-    /* adjust tab */
-    rect = fAdjustView->Bounds();
-    rect.InsetBy( 10, 10 );
-    rect.bottom = rect.top + 30;
-    fBrightnessSlider = new BSlider( rect, "brightness", _("Brightness"),
-                                       new BMessage( ADJUST_UPDATE ),
-                                       0, 200, B_TRIANGLE_THUMB,
-                                       B_FOLLOW_LEFT, B_WILL_DRAW );
-    rect.OffsetBy( 0, 40 );
-    fContrastSlider = new BSlider( rect, "contrast", _("Contrast"),
-                                     new BMessage( ADJUST_UPDATE ),
-                                     0, 200, B_TRIANGLE_THUMB,
-                                     B_FOLLOW_LEFT, B_WILL_DRAW );
-    rect.OffsetBy( 0, 40 );
-    fHueSlider = new BSlider( rect, "hue", _("Hue"),
-                                new BMessage( ADJUST_UPDATE ),
-                                0, 360, B_TRIANGLE_THUMB,
-                                B_FOLLOW_LEFT, B_WILL_DRAW );
-    rect.OffsetBy( 0, 40 );
-    fSaturationSlider = new BSlider( rect, "saturation", _("Saturation"),
-                                       new BMessage( ADJUST_UPDATE ),
-                                       0, 200, B_TRIANGLE_THUMB,
-                                       B_FOLLOW_LEFT, B_WILL_DRAW );
-    fAdjustView->AddChild( fBrightnessSlider );
-    fAdjustView->AddChild( fContrastSlider );
-    fAdjustView->AddChild( fHueSlider );
-    fAdjustView->AddChild( fSaturationSlider );
+    /* Select the first item */
+    fOutline->Select( 0 );
     
-    fPrefsView->AddChild( fTabView );
-
-    /* buttons */
-    BButton *button;
+    /* Add the buttons */
+    BButton * button;
     rect = Bounds();
     rect.InsetBy( 10, 10 );
-    rect.top = rect.bottom - 25;
     rect.left = rect.right - 80;
-    button = new BButton( rect, NULL, _("OK"), new BMessage( PREFS_OK ) );
+    rect.top = rect.bottom - 25;
+    button = new BButton( rect, "", _("OK"), new BMessage( PREFS_OK ),
+                          B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM );
     fPrefsView->AddChild( button );
-
-       SetDefaultButton( button );
-
     rect.OffsetBy( -90, 0 );
-    button = new BButton( rect, NULL, _("Cancel"), new BMessage( PREFS_CANCEL ) );
+    button = new BButton( rect, "", _("Revert"), new BMessage( PREFS_REVERT ),
+                          B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM );
     fPrefsView->AddChild( button );
-
     rect.OffsetBy( -90, 0 );
-    button = new BButton( rect, NULL, _("Revert"), new BMessage( PREFS_REVERT ) );
-    fPrefsView->AddChild( button );
-
-       rect.left = Bounds().left + 10.0;
-       rect.right = rect.left + 80.0;
-    button = new BButton( rect, NULL, _("Defaults"), new BMessage( PREFS_DEFAULTS ) );
+    button = new BButton( rect, "", _("Apply"), new BMessage( PREFS_APPLY ),
+                          B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM );
     fPrefsView->AddChild( button );
-
-
-       // sync GUI to VLC 
-       _SetToSettings();
-
-    // start window thread in hidden state
+    
     Hide();
     Show();
 }
@@ -383,271 +265,175 @@ PreferencesWindow::~PreferencesWindow()
 /*****************************************************************************
  * PreferencesWindow::QuitRequested
  *****************************************************************************/
-bool
-PreferencesWindow::QuitRequested()
+bool PreferencesWindow::QuitRequested()
 {
-       // work arround problem when window is closed or Ok pressed though
-       // the text control has focus (it will not have commited changes)
-       config_PutPsz( p_intf, "beos-screenshot-path", fScreenShotPathTC->Text() );
-       if ( !IsHidden() )
-               Hide();
+    if( !IsHidden() )
+        Hide();
        return false;
 }
 
 /*****************************************************************************
  * PreferencesWindow::MessageReceived
  *****************************************************************************/
-void PreferencesWindow::MessageReceived( BMessage * p_message )
+void PreferencesWindow::MessageReceived( BMessage * message )
 {
-    switch ( p_message->what )
+    switchmessage->what )
     {
-       case SET_TRANSLATOR:
-       case SET_FOLDER:
-               _ApplyScreenShotSettings();
-               break;
-        case DVDMENUS_CHECK:
-               _ApplyDVDSettings();
-               break;
-        case ADJUST_UPDATE:
-               _ApplyPictureSettings();
-               break;
-        case FFMPEG_UPDATE:
-               _ApplyFFmpegSettings();
+        case PREFS_ITEM_SELECTED:
+            Update();
             break;
-        case PREFS_REVERT:
-               _RevertChanges();
-               break;
-        case PREFS_DEFAULTS:
-            _SetDefaults();
-            _ApplyChanges();
-            break;
-        case PREFS_CANCEL:
-               _RevertChanges();
-               // fall through
+        
         case PREFS_OK:
+            ApplyChanges( true );
             PostMessage( B_QUIT_REQUESTED );
             break;
-        default:
-            BWindow::MessageReceived( p_message );
+        
+        case PREFS_REVERT:
+            ApplyChanges( false );
+            break;
+        
+        case PREFS_APPLY:
+            ApplyChanges( true );
             break;
-    }
-}
-
-/*****************************************************************************
- * PreferencesWindow::Show
- *****************************************************************************/
-void
-PreferencesWindow::Show()
-{
-       // collect settings for backup
-    fDVDMenusBackup = fDvdMenusCheck->Value() == B_CONTROL_ON;
-    fPostProcessingBackup = fPpSlider->Value();
-    fBrightnessBackup = fBrightnessSlider->Value();
-    fContrastBackup = fContrastSlider->Value();
-    fHueBackup = fHueSlider->Value();
-    fSaturationBackup = fSaturationSlider->Value();
-    fScreenShotPathBackup.SetTo( fScreenShotPathTC->Text() );
-       if ( BMenuItem* item = fScreenShotFormatMF->Menu()->FindMarked() )
-       {
-               BMessage* message = item->Message();
-               if ( message && message->FindInt32( kTypeField,
-                                                       (int32*)&fScreenShotFormatBackup ) != B_OK )
-                       fScreenShotFormatBackup = kDefaultScreenShotFormat;
-       }
-       else
-           fScreenShotFormatBackup = kDefaultScreenShotFormat;
-
-       BWindow::Show();
-}
-
-/*****************************************************************************
- * PreferencesWindow::ReallyQuit
- *****************************************************************************/
-void PreferencesWindow::ReallyQuit()
-{
-    Lock();
-    Hide();
-    Quit();
-}
-
-void
-PreferencesWindow::_SetGUI( bool dvdMenus, int32 postProcessing,
-                                                  float brightness, float contrast,
-                                                  int32 hue, float saturation,
-                                                  const char* screenShotPath,
-                                                  uint32 screenShotTranslator)
-{
-       fDvdMenusCheck->SetValue( dvdMenus );
-       fPpSlider->SetValue( postProcessing );
-       fBrightnessSlider->SetValue( brightness );
-       fContrastSlider->SetValue( contrast );
-       fHueSlider->SetValue( hue );
-       fSaturationSlider->SetValue( saturation );
-       // mark appropriate translator item
-       bool found = false;
-       for ( int32 i = 0; BMenuItem* item = fScreenShotFormatMF->Menu()->ItemAt( i ); i++ )
-       {
-               if ( BMessage* message = item->Message() )
-               {
-                       uint32 format;
-                       if ( message->FindInt32( kTypeField, (int32*)&format ) == B_OK
-                                && format == screenShotTranslator )
-                       {
-                               item->SetMarked( true );
-                               found = true;
-                               break;
-                       }
-               }
-       }
-       if ( !found )
-       {
-               if ( BMenuItem* item = fScreenShotFormatMF->Menu()->ItemAt( 0 ) )
-                       item->SetMarked( true );
-       }
-       fScreenShotPathTC->SetText( screenShotPath );
-}
-
 
-/*****************************************************************************
- * PreferencesWindow::_SetDefaults
- *****************************************************************************/
-void PreferencesWindow::_SetDefaults()
-{
-       _SetGUI( false, 0, 100.0, 100.0, 0, 100.0,
-                       kDefaultScreenShotPath, kDefaultScreenShotFormat );
+        default:
+            BWindow::MessageReceived( message );
+    }
 }
 
 /*****************************************************************************
- * PreferencesWindow::_SetToSettings
+ * PreferencesWindow::FrameResized
  *****************************************************************************/
-void PreferencesWindow::_SetToSettings()
+void PreferencesWindow::FrameResized( float width, float height )
 {
-       char* path = get_config_string( p_intf, "beos-screenshot-path", kDefaultScreenShotPath );
-
-       p_intf->p_sys->b_dvdmenus = get_config_int( p_intf, "beos-use-dvd-menus", false );
-
-       _SetGUI( p_intf->p_sys->b_dvdmenus,
-                       get_config_int( p_intf, "ffmpeg-pp-q", 0 ),
-                       100 *  get_config_float( p_intf, "brightness", 1.0 ),
-                       100 * get_config_float( p_intf, "contrast", 1.0 ),
-                       get_config_int( p_intf, "hue", 0 ),
-                       100 * get_config_float( p_intf, "saturation", 1.0 ),
-                       path,
-                       get_config_int( p_intf, "beos-screenshot-format",
-                                                       kDefaultScreenShotFormat ) );
-       free( path );
+    BWindow::FrameResized( width, height );
+    UpdateScrollBar();
 }
 
 /*****************************************************************************
- * PreferencesWindow::_RevertChanges
+ * PreferencesWindow::Update
  *****************************************************************************/
-void
-PreferencesWindow::_RevertChanges()
+void PreferencesWindow::Update()
 {
-       _SetGUI( fDVDMenusBackup,
-                       fPostProcessingBackup,
-                       fBrightnessBackup,
-                       fContrastBackup,
-                       fHueBackup,
-                       fSaturationBackup,
-                       fScreenShotPathBackup.String(),
-                       fScreenShotFormatBackup );
+    /* Get the selected item */
+    if( fOutline->CurrentSelection() < 0 )
+        return;
+    StringItemWithView * selectedItem =
+        (StringItemWithView*) fOutline->ItemAt( fOutline->CurrentSelection() );
 
-       _ApplyChanges();
+    if( fConfigScroll )
+    {
+        /* If we don't do this, the ConfigView will remember a wrong position */
+        BScrollBar * scrollBar = fConfigScroll->ScrollBar( B_VERTICAL );
+        scrollBar->SetValue( 0 );
+
+        /* Detach the current ConfigView, remove the BScrollView */
+        BView * view;
+        while( ( view = fConfigScroll->ChildAt( 0 ) ) )
+            fConfigScroll->RemoveChild( view );
+        fDummyView->RemoveChild( fConfigScroll );
+        delete fConfigScroll;
+    }
+    
+    /* Create a BScrollView with the new ConfigView in it */
+    fConfigScroll = new BScrollView( "", selectedItem->fConfigView, B_FOLLOW_ALL_SIDES,
+                                     0, false, true, B_NO_BORDER );
+    fDummyView->AddChild( fConfigScroll );
+    UpdateScrollBar();
 }
 
-/*****************************************************************************
- * PreferencesWindow::_ApplyChanges
- *****************************************************************************/
-void PreferencesWindow::_ApplyChanges()
-{
-       _ApplyScreenShotSettings();
-       _ApplyPictureSettings();
-       _ApplyFFmpegSettings();
-       _ApplyDVDSettings();
-}
 
 /*****************************************************************************
- * PreferencesWindow::_ApplyScreenShotSettings
+ * PreferencesWindow::UpdateScrollBar
  *****************************************************************************/
-void
-PreferencesWindow::_ApplyScreenShotSettings()
+void PreferencesWindow::UpdateScrollBar()
 {
-       // screen shot settings
-       uint32 translator = kDefaultScreenShotFormat;
-       if ( BMenuItem* item = fScreenShotFormatMF->Menu()->FindMarked() )
-       {
-               BMessage* message = item->Message();
-               if ( message && message->FindInt32( kTypeField, (int32*)&translator ) != B_OK )
-                       translator = kDefaultScreenShotFormat;
-       }
-       config_PutInt( p_intf, "beos-screenshot-format", translator );
-       config_PutPsz( p_intf, "beos-screenshot-path", fScreenShotPathTC->Text() );
+    /* We have to fix the scrollbar manually because it doesn't handle
+       correctly simple BViews */
+       
+    /* Get the current config view */
+    if( fOutline->CurrentSelection() < 0 )
+        return;
+    StringItemWithView * selectedItem =
+        (StringItemWithView*) fOutline->ItemAt( fOutline->CurrentSelection() );
+    
+    /* Fix the scrollbar */
+       BRect visible = fConfigScroll->Bounds() & selectedItem->fConfigView->fRealBounds;
+       BRect total = fConfigScroll->Bounds() | selectedItem->fConfigView->fRealBounds;
+    BScrollBar * scrollBar = fConfigScroll->ScrollBar( B_VERTICAL );
+    long max = (long)( selectedItem->fConfigView->fRealBounds.Height() -
+                       fConfigScroll->Bounds().Height() );
+    if( max < 0 ) max = 0;
+    scrollBar->SetRange( 0, max );
+    scrollBar->SetProportion( visible.Height() / total.Height() );
 }
 
 /*****************************************************************************
- * PreferencesWindow::_ApplyPictureSettings
+ * PreferencesWindow::ApplyChanges
+ * Apply changes if doIt is true, revert them otherwise
  *****************************************************************************/
-void
-PreferencesWindow::_ApplyPictureSettings()
+void PreferencesWindow::ApplyChanges( bool doIt )
 {
-       VlcWrapper* p_wrapper = p_intf->p_sys->p_wrapper;
-
-       // picture adjustment settings
-    config_PutFloat( p_intf, "brightness",
-                     (float)fBrightnessSlider->Value() / 100 );
-    config_PutFloat( p_intf, "contrast",
-                     (float)fContrastSlider->Value() / 100 );
-    config_PutInt( p_intf, "hue", fHueSlider->Value() );
-    config_PutFloat( p_intf, "saturation",
-                     (float)fSaturationSlider->Value() / 100 );
-
-       // take care of changing "filters on the fly"
-    if( config_GetFloat( p_intf, "brightness" ) != 1 ||
-        config_GetFloat( p_intf, "contrast" ) != 1 ||
-        config_GetInt( p_intf, "hue" ) != 0 ||
-        config_GetFloat( p_intf, "saturation" ) != 1 )
-    {
-       char* string = config_GetPsz( p_intf, "filter" );
-        if( !string || strcmp( string, "adjust" ) )
-        {
-            config_PutPsz( p_intf, "filter", "adjust" );
-            p_wrapper->FilterChange();
-        }
-        if ( string )
-               free( string );
-    }
-    else
+    StringItemWithView * item;
+    ConfigView * view;
+    BView * child;
+    const char * name;
+    BString string;
+    for( int i = 0; i < fOutline->CountItems(); i++ )
     {
-       char* string = config_GetPsz( p_intf, "filter" );
-        if ( string )
+        item = (StringItemWithView*) fOutline->ItemAt( i );
+        view = item->fConfigView;
+        
+        for( int j = 0; j < view->CountChildren(); j++ )
         {
-            config_PutPsz( p_intf, "filter", NULL );
-            p_wrapper->FilterChange();
-               free( string );
+            child = view->ChildAt( j );
+            name = child->Name();
+            switch( *name )
+            {
+                case 's': /* BTextControl, string variable */
+                    if( doIt )
+                        config_PutPsz( p_intf, name + 1, ((BTextControl*)child)->Text() );
+                    else
+                        ((BTextControl*)child)->SetText( config_GetPsz( p_intf, name + 1 ) );
+                    break;
+                case 'i': /* BTextControl, int variable */
+                    if( doIt )
+                        config_PutInt( p_intf, name + 1, atoi( ((BTextControl*)child)->Text() ) );
+                    else
+                    {
+                        string = "";
+                        string << config_GetInt( p_intf, name + 1 );
+                        ((BTextControl*)child)->SetText( string.String() );
+                    }
+                    break;
+                case 'f': /* BTextControl, float variable */
+                    if( doIt )
+                        config_PutFloat( p_intf, name + 1,
+                                         strtod( ((BTextControl*)child)->Text(), NULL ) );
+                    else
+                    {
+                        string = "";
+                        string << config_GetFloat( p_intf, name + 1 );
+                        ((BTextControl*)child)->SetText( string.String() );
+                    }
+                    break;
+                case 'b': /* BCheckBox, bool variable */
+                    if( doIt )
+                        config_PutInt( p_intf, name + 1, ((BCheckBox*)child)->Value() );
+                    else
+                        ((BCheckBox*)child)->SetValue( config_GetInt( p_intf, name + 1 ) );
+                    break;
+            }
         }
     }
 }
 
 /*****************************************************************************
- * PreferencesWindow::_ApplyFFmpegSettings
- *****************************************************************************/
-void
-PreferencesWindow::_ApplyFFmpegSettings()
-{
-       // ffmpeg post processing
-    config_PutInt( p_intf, "ffmpeg-pp-q", fPpSlider->Value() );
-}
-
-/*****************************************************************************
- * PreferencesWindow::_ApplyDVDSettings
+ * PreferencesWindow::ReallyQuit
  *****************************************************************************/
-void
-PreferencesWindow::_ApplyDVDSettings()
+void PreferencesWindow::ReallyQuit()
 {
-       // dvd menus
-       bool dvdMenus = fDvdMenusCheck->Value() == B_CONTROL_ON;
-       p_intf->p_sys->b_dvdmenus = dvdMenus;
-       config_PutInt( p_intf, "beos-use-dvd-menus", dvdMenus );
+    Lock();
+    Hide();
+    Quit();
 }
-
index 2dc648d7fefb4e83a56fbcfc96cd554f6a27e32b..c17ee75f4e6253629911f12b2b8cd489a2549395 100644 (file)
@@ -2,7 +2,7 @@
  * PreferencesWindow.h
  *****************************************************************************
  * Copyright (C) 1999, 2000, 2001 VideoLAN
- * $Id: PreferencesWindow.h,v 1.9 2003/02/09 17:10:52 stippi Exp $
+ * $Id: PreferencesWindow.h,v 1.10 2003/05/03 13:37:21 titer Exp $
  *
  * Authors: Eric Petit <titer@videolan.org>
  *
 #define BEOS_PREFERENCES_WINDOW_H
 
 #include <Window.h>
-#include <String.h>
 
-#define PREFS_WINDOW_WIDTH   400
-#define PREFS_WINDOW_HEIGHT  280
+#define PREFS_WINDOW_WIDTH   600
+#define PREFS_WINDOW_HEIGHT  300
+#define PREFS_ITEM_SELECTED  'pris'
+#define PREFS_OK             'prok'
+#define PREFS_REVERT         'prre'
+#define PREFS_APPLY          'prap'
+#define TEXT_HEIGHT 16
 
-#define PREFS_OK       'prok'
-#define PREFS_CANCEL   'prcb'
-#define PREFS_DEFAULTS 'prde'
-#define PREFS_REVERT   'prrv'
-#define FFMPEG_UPDATE  'ffup'
-#define ADJUST_UPDATE  'ajst'
-#define DVDMENUS_CHECK 'dvme'
-#define SET_TRANSLATOR 'sttr'
-#define SET_FOLDER 'stdr'
-
-class BTabView;
-class BCheckBox;
-class BSlider;
-class BStringView;
-class BMenuField;
-class BTextControl;
-
-class PreferencesWindow : public BWindow
+class ConfigView : public BView
 {
- public:
-                                                               PreferencesWindow( intf_thread_t* p_intf,
-                                                                                                  BRect frame,
-                                                                                                  const char* name );
-       virtual                                         ~PreferencesWindow();
+  public:
+                            ConfigView( BRect frame, const char * name,
+                                        uint32 resizingMode, uint32 flags );
+
+    /* When we create the view, we have to give it an arbitrary size because
+       it will be the size of the BScrollView. That's why we keep the real size
+       in fRealBounds so we can have a correct BScrollBar later */
+    BRect                   fRealBounds;
+};
 
-       virtual bool                            QuitRequested();
-       virtual void                            MessageReceived(BMessage* message);
-       virtual void                            Show();
+class StringItemWithView : public BStringItem
+{
+  public:
+                            StringItemWithView( const char * text );
 
-                       void                            ReallyQuit();
+    /* Here we store the ConfigView associated to this module */
+    ConfigView *            fConfigView;
+};
 
- private:
-                       void                            _SetGUI( bool dvdMenus,
-                                                                                int32 postProcessing,
-                                                                                float brightness,
-                                                                                float contrast,
-                                                                                int32 hue,
-                                                                                float saturation,
-                                                                                const char* screenShotPath,
-                                                                                uint32 screenShotTranslator );
-                       void                            _SetDefaults();
-                       void                            _SetToSettings();
-                       void                            _RevertChanges();
+class PreferencesWindow : public BWindow
+{
+  public:
+                            PreferencesWindow( intf_thread_t * p_intf,
+                                               BRect frame,
+                                               const char * name );
+    virtual                 ~PreferencesWindow();
 
-                       void                            _ApplyChanges();
+    virtual bool            QuitRequested();
+    virtual void            MessageReceived(BMessage* message);
+    virtual void            FrameResized( float, float );
 
-                       void                            _ApplyScreenShotSettings();
-                       void                            _ApplyPictureSettings();
-                       void                            _ApplyFFmpegSettings();
-                       void                            _ApplyDVDSettings();
+            void            Update();
+            void            UpdateScrollBar();
+            void            ApplyChanges( bool doIt );
 
-       BView*                                          fPrefsView;
-       BTabView*                                       fTabView;
-       BView*                                          fGeneralView;
-       BView*                                          fAdjustView;
-       BTab*                                           fGeneralTab;
-       BTab*                                           fAdjustTab;
-       BCheckBox*                                      fDvdMenusCheck;
-       BSlider*                                        fPpSlider;
-       BSlider*                                        fContrastSlider;
-       BSlider*                                        fBrightnessSlider;
-       BSlider*                                        fHueSlider;
-       BSlider*                                        fSaturationSlider;
-       BStringView*                            fRestartString;
-       BMenuField*                                     fScreenShotFormatMF;
-       BTextControl*                           fScreenShotPathTC;
+            void            ReallyQuit();
 
-       bool                                            fDVDMenusBackup;
-       int32                                           fPostProcessingBackup;
-       float                                           fBrightnessBackup;
-       float                                           fContrastBackup;
-       int32                                           fHueBackup;
-       float                                           fSaturationBackup;
-       BString                                         fScreenShotPathBackup;
-       uint32                                          fScreenShotFormatBackup;
+  private:
+    BView *                 fPrefsView;
+    BOutlineListView *      fOutline;
+    BView *                 fDummyView;
+    BScrollView *           fConfigScroll;
 
-       intf_thread_t*                          p_intf;
+    intf_thread_t *         p_intf;
 };
 
-// some global support functions
-int32
-get_config_int( intf_thread_t* intf,
-                               const char* field,
-                               int32 defaultValue );
-
-float
-get_config_float( intf_thread_t* intf,
-                                 const char* field,
-                                 float defaultValue );
-
-// don't leak the return value! (use free())
-char*
-get_config_string( intf_thread_t* intf,
-                                  const char* field,
-                                  const char* defaultString );
-
 #endif    // BEOS_PREFERENCES_WINDOW_H
-