]> git.sesse.net Git - vlc/blob - modules/gui/win32/mainframe.cpp
22980a8212b08714346518abdb38e363b554f3ba
[vlc] / modules / gui / win32 / mainframe.cpp
1 /*****************************************************************************\r
2  * mainframe.cpp: Win32 interface plugin for vlc\r
3  *****************************************************************************\r
4  * Copyright (C) 2002 VideoLAN\r
5  *\r
6  * Authors: Olivier Teulière <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 #include <vlc/vout.h>\r
29 \r
30 #include "dragdrop.h"\r
31 #include "mainframe.h"\r
32 #include "menu.h"\r
33 #include "disc.h"\r
34 #include "network.h"\r
35 #include "about.h"\r
36 #include "preferences.h"\r
37 #include "messages.h"\r
38 #include "playlist.h"\r
39 #include "misc.h"\r
40 #include "win32_common.h"\r
41 \r
42 #include "netutils.h"\r
43 \r
44 //---------------------------------------------------------------------------\r
45 #pragma link "CSPIN"\r
46 #pragma resource "*.dfm"\r
47 \r
48 extern int Win32Manage( intf_thread_t *p_intf );\r
49 \r
50 //---------------------------------------------------------------------------\r
51 __fastcall TMainFrameDlg::TMainFrameDlg(\r
52     TComponent* Owner, intf_thread_t *_p_intf ) : TForm( Owner )\r
53 {\r
54     p_intf = _p_intf;\r
55 \r
56     Application->ShowHint = true;\r
57     Application->OnHint = DisplayHint;\r
58 \r
59     TimerManage->Interval = INTF_IDLE_SLEEP / 1000;\r
60 \r
61     TrackBar->Max = SLIDER_MAX_VALUE;\r
62 \r
63     /* default height and caption */\r
64     ClientHeight = 37 + ToolBar->Height;\r
65     Caption = VOUT_TITLE " (Win32 interface)";\r
66 \r
67     StringListPref = new TStringList();\r
68 \r
69     Translate( this );\r
70 \r
71     /* drag and drop stuff */\r
72 \r
73     /* initialize the OLE library */\r
74     OleInitialize( NULL );\r
75     /* TDropTarget will send the WM_OLEDROP message to the form */\r
76     lpDropTarget = (LPDROPTARGET)new TDropTarget( this->Handle );\r
77     CoLockObjectExternal( lpDropTarget, true, true );\r
78     /* register the form as a drop target */\r
79     RegisterDragDrop( this->Handle, lpDropTarget );\r
80 }\r
81 //---------------------------------------------------------------------------\r
82 __fastcall TMainFrameDlg::~TMainFrameDlg()\r
83 {\r
84     delete StringListPref;\r
85 }\r
86 //---------------------------------------------------------------------------\r
87 \r
88 \r
89 /*****************************************************************************\r
90  * Event handlers\r
91  ****************************************************************************/\r
92 void __fastcall TMainFrameDlg::TimerManageTimer( TObject *Sender )\r
93 {\r
94     Win32Manage( p_intf );\r
95 }\r
96 //---------------------------------------------------------------------------\r
97 void __fastcall TMainFrameDlg::DisplayHint( TObject *Sender )\r
98 {\r
99     StatusBar->SimpleText = GetLongHint( Application->Hint );\r
100 }\r
101 //---------------------------------------------------------------------------\r
102 void __fastcall TMainFrameDlg::TrackBarChange( TObject *Sender )\r
103 {\r
104     /* This function displays the current date related to the position in\r
105      * the stream. It is called whenever the slider changes its value.\r
106      * The lock has to be taken before the function is called */\r
107 \r
108     if( p_intf->p_sys->p_input != NULL )\r
109     {\r
110 #define p_area p_intf->p_sys->p_input->stream.p_selected_area\r
111         char psz_time[ OFFSETTOTIME_MAX_SIZE ];\r
112         off_t Value = TrackBar->Position;\r
113 \r
114         GroupBoxSlider->Caption =\r
115                 input_OffsetToTime( p_intf->p_sys->p_input, psz_time,\r
116                         ( p_area->i_size * Value ) / (off_t)SLIDER_MAX_VALUE );\r
117 #undef p_area\r
118      }\r
119 }\r
120 //---------------------------------------------------------------------------\r
121 void __fastcall TMainFrameDlg::FormClose( TObject *Sender,\r
122       TCloseAction &Action )\r
123 {\r
124     vlc_mutex_lock( &p_intf->change_lock );\r
125     p_intf->p_vlc->b_die = VLC_TRUE;\r
126     vlc_mutex_unlock( &p_intf->change_lock );\r
127 \r
128     /* remove the form from the list of drop targets */\r
129     RevokeDragDrop( this->Handle );\r
130     lpDropTarget->Release();\r
131     CoLockObjectExternal( lpDropTarget, false, true );\r
132 \r
133     /* uninitialize the OLE library */\r
134     OleUninitialize();\r
135 \r
136     /* we don't destroy the form immediatly */\r
137     Action = caHide;\r
138 }\r
139 //---------------------------------------------------------------------------\r
140 \r
141 \r
142 /*****************************************************************************\r
143  * Main callbacks\r
144  ****************************************************************************/\r
145 void __fastcall TMainFrameDlg::OpenFileActionExecute( TObject *Sender )\r
146 {\r
147     if( OpenDialog1->Execute() )\r
148     {\r
149         /* add the new file to the interface playlist */\r
150         for ( int i = 0 ; i < OpenDialog1->Files->Count ; i++ )\r
151             p_intf->p_sys->p_playwin->Add( OpenDialog1->Files->Strings[i],\r
152                     PLAYLIST_APPEND\r
153                     | ( p_intf->p_sys->b_play_when_adding ? PLAYLIST_GO : 0 ),\r
154                     PLAYLIST_END );\r
155     };\r
156 }\r
157 //---------------------------------------------------------------------------\r
158 void __fastcall TMainFrameDlg::OpenDiscActionExecute( TObject *Sender )\r
159 {\r
160     TDiscDlg *p_disc = p_intf->p_sys->p_disc;\r
161     if( p_disc == NULL )\r
162     {\r
163         p_disc = new TDiscDlg( this, p_intf );\r
164         p_intf->p_sys->p_disc = p_disc;\r
165     }\r
166     p_disc->Show();\r
167 }\r
168 //---------------------------------------------------------------------------\r
169 void __fastcall TMainFrameDlg::NetworkStreamActionExecute( TObject *Sender )\r
170 {\r
171     TNetworkDlg *p_network = p_intf->p_sys->p_network;\r
172     if( p_network == NULL )\r
173     {\r
174         p_network = new TNetworkDlg( this, p_intf );\r
175         p_intf->p_sys->p_network = p_network;\r
176     }\r
177     p_network->Show();\r
178 }\r
179 //---------------------------------------------------------------------------\r
180 void __fastcall TMainFrameDlg::ExitActionExecute( TObject *Sender )\r
181 {\r
182     Close();\r
183 }\r
184 //---------------------------------------------------------------------------\r
185 void __fastcall TMainFrameDlg::FullscreenActionExecute( TObject *Sender )\r
186 {\r
187     vout_thread_t *p_vout;\r
188 \r
189     p_vout = (vout_thread_t *)vlc_object_find( p_intf->p_sys->p_input,\r
190                                                VLC_OBJECT_VOUT, FIND_CHILD );\r
191     if( p_vout == NULL )\r
192     {\r
193         return;\r
194     }\r
195 \r
196     p_vout->i_changes |= VOUT_FULLSCREEN_CHANGE;\r
197     vlc_object_release( p_vout );\r
198 }\r
199 //---------------------------------------------------------------------------\r
200 void __fastcall TMainFrameDlg::PlaylistActionExecute( TObject *Sender )\r
201 {\r
202     TPlaylistDlg *p_playwin = p_intf->p_sys->p_playwin;\r
203     if( p_playwin->Visible )\r
204     {\r
205         p_playwin->Hide();\r
206     }\r
207     else\r
208     {\r
209         p_playwin->UpdateGrid();\r
210         p_playwin->Show();\r
211     }\r
212 }\r
213 //---------------------------------------------------------------------------\r
214 void __fastcall TMainFrameDlg::MessagesActionExecute( TObject *Sender )\r
215 {\r
216      p_intf->p_sys->p_messages->Show();\r
217 }\r
218 //---------------------------------------------------------------------------\r
219 void __fastcall TMainFrameDlg::PreferencesActionExecute( TObject *Sender )\r
220 {\r
221     CreatePreferences( "main" );\r
222 }\r
223 //---------------------------------------------------------------------------\r
224 void __fastcall TMainFrameDlg::AboutActionExecute( TObject *Sender )\r
225 {\r
226     TAboutDlg *AboutDlg = new TAboutDlg( this, p_intf );\r
227     AboutDlg->ShowModal();\r
228     delete AboutDlg;\r
229 }\r
230 //---------------------------------------------------------------------------\r
231 void __fastcall TMainFrameDlg::BackActionExecute( TObject *Sender )\r
232 {\r
233     /* TODO */\r
234 }\r
235 //---------------------------------------------------------------------------\r
236 void __fastcall TMainFrameDlg::PlayActionExecute( TObject *Sender )\r
237 {\r
238     p_intf->p_sys->p_playwin->Play();\r
239 }\r
240 //---------------------------------------------------------------------------\r
241 void __fastcall TMainFrameDlg::PauseActionExecute( TObject *Sender )\r
242 {\r
243     p_intf->p_sys->p_playwin->Pause();\r
244 }\r
245 //---------------------------------------------------------------------------\r
246 void __fastcall TMainFrameDlg::StopActionExecute( TObject *Sender )\r
247 {\r
248     p_intf->p_sys->p_playwin->Stop();\r
249 }\r
250 //---------------------------------------------------------------------------\r
251 void __fastcall TMainFrameDlg::SlowActionExecute( TObject *Sender )\r
252 {\r
253     p_intf->p_sys->p_playwin->Slow();\r
254 }\r
255 //---------------------------------------------------------------------------\r
256 void __fastcall TMainFrameDlg::FastActionExecute( TObject *Sender )\r
257 {\r
258     p_intf->p_sys->p_playwin->Fast();\r
259 }\r
260 //---------------------------------------------------------------------------\r
261 void __fastcall TMainFrameDlg::PreviousActionExecute(TObject *Sender)\r
262 {\r
263     p_intf->p_sys->p_playwin->Previous();\r
264 }\r
265 //---------------------------------------------------------------------------\r
266 void __fastcall TMainFrameDlg::NextActionExecute(TObject *Sender)\r
267 {\r
268     p_intf->p_sys->p_playwin->Next();\r
269 }\r
270 //---------------------------------------------------------------------------\r
271 void __fastcall TMainFrameDlg::EjectActionExecute( TObject *Sender )\r
272 {\r
273     AnsiString Device = "";\r
274     char * psz_current;\r
275     playlist_t * p_playlist;\r
276 \r
277     p_playlist = (playlist_t *)vlc_object_find( p_intf,\r
278                                        VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );\r
279     if( p_playlist == NULL )\r
280     {\r
281         return;\r
282     }\r
283 \r
284     /*\r
285      * Get the active input\r
286      * Determine whether we can eject a media, ie it's a VCD or DVD\r
287      * If it's neither a VCD nor a DVD, then return\r
288      */\r
289 \r
290     vlc_mutex_lock( &p_playlist->object_lock );\r
291     psz_current = p_playlist->pp_items[ p_playlist->i_index ]->psz_name;\r
292 \r
293     if( psz_current != NULL )\r
294     {\r
295         if( strncmp( psz_current, "dvd", 3 )\r
296             || strncmp( psz_current, "vcd", 3 ) )\r
297         {\r
298             /* Determine the device name by omitting the first 4 characters\r
299              * and keeping 3 characters */\r
300             Device = strdup( ( psz_current + 4 ) );\r
301             Device = Device.SubString( 1, 2 );\r
302         }\r
303     }\r
304 \r
305     vlc_mutex_unlock( &p_playlist->object_lock );\r
306     vlc_object_release( p_playlist );\r
307 \r
308     if( Device == "" )\r
309     {\r
310         return;\r
311     }\r
312 \r
313     /* If there's a stream playing, we aren't allowed to eject ! */\r
314     if( p_intf->p_sys->p_input == NULL )\r
315     {\r
316         msg_Dbg( p_intf, "ejecting %s", Device.c_str() );\r
317 \r
318         intf_Eject( p_intf, Device.c_str() );\r
319     }\r
320 }\r
321 //--------------------------------------------------------------------------\r
322 void __fastcall TMainFrameDlg::VolumeUpActionExecute( TObject *Sender )\r
323 {\r
324     aout_instance_t *p_aout;\r
325     p_aout = (aout_instance_t *)vlc_object_find( p_intf, VLC_OBJECT_AOUT,\r
326                                                  FIND_ANYWHERE );\r
327     if ( p_aout != NULL )\r
328     {\r
329         aout_VolumeUp( p_aout, 1, NULL );\r
330         vlc_object_release( (vlc_object_t *)p_aout );\r
331     }\r
332 }\r
333 //---------------------------------------------------------------------------\r
334 void __fastcall TMainFrameDlg::VolumeDownActionExecute( TObject *Sender )\r
335 {\r
336     aout_instance_t *p_aout;\r
337     p_aout = (aout_instance_t *)vlc_object_find( p_intf, VLC_OBJECT_AOUT,\r
338                                                  FIND_ANYWHERE );\r
339     if ( p_aout != NULL )\r
340     {\r
341         aout_VolumeDown( p_aout, 1, NULL );\r
342         vlc_object_release( (vlc_object_t *)p_aout );\r
343     }\r
344 }\r
345 //---------------------------------------------------------------------------\r
346 void __fastcall TMainFrameDlg::MuteActionExecute( TObject *Sender )\r
347 {\r
348     aout_instance_t *p_aout;\r
349     p_aout = (aout_instance_t *)vlc_object_find( p_intf, VLC_OBJECT_AOUT,\r
350                                                  FIND_ANYWHERE );\r
351     if ( p_aout != NULL )\r
352     {\r
353         aout_VolumeMute( p_aout, NULL );\r
354         vlc_object_release( (vlc_object_t *)p_aout );\r
355 \r
356 //        MenuMute->Checked = ! MenuMute->Checked;\r
357     }\r
358 }\r
359 //---------------------------------------------------------------------------\r
360 \r
361 \r
362 /*****************************************************************************\r
363  * External drop handling\r
364  *****************************************************************************/\r
365 void __fastcall TMainFrameDlg::OnDrop( TMessage &Msg )\r
366 {\r
367     /* find the number of files dropped */\r
368     int num_files = DragQueryFile( (HDROP)Msg.WParam, 0xFFFFFFFF,\r
369                                    (LPSTR)NULL, NULL );\r
370 \r
371     /* append each file to the playlist */\r
372     for( int i = 0; i < num_files; i++ )\r
373     {\r
374         /* find the length of the filename */\r
375         int name_length = DragQueryFile( (HDROP)Msg.WParam, i, NULL, NULL ) + 1;\r
376 \r
377         /* get the filename */\r
378         char *FileName = new char[name_length];\r
379         DragQueryFile( (HDROP)Msg.WParam, i, FileName, name_length );\r
380 \r
381         /* add the new file to the playlist */\r
382         p_intf->p_sys->p_playwin->Add( FileName, PLAYLIST_APPEND | PLAYLIST_GO,\r
383                                        PLAYLIST_END );\r
384 \r
385         delete[] FileName;\r
386     }\r
387 \r
388     DragFinish( (HDROP)Msg.WParam );\r
389     Msg.Result = 0;\r
390 }\r
391 //--------------------------------------------------------------------------\r
392 \r
393 \r
394 /*****************************************************************************\r
395  * Menu and popup callbacks\r
396  *****************************************************************************/\r
397 void __fastcall TMainFrameDlg::MenuHideinterfaceClick( TObject *Sender )\r
398 {\r
399      this->SendToBack();\r
400 }\r
401 //---------------------------------------------------------------------------\r
402 void __fastcall TMainFrameDlg::PopupToggleInterfaceClick( TObject *Sender )\r
403 {\r
404     this->BringToFront();\r
405 }\r
406 //---------------------------------------------------------------------------\r
407 void __fastcall TMainFrameDlg::PopupCloseClick( TObject *Sender )\r
408 {\r
409     /* We do nothing, we just need a click on a menu item\r
410      * to close the popup. Don't ask me why... */\r
411     return;\r
412 }\r
413 //---------------------------------------------------------------------------\r
414 void __fastcall TMainFrameDlg::PopupJumpClick( TObject *Sender )\r
415 {\r
416     /* TODO */\r
417 }\r
418 //---------------------------------------------------------------------------\r
419 \r
420 \r
421 /*****************************************************************************\r
422  * Callbacks for DVD/VCD navigation\r
423  ****************************************************************************/\r
424 void __fastcall TMainFrameDlg::PrevTitleActionExecute( TObject *Sender )\r
425 {\r
426     input_area_t  * p_area;\r
427     int             i_id;\r
428 \r
429     i_id = p_intf->p_sys->p_input->stream.p_selected_area->i_id - 1;\r
430 \r
431     /* Disallow area 0 since it is used for video_ts.vob */\r
432     if( i_id > 0 )\r
433     {\r
434         p_area = p_intf->p_sys->p_input->stream.pp_areas[i_id];\r
435         input_ChangeArea( p_intf->p_sys->p_input, (input_area_t*)p_area );\r
436 \r
437         input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY );\r
438 \r
439         p_intf->p_sys->b_title_update = 1;\r
440         vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );\r
441         p_intf->p_sys->p_menus->SetupMenus();\r
442         vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );\r
443     }\r
444 }\r
445 //---------------------------------------------------------------------------\r
446 void __fastcall TMainFrameDlg::NextTitleActionExecute( TObject *Sender )\r
447 {\r
448     input_area_t  * p_area;\r
449     int             i_id;\r
450 \r
451     i_id = p_intf->p_sys->p_input->stream.p_selected_area->i_id + 1;\r
452 \r
453     if( i_id < p_intf->p_sys->p_input->stream.i_area_nb )\r
454     {\r
455         p_area = p_intf->p_sys->p_input->stream.pp_areas[i_id];\r
456         input_ChangeArea( p_intf->p_sys->p_input, (input_area_t*)p_area );\r
457 \r
458         input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY );\r
459 \r
460         p_intf->p_sys->b_title_update = 1;\r
461         vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );\r
462         p_intf->p_sys->p_menus->SetupMenus();\r
463         vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );\r
464     }\r
465 }\r
466 //---------------------------------------------------------------------------\r
467 void __fastcall TMainFrameDlg::PrevChapterActionExecute( TObject *Sender )\r
468 {\r
469     input_area_t  * p_area;\r
470 \r
471     p_area = p_intf->p_sys->p_input->stream.p_selected_area;\r
472 \r
473     if( p_area->i_part > 0 )\r
474     {\r
475         p_area->i_part--;\r
476         input_ChangeArea( p_intf->p_sys->p_input, (input_area_t*)p_area );\r
477 \r
478         input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY );\r
479 \r
480         p_intf->p_sys->b_chapter_update = 1;\r
481         vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );\r
482         p_intf->p_sys->p_menus->SetupMenus();\r
483         vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );\r
484     }\r
485 }\r
486 //---------------------------------------------------------------------------\r
487 void __fastcall TMainFrameDlg::NextChapterActionExecute( TObject *Sender )\r
488 {\r
489     input_area_t  * p_area;\r
490 \r
491     p_area = p_intf->p_sys->p_input->stream.p_selected_area;\r
492 \r
493     if( p_area->i_part < p_area->i_part_nb )\r
494     {\r
495         p_area->i_part++;\r
496         input_ChangeArea( p_intf->p_sys->p_input, (input_area_t*)p_area );\r
497 \r
498         input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY );\r
499 \r
500         p_intf->p_sys->b_chapter_update = 1;\r
501         vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );\r
502         p_intf->p_sys->p_menus->SetupMenus();\r
503         vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );\r
504     }\r
505 }\r
506 //---------------------------------------------------------------------------\r
507 \r
508 \r
509 /*****************************************************************************\r
510  * Callback for the 'go!' button\r
511  ****************************************************************************/\r
512 void __fastcall TMainFrameDlg::ButtonGoClick( TObject *Sender )\r
513 {\r
514     int i_channel;\r
515 \r
516     i_channel = SpinEditChannel->Value;\r
517     msg_Dbg( p_intf, "joining channel %d", i_channel );\r
518 \r
519     vlc_mutex_lock( &p_intf->change_lock );\r
520     network_ChannelJoin( p_intf, i_channel );\r
521     vlc_mutex_unlock( &p_intf->change_lock );\r
522 \r
523 //    input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY );\r
524 }\r
525 //---------------------------------------------------------------------------\r
526 \r
527 \r
528 /*****************************************************************************\r
529  * ModeManage: actualise the aspect of the interface whenever the input\r
530  *             changes.\r
531  *****************************************************************************\r
532  * The lock has to be taken before you call the function.\r
533  *****************************************************************************/\r
534 void __fastcall TMainFrameDlg::ModeManage()\r
535 {\r
536     TGroupBox     * ActiveGB;\r
537     int             i_Height;\r
538     bool            b_control;\r
539 \r
540     /* hide all boxes */\r
541     GroupBoxFile->Visible = false;\r
542     GroupBoxNetwork->Visible = false;\r
543     GroupBoxDisc->Visible = false;\r
544 \r
545     /* hide slider */\r
546     GroupBoxSlider->Hide();\r
547 \r
548     /* controls unavailable */\r
549     b_control = 0;\r
550 \r
551     /* show the box related to current input mode */\r
552     if( p_intf->p_sys->p_input != NULL )\r
553     {\r
554         switch( p_intf->p_sys->p_input->stream.i_method & 0xf0 )\r
555         {\r
556             case INPUT_METHOD_FILE:\r
557                 GroupBoxFile->Visible = true;\r
558                 ActiveGB = GroupBoxFile;\r
559                 LabelFileName->Caption = p_intf->p_sys->p_input->psz_source;\r
560                 break;\r
561             case INPUT_METHOD_DISC:\r
562                 GroupBoxDisc->Visible = true;\r
563                 ActiveGB = GroupBoxDisc;\r
564                 break;\r
565             case INPUT_METHOD_NETWORK:\r
566                 GroupBoxNetwork->Visible = true;\r
567                 ActiveGB = GroupBoxNetwork;\r
568                 LabelServer->Caption = p_intf->p_sys->p_input->psz_source;\r
569                 if( config_GetInt( p_intf, "network-channel" ) )\r
570                 {\r
571                     LabelChannel->Visible = true;\r
572                 }\r
573                 else\r
574                 {\r
575                     LabelChannel->Visible = false;\r
576                 }\r
577                 break;\r
578             default:\r
579                 msg_Warn( p_intf, "cannot determine input method" );\r
580                 GroupBoxFile->Visible = true;\r
581                 ActiveGB = GroupBoxFile;\r
582                 LabelFileName->Caption = p_intf->p_sys->p_input->psz_source;\r
583                 break;\r
584         }\r
585 \r
586         i_Height = StatusBar->Height + ActiveGB->Height + ToolBar->Height + 54;\r
587 \r
588         /* initialize and show slider for seekable streams */\r
589         if( p_intf->p_sys->p_input->stream.b_seekable )\r
590         {\r
591             TrackBar->Position = p_intf->p_sys->OldValue = 0;\r
592             GroupBoxSlider->Show();\r
593             i_Height += GroupBoxSlider->Height;\r
594         }\r
595 \r
596         /* control buttons for free pace streams */\r
597         b_control = p_intf->p_sys->p_input->stream.b_pace_control;\r
598 \r
599         /* get ready for menu regeneration */\r
600         p_intf->p_sys->b_program_update = 1;\r
601         p_intf->p_sys->b_title_update = 1;\r
602         p_intf->p_sys->b_chapter_update = 1;\r
603         p_intf->p_sys->b_audio_update = 1;\r
604         p_intf->p_sys->b_spu_update = 1;\r
605         p_intf->p_sys->i_part = 0;\r
606 \r
607         p_intf->p_sys->p_input->stream.b_changed = 0;\r
608         msg_Dbg( p_intf, "stream has changed, refreshing interface" );\r
609     }\r
610     else\r
611     {\r
612         i_Height = StatusBar->Height + ToolBar->Height + 47;\r
613 \r
614         if( config_GetInt( p_intf, "network-channel" ) )\r
615         {\r
616             GroupBoxNetwork->Visible = true;\r
617             LabelChannel->Visible = true;\r
618             i_Height += GroupBoxNetwork->Height + 7;\r
619         }\r
620         else\r
621         {\r
622             /* add space between tolbar and statusbar when\r
623              * nothing is displayed; isn't it nicer ? :) */\r
624             i_Height += 17;\r
625         }\r
626 \r
627         /* unsensitize menus */\r
628         MenuProgram->Enabled = false;\r
629         MenuTitle->Enabled = false;\r
630         MenuChapter->Enabled = false;\r
631         MenuLanguage->Enabled = false;\r
632         MenuSubtitles->Enabled = false;\r
633         PopupNavigation->Enabled = false;\r
634         PopupLanguage->Enabled = false;\r
635         PopupSubtitles->Enabled = false;\r
636     }\r
637 \r
638     /* resize main window */\r
639     this->Height = i_Height;\r
640 \r
641     /* set control items */\r
642     ToolButtonBack->Enabled = false;\r
643     ToolButtonEject->Enabled = !b_control;\r
644     StopAction->Enabled = true;\r
645     PauseAction->Enabled = b_control;\r
646     SlowAction->Enabled = b_control;\r
647     FastAction->Enabled = b_control;\r
648     PopupBack->Enabled = false;\r
649 }\r
650 //---------------------------------------------------------------------------\r
651 \r
652 \r
653 /*****************************************************************************\r
654  * CreateConfig: create a configuration dialog and save it for further use\r
655  *****************************************************************************\r
656  * Check if the dialog box is already opened, if so this will save us\r
657  * quite a bit of work. (the interface will be destroyed when you actually\r
658  * close the main window, but remember that it is only hidden if you\r
659  * clicked on the action buttons). This trick also allows us not to\r
660  * duplicate identical dialog windows.\r
661  *****************************************************************************/\r
662 void __fastcall TMainFrameDlg::CreatePreferences( AnsiString Name )\r
663 {\r
664     TPreferencesDlg *Preferences;\r
665     int i_index, i_pos;\r
666 \r
667     i_index = StringListPref->IndexOf( Name );\r
668     if( i_index != -1 )\r
669     {\r
670         /* config dialog already exists */\r
671         Preferences = (TPreferencesDlg *)StringListPref->Objects[i_index];\r
672     }\r
673     else\r
674     {\r
675         /* create the config dialog */\r
676         Preferences = new TPreferencesDlg( this, p_intf );\r
677         Preferences->CreateConfigDialog( Name.c_str() );\r
678 \r
679         /* save it */\r
680         i_pos = StringListPref->Add( Name );\r
681         StringListPref->Objects[i_pos] = Preferences;\r
682     }\r
683 \r
684     /* display the dialog */\r
685     Preferences->Show();\r
686 }\r
687 //---------------------------------------------------------------------------\r
688 \r