Commit d7bba658 authored by Olivier Teulière's avatar Olivier Teulière

 * ./plugins/win32:
        - fixed a few bugs in the preferences
        - better auto-resizing of the main window
        - the disc dialog now respects the preferences settings
parent 58e56290
......@@ -31,9 +31,9 @@
#include "interface.h"
#include "intf_playlist.h"
#include "disc.h"
#include "win32_common.h"
#include "disc.h"
//---------------------------------------------------------------------------
//#pragma package(smart_init)
#pragma resource "*.dfm"
......@@ -44,20 +44,7 @@ extern struct intf_thread_s *p_intfGlobal;
__fastcall TDiscDlg::TDiscDlg( TComponent* Owner )
: TForm( Owner )
{
char *psz_dvd_device = config_GetPszVariable( "dvd_device" );
char *psz_vcd_device = config_GetPszVariable( "vcd_device" );
if( psz_dvd_device )
{
EditDevice->Text.sprintf( "%s", psz_dvd_device );
free( psz_dvd_device );
}
if( psz_vcd_device )
{
EditDevice->Text.sprintf( "%s", psz_vcd_device );
free( psz_vcd_device );
}
RadioGroupTypeClick( RadioGroupType );
}
//---------------------------------------------------------------------------
void __fastcall TDiscDlg::FormShow( TObject *Sender )
......@@ -95,7 +82,7 @@ void __fastcall TDiscDlg::BitBtnOkClick( TObject *Sender )
{
Method = "vcd";
}
/* Select title and chapter */
Title.sprintf( "%d", UpDownTitle->Position );
Chapter.sprintf( "%d", UpDownChapter->Position );
......@@ -116,4 +103,25 @@ void __fastcall TDiscDlg::BitBtnOkClick( TObject *Sender )
intf_PlaylistJumpto( p_main->p_playlist, i_end - 1 );
}
//---------------------------------------------------------------------------
void __fastcall TDiscDlg::RadioGroupTypeClick( TObject *Sender )
{
TRadioGroup *RadioGroupType = (TRadioGroup *)Sender;
char *psz_device;
if( RadioGroupType->ItemIndex == 0 )
{
psz_device = config_GetPszVariable( "dvd_device" );
}
else
{
psz_device = config_GetPszVariable( "vcd_device" );
}
if( psz_device )
{
EditDevice->Text = psz_device;
free( psz_device );
}
}
//---------------------------------------------------------------------------
......@@ -329,6 +329,7 @@ object DiscDlg: TDiscDlg
'DVD'
'VCD')
TabOrder = 0
OnClick = RadioGroupTypeClick
end
object BitBtnOk: TBitBtn
Left = 8
......
......@@ -50,6 +50,7 @@ __published: // IDE-managed Components
void __fastcall FormHide(TObject *Sender);
void __fastcall BitBtnCancelClick(TObject *Sender);
void __fastcall BitBtnOkClick(TObject *Sender);
void __fastcall RadioGroupTypeClick(TObject *Sender);
private: // User declarations
public: // User declarations
__fastcall TDiscDlg( TComponent* Owner );
......
......@@ -635,9 +635,6 @@ void __fastcall TMainFrameDlg::ModeManage()
i_Height += GroupBoxSlider->Height;
}
/* resize main window */
this->Height = i_Height;
/* control buttons for free pace streams */
b_control = p_input_bank->pp_input[0]->stream.b_pace_control;
......@@ -654,16 +651,16 @@ void __fastcall TMainFrameDlg::ModeManage()
}
else
{
i_Height = StatusBar->Height + ToolBar->Height + 47;
if( config_GetIntVariable( "network_channel" ) )
{
GroupBoxNetwork->Visible = true;
LabelChannel->Visible = true;
i_Height += GroupBoxNetwork->Height;
}
else
{
/* default mode */
ClientHeight = 37 + ToolBar->Height;
/* unsensitize menus */
MenuProgram->Enabled = false;
MenuTitle->Enabled = false;
......@@ -676,6 +673,9 @@ void __fastcall TMainFrameDlg::ModeManage()
}
}
/* resize main window */
this->Height = i_Height;
/* set control items */
ToolButtonBack->Enabled = false;
ToolButtonStop->Enabled = true;
......@@ -688,4 +688,5 @@ void __fastcall TMainFrameDlg::ModeManage()
PopupSlow->Enabled = b_control;
PopupFast->Enabled = b_control;
}
//---------------------------------------------------------------------------
......@@ -3,6 +3,7 @@ object MainFrameDlg: TMainFrameDlg
Top = 245
Width = 534
Height = 307
BorderIcons = [biSystemMenu, biMinimize]
Caption = 'VideoLAN Client (win32 interface)'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
......@@ -599,7 +600,7 @@ object MainFrameDlg: TMainFrameDlg
Left = 104
Top = 208
Bitmap = {
494C01010D000E00040020002000FFFFFFFFFF00FFFFFFFFFFFFFFFF424D3600
494C01010D000E00040020002000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
0000000000003600000028000000800000008000000001002000000000000000
0100000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
......@@ -2715,7 +2716,8 @@ object MainFrameDlg: TMainFrameDlg
E0000003F800001FC0000001FFFFF001F0000003FC00003FC0000003FFFFFC01
FFFFF803FE00007FC0000007FFFFFF01FFFFFC07FF0000FFFFFFFE1FFFFFFFC1
FFFFFE07FFC003FFFFFFFC3FFFFFFFF9FFFFFFFFFFF80FFFFFFFF8FFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFF9FFFFFFFFFF}
FFFFFFFFFFFFFFFFFFFFF9FFFFFFFFFF00000000000000000000000000000000
000000000000}
end
object PopupMenuMain: TPopupMenu
AutoPopup = False
......
......@@ -23,6 +23,9 @@
#include <vcl.h>
#pragma hdrstop
#include <stdlib.h> /* malloc(), free() */
#include <string.h> /* strcmp */
#include <videolan/vlc.h>
#include "interface.h"
......@@ -36,6 +39,7 @@
extern struct intf_thread_s *p_intfGlobal;
/****************************************************************************
* Functions to help components creation
****************************************************************************/
......@@ -124,6 +128,10 @@ TUpDown * __fastcall TGroupBoxPref::CreateUpDown( TWinControl *Parent,
UpDown->Thousands = Thousands;
return UpDown;
}
//---------------------------------------------------------------------------
void __fastcall TGroupBoxPref::UpdateChanges()
{
}
/****************************************************************************
......@@ -163,7 +171,6 @@ __fastcall TGroupBoxPlugin::TGroupBoxPlugin( TComponent* Owner,
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->OnChange = EditChange;
Height = 233;
};
......@@ -182,7 +189,7 @@ void __fastcall TGroupBoxPlugin::ListViewSelectItem( TObject *Sender,
p_module != NULL ;
p_module = p_module->next )
{
if( !strcmp( p_module->psz_name, Name.c_str() ) )
if( strcmp( p_module->psz_name, Name.c_str() ) == 0 )
{
ModuleSelected = p_module;
LabelHint->Caption = p_module->psz_longname ?
......@@ -203,13 +210,15 @@ void __fastcall TGroupBoxPlugin::ButtonSelectClick( TObject *Sender )
//---------------------------------------------------------------------------
void __fastcall TGroupBoxPlugin::ButtonConfigClick( TObject *Sender )
{
/* FIWME: TODO */
/* FIXME: TODO */
}
//---------------------------------------------------------------------------
void __fastcall TGroupBoxPlugin::EditChange( TObject *Sender )
void __fastcall TGroupBoxPlugin::UpdateChanges()
{
TEdit *Edit = (TEdit *)Sender;
p_config->psz_value = Edit->Text.c_str();
/* 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() );
}
......@@ -228,7 +237,6 @@ __fastcall TGroupBoxString::TGroupBoxString( TComponent* Owner,
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->OnChange = EditChange;
/* vertical alignment */
Height = LabelDesc->Height + 24;
......@@ -236,10 +244,12 @@ __fastcall TGroupBoxString::TGroupBoxString( TComponent* Owner,
Edit->Top = Top + ( Height - Edit->Height ) / 2 + 4;
};
//---------------------------------------------------------------------------
void __fastcall TGroupBoxString::EditChange( TObject *Sender )
void __fastcall TGroupBoxString::UpdateChanges()
{
TEdit *Edit = (TEdit *)Sender;
p_config->psz_value = Edit->Text.c_str();
/* 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() );
}
......@@ -255,7 +265,6 @@ __fastcall TGroupBoxInteger::TGroupBoxInteger( TComponent* Owner,
/* init edit */
Edit = CreateEdit( this, 16, 148, 24, 21, "" );
Edit->OnChange = EditChange;
/* init updown */
UpDown = CreateUpDown( this, -1, 32767, p_config->i_value, false );
......@@ -267,9 +276,8 @@ __fastcall TGroupBoxInteger::TGroupBoxInteger( TComponent* Owner,
Edit->Top = Top + ( Height - Edit->Height ) / 2 + 4;
};
//---------------------------------------------------------------------------
void __fastcall TGroupBoxInteger::EditChange( TObject *Sender )
void __fastcall TGroupBoxInteger::UpdateChanges()
{
TEdit *Edit = (TEdit *)Sender;
p_config->i_value = StrToInt( Edit->Text );
}
......@@ -287,7 +295,6 @@ __fastcall TGroupBoxBool::TGroupBoxBool( TComponent* Owner,
/* init checkbox */
CheckBox = CreateCheckBox( this, 16, 184, 28, 17, p_config->psz_text );
CheckBox->Checked = p_config->i_value;
CheckBox->OnClick = CheckBoxClick;
/* vertical alignment */
Height = LabelDesc->Height + 24;
......@@ -295,9 +302,8 @@ __fastcall TGroupBoxBool::TGroupBoxBool( TComponent* Owner,
CheckBox->Top = Top + ( Height - CheckBox->Height ) / 2 + 4;
};
//---------------------------------------------------------------------------
void __fastcall TGroupBoxBool::CheckBoxClick( TObject *Sender )
void __fastcall TGroupBoxBool::UpdateChanges()
{
TCheckBox *CheckBox = (TCheckBox *)Sender;
p_config->i_value = CheckBox->Checked ? 1 : 0;
}
......@@ -346,19 +352,20 @@ void __fastcall TPreferencesDlg::FormHide( TObject *Sender )
void __fastcall TPreferencesDlg::CreateConfigDialog( char *psz_module_name )
{
bool config_dialog;
module_t *p_module;
module_t *p_module_plugins;
int i, j;
TTabSheet *TabSheet;
TScrollBox *ScrollBox;
TPanel *Panel;
TGroupBoxPlugin *GroupBoxPlugin;
TGroupBoxString *GroupBoxString;
TGroupBoxInteger *GroupBoxInteger;
TGroupBoxBool *GroupBoxBool;
TListItem *ListItem;
bool config_dialog;
module_t *p_module;
module_t *p_module_plugins;
unsigned int i;
int i_pages, i_ctrl;
TTabSheet *TabSheet;
TScrollBox *ScrollBox;
TPanel *Panel;
TGroupBoxPlugin *GroupBoxPlugin;
TGroupBoxString *GroupBoxString;
TGroupBoxInteger *GroupBoxInteger;
TGroupBoxBool *GroupBoxBool;
TListItem *ListItem;
/* Check if the dialog box is already opened, if so this will save us
* quite a bit of work. (the interface will be destroyed when you actually
......@@ -476,14 +483,14 @@ void __fastcall TPreferencesDlg::CreateConfigDialog( char *psz_module_name )
}
/* Reorder groupboxes inside the tabsheets */
for( i = 0; i < PageControlPref->PageCount; i++ )
for( i_pages = 0; i_pages < PageControlPref->PageCount; i_pages++ )
{
/* get scrollbox from the tabsheet */
ScrollBox = (TScrollBox *)PageControlPref->Pages[i]->Controls[0];
ScrollBox = (TScrollBox *)PageControlPref->Pages[i_pages]->Controls[0];
for( j = ScrollBox->ControlCount - 1; j >= 0 ; j-- )
for( i_ctrl = ScrollBox->ControlCount - 1; i_ctrl >= 0 ; i_ctrl-- )
{
ScrollBox->Controls[j]->Align = alTop;
ScrollBox->Controls[i_ctrl]->Align = alTop;
}
}
......@@ -525,6 +532,7 @@ void __fastcall TPreferencesDlg::ButtonApplyClick( TObject *Sender )
if( ScrollBox->Controls[j]->InheritsFrom( __classid( TGroupBoxPref ) ) )
{
GroupBox = (TGroupBoxPref *)ScrollBox->Controls[j];
GroupBox->UpdateChanges();
SaveValue( GroupBox->p_config );
}
}
......@@ -549,7 +557,8 @@ void __fastcall TPreferencesDlg::SaveValue( module_config_t *p_config )
case MODULE_CONFIG_ITEM_STRING:
case MODULE_CONFIG_ITEM_FILE:
case MODULE_CONFIG_ITEM_PLUGIN:
config_PutPszVariable( p_config->psz_name, p_config->psz_value );
config_PutPszVariable( p_config->psz_name,
*p_config->psz_value ? p_config->psz_value : NULL );
break;
case MODULE_CONFIG_ITEM_INTEGER:
case MODULE_CONFIG_ITEM_BOOL:
......
......@@ -36,6 +36,7 @@ class TGroupBoxPref : public TGroupBox
public:
__fastcall TGroupBoxPref( TComponent* Owner, module_config_t *p_config_arg );
module_config_t *p_config;
virtual void __fastcall UpdateChanges();
TListView * __fastcall CreateListView( TWinControl *Parent,
int Left, int Width, int Top, int Height, TViewStyle ViewStyle );
TButton * __fastcall CreateButton( TWinControl *Parent,
......@@ -63,11 +64,11 @@ public:
TLabel *LabelSelected;
TEdit *Edit;
module_t *ModuleSelected;
void __fastcall UpdateChanges();
void __fastcall ListViewSelectItem( TObject *Sender, TListItem *Item,
bool Selected );
void __fastcall ButtonSelectClick( TObject *Sender );
void __fastcall ButtonConfigClick( TObject *Sender );
void __fastcall EditChange( TObject *Sender );
};
//---------------------------------------------------------------------------
class TGroupBoxString : public TGroupBoxPref
......@@ -76,7 +77,7 @@ public:
__fastcall TGroupBoxString( TComponent* Owner, module_config_t *p_config );
TLabel *LabelDesc;
TEdit *Edit;
void __fastcall EditChange( TObject *Sender );
void __fastcall UpdateChanges();
};
//---------------------------------------------------------------------------
class TGroupBoxInteger : public TGroupBoxPref
......@@ -86,7 +87,7 @@ public:
TLabel *LabelDesc;
TEdit *Edit;
TUpDown *UpDown;
void __fastcall EditChange( TObject *Sender );
void __fastcall UpdateChanges();
};
//---------------------------------------------------------------------------
class TGroupBoxBool : public TGroupBoxPref
......@@ -95,7 +96,7 @@ public:
__fastcall TGroupBoxBool( TComponent* Owner, module_config_t *p_config );
TLabel *LabelDesc;
TCheckBox *CheckBox;
void __fastcall CheckBoxClick( TObject *Sender );
void __fastcall UpdateChanges();
};
//---------------------------------------------------------------------------
class TPreferencesDlg : public TForm
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment