/*****************************************************************************
 * preferences.cpp: the "Preferences" dialog box
 *****************************************************************************
 * Copyright (C) 2002 VideoLAN
 *
 * Authors: Olivier Teuliere <ipkiss@via.ecp.fr>
 *          Boris Dores <babal@via.ecp.fr>
 *
 * 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
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * 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.
 *****************************************************************************/

#include <vcl.h>
#pragma hdrstop

#include <stdlib.h>                                      /* malloc(), free() */
#include <string.h>                                                /* strcmp */

#include <vlc/vlc.h>
#include <vlc/intf.h>

#include "preferences.h"
#include "win32_common.h"

//---------------------------------------------------------------------------
//#pragma package(smart_init)
#pragma link "CSPIN"
#pragma resource "*.dfm"

extern intf_thread_t *p_intfGlobal;

/****************************************************************************
 * A THintWindow with a limited width
 ****************************************************************************/
void __fastcall TNarrowHintWindow::ActivateHint(const Windows::TRect &Rect,
    const System::AnsiString AHint)
{
    TRect NarrowRect = CalcHintRect ( 300 , AHint , NULL );
    NarrowRect.Left = Rect.Left;
    NarrowRect.Top = Rect.Top;
    NarrowRect.Right += Rect.Left;
    NarrowRect.Bottom += Rect.Top;
    THintWindow::ActivateHint ( NarrowRect , AHint );
}


/****************************************************************************
 * Just a wrapper to embed an AnsiString into a TObject
 ****************************************************************************/
__fastcall TObjectString::TObjectString(char * String)
{
    FString = AnsiString(String);
}
//---------------------------------------------------------------------------
AnsiString __fastcall TObjectString::String()
{
    return FString;
}


/****************************************************************************
 * A TCheckListBox that automatically disposes any TObject
 * associated with the string items
 ****************************************************************************/
__fastcall TCleanCheckListBox::~TCleanCheckListBox()
{
    for ( int i = 0 ; i < Items->Count ; i++ )
    {
        if ( Items->Objects[i] != NULL ) delete Items->Objects[i];
    }
}


/****************************************************************************
 * Functions to help components creation
 ****************************************************************************/
__fastcall TPanelPref::TPanelPref( TComponent* Owner,
            module_config_t *p_config_arg ) : TPanel( Owner )
{
    p_config = p_config_arg;
    BevelInner = bvNone;
    BevelOuter = bvNone;
    BorderStyle = bsNone;
}
//---------------------------------------------------------------------------
TCleanCheckListBox * __fastcall TPanelPref::CreateCleanCheckListBox(
    TWinControl *Parent, int Left, int Width, int Top, int Height )
{
    TCleanCheckListBox *CleanCheckListBox = new TCleanCheckListBox( Parent );
    CleanCheckListBox->Parent = Parent;
    CleanCheckListBox->Left = Left;
    CleanCheckListBox->Width = Width;
    CleanCheckListBox->Top = Top;
    CleanCheckListBox->Height = Height;
    return CleanCheckListBox;
}
//---------------------------------------------------------------------------
TButton * __fastcall TPanelPref::CreateButton( TWinControl *Parent,
            int Left, int Width, int Top, int Height, AnsiString Caption )
{
    TButton *Button = new TButton( Parent );
    Button->Parent = Parent;
    Button->Left = Left;
    Button->Width = Width;
    Button->Top = Top;
    Button->Height = Height;
    Button->Caption = Caption;
    return Button;
}
//---------------------------------------------------------------------------
TCheckBox * __fastcall TPanelPref::CreateCheckBox( TWinControl *Parent,
            int Left, int Width, int Top, int Height, AnsiString Caption )
{
    TCheckBox *CheckBox = new TCheckBox( Parent );
    CheckBox->Parent = Parent;
    CheckBox->Left = Left;
    CheckBox->Width = Width;
    CheckBox->Top = Top;
    CheckBox->Height = Height;
    CheckBox->Caption = Caption;
    return CheckBox;
}
//---------------------------------------------------------------------------
TLabel * __fastcall TPanelPref::CreateLabel( TWinControl *Parent,
            int Left, int Width, int Top, int Height, AnsiString Caption,
            bool WordWrap )
{
    TLabel *Label = new TLabel( Parent );
    Label->Parent = Parent;
    Label->Caption = Caption;
    Label->Left = Left;
    Label->Width = Width;
    Label->Top = Top;
    Label->Height = Height;
    Label->WordWrap = WordWrap;
    return Label;
}
//---------------------------------------------------------------------------
TEdit * __fastcall TPanelPref::CreateEdit( TWinControl *Parent,
            int Left, int Width, int Top, int Height, AnsiString Text )
{
    TEdit *Edit = new TEdit( Parent );
    Edit->Parent = Parent;
    Edit->Left = Left;
    Edit->Width = Width;
    Edit->Top = Top;
    Edit->Height = Height;
    Edit->Text = Text;
    return Edit;
}
//---------------------------------------------------------------------------
TCSpinEdit * __fastcall TPanelPref::CreateSpinEdit( TWinControl *Parent,
            int Left, int Width, int Top, int Height,
            long Min, long Max, long Value )
{
    TCSpinEdit *SpinEdit = new TCSpinEdit( Parent );
    SpinEdit->Parent = Parent;
    SpinEdit->Left = Left;
    SpinEdit->Width = Width;
    SpinEdit->Top = Top;
    SpinEdit->Height = Height;
    SpinEdit->MinValue = Min;
    SpinEdit->MaxValue = Max;
    SpinEdit->Value = Value;
    return SpinEdit;
}
//---------------------------------------------------------------------------
void __fastcall TPanelPref::UpdateChanges()
{
}

#define LIBWIN32_PREFSIZE_VPAD                4
#define LIBWIN32_PREFSIZE_HPAD                4
#define LIBWIN32_PREFSIZE_LEFT                16
#define LIBWIN32_PREFSIZE_EDIT_LEFT           (LIBWIN32_PREFSIZE_LEFT+32)
#define LIBWIN32_PREFSIZE_WIDTH               375
#define LIBWIN32_PREFSIZE_EDIT_WIDTH          (LIBWIN32_PREFSIZE_WIDTH-32)
#define LIBWIN32_PREFSIZE_BUTTON_WIDTH        150
#define LIBWIN32_PREFSIZE_SPINEDIT_WIDTH      100
#define LIBWIN32_PREFSIZE_RIGHT               (LIBWIN32_PREFSIZE_LEFT+LIBWIN32_PREFSIZE_WIDTH)
#define LIBWIN32_PREFSIZE_BUTTON_HEIGHT       25
#define LIBWIN32_PREFSIZE_LABEL_HEIGHT        26
#define LIBWIN32_PREFSIZE_CHECKLISTBOX_HEIGHT 120
#define LIBWIN32_PREFSIZE_EDIT_HEIGHT         21
#define LIBWIN32_PREFSIZE_CHECKBOX_HEIGHT     17
#define LIBWIN32_PREFSIZE_SPINEDIT_HEIGHT     21

/****************************************************************************
 * Panel for module management
 ****************************************************************************/
__fastcall TPanelPlugin::TPanelPlugin( TComponent* Owner,
            module_config_t *p_config ) : TPanelPref( Owner, p_config )
{
    /* init configure button */
    ButtonConfig = CreateButton( this,
            LIBWIN32_PREFSIZE_RIGHT - LIBWIN32_PREFSIZE_BUTTON_WIDTH,
            LIBWIN32_PREFSIZE_BUTTON_WIDTH,
            LIBWIN32_PREFSIZE_VPAD,
            LIBWIN32_PREFSIZE_BUTTON_HEIGHT,
            "Configure..." );
    ButtonConfig->Enabled = false;
    ButtonConfig->OnClick = ButtonConfigClick;

    /* init label */
    AnsiString Text = AnsiString(p_config->psz_text) + ":";
    Label = CreateLabel( this,
            LIBWIN32_PREFSIZE_LEFT,
            LIBWIN32_PREFSIZE_RIGHT - LIBWIN32_PREFSIZE_BUTTON_WIDTH
             - LIBWIN32_PREFSIZE_HPAD,
            LIBWIN32_PREFSIZE_VPAD,
            LIBWIN32_PREFSIZE_LABEL_HEIGHT,
            Text.c_str(), true );

    /* vertical alignement */
    if ( ButtonConfig->Height > Label->Height )
        Label->Top += ( ButtonConfig->Height - Label->Height ) / 2;
    else
        ButtonConfig->Top += ( Label->Height - ButtonConfig->Height ) / 2;

    /* init checklistbox */
    CleanCheckListBox = CreateCleanCheckListBox( this,
            LIBWIN32_PREFSIZE_EDIT_LEFT,
            LIBWIN32_PREFSIZE_EDIT_WIDTH,
            max ( Label->Top + Label->Height , ButtonConfig->Top
             + ButtonConfig->Height ) + LIBWIN32_PREFSIZE_VPAD,
            LIBWIN32_PREFSIZE_CHECKLISTBOX_HEIGHT );
    CleanCheckListBox->OnClick = CheckListBoxClick;
    CleanCheckListBox->OnClickCheck = CheckListBoxClickCheck;
    CleanCheckListBox->Hint = p_config->psz_longtext;
    CleanCheckListBox->ShowHint = true;

    /* panel height */
    Height = CleanCheckListBox->Top + CleanCheckListBox->Height
            + LIBWIN32_PREFSIZE_VPAD;
};
//---------------------------------------------------------------------------
void __fastcall TPanelPlugin::CheckListBoxClick( TObject *Sender )
{
    module_t **pp_parser;
    vlc_list_t *p_list;

    /* check that the click is valid (we are on an item, and the click
     * started on an item */
    if( CleanCheckListBox->ItemIndex == -1 )
        return;

    AnsiString Name = ((TObjectString*)CleanCheckListBox->Items->
        Objects[CleanCheckListBox->ItemIndex])->String().c_str();
    if( Name == "" )
        return;

    /* look for module 'Name' */
    p_list = vlc_list_find( p_intfGlobal, VLC_OBJECT_MODULE, FIND_ANYWHERE );

    for( pp_parser = (module_t **)p_list->pp_objects ;
         *pp_parser ;
         pp_parser++ )
    {
        if( strcmp( (*pp_parser)->psz_object_name, Name.c_str() ) == 0 )
        {
            ModuleSelected = (*pp_parser);
            ButtonConfig->Enabled =
                (*pp_parser)->i_config_items ? true : false;

            break;
        }
    }
}
//---------------------------------------------------------------------------
void __fastcall TPanelPlugin::CheckListBoxClickCheck( TObject *Sender )
{
    /* one item maximum must be checked */
    if( CleanCheckListBox->Checked[CleanCheckListBox->ItemIndex] )
    {
        for( int item = 0; item < CleanCheckListBox->Items->Count; item++ )
        {
            if( item != CleanCheckListBox->ItemIndex )
            {
                CleanCheckListBox->Checked[item] = false;
            }
        }
    }
}
//---------------------------------------------------------------------------
void __fastcall TPanelPlugin::ButtonConfigClick( TObject *Sender )
{
    p_intfGlobal->p_sys->p_window->
                        CreatePreferences( ModuleSelected->psz_object_name );
}
//---------------------------------------------------------------------------
void __fastcall TPanelPlugin::UpdateChanges()
{
    AnsiString Name = "";

    /* find the selected plugin (if any) */
    for( int item = 0; item < CleanCheckListBox->Items->Count; item++ )
    {
        if( CleanCheckListBox->Checked[item] )
        {
            Name = ((TObjectString*)CleanCheckListBox->Items->Objects[item])
                   ->String().c_str();
            break;
        }
    }

    /* XXX: Necessary, since c_str() returns only a temporary pointer... */
    free( p_config->psz_value );
    p_config->psz_value = (char *)malloc( Name.Length() + 1 );
    strcpy( p_config->psz_value, Name.c_str() );
}


/****************************************************************************
 * Panel for string management
 ****************************************************************************/
__fastcall TPanelString::TPanelString( TComponent* Owner,
            module_config_t *p_config ) : TPanelPref( Owner, p_config )
{
    /* init description label */
    AnsiString Text = AnsiString ( p_config->psz_text ) + ":";
    Label = CreateLabel( this,
            LIBWIN32_PREFSIZE_LEFT,
            LIBWIN32_PREFSIZE_WIDTH,
            LIBWIN32_PREFSIZE_VPAD,
            LIBWIN32_PREFSIZE_LABEL_HEIGHT,
            Text.c_str(), true );

    /* init edit */
    Edit = CreateEdit( this,
            LIBWIN32_PREFSIZE_EDIT_LEFT,
            LIBWIN32_PREFSIZE_EDIT_WIDTH,
            LIBWIN32_PREFSIZE_VPAD + Label->Height + LIBWIN32_PREFSIZE_VPAD,
            LIBWIN32_PREFSIZE_EDIT_HEIGHT, "" );
    vlc_mutex_lock( p_config->p_lock );
    Edit->Text = p_config->psz_value ? p_config->psz_value : "";
    vlc_mutex_unlock( p_config->p_lock );
    Edit->Hint = p_config->psz_longtext;
    Edit->ShowHint = true;

    /* panel height */
    Height = LIBWIN32_PREFSIZE_VPAD + Label->Height + LIBWIN32_PREFSIZE_VPAD
            + Edit->Height + LIBWIN32_PREFSIZE_VPAD;
};
//---------------------------------------------------------------------------
void __fastcall TPanelString::UpdateChanges()
{
    /* XXX: Necessary, since c_str() returns only a temporary pointer... */
    free( p_config->psz_value );
    p_config->psz_value = (char *)malloc( Edit->Text.Length() + 1 );
    strcpy( p_config->psz_value, Edit->Text.c_str() );
}


/****************************************************************************
 * Panel for integer management
 ****************************************************************************/
__fastcall TPanelInteger::TPanelInteger( TComponent* Owner,
            module_config_t *p_config ) : TPanelPref( Owner, p_config )
{
    /* init description label */
    AnsiString Text = AnsiString ( p_config->psz_text ) + ":";
    Label = CreateLabel( this,
            LIBWIN32_PREFSIZE_LEFT,
            LIBWIN32_PREFSIZE_WIDTH - LIBWIN32_PREFSIZE_SPINEDIT_WIDTH
             - LIBWIN32_PREFSIZE_HPAD,
            LIBWIN32_PREFSIZE_VPAD,
            LIBWIN32_PREFSIZE_LABEL_HEIGHT, Text.c_str(), true );

    /* init spinedit */
    SpinEdit = CreateSpinEdit( this,
            LIBWIN32_PREFSIZE_RIGHT - LIBWIN32_PREFSIZE_SPINEDIT_WIDTH,
            LIBWIN32_PREFSIZE_SPINEDIT_WIDTH,
            LIBWIN32_PREFSIZE_VPAD,
            LIBWIN32_PREFSIZE_SPINEDIT_HEIGHT,
            -1, 100000, p_config->i_value );
    SpinEdit->Hint = p_config->psz_longtext;
    SpinEdit->ShowHint = true;

    /* vertical alignement and panel height */
    if ( SpinEdit->Height > Label->Height )
    {
        Label->Top += ( SpinEdit->Height - Label->Height ) / 2;
        Height = SpinEdit->Top + SpinEdit->Height + LIBWIN32_PREFSIZE_VPAD;
    }
    else
    {
        SpinEdit->Top += ( Label->Height - SpinEdit->Height ) / 2;
        Height = Label->Top + Label->Height + LIBWIN32_PREFSIZE_VPAD;
    }
};
//---------------------------------------------------------------------------
void __fastcall TPanelInteger::UpdateChanges()
{
    /* Warning: we're casting from long to int */
    p_config->i_value = (int)SpinEdit->Value;
}


/****************************************************************************
 * Panel for boolean management
 ****************************************************************************/
__fastcall TPanelBool::TPanelBool( TComponent* Owner,
            module_config_t *p_config ) : TPanelPref( Owner, p_config )
{
    /* init checkbox */
    CheckBox = CreateCheckBox( this,
            LIBWIN32_PREFSIZE_LEFT,
            LIBWIN32_PREFSIZE_WIDTH,
            LIBWIN32_PREFSIZE_VPAD,
            LIBWIN32_PREFSIZE_CHECKBOX_HEIGHT, p_config->psz_text );
    CheckBox->Checked = p_config->i_value;
    CheckBox->Hint = p_config->psz_longtext;
    CheckBox->ShowHint = true;

    /* panel height */
    Height = LIBWIN32_PREFSIZE_VPAD + CheckBox->Height + LIBWIN32_PREFSIZE_VPAD;
};
//---------------------------------------------------------------------------
void __fastcall TPanelBool::UpdateChanges()
{
    p_config->i_value = CheckBox->Checked ? 1 : 0;
}


/****************************************************************************
 * Callbacks for the dialog
 ****************************************************************************/
__fastcall TPreferencesDlg::TPreferencesDlg( TComponent* Owner )
        : TForm( Owner )
{
    Icon = p_intfGlobal->p_sys->p_window->Icon;
    Application->HintHidePause = 0x1000000;
    HintWindowClass = __classid ( TNarrowHintWindow );
    /* prevent the form from being resized horizontally */
    Constraints->MinWidth = Width;
    Constraints->MaxWidth = Width;
}
//---------------------------------------------------------------------------
void __fastcall TPreferencesDlg::FormClose( TObject *Sender,
      TCloseAction &Action )
{
    Action = caHide;
}


/****************************************************************************
 * CreateConfigDialog: dynamically creates the configuration dialog
 * box from all the configuration data provided by the selected module.
 ****************************************************************************/
#define ADD_PANEL                               \
{                                               \
            Panel = new TPanel( this );         \
            Panel->Parent = ScrollBox;          \
            Panel->Caption = "";                \
            Panel->BevelOuter = bvNone;         \
            Panel->Height = 12;                 \
}

void __fastcall TPreferencesDlg::CreateConfigDialog( char *psz_module_name )
{
    module_t          **pp_parser;
    vlc_list_t         *p_list;

    module_config_t    *p_item;
    int                 i_pages, i_ctrl;

    TTabSheet          *TabSheet;
    TScrollBox         *ScrollBox;
    TPanel             *Panel;
    TPanelPlugin       *PanelPlugin;
    TPanelString       *PanelString;
    TPanelInteger      *PanelInteger;
    TPanelBool         *PanelBool;

    /* Look for the selected module */
    p_list = vlc_list_find( p_intfGlobal, VLC_OBJECT_MODULE, FIND_ANYWHERE );

    for( pp_parser = (module_t **)p_list->pp_objects ;
         *pp_parser ;
         pp_parser++ )
    {
        if( psz_module_name
             && !strcmp( psz_module_name, (*pp_parser)->psz_object_name ) )
        {
            break;
        }
    }
    if( !(*pp_parser) )
    {
        vlc_list_release( p_list );
        return;
    }

    /*
     * We found it, now we can start building its configuration interface
     */

    /* Enumerate config options and add corresponding config boxes */
    p_item = (*pp_parser)->p_config;
    if( p_item ) do
    {
        switch( p_item->i_type )
        {
        case CONFIG_HINT_CATEGORY:

            /* create a new tabsheet. */
            TabSheet = new TTabSheet( this );
            TabSheet->PageControl = PageControlPref;
            TabSheet->Caption = p_item->psz_text;
            TabSheet->Visible = true;

            /* pack a scrollbox into the tabsheet */
            ScrollBox = new TScrollBox( this );
            ScrollBox->Parent = TabSheet;
            ScrollBox->Align = alClient;
            ScrollBox->BorderStyle = bsNone;
            ScrollBox->HorzScrollBar->Tracking = true;
            ScrollBox->VertScrollBar->Tracking = true;

            /* add a panel as top margin */
            ADD_PANEL;

            break;

        case CONFIG_ITEM_MODULE:

            /* add new panel for the config option */
            PanelPlugin = new TPanelPlugin( this, p_item );
            PanelPlugin->Parent = ScrollBox;

            /* Look for valid modules */
            pp_parser = (module_t **)p_list->pp_objects;

            for( ; *pp_parser ; pp_parser++ )
            {
                if( !strcmp( (*pp_parser)->psz_capability, p_item->psz_type ) )
                {
                    AnsiString ModuleDesc;
                    if ( (*pp_parser)->psz_longname != NULL ) {
                        ModuleDesc = AnsiString((*pp_parser)->psz_longname) +
                            " (" + AnsiString((*pp_parser)->psz_object_name) +
                            ")";
                    }
                    else
                        ModuleDesc = AnsiString((*pp_parser)->psz_object_name);

                    int item = PanelPlugin->CleanCheckListBox->Items->AddObject(
                        ModuleDesc.c_str(),
                        new TObjectString((*pp_parser)->psz_object_name) );

                    /* check the box if it's the default module */
                    AnsiString Name = p_item->psz_value ?
                        p_item->psz_value : "";
                    if( !strcmp( (*pp_parser)->psz_object_name, Name.c_str()) )
                    {
                        PanelPlugin->CleanCheckListBox->Checked[item] = true;
                    }
                }
            }

            break;

        case CONFIG_ITEM_FILE:

        case CONFIG_ITEM_STRING:

            /* add new panel for the config option */
            PanelString = new TPanelString( this, p_item );
            PanelString->Parent = ScrollBox;

            break;

        case CONFIG_ITEM_INTEGER:

            /* add new panel for the config option */
            PanelInteger = new TPanelInteger( this, p_item );
            PanelInteger->Parent = ScrollBox;

            break;

        case CONFIG_ITEM_BOOL:

            /* add new panel for the config option */
            PanelBool = new TPanelBool( this, p_item );
            PanelBool->Parent = ScrollBox;

            break;
        }

        p_item++;
    }
    while( p_item->i_type != CONFIG_HINT_END );

    /* Reorder panels inside the tabsheets */
    for( i_pages = 0; i_pages < PageControlPref->PageCount; i_pages++ )
    {
        /* get scrollbox from the tabsheet */
        ScrollBox = (TScrollBox *)PageControlPref->Pages[i_pages]->Controls[0];

        /* add a panel as bottom margin */
        ADD_PANEL;

        for( i_ctrl = ScrollBox->ControlCount - 1; i_ctrl >= 0 ; i_ctrl-- )
        {
            ScrollBox->Controls[i_ctrl]->Align = alTop;
        }
    }

    vlc_list_release( p_list );

    /* set active tabsheet
     * FIXME: i don't know why, but both lines are necessary */
    PageControlPref->ActivePageIndex = 1;
    PageControlPref->ActivePageIndex = 0;
}
#undef ADD_PANEL
//---------------------------------------------------------------------------
void __fastcall TPreferencesDlg::ButtonOkClick( TObject *Sender )
{
    ButtonApplyClick( Sender );
    Hide();
}
//---------------------------------------------------------------------------
void __fastcall TPreferencesDlg::ButtonApplyClick( TObject *Sender )
{
    TScrollBox *ScrollBox;
    TPanelPref *Panel;
    int i, j;

    for( i = 0; i < PageControlPref->PageCount; i++ )
    {
        /* get scrollbox from the tabsheet */
        ScrollBox = (TScrollBox *)PageControlPref->Pages[i]->Controls[0];

        for( j = 0; j < ScrollBox->ControlCount ; j++ )
        {
            /* skip the panels */
            if( ScrollBox->Controls[j]->InheritsFrom( __classid( TPanelPref ) ) )
            {
                Panel = (TPanelPref *)ScrollBox->Controls[j];
                Panel->UpdateChanges();
                SaveValue( Panel->p_config );
            }
        }
    }
}
//---------------------------------------------------------------------------
void __fastcall TPreferencesDlg::ButtonSaveClick( TObject *Sender )
{
    ButtonApplyClick( Sender );
    config_SaveConfigFile( p_intfGlobal, NULL );
}
//---------------------------------------------------------------------------
void __fastcall TPreferencesDlg::ButtonCancelClick( TObject *Sender )
{
    Hide();
}
//---------------------------------------------------------------------------
void __fastcall TPreferencesDlg::SaveValue( module_config_t *p_config )
{
    switch( p_config->i_type )
    {
        case CONFIG_ITEM_STRING:
        case CONFIG_ITEM_FILE:
        case CONFIG_ITEM_MODULE:
            config_PutPsz( p_intfGlobal, p_config->psz_name,
                           *p_config->psz_value ? p_config->psz_value : NULL );
            break;
        case CONFIG_ITEM_INTEGER:
        case CONFIG_ITEM_BOOL:
            config_PutInt( p_intfGlobal, p_config->psz_name,
                           p_config->i_value );
            break;
    }
}
//---------------------------------------------------------------------------

