modules/gui/beos/PreferenceWindow.h/.cpp
authorStephan Assmus <stippi@videolan.org>
Sun, 9 Feb 2003 17:10:52 +0000 (17:10 +0000)
committerStephan Assmus <stippi@videolan.org>
Sun, 9 Feb 2003 17:10:52 +0000 (17:10 +0000)
- 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.

include/vlc_config.h
modules/gui/beos/BeOS.cpp
modules/gui/beos/InterfaceWindow.cpp
modules/gui/beos/InterfaceWindow.h
modules/gui/beos/MsgVals.h
modules/gui/beos/PreferencesWindow.cpp
modules/gui/beos/PreferencesWindow.h
modules/gui/beos/VideoOutput.cpp
modules/gui/beos/VlcWrapper.cpp

index 9ee0454..9a4ea7e 100644 (file)
@@ -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 )
index 0bcc98c..b89ac67 100644 (file)
@@ -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) );
index 81e52c4..f522aa3 100644 (file)
@@ -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" );
 }
 
 
index b5c503a..1d3793a 100644 (file)
@@ -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;
index b29cdd3..1e3a79d 100644 (file)
@@ -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';
index 2e1a3a5..ce0cffb 100644 (file)
@@ -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>
  *
  * 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>
 #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 ),
+         fScreenShotFormatBackup( kDefaultScreenShotFormat ),
+         p_intf( p_interface )
 {
-    this->p_intf = p_intf;
     BRect rect;
 
     /* "background" view */
+    rgb_color background = ui_color( B_PANEL_BACKGROUND_COLOR );
     fPrefsView = new BView( Bounds(), NULL, B_FOLLOW_ALL, B_WILL_DRAW );
-    fPrefsView->SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) );
+    fPrefsView->SetViewColor( background );
     AddChild( fPrefsView );
 
     /* add the tabs */
     rect = Bounds();
-    rect.top += 10;
-    rect.bottom -= 65;
+    rect.top += 10.0;
+    rect.bottom -= 45.0;
     fTabView = new BTabView( rect, "preferences view" );
-    fTabView->SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) );
+    fTabView->SetViewColor( background );
     
     fGeneralView = new BView( fTabView->Bounds(), NULL, B_FOLLOW_ALL, B_WILL_DRAW );
-    fGeneralView->SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) );
+    fGeneralView->SetViewColor( background );
     fAdjustView = new BView( fTabView->Bounds(), NULL, B_FOLLOW_ALL, B_WILL_DRAW );
-    fAdjustView->SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) );
+    fAdjustView->SetViewColor( background );
     
     fGeneralTab = new BTab();
     fTabView->AddTab( fGeneralView, fGeneralTab );
@@ -68,10 +239,10 @@ PreferencesWindow::PreferencesWindow( intf_thread_t * p_intf,
     
     fAdjustTab = new BTab();
     fTabView->AddTab( fAdjustView, fAdjustTab );
-    fAdjustTab->SetLabel( "Adjust" );
+    fAdjustTab->SetLabel( "Picture" );
     
     /* fills the tabs */
-    /* ffmpeg tab */
+    /* general tab */
     rect = fGeneralView->Bounds();
     rect.InsetBy( 10, 10 );
     rect.bottom = rect.top + 10;
@@ -82,43 +253,86 @@ PreferencesWindow::PreferencesWindow( intf_thread_t * p_intf,
     rect.top = rect.bottom + 20;
     rect.bottom = rect.top + 30;
     fPpSlider = new BSlider( rect, "post-processing", "MPEG4 post-processing level",
-                               new BMessage( SLIDER_UPDATE ),
+                               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" );
-    fPpSlider->SetValue( config_GetInt( p_intf, "ffmpeg-pp-q" ) );
     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 );
+
     
     /* adjust tab */
     rect = fAdjustView->Bounds();
     rect.InsetBy( 10, 10 );
     rect.bottom = rect.top + 30;
     fBrightnessSlider = new BSlider( rect, "brightness", "Brightness",
-                                       new BMessage( SLIDER_UPDATE ),
+                                       new BMessage( ADJUST_UPDATE ),
                                        0, 200, B_TRIANGLE_THUMB,
                                        B_FOLLOW_LEFT, B_WILL_DRAW );
-    fBrightnessSlider->SetValue( 100 * config_GetFloat( p_intf, "brightness" ) );
     rect.OffsetBy( 0, 40 );
     fContrastSlider = new BSlider( rect, "contrast", "Contrast",
-                                     new BMessage( SLIDER_UPDATE ),
+                                     new BMessage( ADJUST_UPDATE ),
                                      0, 200, B_TRIANGLE_THUMB,
                                      B_FOLLOW_LEFT, B_WILL_DRAW );
-    fContrastSlider->SetValue( 100 * config_GetFloat( p_intf, "contrast" ) );
     rect.OffsetBy( 0, 40 );
     fHueSlider = new BSlider( rect, "hue", "Hue",
-                                new BMessage( SLIDER_UPDATE ),
+                                new BMessage( ADJUST_UPDATE ),
                                 0, 360, B_TRIANGLE_THUMB,
                                 B_FOLLOW_LEFT, B_WILL_DRAW );
-    fHueSlider->SetValue( config_GetInt( p_intf, "hue" ) );
     rect.OffsetBy( 0, 40 );
     fSaturationSlider = new BSlider( rect, "saturation", "Saturation",
-                                       new BMessage( SLIDER_UPDATE ),
+                                       new BMessage( ADJUST_UPDATE ),
                                        0, 200, B_TRIANGLE_THUMB,
                                        B_FOLLOW_LEFT, B_WILL_DRAW );
-    fSaturationSlider->SetValue( 100 * config_GetFloat( p_intf, "saturation" ) );
     fAdjustView->AddChild( fBrightnessSlider );
     fAdjustView->AddChild( fContrastSlider );
     fAdjustView->AddChild( fHueSlider );
@@ -126,15 +340,6 @@ PreferencesWindow::PreferencesWindow( intf_thread_t * p_intf,
     
     fPrefsView->AddChild( fTabView );
 
-    /* restart message */
-    rect = fPrefsView->Bounds();
-    rect.bottom -= 43;
-    rect.top = rect.bottom - 10;
-    fRestartString = new BStringView( rect, NULL,
-        "Warning: changing settings after starting playback may have no effect." );
-    fRestartString->SetAlignment( B_ALIGN_CENTER );
-    fPrefsView->AddChild( fRestartString );
-
     /* buttons */
     BButton *button;
     rect = Bounds();
@@ -144,14 +349,25 @@ PreferencesWindow::PreferencesWindow( intf_thread_t * p_intf,
     button = new BButton( rect, NULL, "OK", new BMessage( PREFS_OK ) );
     fPrefsView->AddChild( button );
 
+       SetDefaultButton( button );
+
     rect.OffsetBy( -90, 0 );
-    button = new BButton( rect, NULL, "Save", new BMessage( PREFS_SAVE ) );
+    button = new BButton( rect, NULL, "Cancel", new BMessage( PREFS_CANCEL ) );
     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 ) );
     fPrefsView->AddChild( button );
-    
+
+
+       // sync GUI to VLC 
+       _SetToSettings();
+
     // start window thread in hidden state
     Hide();
     Show();
@@ -164,6 +380,20 @@ PreferencesWindow::~PreferencesWindow()
 {
 }
 
+/*****************************************************************************
+ * 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();
+       return false;
+}
+
 /*****************************************************************************
  * PreferencesWindow::MessageReceived
  *****************************************************************************/
@@ -171,36 +401,65 @@ void PreferencesWindow::MessageReceived( BMessage * p_message )
 {
     switch ( p_message->what )
     {
+       case SET_TRANSLATOR:
+       case SET_FOLDER:
+               _ApplyScreenShotSettings();
+               break;
         case DVDMENUS_CHECK:
-        case SLIDER_UPDATE:
-        {
-            ApplyChanges();
+               _ApplyDVDSettings();
+               break;
+        case ADJUST_UPDATE:
+               _ApplyPictureSettings();
+               break;
+        case FFMPEG_UPDATE:
+               _ApplyFFmpegSettings();
             break;
-        }
+        case PREFS_REVERT:
+               _RevertChanges();
+               break;
         case PREFS_DEFAULTS:
-        {
-            SetDefaults();
-            ApplyChanges();
-            break;
-        }
-        case PREFS_SAVE:
-        {
-            config_SaveConfigFile( p_intf, "main" );
-            config_SaveConfigFile( p_intf, "adjust" );
-            config_SaveConfigFile( p_intf, "ffmpeg" );
+            _SetDefaults();
+            _ApplyChanges();
             break;
-        }
+        case PREFS_CANCEL:
+               _RevertChanges();
+               // fall through
         case PREFS_OK:
-        {
-            Hide();
+            PostMessage( B_QUIT_REQUESTED );
             break;
-        }
         default:
             BWindow::MessageReceived( p_message );
             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
  *****************************************************************************/
@@ -211,32 +470,130 @@ void PreferencesWindow::ReallyQuit()
     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
+ * PreferencesWindow::_SetDefaults
  *****************************************************************************/
-void PreferencesWindow::SetDefaults()
+void PreferencesWindow::_SetDefaults()
 {
-    fDvdMenusCheck->SetValue( 0 );
-    fPpSlider->SetValue( 0 );
-    fBrightnessSlider->SetValue( 100 );
-    fContrastSlider->SetValue( 100 );
-    fHueSlider->SetValue( 0 );
-    fSaturationSlider->SetValue( 100 );
+       _SetGUI( false, 0, 100.0, 100.0, 0, 100.0,
+                       kDefaultScreenShotPath, kDefaultScreenShotFormat );
 }
 
 /*****************************************************************************
- * PreferencesWindow::ApplyChanges
+ * PreferencesWindow::_SetToSettings
  *****************************************************************************/
-void PreferencesWindow::ApplyChanges()
+void PreferencesWindow::_SetToSettings()
 {
-    VlcWrapper * p_wrapper = p_intf->p_sys->p_wrapper;
+       char* path = get_config_string( p_intf, "beos-screenshot-path", kDefaultScreenShotPath );
 
-    if( fDvdMenusCheck->Value() )
-        p_intf->p_sys->b_dvdmenus = true;
-    else
-        p_intf->p_sys->b_dvdmenus = false;
-    
-    config_PutInt( p_intf, "ffmpeg-pp-q", fPpSlider->Value() );
+       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 );
+}
+
+/*****************************************************************************
+ * PreferencesWindow::_RevertChanges
+ *****************************************************************************/
+void
+PreferencesWindow::_RevertChanges()
+{
+       _SetGUI( fDVDMenusBackup,
+                       fPostProcessingBackup,
+                       fBrightnessBackup,
+                       fContrastBackup,
+                       fHueBackup,
+                       fSaturationBackup,
+                       fScreenShotPathBackup.String(),
+                       fScreenShotFormatBackup );
+
+       _ApplyChanges();
+}
+
+/*****************************************************************************
+ * PreferencesWindow::_ApplyChanges
+ *****************************************************************************/
+void PreferencesWindow::_ApplyChanges()
+{
+       _ApplyScreenShotSettings();
+       _ApplyPictureSettings();
+       _ApplyFFmpegSettings();
+       _ApplyDVDSettings();
+}
+
+/*****************************************************************************
+ * PreferencesWindow::_ApplyScreenShotSettings
+ *****************************************************************************/
+void
+PreferencesWindow::_ApplyScreenShotSettings()
+{
+       // 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() );
+}
+
+/*****************************************************************************
+ * PreferencesWindow::_ApplyPictureSettings
+ *****************************************************************************/
+void
+PreferencesWindow::_ApplyPictureSettings()
+{
+       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",
@@ -245,24 +602,52 @@ void PreferencesWindow::ApplyChanges()
     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 )
     {
-        if( !config_GetPsz( p_intf, "filter" ) ||
-            strcmp( config_GetPsz( p_intf, "filter" ), "adjust" ) )
+       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
     {
-        if( config_GetPsz( p_intf, "filter" ) )
+       char* string = config_GetPsz( p_intf, "filter" );
+        if ( string )
         {
             config_PutPsz( p_intf, "filter", NULL );
             p_wrapper->FilterChange();
+               free( string );
         }
     }
 }
+
+/*****************************************************************************
+ * PreferencesWindow::_ApplyFFmpegSettings
+ *****************************************************************************/
+void
+PreferencesWindow::_ApplyFFmpegSettings()
+{
+       // ffmpeg post processing
+    config_PutInt( p_intf, "ffmpeg-pp-q", fPpSlider->Value() );
+}
+
+/*****************************************************************************
+ * PreferencesWindow::_ApplyDVDSettings
+ *****************************************************************************/
+void
+PreferencesWindow::_ApplyDVDSettings()
+{
+       // 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 );
+}
+
index b165ff0..2dc648d 100644 (file)
@@ -2,7 +2,7 @@
  * PreferencesWindow.h
  *****************************************************************************
  * Copyright (C) 1999, 2000, 2001 VideoLAN
- * $Id: PreferencesWindow.h,v 1.8 2003/01/27 10:29:22 titer Exp $
+ * $Id: PreferencesWindow.h,v 1.9 2003/02/09 17:10:52 stippi 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_OK       'prok'
-#define PREFS_SAVE     'prsa'
+#define PREFS_CANCEL   'prcb'
 #define PREFS_DEFAULTS 'prde'
-#define SLIDER_UPDATE  'slup'
+#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
 {
-    public:
-                         PreferencesWindow( intf_thread_t * p_intf,
-                                            BRect frame,
-                                            const char * name );
-        virtual          ~PreferencesWindow();
-        virtual void     MessageReceived(BMessage *message);
-        void             ReallyQuit();
-
-    private:
-        void             SetDefaults();
-        void             ApplyChanges();
-        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;
-
-        intf_thread_t *  p_intf;
+ public:
+                                                               PreferencesWindow( intf_thread_t* p_intf,
+                                                                                                  BRect frame,
+                                                                                                  const char* name );
+       virtual                                         ~PreferencesWindow();
+
+       virtual bool                            QuitRequested();
+       virtual void                            MessageReceived(BMessage* message);
+       virtual void                            Show();
+
+                       void                            ReallyQuit();
+
+ 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();
+
+                       void                            _ApplyChanges();
+
+                       void                            _ApplyScreenShotSettings();
+                       void                            _ApplyPictureSettings();
+                       void                            _ApplyFFmpegSettings();
+                       void                            _ApplyDVDSettings();
+
+       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;
+
+       bool                                            fDVDMenusBackup;
+       int32                                           fPostProcessingBackup;
+       float                                           fBrightnessBackup;
+       float                                           fContrastBackup;
+       int32                                           fHueBackup;
+       float                                           fSaturationBackup;
+       BString                                         fScreenShotPathBackup;
+       uint32                                          fScreenShotFormatBackup;
+
+       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
 
index 377ab0b..5b7b02d 100644 (file)
@@ -2,7 +2,7 @@
  * vout_beos.cpp: beos video output display method
  *****************************************************************************
  * Copyright (C) 2000, 2001 VideoLAN
- * $Id: VideoOutput.cpp,v 1.11 2003/02/01 12:01:11 stippi Exp $
+ * $Id: VideoOutput.cpp,v 1.12 2003/02/09 17:10:52 stippi Exp $
  *
  * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
  *          Samuel Hocevar <sam@zoy.org>
@@ -36,6 +36,7 @@
 #include <Application.h>
 #include <BitmapStream.h>
 #include <Bitmap.h>
+#include <Directory.h>
 #include <DirectWindow.h>
 #include <File.h>
 #include <InterfaceKit.h>
@@ -366,9 +367,11 @@ VideoWindow::MessageReceived( BMessage *p_message )
                                                dst += dstBpr;
                                                src += srcBpr;
                                        }
-                                       _SaveScreenShot( temp,
-                                                                        strdup( DEFAULT_SCREEN_SHOT_PATH ),
-                                                                        DEFAULT_SCREEN_SHOT_FORMAT );
+                                       char* path = config_GetPsz( p_vout, "beos-screenshot-path" );
+                                       if ( !path )
+                                               path = strdup( DEFAULT_SCREEN_SHOT_PATH );
+                                       int32 format = config_GetInt( p_vout, "beos-screenshot-format" );
+                                       _SaveScreenShot( temp, path, format );
                                }
                                else
                                {
@@ -892,6 +895,21 @@ VideoWindow::_save_screen_shot( void* cookie )
                // taken the next screen shot already!)
                // make sure we have a unique name for the screen shot
                BString path( info->path );
+               // create the folder if it doesn't exist
+               BString folder( info->path );
+               int32 pos = folder.FindLast("/");
+               if ( pos > 0 )
+               {
+                       pos++; // leave the last '/' in the string
+                       if ( pos == path.Length() )
+                               path << "vlc screenshot";
+                       else
+                       {
+                               int32 removeChars = folder.Length() - pos;      
+                               folder.Remove( pos, removeChars );
+                       }
+                       create_directory( folder.String(), 0777 );
+               }
                BEntry entry( path.String() );
                int32 appendedNumber = 0;
                if ( entry.Exists() && !entry.IsSymLink() )
@@ -900,7 +918,7 @@ VideoWindow::_save_screen_shot( void* cookie )
                        bool foundUniqueName = false;
                        appendedNumber = 1;
                        while ( !foundUniqueName ) {
-                               BString newName( info->path );
+                               BString newName( path.String() );
                                newName << " " << appendedNumber;
                                BEntry possiblyClobberedEntry( newName.String() );
                                if ( possiblyClobberedEntry.Exists()
@@ -920,8 +938,6 @@ VideoWindow::_save_screen_shot( void* cookie )
                // make colorspace converted copy of bitmap
                BBitmap* converted = new BBitmap( BRect( 0.0, 0.0, info->width, info->height ),
                                                                                  B_RGB32 );
-//             if ( converted->IsValid() )
-//                     memset( converted->Bits(), 0, converted->BitsLength() );
                status_t status = convert_bitmap( info->bitmap, converted );
                if ( status == B_OK )
                {
@@ -1021,7 +1037,7 @@ VideoWindow::_save_screen_shot( void* cookie )
        if ( info )
        {
                delete info->bitmap;
-               delete[] info->path;
+               free( info->path );
        }
        delete info;
        return B_OK;
index fc99088..723486a 100644 (file)
@@ -2,7 +2,7 @@
  * VlcWrapper.cpp: BeOS plugin for vlc (derived from MacOS X port)
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: VlcWrapper.cpp,v 1.25 2003/02/09 11:51:36 titer Exp $
+ * $Id: VlcWrapper.cpp,v 1.26 2003/02/09 17:10:52 stippi Exp $
  *
  * Authors: Florian G. Pflug <fgp@phlo.org>
  *          Jon Lech Johansen <jon-vl@nanocrew.net>
@@ -33,6 +33,7 @@
 #include <vlc/vout.h>
 extern "C"
 {
+  #include <input_ext-plugins.h>       // needed here when compiling without plugins
   #include <audio_output.h>
   #include <aout_internal.h>
 }
@@ -973,7 +974,7 @@ void VlcWrapper::FilterChange()
     vout_thread_t * p_vout;
     vlc_mutex_lock( &p_input->stream.stream_lock );
 
-    /* Warn the vout we are about to change the filter chain */
+    // Warn the vout we are about to change the filter chain
     p_vout = (vout_thread_t*)vlc_object_find( p_intf, VLC_OBJECT_VOUT,
                                               FIND_ANYWHERE );
     if( p_vout )
@@ -982,7 +983,7 @@ void VlcWrapper::FilterChange()
         vlc_object_release( p_vout );
     }
 
-    /* restart all video stream */
+    // restart all video stream
     for( unsigned int i = 0; i < p_input->stream.i_es_number; i++ )
     {
         if( ( p_input->stream.pp_es[i]->i_cat == VIDEO_ES ) &&