1 /*****************************************************************************
2 * InterfaceWindow.cpp: beos interface
3 *****************************************************************************
4 * Copyright (C) 1999, 2000, 2001 VideoLAN
5 * $Id: InterfaceWindow.cpp,v 1.23 2003/01/27 10:29:21 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 "MessagesWindow.h"
52 #include "InterfaceWindow.h"
54 #define INTERFACE_UPDATE_TIMEOUT 80000 // 2 frames if at 25 fps
57 /*****************************************************************************
59 *****************************************************************************/
61 InterfaceWindow::InterfaceWindow( BRect frame, const char *name,
62 intf_thread_t *p_interface )
63 : BWindow( frame, name, B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
64 B_NOT_ZOOMABLE | B_WILL_ACCEPT_FIRST_CLICK | B_ASYNCHRONOUS_CONTROLS ),
65 p_intf( p_interface ),
67 fSubtitlesPanel( NULL ),
68 fLastUpdateTime( system_time() )
71 p_wrapper = p_intf->p_sys->p_wrapper;
72 p_intf->p_sys->b_dvdmenus = false;
74 fPlaylistIsEmpty = !( p_wrapper->PlaylistSize() > 0 );
76 BScreen *p_screen = new BScreen();
77 BRect screen_rect = p_screen->Frame();
80 window_rect.Set( ( screen_rect.right - PREFS_WINDOW_WIDTH ) / 2,
81 ( screen_rect.bottom - PREFS_WINDOW_HEIGHT ) / 2,
82 ( screen_rect.right + PREFS_WINDOW_WIDTH ) / 2,
83 ( screen_rect.bottom + PREFS_WINDOW_HEIGHT ) / 2 );
84 fPreferencesWindow = new PreferencesWindow( p_intf, window_rect, "Preferences" );
85 window_rect.Set( screen_rect.right - 500,
87 screen_rect.right - 150,
88 screen_rect.top + 250 );
89 fPlaylistWindow = new PlayListWindow( window_rect, "Playlist", this, p_intf );
90 window_rect.Set( screen_rect.right - 500,
91 screen_rect.top + 300,
92 screen_rect.right - 150,
93 screen_rect.top + 600 );
94 fMessagesWindow = new MessagesWindow( p_intf, window_rect, "Messages" );
97 SetName( "interface" );
98 SetTitle( VOUT_TITLE );
100 // the media control view
101 p_mediaControl = new MediaControlView( BRect( 0.0, 0.0, 250.0, 50.0 ),
103 p_mediaControl->SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) );
106 p_mediaControl->GetPreferredSize( &width, &height );
108 // set up the main menu
109 fMenuBar = new BMenuBar( BRect(0.0, 0.0, width, 15.0), "main menu",
110 B_FOLLOW_NONE, B_ITEMS_IN_ROW, false );
112 // make menu bar resize to correct height
113 float menuWidth, menuHeight;
114 fMenuBar->GetPreferredSize( &menuWidth, &menuHeight );
115 fMenuBar->ResizeTo( width, menuHeight ); // don't change! it's a workarround!
116 // take care of proper size for ourself
117 height += fMenuBar->Bounds().Height();
118 ResizeTo( width, height );
120 p_mediaControl->MoveTo( fMenuBar->Bounds().LeftBottom() + BPoint(0.0, 1.0) );
121 AddChild( fMenuBar );
122 AddChild( p_mediaControl );
125 BMenu* fileMenu = new BMenu( "File" );
126 fMenuBar->AddItem( fileMenu );
127 fileMenu->AddItem( new BMenuItem( "Open File" B_UTF8_ELLIPSIS,
128 new BMessage( OPEN_FILE ), 'O') );
130 fileMenu->AddItem( new CDMenu( "Open Disc" ) );
132 fileMenu->AddItem( new BMenuItem( "Load a subtitle file" B_UTF8_ELLIPSIS,
133 new BMessage( LOAD_SUBFILE ) ) );
135 fileMenu->AddSeparatorItem();
136 BMenuItem* item = new BMenuItem( "About" B_UTF8_ELLIPSIS,
137 new BMessage( B_ABOUT_REQUESTED ), 'A');
138 item->SetTarget( be_app );
139 fileMenu->AddItem( item );
140 fileMenu->AddItem( new BMenuItem( "Quit", new BMessage( B_QUIT_REQUESTED ), 'Q') );
142 fLanguageMenu = new LanguageMenu("Language", AUDIO_ES, p_wrapper);
143 fSubtitlesMenu = new LanguageMenu("Subtitles", SPU_ES, p_wrapper);
145 /* Add the Audio menu */
146 fAudioMenu = new BMenu( "Audio" );
147 fMenuBar->AddItem ( fAudioMenu );
148 fAudioMenu->AddItem( fLanguageMenu );
149 fAudioMenu->AddItem( fSubtitlesMenu );
151 fPrevTitleMI = new BMenuItem( "Prev Title", new BMessage( PREV_TITLE ) );
152 fNextTitleMI = new BMenuItem( "Next Title", new BMessage( NEXT_TITLE ) );
153 fPrevChapterMI = new BMenuItem( "Prev Chapter", new BMessage( PREV_CHAPTER ) );
154 fNextChapterMI = new BMenuItem( "Next Chapter", new BMessage( NEXT_CHAPTER ) );
156 /* Add the Navigation menu */
157 fNavigationMenu = new BMenu( "Navigation" );
158 fMenuBar->AddItem( fNavigationMenu );
159 fNavigationMenu->AddItem( fPrevTitleMI );
160 fNavigationMenu->AddItem( fNextTitleMI );
161 fNavigationMenu->AddItem( fTitleMenu = new TitleMenu( "Go to Title", p_intf ) );
162 fNavigationMenu->AddSeparatorItem();
163 fNavigationMenu->AddItem( fPrevChapterMI );
164 fNavigationMenu->AddItem( fNextChapterMI );
165 fNavigationMenu->AddItem( fChapterMenu = new ChapterMenu( "Go to Chapter", p_intf ) );
167 /* Add the Speed menu */
168 fSpeedMenu = new BMenu( "Speed" );
169 fSpeedMenu->SetRadioMode( true );
170 fSpeedMenu->AddItem( fSlowerMI = new BMenuItem( "Slower", new BMessage( SLOWER_PLAY ) ) );
171 fNormalMI = new BMenuItem( "Normal", new BMessage( NORMAL_PLAY ) );
172 fNormalMI->SetMarked(true); // default to normal speed
173 fSpeedMenu->AddItem( fNormalMI );
174 fSpeedMenu->AddItem( fFasterMI = new BMenuItem( "Faster", new BMessage( FASTER_PLAY) ) );
175 fSpeedMenu->SetTargetForItems( this );
176 fMenuBar->AddItem( fSpeedMenu );
178 /* Add the Show menu */
179 fShowMenu = new BMenu( "Show" );
180 fShowMenu->AddItem( new BMenuItem( "Play List" B_UTF8_ELLIPSIS,
181 new BMessage( OPEN_PLAYLIST ), 'P') );
182 fShowMenu->AddItem( new BMenuItem( "Messages" B_UTF8_ELLIPSIS,
183 new BMessage( OPEN_MESSAGES ), 'M' ) );
184 fShowMenu->AddItem( new BMenuItem( "Settings" B_UTF8_ELLIPSIS,
185 new BMessage( OPEN_PREFERENCES ), 'S' ) );
186 fMenuBar->AddItem( fShowMenu );
188 /* Prepare fow showing */
189 _SetMenusEnabled( false );
190 p_mediaControl->SetEnabled( false );
192 /* Restore interface settings */
193 int i_width = config_GetInt( p_intf, "beos-intf-width" ),
194 i_height = config_GetInt( p_intf, "beos-intf-height" ),
195 i_xpos = config_GetInt( p_intf, "beos-intf-xpos" ),
196 i_ypos = config_GetInt( p_intf, "beos-intf-ypos" );
197 if( i_width && i_height && i_xpos && i_ypos )
199 /* main window size and position */
200 ResizeTo( i_width, i_height );
201 MoveTo( i_xpos, i_ypos );
203 i_width = config_GetInt( p_intf, "beos-playlist-width" ),
204 i_height = config_GetInt( p_intf, "beos-playlist-height" ),
205 i_xpos = config_GetInt( p_intf, "beos-playlist-xpos" ),
206 i_ypos = config_GetInt( p_intf, "beos-playlist-ypos" );
207 if( i_width && i_height && i_xpos && i_ypos )
209 /* playlist window size and position */
210 fPlaylistWindow->ResizeTo( i_width, i_height );
211 fPlaylistWindow->MoveTo( i_xpos, i_ypos );
213 if( config_GetInt( p_intf, "beos-playlist-show" ) )
215 /* playlist showing */
216 if( fPlaylistWindow->Lock() )
218 fPlaylistWindow->Show();
219 fPlaylistWindow->Unlock();
222 if( config_GetInt( p_intf, "beos-messages-show" ) )
224 /* messages showing */
225 if( fMessagesWindow->Lock() )
227 fMessagesWindow->Show();
228 fMessagesWindow->Unlock();
235 InterfaceWindow::~InterfaceWindow()
238 fPlaylistWindow->ReallyQuit();
241 /*****************************************************************************
242 * InterfaceWindow::FrameResized
243 *****************************************************************************/
245 InterfaceWindow::FrameResized(float width, float height)
248 fMenuBar->MoveTo(r.LeftTop());
249 fMenuBar->ResizeTo(r.Width(), fMenuBar->Bounds().Height());
250 r.top += fMenuBar->Bounds().Height() + 1.0;
251 p_mediaControl->MoveTo(r.LeftTop());
252 p_mediaControl->ResizeTo(r.Width(), r.Height());
255 /*****************************************************************************
256 * InterfaceWindow::MessageReceived
257 *****************************************************************************/
258 void InterfaceWindow::MessageReceived( BMessage * p_message )
260 int playback_status; // remember playback state
261 playback_status = p_wrapper->InputStatus();
263 switch( p_message->what )
265 case B_ABOUT_REQUESTED:
267 BAlert* alert = new BAlert( VOUT_TITLE,
268 "BeOS " VOUT_TITLE "\n\n<www.videolan.org>", "Ok");
281 fFilePanel = new BFilePanel();
282 fFilePanel->SetTarget( this );
287 if (fPlaylistWindow->Lock())
289 if (fPlaylistWindow->IsHidden())
290 fPlaylistWindow->Show();
292 fPlaylistWindow->Activate();
293 fPlaylistWindow->Unlock();
298 const char *psz_device;
299 BString type( "dvd" );
300 if( p_message->FindString( "device", &psz_device ) == B_OK )
302 BString device( psz_device );
303 p_wrapper->OpenDisc( type, device, 0, 0 );
310 if( fSubtitlesPanel )
312 fSubtitlesPanel->Show();
315 fSubtitlesPanel = new BFilePanel();
316 fSubtitlesPanel->SetTarget( this );
317 fSubtitlesPanel->SetMessage( new BMessage( SUBFILE_RECEIVED ) );
318 fSubtitlesPanel->Show();
321 case SUBFILE_RECEIVED:
324 if( p_message->FindRef( "refs", 0, &ref ) == B_OK )
327 if ( path.InitCheck() == B_OK )
328 p_wrapper->LoadSubFile( (char*)path.Path() );
334 // this currently stops playback not nicely
335 if (playback_status > UNDEF_S)
338 p_wrapper->PlaylistStop();
339 p_mediaControl->SetStatus(NOT_STARTED_S, DEFAULT_RATE);
344 /* starts playing in normal mode */
347 /* toggle between pause and play */
348 if (playback_status > UNDEF_S)
350 /* pause if currently playing */
351 if ( playback_status == PLAYING_S )
353 p_wrapper->PlaylistPause();
357 p_wrapper->PlaylistPlay();
362 /* Play a new file */
363 p_wrapper->PlaylistPlay();
368 /* cycle the fast playback modes */
369 if (playback_status > UNDEF_S)
371 p_wrapper->InputFaster();
376 /* cycle the slow playback modes */
377 if (playback_status > UNDEF_S)
379 p_wrapper->InputSlower();
384 /* restore speed to normal if already playing */
385 if (playback_status > UNDEF_S)
387 p_wrapper->PlaylistPlay();
392 /* handled by semaphores */
394 // volume related messages
396 /* adjust the volume */
397 if (playback_status > UNDEF_S)
399 p_wrapper->SetVolume( p_mediaControl->GetVolume() );
400 p_mediaControl->SetMuted( p_wrapper->IsMuted() );
406 if( p_wrapper->IsMuted() )
407 p_wrapper->VolumeRestore();
409 p_wrapper->VolumeMute();
410 p_mediaControl->SetMuted( p_wrapper->IsMuted() );
414 if ( playback_status > UNDEF_S )
417 if ( p_message->FindInt32( "channel", &channel ) == B_OK )
419 p_wrapper->ToggleLanguage( channel );
424 case SELECT_SUBTITLE:
425 if ( playback_status > UNDEF_S )
428 if ( p_message->FindInt32( "subtitle", &subtitle ) == B_OK )
429 p_wrapper->ToggleSubtitle( subtitle );
433 // specific navigation messages
436 p_wrapper->PrevTitle();
441 p_wrapper->NextTitle();
445 if ( playback_status > UNDEF_S )
448 if( p_message->FindInt32( "index", &index ) == B_OK )
449 p_wrapper->ToggleTitle( index );
454 p_wrapper->PrevChapter();
459 p_wrapper->NextChapter();
463 if ( playback_status > UNDEF_S )
466 if( p_message->FindInt32( "index", &index ) == B_OK )
467 p_wrapper->ToggleChapter( index );
471 p_wrapper->PlaylistPrev();
474 p_wrapper->PlaylistNext();
476 // general next/prev functionality (skips to whatever makes most sense)
478 p_wrapper->NavigatePrev();
481 p_wrapper->NavigateNext();
483 // drag'n'drop and system messages
484 case B_REFS_RECEIVED:
487 /* file(s) opened by the File menu -> append to the playlist;
488 * file(s) opened by drag & drop -> replace playlist;
489 * file(s) opened by 'shift' + drag & drop -> append */
490 bool replace = false;
491 if ( p_message->WasDropped() )
492 replace = !( modifiers() & B_SHIFT_KEY );
494 // build list of files to be played from message contents
497 for ( int i = 0; p_message->FindRef( "refs", i, &ref ) == B_OK; i++ )
500 if ( path.InitCheck() == B_OK )
503 // has the user dropped a dvd disk icon?
504 BDirectory dir( &ref );
505 if ( dir.InitCheck() == B_OK && dir.IsRootDirectory() )
507 BVolumeRoster volRoster;
509 BDirectory volumeRoot;
510 status_t status = volRoster.GetNextVolume( &vol );
511 while( status == B_NO_ERROR )
513 if( vol.GetRootDirectory( &volumeRoot ) == B_OK
514 && dir == volumeRoot )
518 bool isCDROM = false;
519 bool success = false;
522 char name[B_FILE_NAME_LENGTH];
523 if ( vol.GetName( name ) >= B_OK ) // disk is currently mounted
526 dev_t dev = vol.Device();
528 if ( fs_stat_dev( dev, &info ) == B_OK )
531 deviceName = info.device_name;
532 if ( vol.IsReadOnly() )
534 int i_dev = open( info.device_name, O_RDONLY );
538 if ( ioctl( i_dev, B_GET_GEOMETRY, &g, sizeof( g ) ) >= 0 )
539 isCDROM = ( g.device_type == B_CD );
546 if( success && isCDROM )
548 BMessage msg( OPEN_DVD );
549 msg.AddString( "device", deviceName.String() );
558 status = volRoster.GetNextVolume( &vol );
564 files.AddItem( new BString( (char*)path.Path() ) );
568 // give the list to VLC
569 p_wrapper->OpenFiles(&files, replace);
574 case OPEN_PREFERENCES:
576 if( fPreferencesWindow->Lock() )
578 if (fPreferencesWindow->IsHidden())
579 fPreferencesWindow->Show();
581 fPreferencesWindow->Activate();
582 fPreferencesWindow->Unlock();
589 if( fMessagesWindow->Lock() )
591 if (fMessagesWindow->IsHidden())
592 fMessagesWindow->Show();
594 fMessagesWindow->Activate();
595 fMessagesWindow->Unlock();
601 BWindow::MessageReceived( p_message );
607 /*****************************************************************************
608 * InterfaceWindow::QuitRequested
609 *****************************************************************************/
610 bool InterfaceWindow::QuitRequested()
612 p_wrapper->PlaylistStop();
613 p_mediaControl->SetStatus(NOT_STARTED_S, DEFAULT_RATE);
615 /* Save interface settings */
616 BRect frame = Frame();
617 config_PutInt( p_intf, "beos-intf-width", (int)frame.Width() );
618 config_PutInt( p_intf, "beos-intf-height", (int)frame.Height() );
619 config_PutInt( p_intf, "beos-intf-xpos", (int)frame.left );
620 config_PutInt( p_intf, "beos-intf-ypos", (int)frame.top );
621 if( fPlaylistWindow->Lock() )
623 frame = fPlaylistWindow->Frame();
624 config_PutInt( p_intf, "beos-playlist-width", (int)frame.Width() );
625 config_PutInt( p_intf, "beos-playlist-height", (int)frame.Height() );
626 config_PutInt( p_intf, "beos-playlist-xpos", (int)frame.left );
627 config_PutInt( p_intf, "beos-playlist-ypos", (int)frame.top );
628 config_PutInt( p_intf, "beos-playlist-show", !fPlaylistWindow->IsHidden() );
629 fPlaylistWindow->Unlock();
631 if( fMessagesWindow->Lock() )
633 config_PutInt( p_intf, "beos-messages-show", !fMessagesWindow->IsHidden() );
634 fMessagesWindow->Unlock();
636 config_SaveConfigFile( p_intf, "beos" );
643 /*****************************************************************************
644 * InterfaceWindow::UpdateInterface
645 *****************************************************************************/
646 void InterfaceWindow::UpdateInterface()
648 if( p_wrapper->HasInput() )
650 if ( acquire_sem( p_mediaControl->fScrubSem ) == B_OK )
652 p_wrapper->SetTimeAsFloat(p_mediaControl->GetSeekTo());
656 p_mediaControl->SetEnabled( true );
657 bool hasTitles = p_wrapper->HasTitles();
658 bool hasChapters = p_wrapper->HasChapters();
659 p_mediaControl->SetStatus( p_wrapper->InputStatus(),
660 p_wrapper->InputRate() );
661 p_mediaControl->SetProgress( p_wrapper->GetTimeAsFloat() );
662 _SetMenusEnabled( true, hasChapters, hasTitles );
664 _UpdateSpeedMenu( p_wrapper->InputRate() );
666 // enable/disable skip buttons
669 p_wrapper->GetNavCapabilities( &canSkipPrev, &canSkipNext );
670 p_mediaControl->SetSkippable( canSkipPrev, canSkipNext );
672 if ( p_wrapper->HasAudio() )
674 p_mediaControl->SetAudioEnabled( true );
675 p_mediaControl->SetMuted( p_wrapper->IsMuted() );
677 p_mediaControl->SetAudioEnabled( false );
681 // update playlist as well
682 if ( fPlaylistWindow->Lock() )
684 fPlaylistWindow->UpdatePlaylist();
685 fPlaylistWindow->Unlock();
690 _SetMenusEnabled( false );
691 if( !( p_wrapper->PlaylistSize() > 0 ) )
692 p_mediaControl->SetEnabled( false );
694 p_mediaControl->SetProgress( 0 );
697 /* always force the user-specified volume */
698 /* FIXME : I'm quite sure there is a cleaner way to do this */
699 int i_volume = p_mediaControl->GetVolume();
700 if( p_wrapper->GetVolume() != i_volume )
702 p_wrapper->SetVolume( i_volume );
705 fMessagesWindow->UpdateMessages();
707 fLastUpdateTime = system_time();
710 /*****************************************************************************
711 * InterfaceWindow::IsStopped
712 *****************************************************************************/
714 InterfaceWindow::IsStopped() const
716 return (system_time() - fLastUpdateTime > INTERFACE_UPDATE_TIMEOUT);
719 /*****************************************************************************
720 * InterfaceWindow::_UpdatePlaylist
721 *****************************************************************************/
723 InterfaceWindow::_UpdatePlaylist()
725 if ( fPlaylistWindow->Lock() )
727 fPlaylistWindow->UpdatePlaylist( true );
728 fPlaylistWindow->Unlock();
729 p_mediaControl->SetEnabled( p_wrapper->PlaylistSize() );
733 /*****************************************************************************
734 * InterfaceWindow::_SetMenusEnabled
735 *****************************************************************************/
737 InterfaceWindow::_SetMenusEnabled(bool hasFile, bool hasChapters, bool hasTitles)
746 if (fNextChapterMI->IsEnabled() != hasChapters)
747 fNextChapterMI->SetEnabled(hasChapters);
748 if (fPrevChapterMI->IsEnabled() != hasChapters)
749 fPrevChapterMI->SetEnabled(hasChapters);
750 if (fChapterMenu->IsEnabled() != hasChapters)
751 fChapterMenu->SetEnabled(hasChapters);
752 if (fNextTitleMI->IsEnabled() != hasTitles)
753 fNextTitleMI->SetEnabled(hasTitles);
754 if (fPrevTitleMI->IsEnabled() != hasTitles)
755 fPrevTitleMI->SetEnabled(hasTitles);
756 if (fTitleMenu->IsEnabled() != hasTitles)
757 fTitleMenu->SetEnabled(hasTitles);
758 if (fAudioMenu->IsEnabled() != hasFile)
759 fAudioMenu->SetEnabled(hasFile);
760 if (fNavigationMenu->IsEnabled() != hasFile)
761 fNavigationMenu->SetEnabled(hasFile);
762 if (fLanguageMenu->IsEnabled() != hasFile)
763 fLanguageMenu->SetEnabled(hasFile);
764 if (fSubtitlesMenu->IsEnabled() != hasFile)
765 fSubtitlesMenu->SetEnabled(hasFile);
766 if (fSpeedMenu->IsEnabled() != hasFile)
767 fSpeedMenu->SetEnabled(hasFile);
772 /*****************************************************************************
773 * InterfaceWindow::_UpdateSpeedMenu
774 *****************************************************************************/
776 InterfaceWindow::_UpdateSpeedMenu( int rate )
778 if ( rate == DEFAULT_RATE )
780 if ( !fNormalMI->IsMarked() )
781 fNormalMI->SetMarked( true );
783 else if ( rate < DEFAULT_RATE )
785 if ( !fFasterMI->IsMarked() )
786 fFasterMI->SetMarked( true );
790 if ( !fSlowerMI->IsMarked() )
791 fSlowerMI->SetMarked( true );
795 /*****************************************************************************
796 * InterfaceWindow::_InputStreamChanged
797 *****************************************************************************/
799 InterfaceWindow::_InputStreamChanged()
801 // TODO: move more stuff from updateInterface() here!
803 p_wrapper->SetVolume( p_mediaControl->GetVolume() );
807 make_sure_frame_is_within_limits( BRect& frame, float minWidth, float minHeight,
808 float maxWidth, float maxHeight )
810 if ( frame.Width() < minWidth )
811 frame.right = frame.left + minWidth;
812 if ( frame.Height() < minHeight )
813 frame.bottom = frame.top + minHeight;
814 if ( frame.Width() > maxWidth )
815 frame.right = frame.left + maxWidth;
816 if ( frame.Height() > maxHeight )
817 frame.bottom = frame.top + maxHeight;
820 /*****************************************************************************
822 *****************************************************************************/
823 CDMenu::CDMenu(const char *name)
828 /*****************************************************************************
830 *****************************************************************************/
835 /*****************************************************************************
836 * CDMenu::AttachedToWindow
837 *****************************************************************************/
838 void CDMenu::AttachedToWindow(void)
841 while (BMenuItem* item = RemoveItem(0L))
844 BMenu::AttachedToWindow();
847 /*****************************************************************************
849 *****************************************************************************/
850 int CDMenu::GetCD( const char *directory )
852 BVolumeRoster *volRoster;
857 char name[B_FILE_NAME_LENGTH];
861 volRoster = new BVolumeRoster();
863 dir = new BDirectory();
864 status = volRoster->GetNextVolume(vol);
865 status = vol->GetRootDirectory(dir);
866 while (status == B_NO_ERROR)
868 mounted = vol->GetName(name);
869 if ((mounted == B_OK) && /* Disk is currently Mounted */
870 (vol->IsReadOnly()) ) /* Disk is read-only */
873 fs_stat_dev(dev, &info);
877 i_dev = open( info.device_name, O_RDONLY );
881 if( ioctl(i_dev, B_GET_GEOMETRY, &g, sizeof(g)) >= 0 )
883 if( g.device_type == B_CD ) //ensure the drive is a CD-ROM
886 msg = new BMessage( OPEN_DVD );
887 msg->AddString( "device", info.device_name );
888 BMenuItem *menu_item;
889 menu_item = new BMenuItem( name, msg );
890 AddItem( menu_item );
897 status = volRoster->GetNextVolume(vol);
902 /*****************************************************************************
903 * LanguageMenu::LanguageMenu
904 *****************************************************************************/
905 LanguageMenu::LanguageMenu( const char *name, int menu_kind,
906 VlcWrapper *p_wrapper )
910 this->p_wrapper = p_wrapper;
913 /*****************************************************************************
914 * LanguageMenu::~LanguageMenu
915 *****************************************************************************/
916 LanguageMenu::~LanguageMenu()
920 /*****************************************************************************
921 * LanguageMenu::AttachedToWindow
922 *****************************************************************************/
923 void LanguageMenu::AttachedToWindow()
926 while ( BMenuItem* item = RemoveItem( 0L ) )
929 SetRadioMode( true );
931 BMenu::AttachedToWindow();
934 /*****************************************************************************
935 * LanguageMenu::_GetChannels
936 *****************************************************************************/
937 void LanguageMenu::_GetChannels()
942 if( ( list = p_wrapper->GetChannels( kind ) ) == NULL )
945 for( int i = 0; i < list->CountItems(); i++ )
947 item = (BMenuItem*)list->ItemAt( i );
951 if( list->CountItems() > 1 )
952 AddItem( new BSeparatorItem(), 1 );
956 /*****************************************************************************
957 * TitleMenu::TitleMenu
958 *****************************************************************************/
959 TitleMenu::TitleMenu( const char *name, intf_thread_t *p_interface )
961 p_intf( p_interface )
965 /*****************************************************************************
966 * TitleMenu::~TitleMenu
967 *****************************************************************************/
968 TitleMenu::~TitleMenu()
972 /*****************************************************************************
973 * TitleMenu::AttachedToWindow
974 *****************************************************************************/
975 void TitleMenu::AttachedToWindow()
980 while( ( item = RemoveItem( 0L ) ) )
983 if( ( list = p_intf->p_sys->p_wrapper->GetTitles() ) == NULL )
986 for( int i = 0; i < list->CountItems(); i++ )
988 item = (BMenuItem*)list->ItemAt( i );
992 BMenu::AttachedToWindow();
996 /*****************************************************************************
997 * ChapterMenu::ChapterMenu
998 *****************************************************************************/
999 ChapterMenu::ChapterMenu( const char *name, intf_thread_t *p_interface )
1001 p_intf( p_interface )
1005 /*****************************************************************************
1006 * ChapterMenu::~ChapterMenu
1007 *****************************************************************************/
1008 ChapterMenu::~ChapterMenu()
1012 /*****************************************************************************
1013 * ChapterMenu::AttachedToWindow
1014 *****************************************************************************/
1015 void ChapterMenu::AttachedToWindow()
1020 while( ( item = RemoveItem( 0L ) ) )
1023 if( ( list = p_intf->p_sys->p_wrapper->GetChapters() ) == NULL )
1026 for( int i = 0; i < list->CountItems(); i++ )
1028 item = (BMenuItem*)list->ItemAt( i );
1032 BMenu::AttachedToWindow();