]> git.sesse.net Git - vlc/blob - modules/gui/win32/disc.cpp
e8162d0d4ae3865ec871d624c35a8c6d3c0d66de
[vlc] / modules / gui / win32 / disc.cpp
1 /*****************************************************************************\r
2  * disc.cpp: "Open disc" dialog box.\r
3  *****************************************************************************\r
4  * Copyright (C) 2002 VideoLAN\r
5  *\r
6  * Authors: Olivier Teuliere <ipkiss@via.ecp.fr>\r
7  *\r
8  * This program is free software; you can redistribute it and/or modify\r
9  * it under the terms of the GNU General Public License as published by\r
10  * the Free Software Foundation; either version 2 of the License, or\r
11  * (at your option) any later version.\r
12  * \r
13  * This program is distributed in the hope that it will be useful,\r
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
16  * GNU General Public License for more details.\r
17  *\r
18  * You should have received a copy of the GNU General Public License\r
19  * along with this program; if not, write to the Free Software\r
20  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.\r
21  *****************************************************************************/\r
22 \r
23 #include <vcl.h>\r
24 #pragma hdrstop\r
25 \r
26 #include <vlc/vlc.h>\r
27 #include <vlc/intf.h>\r
28 \r
29 #include "disc.h"\r
30 #include "misc.h";\r
31 #include "win32_common.h"\r
32 \r
33 //---------------------------------------------------------------------------\r
34 //#pragma package(smart_init)\r
35 #pragma link "CSPIN"\r
36 #pragma resource "*.dfm"\r
37 \r
38 //---------------------------------------------------------------------------\r
39 __fastcall TDiscDlg::TDiscDlg( TComponent* Owner, intf_thread_t *_p_intf )\r
40         : TForm( Owner )\r
41 {\r
42     p_intf = _p_intf;\r
43     /* Simulate a click to get the correct device name */\r
44     RadioGroupTypeClick( RadioGroupType );\r
45     Translate( this );\r
46 }\r
47 //---------------------------------------------------------------------------\r
48 void __fastcall TDiscDlg::FormShow( TObject *Sender )\r
49 {\r
50     p_intf->p_sys->p_window->OpenDiscAction->Checked = true;\r
51 }\r
52 //---------------------------------------------------------------------------\r
53 void __fastcall TDiscDlg::FormHide( TObject *Sender )\r
54 {\r
55     p_intf->p_sys->p_window->OpenDiscAction->Checked = false;\r
56 }\r
57 //---------------------------------------------------------------------------\r
58 void __fastcall TDiscDlg::BitBtnCancelClick( TObject *Sender )\r
59 {\r
60     Hide();\r
61 }\r
62 //---------------------------------------------------------------------------\r
63 void __fastcall TDiscDlg::BitBtnOkClick( TObject *Sender )\r
64 {\r
65     AnsiString  Device, Source, Method, Title, Chapter;\r
66 \r
67     Hide();\r
68 \r
69     Device = EditDevice->Text;\r
70 \r
71     /* Check which method was activated */\r
72     if( RadioGroupType->ItemIndex == 0 )\r
73         Method = "dvd";\r
74     else\r
75         Method = "vcd";\r
76 \r
77     /* Select title and chapter */\r
78     Title.sprintf( "%d", SpinEditTitle->Value );\r
79     Chapter.sprintf( "%d", SpinEditChapter->Value );\r
80 \r
81     /* Build source name and add it to playlist */\r
82     Source = Method + ":" + Device + "@" + Title + "," + Chapter;\r
83 \r
84     p_intf->p_sys->p_playwin->Add( Source, PLAYLIST_APPEND | PLAYLIST_GO,\r
85                                    PLAYLIST_END );\r
86 }\r
87 //---------------------------------------------------------------------------\r
88 void __fastcall TDiscDlg::RadioGroupTypeClick( TObject *Sender )\r
89 {\r
90     TRadioGroup *RadioGroupType = (TRadioGroup *)Sender;\r
91     char *psz_device;\r
92 \r
93     if( RadioGroupType->ItemIndex == 0 )\r
94     {\r
95         psz_device = config_GetPsz( p_intf, "dvd" );\r
96     }\r
97     else\r
98     {\r
99         psz_device = config_GetPsz( p_intf, "vcd" );\r
100     }\r
101 \r
102     if( psz_device )\r
103     {\r
104         EditDevice->Text = psz_device;\r
105         free( psz_device );\r
106     }\r
107 }\r
108 //---------------------------------------------------------------------------\r
109 \r