1 /*****************************************************************************
2 * InterfaceWindow.cpp: beos interface
3 *****************************************************************************
4 * Copyright (C) 1999, 2000, 2001 VideoLAN
5 * $Id: InterfaceWindow.cpp,v 1.21 2003/01/25 01:03:44 titer Exp $
7 * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
8 * Samuel Hocevar <sam@zoy.org>
9 * Tony Castley <tony@castley.net>
10 * Richard Shepherd <richard@rshepherd.demon.co.uk>
11 * Stephan Aßmus <stippi@yellowbites.com>
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
26 *****************************************************************************/
29 #include <kernel/OS.h>
30 #include <InterfaceKit.h>
32 #include <StorageKit.h>
33 #include <SupportKit.h>
36 #include <scsiprobe_driver.h>
45 /* BeOS interface headers */
46 #include "VlcWrapper.h"
48 #include "MediaControlView.h"
49 #include "PlayListWindow.h"
50 #include "PreferencesWindow.h"
51 #include "InterfaceWindow.h"
53 #define INTERFACE_UPDATE_TIMEOUT 80000 // 2 frames if at 25 fps
56 /*****************************************************************************
58 *****************************************************************************/
60 InterfaceWindow::InterfaceWindow( BRect frame, const char *name,
61 intf_thread_t *p_interface )
62 : BWindow( frame, name, B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
63 B_NOT_ZOOMABLE | B_WILL_ACCEPT_FIRST_CLICK | B_ASYNCHRONOUS_CONTROLS ),
64 p_intf( p_interface ),
66 fSubtitlesPanel( NULL ),
67 fLastUpdateTime( system_time() )
70 p_wrapper = p_intf->p_sys->p_wrapper;
71 p_intf->p_sys->b_dvdold = false;
73 fPlaylistIsEmpty = !( p_wrapper->PlaylistSize() > 0 );
75 fPlaylistWindow = new PlayListWindow( BRect( 100.0, 100.0, 400.0, 350.0 ),
79 BScreen *p_screen = new BScreen();
80 BRect screen_rect = p_screen->Frame();
83 window_rect.Set( ( screen_rect.right - PREFS_WINDOW_WIDTH ) / 2,
84 ( screen_rect.bottom - PREFS_WINDOW_HEIGHT ) / 2,
85 ( screen_rect.right + PREFS_WINDOW_WIDTH ) / 2,
86 ( screen_rect.bottom + PREFS_WINDOW_HEIGHT ) / 2 );
87 fPreferencesWindow = new PreferencesWindow( window_rect,
92 SetName( "interface" );
93 SetTitle( VOUT_TITLE );
95 // the media control view
96 p_mediaControl = new MediaControlView( BRect( 0.0, 0.0, 250.0, 50.0 ),
98 p_mediaControl->SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) );
101 p_mediaControl->GetPreferredSize( &width, &height );
103 // set up the main menu
104 fMenuBar = new BMenuBar( BRect(0.0, 0.0, width, 15.0), "main menu",
105 B_FOLLOW_NONE, B_ITEMS_IN_ROW, false );
107 // make menu bar resize to correct height
108 float menuWidth, menuHeight;
109 fMenuBar->GetPreferredSize( &menuWidth, &menuHeight );
110 fMenuBar->ResizeTo( width, menuHeight ); // don't change! it's a workarround!
111 // take care of proper size for ourself
112 height += fMenuBar->Bounds().Height();
113 ResizeTo( width, height );
115 p_mediaControl->MoveTo( fMenuBar->Bounds().LeftBottom() + BPoint(0.0, 1.0) );
116 AddChild( fMenuBar );
117 AddChild( p_mediaControl );
120 BMenu* fileMenu = new BMenu( "File" );
121 fMenuBar->AddItem( fileMenu );
122 fileMenu->AddItem( new BMenuItem( "Open File" B_UTF8_ELLIPSIS,
123 new BMessage( OPEN_FILE ), 'O') );
125 fileMenu->AddItem( new CDMenu( "Open Disc" ) );
127 fileMenu->AddItem( new BMenuItem( "Load a subtitle file" B_UTF8_ELLIPSIS,
128 new BMessage( LOAD_SUBFILE ) ) );
130 fileMenu->AddSeparatorItem();
131 fileMenu->AddItem( new BMenuItem( "Play List" B_UTF8_ELLIPSIS,
132 new BMessage( OPEN_PLAYLIST ), 'P') );
134 fileMenu->AddSeparatorItem();
135 BMenuItem* item = new BMenuItem( "About" B_UTF8_ELLIPSIS,
136 new BMessage( B_ABOUT_REQUESTED ), 'A');
137 item->SetTarget( be_app );
138 fileMenu->AddItem( item );
139 fileMenu->AddItem( new BMenuItem( "Quit", new BMessage( B_QUIT_REQUESTED ), 'Q') );
141 fLanguageMenu = new LanguageMenu("Language", AUDIO_ES, p_wrapper);
142 fSubtitlesMenu = new LanguageMenu("Subtitles", SPU_ES, p_wrapper);
144 /* Add the Audio menu */
145 fAudioMenu = new BMenu( "Audio" );
146 fMenuBar->AddItem ( fAudioMenu );
147 fAudioMenu->AddItem( fLanguageMenu );
148 fAudioMenu->AddItem( fSubtitlesMenu );
150 fPrevTitleMI = new BMenuItem( "Prev Title", new BMessage( PREV_TITLE ) );
151 fNextTitleMI = new BMenuItem( "Next Title", new BMessage( NEXT_TITLE ) );
152 fPrevChapterMI = new BMenuItem( "Prev Chapter", new BMessage( PREV_CHAPTER ) );
153 fNextChapterMI = new BMenuItem( "Next Chapter", new BMessage( NEXT_CHAPTER ) );
155 /* Add the Navigation menu */
156 fNavigationMenu = new BMenu( "Navigation" );
157 fMenuBar->AddItem( fNavigationMenu );
158 fNavigationMenu->AddItem( fPrevTitleMI );
159 fNavigationMenu->AddItem( fNextTitleMI );
160 fNavigationMenu->AddItem( fTitleMenu = new TitleMenu( "Go to Title", p_intf ) );
161 fNavigationMenu->AddSeparatorItem();
162 fNavigationMenu->AddItem( fPrevChapterMI );
163 fNavigationMenu->AddItem( fNextChapterMI );
164 fNavigationMenu->AddItem( fChapterMenu = new ChapterMenu( "Go to Chapter", p_intf ) );
166 /* Add the Speed menu */
167 fSpeedMenu = new BMenu( "Speed" );
168 fSpeedMenu->SetRadioMode( true );
169 fSpeedMenu->AddItem( fSlowerMI = new BMenuItem( "Slower", new BMessage( SLOWER_PLAY ) ) );
170 fNormalMI = new BMenuItem( "Normal", new BMessage( NORMAL_PLAY ) );
171 fNormalMI->SetMarked(true); // default to normal speed
172 fSpeedMenu->AddItem( fNormalMI );
173 fSpeedMenu->AddItem( fFasterMI = new BMenuItem( "Faster", new BMessage( FASTER_PLAY) ) );
174 fSpeedMenu->SetTargetForItems( this );
175 fMenuBar->AddItem( fSpeedMenu );
177 /* Add the Settings menu */
178 fSettingsMenu = new BMenu( "Settings" );
179 fSettingsMenu->AddItem( fPreferencesMI =
180 new BMenuItem( "Preferences", new BMessage( OPEN_PREFERENCES ) ) );
181 fMenuBar->AddItem( fSettingsMenu );
183 /* Prepare fow showing */
184 _SetMenusEnabled( false );
185 p_mediaControl->SetEnabled( false );
187 /* Restore interface settings */
188 int i_width = config_GetInt( p_intf, "beos-intf-width" ),
189 i_height = config_GetInt( p_intf, "beos-intf-height" ),
190 i_xpos = config_GetInt( p_intf, "beos-intf-xpos" ),
191 i_ypos = config_GetInt( p_intf, "beos-intf-ypos" );
192 if( i_width && i_height && i_xpos && i_ypos )
194 /* main window size and position */
195 ResizeTo( i_width, i_height );
196 MoveTo( i_xpos, i_ypos );
198 i_width = config_GetInt( p_intf, "beos-playlist-width" ),
199 i_height = config_GetInt( p_intf, "beos-playlist-height" ),
200 i_xpos = config_GetInt( p_intf, "beos-playlist-xpos" ),
201 i_ypos = config_GetInt( p_intf, "beos-playlist-ypos" );
202 if( i_width && i_height && i_xpos && i_ypos )
204 /* playlist window size and position */
205 fPlaylistWindow->ResizeTo( i_width, i_height );
206 fPlaylistWindow->MoveTo( i_xpos, i_ypos );
208 if( config_GetInt( p_intf, "beos-playlist-show" ) )
210 /* playlist showing */
211 if( fPlaylistWindow->Lock() )
213 fPlaylistWindow->Show();
214 fPlaylistWindow->Unlock();
221 InterfaceWindow::~InterfaceWindow()
224 fPlaylistWindow->ReallyQuit();
227 /*****************************************************************************
228 * InterfaceWindow::FrameResized
229 *****************************************************************************/
231 InterfaceWindow::FrameResized(float width, float height)
234 fMenuBar->MoveTo(r.LeftTop());
235 fMenuBar->ResizeTo(r.Width(), fMenuBar->Bounds().Height());
236 r.top += fMenuBar->Bounds().Height() + 1.0;
237 p_mediaControl->MoveTo(r.LeftTop());
238 p_mediaControl->ResizeTo(r.Width(), r.Height());
241 /*****************************************************************************
242 * InterfaceWindow::MessageReceived
243 *****************************************************************************/
244 void InterfaceWindow::MessageReceived( BMessage * p_message )
246 int playback_status; // remember playback state
247 playback_status = p_wrapper->InputStatus();
249 switch( p_message->what )
251 case B_ABOUT_REQUESTED:
253 BAlert* alert = new BAlert( VOUT_TITLE,
254 "BeOS " VOUT_TITLE "\n\n<www.videolan.org>", "Ok");
267 fFilePanel = new BFilePanel();
268 fFilePanel->SetTarget( this );
273 if (fPlaylistWindow->Lock())
275 if (fPlaylistWindow->IsHidden())
276 fPlaylistWindow->Show();
278 fPlaylistWindow->Activate();
279 fPlaylistWindow->Unlock();
284 const char *psz_device;
285 BString type( "dvd" );
286 if( p_message->FindString( "device", &psz_device ) == B_OK )
288 BString device( psz_device );
289 p_wrapper->OpenDisc( type, device, 0, 0 );
296 if( fSubtitlesPanel )
298 fSubtitlesPanel->Show();
301 fSubtitlesPanel = new BFilePanel();
302 fSubtitlesPanel->SetTarget( this );
303 fSubtitlesPanel->SetMessage( new BMessage( SUBFILE_RECEIVED ) );
304 fSubtitlesPanel->Show();
307 case SUBFILE_RECEIVED:
310 if( p_message->FindRef( "refs", 0, &ref ) == B_OK )
313 if ( path.InitCheck() == B_OK )
314 p_wrapper->LoadSubFile( (char*)path.Path() );
320 // this currently stops playback not nicely
321 if (playback_status > UNDEF_S)
324 p_wrapper->PlaylistStop();
325 p_mediaControl->SetStatus(NOT_STARTED_S, DEFAULT_RATE);
330 /* starts playing in normal mode */
333 /* toggle between pause and play */
334 if (playback_status > UNDEF_S)
336 /* pause if currently playing */
337 if ( playback_status == PLAYING_S )
339 p_wrapper->PlaylistPause();
343 p_wrapper->PlaylistPlay();
348 /* Play a new file */
349 p_wrapper->PlaylistPlay();
354 /* cycle the fast playback modes */
355 if (playback_status > UNDEF_S)
357 p_wrapper->InputFaster();
362 /* cycle the slow playback modes */
363 if (playback_status > UNDEF_S)
365 p_wrapper->InputSlower();
370 /* restore speed to normal if already playing */
371 if (playback_status > UNDEF_S)
373 p_wrapper->PlaylistPlay();
378 /* handled by semaphores */
380 // volume related messages
382 /* adjust the volume */
383 if (playback_status > UNDEF_S)
385 p_wrapper->SetVolume( p_mediaControl->GetVolume() );
386 p_mediaControl->SetMuted( p_wrapper->IsMuted() );
392 if( p_wrapper->IsMuted() )
393 p_wrapper->VolumeRestore();
395 p_wrapper->VolumeMute();
396 p_mediaControl->SetMuted( p_wrapper->IsMuted() );
400 if ( playback_status > UNDEF_S )
403 if ( p_message->FindInt32( "channel", &channel ) == B_OK )
405 p_wrapper->ToggleLanguage( channel );
410 case SELECT_SUBTITLE:
411 if ( playback_status > UNDEF_S )
414 if ( p_message->FindInt32( "subtitle", &subtitle ) == B_OK )
415 p_wrapper->ToggleSubtitle( subtitle );
419 // specific navigation messages
422 p_wrapper->PrevTitle();
427 p_wrapper->NextTitle();
431 if ( playback_status > UNDEF_S )
434 if( p_message->FindInt32( "index", &index ) == B_OK )
435 p_wrapper->ToggleTitle( index );
440 p_wrapper->PrevChapter();
445 p_wrapper->NextChapter();
449 if ( playback_status > UNDEF_S )
452 if( p_message->FindInt32( "index", &index ) == B_OK )
453 p_wrapper->ToggleChapter( index );
457 p_wrapper->PlaylistPrev();
460 p_wrapper->PlaylistNext();
462 // general next/prev functionality (skips to whatever makes most sense)
464 p_wrapper->NavigatePrev();
467 p_wrapper->NavigateNext();
469 // drag'n'drop and system messages
470 case B_REFS_RECEIVED:
473 /* file(s) opened by the File menu -> append to the playlist;
474 * file(s) opened by drag & drop -> replace playlist;
475 * file(s) opened by 'shift' + drag & drop -> append */
476 bool replace = false;
477 if ( p_message->WasDropped() )
478 replace = !( modifiers() & B_SHIFT_KEY );
480 // build list of files to be played from message contents
483 for ( int i = 0; p_message->FindRef( "refs", i, &ref ) == B_OK; i++ )
486 if ( path.InitCheck() == B_OK )
489 // has the user dropped a dvd disk icon?
490 BDirectory dir( &ref );
491 if ( dir.InitCheck() == B_OK && dir.IsRootDirectory() )
493 BVolumeRoster volRoster;
495 BDirectory volumeRoot;
496 status_t status = volRoster.GetNextVolume( &vol );
497 while( status == B_NO_ERROR )
499 if( vol.GetRootDirectory( &volumeRoot ) == B_OK
500 && dir == volumeRoot )
504 bool isCDROM = false;
505 bool success = false;
508 char name[B_FILE_NAME_LENGTH];
509 if ( vol.GetName( name ) >= B_OK ) // disk is currently mounted
512 dev_t dev = vol.Device();
514 if ( fs_stat_dev( dev, &info ) == B_OK )
517 deviceName = info.device_name;
518 if ( vol.IsReadOnly() )
520 int i_dev = open( info.device_name, O_RDONLY );
524 if ( ioctl( i_dev, B_GET_GEOMETRY, &g, sizeof( g ) ) >= 0 )
525 isCDROM = ( g.device_type == B_CD );
532 if( success && isCDROM )
534 BMessage msg( OPEN_DVD );
535 msg.AddString( "device", deviceName.String() );
544 status = volRoster.GetNextVolume( &vol );
550 files.AddItem( new BString( (char*)path.Path() ) );
554 // give the list to VLC
555 p_wrapper->OpenFiles(&files, replace);
560 case OPEN_PREFERENCES:
561 if( fPreferencesWindow->Lock() )
563 if (fPreferencesWindow->IsHidden())
564 fPreferencesWindow->Show();
566 fPreferencesWindow->Activate();
567 fPreferencesWindow->Unlock();
572 BWindow::MessageReceived( p_message );
578 /*****************************************************************************
579 * InterfaceWindow::QuitRequested
580 *****************************************************************************/
581 bool InterfaceWindow::QuitRequested()
583 p_wrapper->PlaylistStop();
584 p_mediaControl->SetStatus(NOT_STARTED_S, DEFAULT_RATE);
586 /* Save interface settings */
587 BRect frame = Frame();
588 config_PutInt( p_intf, "beos-intf-width", (int)frame.Width() );
589 config_PutInt( p_intf, "beos-intf-height", (int)frame.Height() );
590 config_PutInt( p_intf, "beos-intf-xpos", (int)frame.left );
591 config_PutInt( p_intf, "beos-intf-ypos", (int)frame.top );
592 if( fPlaylistWindow->Lock() )
594 frame = fPlaylistWindow->Frame();
595 config_PutInt( p_intf, "beos-playlist-width", (int)frame.Width() );
596 config_PutInt( p_intf, "beos-playlist-height", (int)frame.Height() );
597 config_PutInt( p_intf, "beos-playlist-xpos", (int)frame.left );
598 config_PutInt( p_intf, "beos-playlist-ypos", (int)frame.top );
599 config_PutInt( p_intf, "beos-playlist-show", !fPlaylistWindow->IsHidden() );
600 fPlaylistWindow->Unlock();
602 config_SaveConfigFile( p_intf, "beos" );
609 /*****************************************************************************
610 * InterfaceWindow::updateInterface
611 *****************************************************************************/
612 void InterfaceWindow::updateInterface()
614 if( p_wrapper->HasInput() )
616 if ( acquire_sem( p_mediaControl->fScrubSem ) == B_OK )
618 p_wrapper->SetTimeAsFloat(p_mediaControl->GetSeekTo());
622 p_mediaControl->SetEnabled( true );
623 bool hasTitles = p_wrapper->HasTitles();
624 bool hasChapters = p_wrapper->HasChapters();
625 p_mediaControl->SetStatus( p_wrapper->InputStatus(),
626 p_wrapper->InputRate() );
627 p_mediaControl->SetProgress( p_wrapper->GetTimeAsFloat() );
628 _SetMenusEnabled( true, hasChapters, hasTitles );
630 _UpdateSpeedMenu( p_wrapper->InputRate() );
632 // enable/disable skip buttons
635 p_wrapper->GetNavCapabilities( &canSkipPrev, &canSkipNext );
636 p_mediaControl->SetSkippable( canSkipPrev, canSkipNext );
638 if ( p_wrapper->HasAudio() )
640 p_mediaControl->SetAudioEnabled( true );
641 p_mediaControl->SetMuted( p_wrapper->IsMuted() );
643 p_mediaControl->SetAudioEnabled( false );
647 // update playlist as well
648 if ( fPlaylistWindow->Lock() )
650 fPlaylistWindow->UpdatePlaylist();
651 fPlaylistWindow->Unlock();
656 _SetMenusEnabled( false );
657 if( !( p_wrapper->PlaylistSize() > 0 ) )
658 p_mediaControl->SetEnabled( false );
660 p_mediaControl->SetProgress( 0 );
663 /* always force the user-specified volume */
664 /* FIXME : I'm quite sure there is a cleaner way to do this */
665 int i_volume = p_mediaControl->GetVolume();
666 if( p_wrapper->GetVolume() != i_volume )
668 p_wrapper->SetVolume( i_volume );
671 fLastUpdateTime = system_time();
674 /*****************************************************************************
675 * InterfaceWindow::IsStopped
676 *****************************************************************************/
678 InterfaceWindow::IsStopped() const
680 return (system_time() - fLastUpdateTime > INTERFACE_UPDATE_TIMEOUT);
683 /*****************************************************************************
684 * InterfaceWindow::_UpdatePlaylist
685 *****************************************************************************/
687 InterfaceWindow::_UpdatePlaylist()
689 if ( fPlaylistWindow->Lock() )
691 fPlaylistWindow->UpdatePlaylist( true );
692 fPlaylistWindow->Unlock();
693 p_mediaControl->SetEnabled( p_wrapper->PlaylistSize() );
697 /*****************************************************************************
698 * InterfaceWindow::_SetMenusEnabled
699 *****************************************************************************/
701 InterfaceWindow::_SetMenusEnabled(bool hasFile, bool hasChapters, bool hasTitles)
710 if (fNextChapterMI->IsEnabled() != hasChapters)
711 fNextChapterMI->SetEnabled(hasChapters);
712 if (fPrevChapterMI->IsEnabled() != hasChapters)
713 fPrevChapterMI->SetEnabled(hasChapters);
714 if (fChapterMenu->IsEnabled() != hasChapters)
715 fChapterMenu->SetEnabled(hasChapters);
716 if (fNextTitleMI->IsEnabled() != hasTitles)
717 fNextTitleMI->SetEnabled(hasTitles);
718 if (fPrevTitleMI->IsEnabled() != hasTitles)
719 fPrevTitleMI->SetEnabled(hasTitles);
720 if (fTitleMenu->IsEnabled() != hasTitles)
721 fTitleMenu->SetEnabled(hasTitles);
722 if (fAudioMenu->IsEnabled() != hasFile)
723 fAudioMenu->SetEnabled(hasFile);
724 if (fNavigationMenu->IsEnabled() != hasFile)
725 fNavigationMenu->SetEnabled(hasFile);
726 if (fLanguageMenu->IsEnabled() != hasFile)
727 fLanguageMenu->SetEnabled(hasFile);
728 if (fSubtitlesMenu->IsEnabled() != hasFile)
729 fSubtitlesMenu->SetEnabled(hasFile);
730 if (fSpeedMenu->IsEnabled() != hasFile)
731 fSpeedMenu->SetEnabled(hasFile);
736 /*****************************************************************************
737 * InterfaceWindow::_UpdateSpeedMenu
738 *****************************************************************************/
740 InterfaceWindow::_UpdateSpeedMenu( int rate )
742 if ( rate == DEFAULT_RATE )
744 if ( !fNormalMI->IsMarked() )
745 fNormalMI->SetMarked( true );
747 else if ( rate < DEFAULT_RATE )
749 if ( !fFasterMI->IsMarked() )
750 fFasterMI->SetMarked( true );
754 if ( !fSlowerMI->IsMarked() )
755 fSlowerMI->SetMarked( true );
759 /*****************************************************************************
760 * InterfaceWindow::_InputStreamChanged
761 *****************************************************************************/
763 InterfaceWindow::_InputStreamChanged()
765 // TODO: move more stuff from updateInterface() here!
767 p_wrapper->SetVolume( p_mediaControl->GetVolume() );
771 make_sure_frame_is_within_limits( BRect& frame, float minWidth, float minHeight,
772 float maxWidth, float maxHeight )
774 if ( frame.Width() < minWidth )
775 frame.right = frame.left + minWidth;
776 if ( frame.Height() < minHeight )
777 frame.bottom = frame.top + minHeight;
778 if ( frame.Width() > maxWidth )
779 frame.right = frame.left + maxWidth;
780 if ( frame.Height() > maxHeight )
781 frame.bottom = frame.top + maxHeight;
784 /*****************************************************************************
786 *****************************************************************************/
787 CDMenu::CDMenu(const char *name)
792 /*****************************************************************************
794 *****************************************************************************/
799 /*****************************************************************************
800 * CDMenu::AttachedToWindow
801 *****************************************************************************/
802 void CDMenu::AttachedToWindow(void)
805 while (BMenuItem* item = RemoveItem(0L))
808 BMenu::AttachedToWindow();
811 /*****************************************************************************
813 *****************************************************************************/
814 int CDMenu::GetCD( const char *directory )
816 BVolumeRoster *volRoster;
821 char name[B_FILE_NAME_LENGTH];
825 volRoster = new BVolumeRoster();
827 dir = new BDirectory();
828 status = volRoster->GetNextVolume(vol);
829 status = vol->GetRootDirectory(dir);
830 while (status == B_NO_ERROR)
832 mounted = vol->GetName(name);
833 if ((mounted == B_OK) && /* Disk is currently Mounted */
834 (vol->IsReadOnly()) ) /* Disk is read-only */
837 fs_stat_dev(dev, &info);
841 i_dev = open( info.device_name, O_RDONLY );
845 if( ioctl(i_dev, B_GET_GEOMETRY, &g, sizeof(g)) >= 0 )
847 if( g.device_type == B_CD ) //ensure the drive is a CD-ROM
850 msg = new BMessage( OPEN_DVD );
851 msg->AddString( "device", info.device_name );
852 BMenuItem *menu_item;
853 menu_item = new BMenuItem( name, msg );
854 AddItem( menu_item );
861 status = volRoster->GetNextVolume(vol);
866 /*****************************************************************************
867 * LanguageMenu::LanguageMenu
868 *****************************************************************************/
869 LanguageMenu::LanguageMenu( const char *name, int menu_kind,
870 VlcWrapper *p_wrapper )
874 this->p_wrapper = p_wrapper;
877 /*****************************************************************************
878 * LanguageMenu::~LanguageMenu
879 *****************************************************************************/
880 LanguageMenu::~LanguageMenu()
884 /*****************************************************************************
885 * LanguageMenu::AttachedToWindow
886 *****************************************************************************/
887 void LanguageMenu::AttachedToWindow()
890 while ( BMenuItem* item = RemoveItem( 0L ) )
893 SetRadioMode( true );
895 BMenu::AttachedToWindow();
898 /*****************************************************************************
899 * LanguageMenu::_GetChannels
900 *****************************************************************************/
901 void LanguageMenu::_GetChannels()
906 if( ( list = p_wrapper->GetChannels( kind ) ) == NULL )
909 for( int i = 0; i < list->CountItems(); i++ )
911 item = (BMenuItem*)list->ItemAt( i );
915 if( list->CountItems() > 1 )
916 AddItem( new BSeparatorItem(), 1 );
920 /*****************************************************************************
921 * TitleMenu::TitleMenu
922 *****************************************************************************/
923 TitleMenu::TitleMenu( const char *name, intf_thread_t *p_interface )
925 p_intf( p_interface )
929 /*****************************************************************************
930 * TitleMenu::~TitleMenu
931 *****************************************************************************/
932 TitleMenu::~TitleMenu()
936 /*****************************************************************************
937 * TitleMenu::AttachedToWindow
938 *****************************************************************************/
939 void TitleMenu::AttachedToWindow()
944 while( ( item = RemoveItem( 0L ) ) )
947 if( ( list = p_intf->p_sys->p_wrapper->GetTitles() ) == NULL )
950 for( int i = 0; i < list->CountItems(); i++ )
952 item = (BMenuItem*)list->ItemAt( i );
956 BMenu::AttachedToWindow();
960 /*****************************************************************************
961 * ChapterMenu::ChapterMenu
962 *****************************************************************************/
963 ChapterMenu::ChapterMenu( const char *name, intf_thread_t *p_interface )
965 p_intf( p_interface )
969 /*****************************************************************************
970 * ChapterMenu::~ChapterMenu
971 *****************************************************************************/
972 ChapterMenu::~ChapterMenu()
976 /*****************************************************************************
977 * ChapterMenu::AttachedToWindow
978 *****************************************************************************/
979 void ChapterMenu::AttachedToWindow()
984 while( ( item = RemoveItem( 0L ) ) )
987 if( ( list = p_intf->p_sys->p_wrapper->GetChapters() ) == NULL )
990 for( int i = 0; i < list->CountItems(); i++ )
992 item = (BMenuItem*)list->ItemAt( i );
996 BMenu::AttachedToWindow();