/*****************************************************************************
* PreferencesWindow.cpp: beos interface
*****************************************************************************
- * Copyright (C) 1999, 2000, 2001 VideoLAN
+ * Copyright (C) 1999, 2000, 2001 the VideoLAN team
* $Id$
*
* Authors: Eric Petit <titer@m0k.org>
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
-#include <stdlib.h> /* atoi(), strtod() */
#include <String.h>
#include <vlc/vlc.h>
-#include <vlc/intf.h>
+#include <vlc_interface.h>
#include <vlc_keys.h>
#include <vlc_config_cat.h>
if( options < 1 || category < 0 || subcategory < 0 )
continue;
-#if 0
- fprintf( stderr, "cat %d, sub %d, %s\n", category, subcategory,
- p_module->psz_shortname ? p_module->psz_shortname :
- p_module->psz_object_name );
-#endif
-
catItem = NULL;
for( int j = 0; j < fOutline->CountItemsUnder( NULL, true ); j++ )
{
vlc_list_release( p_list );
+ /* Collapse the whole tree */
for( int i = 0; i < fOutline->FullListCountItems(); i++ )
{
- otherItem = (ConfigItem *)
- fOutline->FullListItemAt( i );
- if( fOutline->Superitem( otherItem ) )
- {
- fOutline->Collapse( otherItem );
- }
+ otherItem = (ConfigItem *) fOutline->FullListItemAt( i );
+ fOutline->Collapse( otherItem );
}
/* Set the correct values */
- ApplyChanges( false );
+ Apply( false );
/* Select the first item */
fOutline->Select( 0 );
case PREFS_DEFAULTS:
config_ResetAll( p_intf );
- ApplyChanges( false );
+ config_SaveConfigFile( p_intf, NULL );
+ Apply( false );
break;
case PREFS_APPLY:
- ApplyChanges( true );
+ Apply( true );
break;
case PREFS_SAVE:
- SaveChanges();
+ Apply( true );
+ config_SaveConfigFile( p_intf, NULL );
break;
default:
}
/*****************************************************************************
- * PreferencesWindow::ApplyChanges
+ * PreferencesWindow::Apply
* Apply changes if doIt is true, revert them otherwise
*****************************************************************************/
-void PreferencesWindow::ApplyChanges( bool doIt )
+void PreferencesWindow::Apply( bool doIt )
{
ConfigItem * item;
- for( int i = 0; i < fOutline->CountItems(); i++ )
+ for( int i = 0; i < fOutline->FullListCountItems(); i++ )
{
- item = (ConfigItem*) fOutline->ItemAt( i );
+ item = (ConfigItem*) fOutline->FullListItemAt( i );
item->Apply( doIt );
}
}
-/*****************************************************************************
- * PreferencesWindow::SaveChanges
- *****************************************************************************/
-void PreferencesWindow::SaveChanges()
-{
- ApplyChanges( true );
- config_SaveConfigFile( p_intf, NULL );
-}
-
/*****************************************************************************
* PreferencesWindow::ReallyQuit
*****************************************************************************/
**********************************************************************/
void ConfigItem::Apply( bool doIt )
{
- ConfigWidget * widget;
-
- return;
-
- if( !fView )
+ if( !fScroll )
{
- /* This is a category */
return;
}
/* Call ConfigWidget::Apply for every child of your fView */
+ ConfigWidget * widget;
for( int i = 0; i < fView->CountChildren(); i++ )
{
widget = (ConfigWidget*) fView->ChildAt( i );
{
p_intf = _p_intf;
- fInitOK = true;
SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) );
BRect r;
BMenuItem * menuItem;
+ /* Skip deprecated options */
+ if( p_item->psz_current )
+ {
+ fInitOK = false;
+ return;
+ }
+
+ fInitOK = true;
+
+ fType = p_item->i_type;
+ fName = strdup( p_item->psz_name );
- switch( p_item->i_type )
+ switch( fType )
{
case CONFIG_ITEM_MODULE:
case CONFIG_ITEM_MODULE_CAT:
}
}
+ConfigWidget::~ConfigWidget()
+{
+ free( fName );
+}
+
/***********************************************************************
* ConfigWidget::Apply
***********************************************************************
**********************************************************************/
void ConfigWidget::Apply( bool doIt )
{
-#if 0
+ BMenuItem * menuItem;
+ char string[256];
+ vlc_value_t val;
+
switch( fType )
{
case CONFIG_ITEM_STRING:
case CONFIG_ITEM_FILE:
case CONFIG_ITEM_MODULE:
+ case CONFIG_ITEM_MODULE_CAT:
+ case CONFIG_ITEM_MODULE_LIST_CAT:
case CONFIG_ITEM_DIRECTORY:
if( doIt )
{
- config_PutPsz( p_intf, fConfigName, fTextControl->Text() );
+ config_PutPsz( p_intf, fName, fTextControl->Text() );
}
else
{
- fTextControl->SetText( config_GetPsz( p_intf, fConfigName ) );
+ fTextControl->SetText( config_GetPsz( p_intf, fName ) );
}
break;
case CONFIG_ITEM_INTEGER:
if( doIt )
{
- config_PutInt( p_intf, fConfigName,
- atoi( fTextControl->Text() ) );
+ config_PutInt( p_intf, fName, atoi( fTextControl->Text() ) );
}
else
{
- memset( string, 0, 1024 );
- snprintf( string, 1023, "%d",
- config_GetInt( p_intf, fConfigName ) );
+ snprintf( string, 256, "%d", config_GetInt( p_intf, fName ) );
fTextControl->SetText( string );
}
break;
case CONFIG_ITEM_FLOAT:
if( doIt )
{
- config_PutFloat( p_intf, fConfigName,
- strtod( fTextControl->Text(), NULL ) );
+ config_PutFloat( p_intf, fName, atof( fTextControl->Text() ) );
}
else
{
- memset( string, 0, 1024 );
- snprintf( string, 1023, "%f",
- config_GetFloat( p_intf, fConfigName ) );
+ snprintf( string, 256, "%f", config_GetFloat( p_intf, fName ) );
fTextControl->SetText( string );
}
break;
- case CONFIG_ITEM_BOOL:
- if( doIt )
- {
- config_PutInt( p_intf, fConfigName, fCheckBox->Value() );
- }
- else
- {
- fCheckBox->SetValue( config_GetInt( p_intf, fConfigName ) );
- }
- break;
-
case CONFIG_ITEM_KEY:
if( doIt )
{
menuItem = fPopUpMenu->FindMarked();
if( menuItem )
{
- int value = vlc_keys[fPopUpMenu->IndexOf( menuItem )].i_key_code;
+ val.i_int = vlc_keys[fPopUpMenu->IndexOf( menuItem )].i_key_code;
if( fAltCheck->Value() )
{
- value |= KEY_MODIFIER_ALT;
+ val.i_int |= KEY_MODIFIER_ALT;
}
if( fCtrlCheck->Value() )
{
- value |= KEY_MODIFIER_CTRL;
+ val.i_int |= KEY_MODIFIER_CTRL;
}
if( fShiftCheck->Value() )
{
- value |= KEY_MODIFIER_SHIFT;
+ val.i_int |= KEY_MODIFIER_SHIFT;
}
- config_PutInt( p_intf, fConfigName, value );
+ var_Set( p_intf->p_libvlc, fName, val );
}
}
else
{
- int value = config_GetInt( p_intf, fConfigName );
- fAltCheck->SetValue( value & KEY_MODIFIER_ALT );
- fCtrlCheck->SetValue( value & KEY_MODIFIER_CTRL );
- fShiftCheck->SetValue( value & KEY_MODIFIER_SHIFT );
-
+ val.i_int = config_GetInt( p_intf, fName );
+ fAltCheck->SetValue( val.i_int & KEY_MODIFIER_ALT );
+ fCtrlCheck->SetValue( val.i_int & KEY_MODIFIER_CTRL );
+ fShiftCheck->SetValue( val.i_int & KEY_MODIFIER_SHIFT );
+
for( unsigned i = 0;
i < sizeof( vlc_keys ) / sizeof( key_descriptor_t ); i++ )
{
if( (unsigned) vlc_keys[i].i_key_code ==
- ( value & ~KEY_MODIFIER ) )
+ ( val.i_int & ~KEY_MODIFIER ) )
{
menuItem = fPopUpMenu->ItemAt( i );
menuItem->SetMarked( true );
}
}
}
+ break;
+
+ case CONFIG_ITEM_BOOL:
+ if( doIt )
+ {
+ config_PutInt( p_intf, fName, fCheckBox->Value() );
+ }
+ else
+ {
+ fCheckBox->SetValue( config_GetInt( p_intf, fName ) );
+ }
+ break;
+ default:
break;
}
-#endif
}
VTextView::VTextView( BRect frame, const char *name,