Commit ea3e2be6 authored by Stephan Assmus's avatar Stephan Assmus

modules/gui/beos/PreferenceWindow.h/.cpp

	- added settings for screenshot path and image format

	- removed "Save" button, added "Cancel" and "Revert" buttons

	- added revert functionality

	- changed class design for cleaner functionality,
		separated ApplyChanges() into more functions
		to have finer control

	- added more error checking and fixed memory leaks
		(config_GetPsz() returns char*, not const char*!)

	- all settings are now correctly saved and restored

	- some more cosmetic changes


modules/gui/beos/InterfaceWindow.h/.cpp

	- updated vlc way of saving settings to be on par with BeOS way
		and made it selectable in the code which way is used.
		However, the VideoSettings are still only savable in
		the BeOS way.

	- if dvd menus are used, the navigation menu enables a
		"Goto Menu" item. Unfortunately, I don't see a clean
		way to really detect the usage of dvd/dvdold in the
		currently playing stream. I wouldn't want to see
		if a playlist item has "dvd:" or "dvdold:" prepended
		at each interface update.
parent 0d558bdf
......@@ -49,7 +49,7 @@
/* The configuration file and directory */
#ifdef SYS_BEOS
# define CONFIG_DIR "config/settings"
# define CONFIG_DIR "config/settings/VideoLAN Client"
#elif SYS_DARWIN
# define CONFIG_DIR "Library/Preferences/VLC"
#elif defined( WIN32 ) || defined( UNDER_CE )
......
......@@ -2,10 +2,11 @@
* beos.cpp : BeOS plugin for vlc
*****************************************************************************
* Copyright (C) 2000, 2001 VideoLAN
* $Id: BeOS.cpp,v 1.5 2003/01/31 06:45:00 titer Exp $
* $Id: BeOS.cpp,v 1.6 2003/02/09 17:10:52 stippi Exp $
*
* Authors: Jean-Marc Dressler <polux@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
* Stephan Aßmus <stippi@yellowbites.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -64,6 +65,14 @@ vlc_module_begin();
add_integer( "beos-messages-xpos", 0, NULL, "", "" );
add_integer( "beos-messages-ypos", 0, NULL, "", "" );
add_bool( "beos-messages-show", 0, NULL, "", "" );
add_integer( "beos-settings-width", 0, NULL, "", "" );
add_integer( "beos-settings-height", 0, NULL, "", "" );
add_integer( "beos-settings-xpos", 0, NULL, "", "" );
add_integer( "beos-settings-ypos", 0, NULL, "", "" );
add_bool( "beos-settings-show", 0, NULL, "", "" );
add_integer( "beos-screenshot-format", 0, NULL, "", "" );
add_string( "beos-screenshot-path", 0, NULL, "", "" );
add_bool( "beos-use-dvd-menus", 0, NULL, "", "" );
add_submodule();
set_capability( "video output", 100 );
set_callbacks( E_(OpenVideo), E_(CloseVideo) );
......
......@@ -2,7 +2,7 @@
* InterfaceWindow.cpp: beos interface
*****************************************************************************
* Copyright (C) 1999, 2000, 2001 VideoLAN
* $Id: InterfaceWindow.cpp,v 1.28 2003/02/09 11:51:36 titer Exp $
* $Id: InterfaceWindow.cpp,v 1.29 2003/02/09 17:10:52 stippi Exp $
*
* Authors: Jean-Marc Dressler <polux@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
......@@ -53,6 +53,7 @@
#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
......@@ -201,7 +202,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, "Preferences" );
fPreferencesWindow = new PreferencesWindow( p_intf, window_rect, "Settings" );
window_rect.Set( screen_rect.right - 500,
screen_rect.top + 50,
screen_rect.right - 150,
......@@ -272,10 +273,13 @@ InterfaceWindow::InterfaceWindow( BRect frame, const char* name,
fNextTitleMI = new BMenuItem( "Next Title", new BMessage( NEXT_TITLE ) );
fPrevChapterMI = new BMenuItem( "Prev Chapter", new BMessage( PREV_CHAPTER ) );
fNextChapterMI = new BMenuItem( "Next Chapter", new BMessage( NEXT_CHAPTER ) );
fGotoMenuMI = new BMenuItem( "Goto Menu", new BMessage( NAVIGATE_MENU ) );
/* Add the Navigation menu */
fNavigationMenu = new BMenu( "Navigation" );
fMenuBar->AddItem( fNavigationMenu );
fNavigationMenu->AddItem( fGotoMenuMI );
fNavigationMenu->AddSeparatorItem();
fNavigationMenu->AddItem( fPrevTitleMI );
fNavigationMenu->AddItem( fNextTitleMI );
fNavigationMenu->AddItem( fTitleMenu = new TitleMenu( "Go to Title", p_intf ) );
......@@ -309,106 +313,8 @@ InterfaceWindow::InterfaceWindow( BRect frame, const char* name,
_SetMenusEnabled( false );
p_mediaControl->SetEnabled( false );
_RestoreSettings();
/* // Restore interface settings
// 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 );
float minWidth, maxWidth, minHeight, maxHeight;
GetSizeLimits( &minWidth, &maxWidth, &minHeight, &maxHeight );
make_sure_frame_is_within_limits( r, minWidth, minHeight, maxWidth, maxHeight );
if ( make_sure_frame_is_on_screen( r ) )
{
ResizeTo( r.Width(), r.Height() );
MoveTo( r.LeftTop() );
}
}
// 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 );
float minWidth, maxWidth, minHeight, maxHeight;
fPlaylistWindow->GetSizeLimits( &minWidth, &maxWidth, &minHeight, &maxHeight );
make_sure_frame_is_within_limits( r, minWidth, minHeight, maxWidth, maxHeight );
if ( make_sure_frame_is_on_screen( r ) )
{
fPlaylistWindow->ResizeTo( r.Width(), r.Height() );
fPlaylistWindow->MoveTo( r.LeftTop() );
}
}
// child windows are not running yet, that's why we aint locking them
// playlist showing
// 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 && i_height && i_xpos && i_ypos )
{
BRect r( i_xpos, i_ypos, i_xpos + i_width, i_ypos + i_height );
_RestoreSettings();
float minWidth, maxWidth, minHeight, maxHeight;
fMessagesWindow->GetSizeLimits( &minWidth, &maxWidth, &minHeight, &maxHeight );
make_sure_frame_is_within_limits( r, minWidth, minHeight, maxWidth, maxHeight );
if ( make_sure_frame_is_on_screen( r ) )
{
fMessagesWindow->ResizeTo( r.Width(), r.Height() );
fMessagesWindow->MoveTo( r.LeftTop() );
}
}
if( config_GetInt( p_intf, "beos-playlist-show" ) )
{
fPlaylistWindow->Show();
}
else
{
fPlaylistWindow->Hide();
fPlaylistWindow->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 );
float minWidth, maxWidth, minHeight, maxHeight;
fMessagesWindow->GetSizeLimits( &minWidth, &maxWidth, &minHeight, &maxHeight );
make_sure_frame_is_within_limits( r, minWidth, minHeight, maxWidth, maxHeight );
if ( make_sure_frame_is_on_screen( r ) )
{
fMessagesWindow->ResizeTo( r.Width(), r.Height() );
fMessagesWindow->MoveTo( r.LeftTop() );
}
}
// messages showing
if( config_GetInt( p_intf, "beos-messages-show" ) )
{
fMessagesWindow->Show();
}
else
{
fMessagesWindow->Hide();
fMessagesWindow->Show();
}*/
Show();
}
......@@ -420,6 +326,9 @@ InterfaceWindow::~InterfaceWindow()
if( fMessagesWindow )
fMessagesWindow->ReallyQuit();
fMessagesWindow = NULL;
if( fPreferencesWindow )
fPreferencesWindow->ReallyQuit();
fPreferencesWindow = NULL;
delete fFilePanel;
delete fSettings;
}
......@@ -611,6 +520,9 @@ void InterfaceWindow::MessageReceived( BMessage * p_message )
p_wrapper->NextTitle();
break;
}
case NAVIGATE_MENU:
p_wrapper->ToggleTitle( 0 );
break;
case TOGGLE_TITLE:
if ( playback_status > UNDEF_S )
{
......@@ -807,33 +719,6 @@ bool InterfaceWindow::QuitRequested()
p_wrapper->PlaylistStop();
p_mediaControl->SetStatus(NOT_STARTED_S, DEFAULT_RATE);
/* Save interface settings */
/* 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();
}*/
config_SaveConfigFile( p_intf, "beos" );
_StoreSettings();
p_intf->b_die = 1;
......@@ -972,6 +857,10 @@ InterfaceWindow::_SetMenusEnabled(bool hasFile, bool hasChapters, bool hasTitles
fSubtitlesMenu->SetEnabled( hasFile );
if ( fSpeedMenu->IsEnabled() != hasFile )
fSpeedMenu->SetEnabled( hasFile );
// "goto menu" menu item
bool hasMenu = p_intf->p_sys->b_dvdmenus ? hasTitles : false;
if ( fGotoMenuMI->IsEnabled() != hasMenu )
fGotoMenuMI->SetEnabled( hasMenu );
Unlock();
}
}
......@@ -1076,29 +965,82 @@ launch_window( BWindow* window, bool showing )
void
InterfaceWindow::_RestoreSettings()
{
if ( load_settings( fSettings, "interface_settings", "VideoLAN Client" ) == B_OK )
if ( USE_VLC_CONFIG_FILE )
{
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 );
// 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 )
{
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 );
}
}
}
......@@ -1108,38 +1050,85 @@ InterfaceWindow::_RestoreSettings()
void
InterfaceWindow::_StoreSettings()
{
if ( fSettings->ReplaceRect( "main frame", Frame() ) != B_OK )
fSettings->AddRect( "main frame", Frame() );
if ( fPlaylistWindow->Lock() )
if ( USE_VLC_CONFIG_FILE )
{
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();
// 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 ( 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 );
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" );
}
save_settings( fSettings, "interface_settings", "VideoLAN Client" );
// save VLC internal settings
config_SaveConfigFile( p_intf, "beos" );
config_SaveConfigFile( p_intf, "main" );
config_SaveConfigFile( p_intf, "adjust" );
config_SaveConfigFile( p_intf, "ffmpeg" );
}
......
......@@ -2,7 +2,7 @@
* InterfaceWindow.h: BeOS interface window class prototype
*****************************************************************************
* Copyright (C) 1999, 2000, 2001 VideoLAN
* $Id: InterfaceWindow.h,v 1.11 2003/02/01 12:01:11 stippi Exp $
* $Id: InterfaceWindow.h,v 1.12 2003/02/09 17:10:52 stippi Exp $
*
* Authors: Jean-Marc Dressler <polux@via.ecp.fr>
* Tony Castley <tcastley@mail.powerup.com.au>
......@@ -128,6 +128,7 @@ class InterfaceWindow : public BWindow
PreferencesWindow* fPreferencesWindow;
MessagesWindow* fMessagesWindow;
BMenuBar* fMenuBar;
BMenuItem* fGotoMenuMI;
BMenuItem* fNextTitleMI;
BMenuItem* fPrevTitleMI;
BMenuItem* fNextChapterMI;
......
......@@ -2,7 +2,7 @@
* MsgVals.h
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: MsgVals.h,v 1.6 2003/02/03 17:18:48 stippi Exp $
* $Id: MsgVals.h,v 1.7 2003/02/09 17:10:52 stippi Exp $
*
* Authors: Tony Castley <tcastley@mail.powerup.com.au>
* Stephan Aßmus <stippi@yellowbites.com>
......@@ -47,6 +47,7 @@ const uint32 SELECT_SUBTITLE = 'subt';
const uint32 PREV_TITLE = 'prti';
const uint32 NEXT_TITLE = 'nxti';
const uint32 TOGGLE_TITLE = 'tgti';
const uint32 NAVIGATE_MENU = 'navm';
const uint32 PREV_CHAPTER = 'prch';
const uint32 NEXT_CHAPTER = 'nxch';
const uint32 TOGGLE_CHAPTER = 'tgch';
......
......@@ -2,7 +2,7 @@
* PreferencesWindow.cpp: beos interface
*****************************************************************************
* Copyright (C) 1999, 2000, 2001 VideoLAN
* $Id: PreferencesWindow.cpp,v 1.12 2003/01/29 00:02:09 titer Exp $
* $Id: PreferencesWindow.cpp,v 1.13 2003/02/09 17:10:52 stippi Exp $
*
* Authors: Eric Petit <titer@videolan.org>
*
......@@ -21,8 +21,15 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
/* system headers */
#include <malloc.h>
#include <string.h>
/* BeOS headers */
#include <InterfaceKit.h>
#include <Entry.h>
#include <Path.h>
#include <TranslatorRoster.h>
/* VLC headers */
#include <vlc/vlc.h>
......@@ -33,34 +40,198 @@
#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
*****************************************************************************/
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()
{
}
/*****************************************************************************
* DirectoryTextControl::MessageReceived
*****************************************************************************/
void
DirectoryTextControl::MessageReceived( BMessage* message )
{
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;
}
}
/*****************************************************************************
* Preferences::PreferencesWindow
*****************************************************************************/
PreferencesWindow::PreferencesWindow( intf_thread_t * p_intf,
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 | B_NOT_CLOSABLE )
B_NOT_ZOOMABLE | B_NOT_RESIZABLE ),
fDVDMenusBackup( false ),
fPostProcessingBackup( 0 ),
fBrightnessBackup( 100.0 ),
fContrastBackup( 100.0 ),
fHueBackup( 0 ),
fSaturationBackup( 100.0 ),
fScreenShotPathBackup( kDefaultScreenShotPath ),