Commit a4a766a3 authored by Eric Petit's avatar Eric Petit

beos/* : New Preferences window that lets you configure everything.

          It is not complete yet (see the TODO in PreferencesWindow.cpp)
parent c7bfd461
......@@ -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) );
......
......@@ -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);
......
......@@ -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
*****************************************************************************/
......
......@@ -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>
*
......@@ -21,354 +21,236 @@
* 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;