1 /*****************************************************************************
2 * InterfaceWindow.cpp: beos interface
3 *****************************************************************************
4 * Copyright (C) 1999, 2000, 2001 VideoLAN
5 * $Id: InterfaceWindow.cpp,v 1.24 2003/01/28 08:17:26 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()
237 if( fPlaylistWindow )
238 fPlaylistWindow->ReallyQuit();
239 if( fMessagesWindow )
240 fMessagesWindow->ReallyQuit();
243 /*****************************************************************************
244 * InterfaceWindow::FrameResized
245 *****************************************************************************/
247 InterfaceWindow::FrameResized(float width, float height)
250 fMenuBar->MoveTo(r.LeftTop());
251 fMenuBar->ResizeTo(r.Width(), fMenuBar->Bounds().Height());
252 r.top += fMenuBar->Bounds().Height() + 1.0;
253 p_mediaControl->MoveTo(r.LeftTop());
254 p_mediaControl->ResizeTo(r.Width(), r.Height());
257 /*****************************************************************************
258 * InterfaceWindow::MessageReceived
259 *****************************************************************************/
260 void InterfaceWindow::MessageReceived( BMessage * p_message )
262 int playback_status; // remember playback state
263 playback_status = p_wrapper->InputStatus();
265 switch( p_message->what )
267 case B_ABOUT_REQUESTED:
269 BAlert* alert = new BAlert( VOUT_TITLE,
270 "BeOS " VOUT_TITLE "\n\n<www.videolan.org>", "Ok");
283 fFilePanel = new BFilePanel();
284 fFilePanel->SetTarget( this );
289 if (fPlaylistWindow->Lock())
291 if (fPlaylistWindow->IsHidden())
292 fPlaylistWindow->Show();
294 fPlaylistWindow->Activate();
295 fPlaylistWindow->Unlock();
300 const char *psz_device;
301 BString type( "dvd" );
302 if( p_message->FindString( "device", &psz_device ) == B_OK )
304 BString device( psz_device );
305 p_wrapper->OpenDisc( type, device, 0, 0 );
312 if( fSubtitlesPanel )
314 fSubtitlesPanel->Show();
317 fSubtitlesPanel = new BFilePanel();
318 fSubtitlesPanel->SetTarget( this );
319 fSubtitlesPanel->SetMessage( new BMessage( SUBFILE_RECEIVED ) );
320 fSubtitlesPanel->Show();
323 case SUBFILE_RECEIVED:
326 if( p_message->FindRef( "refs", 0, &ref ) == B_OK )
329 if ( path.InitCheck() == B_OK )
330 p_wrapper->LoadSubFile( (char*)path.Path() );
336 // this currently stops playback not nicely
337 if (playback_status > UNDEF_S)
340 p_wrapper->PlaylistStop();
341 p_mediaControl->SetStatus(NOT_STARTED_S, DEFAULT_RATE);
346 /* starts playing in normal mode */
349 /* toggle between pause and play */
350 if (playback_status > UNDEF_S)
352 /* pause if currently playing */
353 if ( playback_status == PLAYING_S )
355 p_wrapper->PlaylistPause();
359 p_wrapper->PlaylistPlay();
364 /* Play a new file */
365 p_wrapper->PlaylistPlay();
370 /* cycle the fast playback modes */
371 if (playback_status > UNDEF_S)
373 p_wrapper->InputFaster();
378 /* cycle the slow playback modes */
379 if (playback_status > UNDEF_S)
381 p_wrapper->InputSlower();
386 /* restore speed to normal if already playing */
387 if (playback_status > UNDEF_S)
389 p_wrapper->PlaylistPlay();
394 /* handled by semaphores */
396 // volume related messages
398 /* adjust the volume */
399 if (playback_status > UNDEF_S)
401 p_wrapper->SetVolume( p_mediaControl->GetVolume() );
402 p_mediaControl->SetMuted( p_wrapper->IsMuted() );
408 if( p_wrapper->IsMuted() )
409 p_wrapper->VolumeRestore();
411 p_wrapper->VolumeMute();
412 p_mediaControl->SetMuted( p_wrapper->IsMuted() );
416 if ( playback_status > UNDEF_S )
419 if ( p_message->FindInt32( "channel", &channel ) == B_OK )
421 p_wrapper->ToggleLanguage( channel );
426 case SELECT_SUBTITLE:
427 if ( playback_status > UNDEF_S )
430 if ( p_message->FindInt32( "subtitle", &subtitle ) == B_OK )
431 p_wrapper->ToggleSubtitle( subtitle );
435 // specific navigation messages
438 p_wrapper->PrevTitle();
443 p_wrapper->NextTitle();
447 if ( playback_status > UNDEF_S )
450 if( p_message->FindInt32( "index", &index ) == B_OK )
451 p_wrapper->ToggleTitle( index );
456 p_wrapper->PrevChapter();
461 p_wrapper->NextChapter();
465 if ( playback_status > UNDEF_S )
468 if( p_message->FindInt32( "index", &index ) == B_OK )
469 p_wrapper->ToggleChapter( index );
473 p_wrapper->PlaylistPrev();
476 p_wrapper->PlaylistNext();
478 // general next/prev functionality (skips to whatever makes most sense)
480 p_wrapper->NavigatePrev();
483 p_wrapper->NavigateNext();
485 // drag'n'drop and system messages
486 case B_REFS_RECEIVED:
489 /* file(s) opened by the File menu -> append to the playlist;
490 * file(s) opened by drag & drop -> replace playlist;
491 * file(s) opened by 'shift' + drag & drop -> append */
492 bool replace = false;
493 if ( p_message->WasDropped() )
494 replace = !( modifiers() & B_SHIFT_KEY );
496 // build list of files to be played from message contents
499 for ( int i = 0; p_message->FindRef( "refs", i, &ref ) == B_OK; i++ )
502 if ( path.InitCheck() == B_OK )
505 // has the user dropped a dvd disk icon?
506 BDirectory dir( &ref );
507 if ( dir.InitCheck() == B_OK && dir.IsRootDirectory() )
509 BVolumeRoster volRoster;
511 BDirectory volumeRoot;
512 status_t status = volRoster.GetNextVolume( &vol );
513 while( status == B_NO_ERROR )
515 if( vol.GetRootDirectory( &volumeRoot ) == B_OK
516 && dir == volumeRoot )
520 bool isCDROM = false;
521 bool success = false;
524 char name[B_FILE_NAME_LENGTH];
525 if ( vol.GetName( name ) >= B_OK ) // disk is currently mounted
528 dev_t dev = vol.Device();
530 if ( fs_stat_dev( dev, &info ) == B_OK )
533 deviceName = info.device_name;
534 if ( vol.IsReadOnly() )
536 int i_dev = open( info.device_name, O_RDONLY );
540 if ( ioctl( i_dev, B_GET_GEOMETRY, &g, sizeof( g ) ) >= 0 )
541 isCDROM = ( g.device_type == B_CD );
548 if( success && isCDROM )
550 BMessage msg( OPEN_DVD );
551 msg.AddString( "device", deviceName.String() );
560 status = volRoster.GetNextVolume( &vol );
566 files.AddItem( new BString( (char*)path.Path() ) );
570 // give the list to VLC
571 p_wrapper->OpenFiles(&files, replace);
576 case OPEN_PREFERENCES:
578 if( fPreferencesWindow->Lock() )
580 if (fPreferencesWindow->IsHidden())
581 fPreferencesWindow->Show();
583 fPreferencesWindow->Activate();
584 fPreferencesWindow->Unlock();
591 if( fMessagesWindow->Lock() )
593 if (fMessagesWindow->IsHidden())
594 fMessagesWindow->Show();
596 fMessagesWindow->Activate();
597 fMessagesWindow->Unlock();
603 BWindow::MessageReceived( p_message );
609 /*****************************************************************************
610 * InterfaceWindow::QuitRequested
611 *****************************************************************************/
612 bool InterfaceWindow::QuitRequested()
614 p_wrapper->PlaylistStop();
615 p_mediaControl->SetStatus(NOT_STARTED_S, DEFAULT_RATE);
617 /* Save interface settings */
618 BRect frame = Frame();
619 config_PutInt( p_intf, "beos-intf-width", (int)frame.Width() );
620 config_PutInt( p_intf, "beos-intf-height", (int)frame.Height() );
621 config_PutInt( p_intf, "beos-intf-xpos", (int)frame.left );
622 config_PutInt( p_intf, "beos-intf-ypos", (int)frame.top );
623 if( fPlaylistWindow->Lock() )
625 frame = fPlaylistWindow->Frame();
626 config_PutInt( p_intf, "beos-playlist-width", (int)frame.Width() );
627 config_PutInt( p_intf, "beos-playlist-height", (int)frame.Height() );
628 config_PutInt( p_intf, "beos-playlist-xpos", (int)frame.left );
629 config_PutInt( p_intf, "beos-playlist-ypos", (int)frame.top );
630 config_PutInt( p_intf, "beos-playlist-show", !fPlaylistWindow->IsHidden() );
631 fPlaylistWindow->Unlock();
633 if( fMessagesWindow->Lock() )
635 config_PutInt( p_intf, "beos-messages-show", !fMessagesWindow->IsHidden() );
636 fMessagesWindow->Unlock();
638 config_SaveConfigFile( p_intf, "beos" );
645 /*****************************************************************************
646 * InterfaceWindow::UpdateInterface
647 *****************************************************************************/
648 void InterfaceWindow::UpdateInterface()
650 if( p_wrapper->HasInput() )
652 if ( acquire_sem( p_mediaControl->fScrubSem ) == B_OK )
654 p_wrapper->SetTimeAsFloat(p_mediaControl->GetSeekTo());
658 p_mediaControl->SetEnabled( true );
659 bool hasTitles = p_wrapper->HasTitles();
660 bool hasChapters = p_wrapper->HasChapters();
661 p_mediaControl->SetStatus( p_wrapper->InputStatus(),
662 p_wrapper->InputRate() );
663 p_mediaControl->SetProgress( p_wrapper->GetTimeAsFloat() );
664 _SetMenusEnabled( true, hasChapters, hasTitles );
666 _UpdateSpeedMenu( p_wrapper->InputRate() );
668 // enable/disable skip buttons
671 p_wrapper->GetNavCapabilities( &canSkipPrev, &canSkipNext );
672 p_mediaControl->SetSkippable( canSkipPrev, canSkipNext );
674 if ( p_wrapper->HasAudio() )
676 p_mediaControl->SetAudioEnabled( true );
677 p_mediaControl->SetMuted( p_wrapper->IsMuted() );
679 p_mediaControl->SetAudioEnabled( false );
683 // update playlist as well
684 if ( fPlaylistWindow->Lock() )
686 fPlaylistWindow->UpdatePlaylist();
687 fPlaylistWindow->Unlock();
692 _SetMenusEnabled( false );
693 if( !( p_wrapper->PlaylistSize() > 0 ) )
694 p_mediaControl->SetEnabled( false );
696 p_mediaControl->SetProgress( 0 );
699 /* always force the user-specified volume */
700 /* FIXME : I'm quite sure there is a cleaner way to do this */
701 int i_volume = p_mediaControl->GetVolume();
702 if( p_wrapper->GetVolume() != i_volume )
704 p_wrapper->SetVolume( i_volume );
707 fMessagesWindow->UpdateMessages();
709 fLastUpdateTime = system_time();
712 /*****************************************************************************
713 * InterfaceWindow::IsStopped
714 *****************************************************************************/
716 InterfaceWindow::IsStopped() const
718 return (system_time() - fLastUpdateTime > INTERFACE_UPDATE_TIMEOUT);
721 /*****************************************************************************
722 * InterfaceWindow::_UpdatePlaylist
723 *****************************************************************************/
725 InterfaceWindow::_UpdatePlaylist()
727 if ( fPlaylistWindow->Lock() )
729 fPlaylistWindow->UpdatePlaylist( true );
730 fPlaylistWindow->Unlock();
731 p_mediaControl->SetEnabled( p_wrapper->PlaylistSize() );
735 /*****************************************************************************
736 * InterfaceWindow::_SetMenusEnabled
737 *****************************************************************************/
739 InterfaceWindow::_SetMenusEnabled(bool hasFile, bool hasChapters, bool hasTitles)
748 if (fNextChapterMI->IsEnabled() != hasChapters)
749 fNextChapterMI->SetEnabled(hasChapters);
750 if (fPrevChapterMI->IsEnabled() != hasChapters)
751 fPrevChapterMI->SetEnabled(hasChapters);
752 if (fChapterMenu->IsEnabled() != hasChapters)
753 fChapterMenu->SetEnabled(hasChapters);
754 if (fNextTitleMI->IsEnabled() != hasTitles)
755 fNextTitleMI->SetEnabled(hasTitles);
756 if (fPrevTitleMI->IsEnabled() != hasTitles)
757 fPrevTitleMI->SetEnabled(hasTitles);
758 if (fTitleMenu->IsEnabled() != hasTitles)
759 fTitleMenu->SetEnabled(hasTitles);
760 if (fAudioMenu->IsEnabled() != hasFile)
761 fAudioMenu->SetEnabled(hasFile);
762 if (fNavigationMenu->IsEnabled() != hasFile)
763 fNavigationMenu->SetEnabled(hasFile);
764 if (fLanguageMenu->IsEnabled() != hasFile)
765 fLanguageMenu->SetEnabled(hasFile);
766 if (fSubtitlesMenu->IsEnabled() != hasFile)
767 fSubtitlesMenu->SetEnabled(hasFile);
768 if (fSpeedMenu->IsEnabled() != hasFile)
769 fSpeedMenu->SetEnabled(hasFile);
774 /*****************************************************************************
775 * InterfaceWindow::_UpdateSpeedMenu
776 *****************************************************************************/
778 InterfaceWindow::_UpdateSpeedMenu( int rate )
780 if ( rate == DEFAULT_RATE )
782 if ( !fNormalMI->IsMarked() )
783 fNormalMI->SetMarked( true );
785 else if ( rate < DEFAULT_RATE )
787 if ( !fFasterMI->IsMarked() )
788 fFasterMI->SetMarked( true );
792 if ( !fSlowerMI->IsMarked() )
793 fSlowerMI->SetMarked( true );
797 /*****************************************************************************
798 * InterfaceWindow::_InputStreamChanged
799 *****************************************************************************/
801 InterfaceWindow::_InputStreamChanged()
803 // TODO: move more stuff from updateInterface() here!
805 p_wrapper->SetVolume( p_mediaControl->GetVolume() );
809 make_sure_frame_is_within_limits( BRect& frame, float minWidth, float minHeight,
810 float maxWidth, float maxHeight )
812 if ( frame.Width() < minWidth )
813 frame.right = frame.left + minWidth;
814 if ( frame.Height() < minHeight )
815 frame.bottom = frame.top + minHeight;
816 if ( frame.Width() > maxWidth )
817 frame.right = frame.left + maxWidth;
818 if ( frame.Height() > maxHeight )
819 frame.bottom = frame.top + maxHeight;
822 /*****************************************************************************
824 *****************************************************************************/
825 CDMenu::CDMenu(const char *name)
830 /*****************************************************************************
832 *****************************************************************************/
837 /*****************************************************************************
838 * CDMenu::AttachedToWindow
839 *****************************************************************************/
840 void CDMenu::AttachedToWindow(void)
843 while (BMenuItem* item = RemoveItem(0L))
846 BMenu::AttachedToWindow();
849 /*****************************************************************************
851 *****************************************************************************/
852 int CDMenu::GetCD( const char *directory )
854 BVolumeRoster *volRoster;
859 char name[B_FILE_NAME_LENGTH];
863 volRoster = new BVolumeRoster();
865 dir = new BDirectory();
866 status = volRoster->GetNextVolume(vol);
867 status = vol->GetRootDirectory(dir);
868 while (status == B_NO_ERROR)
870 mounted = vol->GetName(name);
871 if ((mounted == B_OK) && /* Disk is currently Mounted */
872 (vol->IsReadOnly()) ) /* Disk is read-only */
875 fs_stat_dev(dev, &info);
879 i_dev = open( info.device_name, O_RDONLY );
883 if( ioctl(i_dev, B_GET_GEOMETRY, &g, sizeof(g)) >= 0 )
885 if( g.device_type == B_CD ) //ensure the drive is a CD-ROM
888 msg = new BMessage( OPEN_DVD );
889 msg->AddString( "device", info.device_name );
890 BMenuItem *menu_item;
891 menu_item = new BMenuItem( name, msg );
892 AddItem( menu_item );
899 status = volRoster->GetNextVolume(vol);
904 /*****************************************************************************
905 * LanguageMenu::LanguageMenu
906 *****************************************************************************/
907 LanguageMenu::LanguageMenu( const char *name, int menu_kind,
908 VlcWrapper *p_wrapper )
912 this->p_wrapper = p_wrapper;
915 /*****************************************************************************
916 * LanguageMenu::~LanguageMenu
917 *****************************************************************************/
918 LanguageMenu::~LanguageMenu()
922 /*****************************************************************************
923 * LanguageMenu::AttachedToWindow
924 *****************************************************************************/
925 void LanguageMenu::AttachedToWindow()
928 while ( BMenuItem* item = RemoveItem( 0L ) )
931 SetRadioMode( true );
933 BMenu::AttachedToWindow();
936 /*****************************************************************************
937 * LanguageMenu::_GetChannels
938 *****************************************************************************/
939 void LanguageMenu::_GetChannels()
944 if( ( list = p_wrapper->GetChannels( kind ) ) == NULL )
947 for( int i = 0; i < list->CountItems(); i++ )
949 item = (BMenuItem*)list->ItemAt( i );
953 if( list->CountItems() > 1 )
954 AddItem( new BSeparatorItem(), 1 );
958 /*****************************************************************************
959 * TitleMenu::TitleMenu
960 *****************************************************************************/
961 TitleMenu::TitleMenu( const char *name, intf_thread_t *p_interface )
963 p_intf( p_interface )
967 /*****************************************************************************
968 * TitleMenu::~TitleMenu
969 *****************************************************************************/
970 TitleMenu::~TitleMenu()
974 /*****************************************************************************
975 * TitleMenu::AttachedToWindow
976 *****************************************************************************/
977 void TitleMenu::AttachedToWindow()
982 while( ( item = RemoveItem( 0L ) ) )
985 if( ( list = p_intf->p_sys->p_wrapper->GetTitles() ) == NULL )
988 for( int i = 0; i < list->CountItems(); i++ )
990 item = (BMenuItem*)list->ItemAt( i );
994 BMenu::AttachedToWindow();
998 /*****************************************************************************
999 * ChapterMenu::ChapterMenu
1000 *****************************************************************************/
1001 ChapterMenu::ChapterMenu( const char *name, intf_thread_t *p_interface )
1003 p_intf( p_interface )
1007 /*****************************************************************************
1008 * ChapterMenu::~ChapterMenu
1009 *****************************************************************************/
1010 ChapterMenu::~ChapterMenu()
1014 /*****************************************************************************
1015 * ChapterMenu::AttachedToWindow
1016 *****************************************************************************/
1017 void ChapterMenu::AttachedToWindow()
1022 while( ( item = RemoveItem( 0L ) ) )
1025 if( ( list = p_intf->p_sys->p_wrapper->GetChapters() ) == NULL )
1028 for( int i = 0; i < list->CountItems(); i++ )
1030 item = (BMenuItem*)list->ItemAt( i );
1034 BMenu::AttachedToWindow();