#include "interface.h"\r
#include "intf_playlist.h"\r
\r
+#include "disc.h"\r
#include "win32_common.h"\r
\r
-#include "disc.h"\r
//---------------------------------------------------------------------------\r
//#pragma package(smart_init)\r
#pragma resource "*.dfm"\r
__fastcall TDiscDlg::TDiscDlg( TComponent* Owner )\r
: TForm( Owner )\r
{\r
- char *psz_dvd_device = config_GetPszVariable( "dvd_device" );\r
- char *psz_vcd_device = config_GetPszVariable( "vcd_device" );\r
-\r
- if( psz_dvd_device )\r
- {\r
- EditDevice->Text.sprintf( "%s", psz_dvd_device );\r
- free( psz_dvd_device );\r
- }\r
-\r
- if( psz_vcd_device )\r
- {\r
- EditDevice->Text.sprintf( "%s", psz_vcd_device );\r
- free( psz_vcd_device );\r
- }\r
+ RadioGroupTypeClick( RadioGroupType );\r
}\r
//---------------------------------------------------------------------------\r
void __fastcall TDiscDlg::FormShow( TObject *Sender )\r
{\r
Method = "vcd";\r
}\r
- \r
+\r
/* Select title and chapter */\r
Title.sprintf( "%d", UpDownTitle->Position );\r
Chapter.sprintf( "%d", UpDownChapter->Position );\r
intf_PlaylistJumpto( p_main->p_playlist, i_end - 1 );\r
}\r
//---------------------------------------------------------------------------\r
+void __fastcall TDiscDlg::RadioGroupTypeClick( TObject *Sender )\r
+{\r
+ TRadioGroup *RadioGroupType = (TRadioGroup *)Sender;\r
+ char *psz_device;\r
+\r
+ if( RadioGroupType->ItemIndex == 0 )\r
+ {\r
+ psz_device = config_GetPszVariable( "dvd_device" );\r
+ }\r
+ else\r
+ {\r
+ psz_device = config_GetPszVariable( "vcd_device" );\r
+ }\r
+\r
+ if( psz_device )\r
+ {\r
+ EditDevice->Text = psz_device;\r
+ free( psz_device );\r
+ }\r
+}\r
+//---------------------------------------------------------------------------\r
\r
#include <vcl.h>\r
#pragma hdrstop\r
\r
+#include <stdlib.h> /* malloc(), free() */\r
+#include <string.h> /* strcmp */\r
+\r
#include <videolan/vlc.h>\r
\r
#include "interface.h"\r
\r
extern struct intf_thread_s *p_intfGlobal;\r
\r
+\r
/****************************************************************************\r
* Functions to help components creation\r
****************************************************************************/\r
UpDown->Thousands = Thousands;\r
return UpDown;\r
}\r
+//---------------------------------------------------------------------------\r
+void __fastcall TGroupBoxPref::UpdateChanges()\r
+{\r
+}\r
\r
\r
/****************************************************************************\r
vlc_mutex_lock( p_config->p_lock );\r
Edit->Text = p_config->psz_value ? p_config->psz_value : "";\r
vlc_mutex_unlock( p_config->p_lock );\r
- Edit->OnChange = EditChange;\r
\r
Height = 233;\r
};\r
p_module != NULL ;\r
p_module = p_module->next )\r
{\r
- if( !strcmp( p_module->psz_name, Name.c_str() ) )\r
+ if( strcmp( p_module->psz_name, Name.c_str() ) == 0 )\r
{\r
ModuleSelected = p_module;\r
LabelHint->Caption = p_module->psz_longname ?\r
//---------------------------------------------------------------------------\r
void __fastcall TGroupBoxPlugin::ButtonConfigClick( TObject *Sender )\r
{\r
- /* FIWME: TODO */\r
+ /* FIXME: TODO */\r
}\r
//---------------------------------------------------------------------------\r
-void __fastcall TGroupBoxPlugin::EditChange( TObject *Sender )\r
+void __fastcall TGroupBoxPlugin::UpdateChanges()\r
{\r
- TEdit *Edit = (TEdit *)Sender;\r
- p_config->psz_value = Edit->Text.c_str();\r
+ /* XXX: Necessary, since c_str() returns only a temporary pointer... */\r
+ free( p_config->psz_value );\r
+ p_config->psz_value = (char *)malloc( Edit->Text.Length() + 1 );\r
+ strcpy( p_config->psz_value, Edit->Text.c_str() );\r
}\r
\r
\r
vlc_mutex_lock( p_config->p_lock );\r
Edit->Text = p_config->psz_value ? p_config->psz_value : "";\r
vlc_mutex_unlock( p_config->p_lock );\r
- Edit->OnChange = EditChange;\r
\r
/* vertical alignment */\r
Height = LabelDesc->Height + 24;\r
Edit->Top = Top + ( Height - Edit->Height ) / 2 + 4;\r
};\r
//---------------------------------------------------------------------------\r
-void __fastcall TGroupBoxString::EditChange( TObject *Sender )\r
+void __fastcall TGroupBoxString::UpdateChanges()\r
{\r
- TEdit *Edit = (TEdit *)Sender;\r
- p_config->psz_value = Edit->Text.c_str();\r
+ /* XXX: Necessary, since c_str() returns only a temporary pointer... */\r
+ free( p_config->psz_value );\r
+ p_config->psz_value = (char *)malloc( Edit->Text.Length() + 1 );\r
+ strcpy( p_config->psz_value, Edit->Text.c_str() );\r
}\r
\r
\r
\r
/* init edit */\r
Edit = CreateEdit( this, 16, 148, 24, 21, "" );\r
- Edit->OnChange = EditChange;\r
\r
/* init updown */\r
UpDown = CreateUpDown( this, -1, 32767, p_config->i_value, false );\r
Edit->Top = Top + ( Height - Edit->Height ) / 2 + 4;\r
};\r
//---------------------------------------------------------------------------\r
-void __fastcall TGroupBoxInteger::EditChange( TObject *Sender )\r
+void __fastcall TGroupBoxInteger::UpdateChanges()\r
{\r
- TEdit *Edit = (TEdit *)Sender;\r
p_config->i_value = StrToInt( Edit->Text );\r
}\r
\r
/* init checkbox */\r
CheckBox = CreateCheckBox( this, 16, 184, 28, 17, p_config->psz_text );\r
CheckBox->Checked = p_config->i_value;\r
- CheckBox->OnClick = CheckBoxClick;\r
\r
/* vertical alignment */\r
Height = LabelDesc->Height + 24;\r
CheckBox->Top = Top + ( Height - CheckBox->Height ) / 2 + 4;\r
};\r
//---------------------------------------------------------------------------\r
-void __fastcall TGroupBoxBool::CheckBoxClick( TObject *Sender )\r
+void __fastcall TGroupBoxBool::UpdateChanges()\r
{\r
- TCheckBox *CheckBox = (TCheckBox *)Sender;\r
p_config->i_value = CheckBox->Checked ? 1 : 0;\r
}\r
\r
\r
void __fastcall TPreferencesDlg::CreateConfigDialog( char *psz_module_name )\r
{\r
- bool config_dialog;\r
- module_t *p_module;\r
- module_t *p_module_plugins;\r
- int i, j;\r
-\r
- TTabSheet *TabSheet;\r
- TScrollBox *ScrollBox;\r
- TPanel *Panel;\r
- TGroupBoxPlugin *GroupBoxPlugin;\r
- TGroupBoxString *GroupBoxString;\r
- TGroupBoxInteger *GroupBoxInteger;\r
- TGroupBoxBool *GroupBoxBool;\r
- TListItem *ListItem;\r
+ bool config_dialog;\r
+ module_t *p_module;\r
+ module_t *p_module_plugins;\r
+ unsigned int i;\r
+ int i_pages, i_ctrl;\r
+ \r
+ TTabSheet *TabSheet;\r
+ TScrollBox *ScrollBox;\r
+ TPanel *Panel;\r
+ TGroupBoxPlugin *GroupBoxPlugin;\r
+ TGroupBoxString *GroupBoxString;\r
+ TGroupBoxInteger *GroupBoxInteger;\r
+ TGroupBoxBool *GroupBoxBool;\r
+ TListItem *ListItem;\r
\r
/* Check if the dialog box is already opened, if so this will save us\r
* quite a bit of work. (the interface will be destroyed when you actually\r
}\r
\r
/* Reorder groupboxes inside the tabsheets */\r
- for( i = 0; i < PageControlPref->PageCount; i++ )\r
+ for( i_pages = 0; i_pages < PageControlPref->PageCount; i_pages++ )\r
{\r
/* get scrollbox from the tabsheet */\r
- ScrollBox = (TScrollBox *)PageControlPref->Pages[i]->Controls[0];\r
+ ScrollBox = (TScrollBox *)PageControlPref->Pages[i_pages]->Controls[0];\r
\r
- for( j = ScrollBox->ControlCount - 1; j >= 0 ; j-- )\r
+ for( i_ctrl = ScrollBox->ControlCount - 1; i_ctrl >= 0 ; i_ctrl-- )\r
{\r
- ScrollBox->Controls[j]->Align = alTop;\r
+ ScrollBox->Controls[i_ctrl]->Align = alTop;\r
}\r
}\r
\r
if( ScrollBox->Controls[j]->InheritsFrom( __classid( TGroupBoxPref ) ) )\r
{\r
GroupBox = (TGroupBoxPref *)ScrollBox->Controls[j];\r
+ GroupBox->UpdateChanges();\r
SaveValue( GroupBox->p_config );\r
}\r
}\r
case MODULE_CONFIG_ITEM_STRING:\r
case MODULE_CONFIG_ITEM_FILE:\r
case MODULE_CONFIG_ITEM_PLUGIN:\r
- config_PutPszVariable( p_config->psz_name, p_config->psz_value );\r
+ config_PutPszVariable( p_config->psz_name,\r
+ *p_config->psz_value ? p_config->psz_value : NULL );\r
break;\r
case MODULE_CONFIG_ITEM_INTEGER:\r
case MODULE_CONFIG_ITEM_BOOL:\r
public:\r
__fastcall TGroupBoxPref( TComponent* Owner, module_config_t *p_config_arg );\r
module_config_t *p_config;\r
+ virtual void __fastcall UpdateChanges();\r
TListView * __fastcall CreateListView( TWinControl *Parent,\r
int Left, int Width, int Top, int Height, TViewStyle ViewStyle );\r
TButton * __fastcall CreateButton( TWinControl *Parent,\r
TLabel *LabelSelected;\r
TEdit *Edit;\r
module_t *ModuleSelected;\r
+ void __fastcall UpdateChanges();\r
void __fastcall ListViewSelectItem( TObject *Sender, TListItem *Item,\r
bool Selected );\r
void __fastcall ButtonSelectClick( TObject *Sender );\r
void __fastcall ButtonConfigClick( TObject *Sender );\r
- void __fastcall EditChange( TObject *Sender );\r
};\r
//---------------------------------------------------------------------------\r
class TGroupBoxString : public TGroupBoxPref\r
__fastcall TGroupBoxString( TComponent* Owner, module_config_t *p_config );\r
TLabel *LabelDesc;\r
TEdit *Edit;\r
- void __fastcall EditChange( TObject *Sender );\r
+ void __fastcall UpdateChanges();\r
};\r
//---------------------------------------------------------------------------\r
class TGroupBoxInteger : public TGroupBoxPref\r
TLabel *LabelDesc;\r
TEdit *Edit;\r
TUpDown *UpDown;\r
- void __fastcall EditChange( TObject *Sender );\r
+ void __fastcall UpdateChanges();\r
};\r
//---------------------------------------------------------------------------\r
class TGroupBoxBool : public TGroupBoxPref\r
__fastcall TGroupBoxBool( TComponent* Owner, module_config_t *p_config );\r
TLabel *LabelDesc;\r
TCheckBox *CheckBox;\r
- void __fastcall CheckBoxClick( TObject *Sender );\r
+ void __fastcall UpdateChanges();\r
};\r
//---------------------------------------------------------------------------\r
class TPreferencesDlg : public TForm\r