* intf_beos.cpp: beos interface
*****************************************************************************
* Copyright (C) 1999, 2000, 2001 VideoLAN
- * $Id: intf_beos.cpp,v 1.15 2001/03/05 20:36:04 richards Exp $
+ * $Id: intf_beos.cpp,v 1.20 2001/03/15 01:42:19 sam Exp $
*
* Authors: Jean-Marc Dressler <polux@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
#include <Locker.h>
#include <DirectWindow.h>
#include <Box.h>
+#include <Alert.h>
#include <MenuBar.h>
#include <MenuItem.h>
#include <FilePanel.h>
-#include <Alert.h>
+#include <Screen.h>
#include <malloc.h>
#include <string.h>
+#include <Directory.h>
+#include <Entry.h>
+#include <Path.h>
+#include <StorageDefs.h>
+#include <scsi.h>
+#include <scsiprobe_driver.h>
extern "C"
{
#include "input_ext-intf.h"
#include "interface.h"
-#include "intf_plst.h"
+#include "intf_playlist.h"
#include "intf_msg.h"
#include "audio_output.h"
#include "MsgVals.h"
file_panel = NULL;
p_intf = p_interface;
BRect ButtonRect;
- float xStart = 2.0;
- float yStart = 40.0;
+ float xStart = 5.0;
+ float yStart = 20.0;
SetName( "interface" );
SetTitle(VOUT_TITLE " (BeOS interface)");
- BRect rect(0, 0, 0, MENU_HEIGHT);
+ BRect rect(0, 0, 0, 0);
BMenuBar *menu_bar;
menu_bar = new BMenuBar(rect, "main menu");
AddChild( menu_bar );
- BMenu *m;
- BMenuItem *i;
+ BMenu *m;
+ CDMenu *cd_menu;
menu_bar->AddItem( m = new BMenu("File") );
menu_bar->ResizeToPreferred();
- m->AddItem( new BMenuItem("Open file...", new BMessage(OPEN_FILE), 'O'));
- m->AddItem( new BMenuItem("Open DVD...", new BMessage(OPEN_DVD), 'D'));
+ m->AddItem( new BMenuItem("Open File...", new BMessage(OPEN_FILE), 'O'));
+ cd_menu = new CDMenu("Open DVD");
+ //GetCD("/dev/disk", cd_menu);
+ m->AddItem(cd_menu);
m->AddSeparatorItem();
+ m->AddItem( new BMenuItem("About...", new BMessage(B_ABOUT_REQUESTED), 'A'));
m->AddItem( new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED), 'Q'));
rect.top += menu_bar->Bounds().IntegerHeight()+1;
BBox* p_view;
- p_view = new BBox( rect, NULL, B_FOLLOW_ALL, B_WILL_DRAW );
+ p_view = new BBox( rect, NULL, B_FOLLOW_ALL, B_WILL_DRAW, B_PLAIN_BORDER );
p_view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
/* Buttons */
/* Seek Status */
rgb_color fill_color = {0,255,0};
- p_seek = new SeekSlider(BRect(5,10,250,30), this, 0, 100,
+ p_seek = new SeekSlider(BRect(5,2,255,15), this, 0, 100,
B_TRIANGLE_THUMB);
p_seek->SetValue(0);
p_seek->UseFillColor(true, &fill_color);
p_view->AddChild( p_seek );
/* Volume Slider */
- p_vol = new MediaSlider(BRect(xStart,40,250,60), new BMessage(VOLUME_CHG),
+ p_vol = new MediaSlider(BRect(xStart,20,255,30), new BMessage(VOLUME_CHG),
0, VOLUME_MAX);
p_vol->SetValue(VOLUME_DEFAULT);
p_vol->UseFillColor(true, &fill_color);
/* Set size and Show */
AddChild( p_view );
- ResizeTo(260,70 + menu_bar->Bounds().IntegerHeight()+1);
+ ResizeTo(260,50 + menu_bar->Bounds().IntegerHeight()+1);
Show();
}
static int playback_status; // remember playback state
BAlert *alert;
-
Activate();
switch( p_message->what )
{
+ case B_ABOUT_REQUESTED:
+ alert = new BAlert(VOUT_TITLE, "BeOS " VOUT_TITLE "\n\n<www.videolan.org>", "Ok");
+ alert->Go();
+ break;
+
case OPEN_FILE:
if(file_panel)
{
break;
case OPEN_DVD:
- alert = new BAlert(VOUT_TITLE, "Opening DVDs not yet implemented", "Bummer");
- alert->Go();
+ const char **device;
+ char device_method_and_name[B_FILE_NAME_LENGTH + 4];
+ if(p_message->FindString("device", device) != B_ERROR)
+ {
+ sprintf(device_method_and_name, "dvd:%s", *device);
+ intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END, device_method_and_name );
+ }
break;
case STOP_PLAYBACK:
{
if (p_main->p_aout->vol == 0)
{
+ p_vol->SetEnabled(true);
p_main->p_aout->vol = vol_val;
}
else
{
+ p_vol->SetEnabled(false);
p_main->p_aout->vol = 0;
}
}
if( p_message->FindRef( "refs", &ref ) == B_OK )
{
BPath path( &ref );
- char * psz_name = strdup(path.Path());
- intf_PlstAdd( p_main->p_playlist, PLAYLIST_END, psz_name );
+ intf_PlaylistAdd( p_main->p_playlist,
+ PLAYLIST_END, path.Path() );
}
}
return( false );
}
+
+/*****************************************************************************
+ * CDMenu::CDMenu
+ *****************************************************************************/
+
+CDMenu::CDMenu(const char *name)
+ : BMenu(name)
+{
+
+}
+/*****************************************************************************
+ * CDMenu::~CDMenu
+ *****************************************************************************/
+
+
+CDMenu::~CDMenu()
+{
+
+}
+/*****************************************************************************
+ * CDMenu::AttachedToWindow
+ *****************************************************************************/
+
+void CDMenu::AttachedToWindow(void)
+{
+int32 items = CountItems();
+for(int32 i = 0; i < items; i++)
+ RemoveItem(i);
+GetCD("/dev/disk");
+BMenu::AttachedToWindow();
+}
+
+/*****************************************************************************
+ * CDMenu::GetCD
+ *****************************************************************************/
+
+int CDMenu::GetCD(const char *directory)
+{
+ BDirectory dir;
+ dir.SetTo(directory);
+ if(dir.InitCheck() != B_NO_ERROR) {
+ return B_ERROR;
+ }
+ dir.Rewind();
+ BEntry entry;
+ while(dir.GetNextEntry(&entry) >= 0) {
+ BPath path;
+ const char *name;
+ entry_ref e;
+
+ if(entry.GetPath(&path) != B_NO_ERROR)
+ continue;
+ name = path.Path();
+
+
+ if(entry.GetRef(&e) != B_NO_ERROR)
+ continue;
+
+ if(entry.IsDirectory()) {
+ if(strcmp(e.name, "floppy") == 0)
+ continue; // ignore floppy (it is not silent)
+ int devfd = GetCD(name);
+ if(devfd >= 0)
+ {
+ return devfd;
+ }
+ }
+ else {
+ int devfd;
+ device_geometry g;
+ status_t m;
+
+ if(strcmp(e.name, "raw") != 0)
+ continue; // ignore partitions
+
+ devfd = open(name, O_RDONLY);
+ if(devfd < 0)
+ continue;
+
+ if(ioctl(devfd, B_GET_GEOMETRY, &g, sizeof(g)) >= 0) {
+ if(g.device_type == B_CD) //ensure the drive is a CD-ROM
+ {
+ if(ioctl(devfd, B_GET_MEDIA_STATUS, &m, sizeof(m)) >= 0 )
+ if(m == B_NO_ERROR) //ensure media is present
+ {
+ BMessage *msg;
+ msg = new BMessage(OPEN_DVD);
+ msg->AddString("device", name);
+ BMenuItem *menu_item;
+ menu_item = new BMenuItem(name, msg);
+ AddItem(menu_item);
+ continue;
+ }
+ }
+ }
+ close(devfd);
+ }
+ }
+ return B_ERROR;
+}
+
+
/*****************************************************************************
* MediaSlider
*****************************************************************************/
BRect r;
BView *v;
+ rgb_color black = {0,0,0};
r = ThumbFrame();
v = OffscreenView();
- v->SetHighColor(0,0,0);
+ if(IsEnabled())
+ v->SetHighColor(black);
+ else
+ v->SetHighColor(tint_color(black, B_LIGHTEN_2_TINT));
r.InsetBy(r.IntegerWidth()/4, r.IntegerHeight()/6);
v->StrokeEllipse(r);
- v->SetHighColor(ui_color(B_PANEL_BACKGROUND_COLOR));
+ if(IsEnabled())
+ v->SetHighColor(ui_color(B_PANEL_BACKGROUND_COLOR));
+ else
+ v->SetHighColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_LIGHTEN_2_TINT));
r.InsetBy(1,1);
v->FillEllipse(r);
}
*****************************************************************************/
static int intf_Open( intf_thread_t *p_intf )
{
+ BScreen *screen;
+ screen = new BScreen();
+ BRect rect = screen->Frame();
+ rect.top = rect.bottom-100;
+ rect.bottom -= 50;
+ rect.left += 50;
+ rect.right = rect.left + 350;
+ delete screen;
+
/* Allocate instance and initialize some members */
p_intf->p_sys = (intf_sys_t*) malloc( sizeof( intf_sys_t ) );
if( p_intf->p_sys == NULL )
/* Create the interface window */
p_intf->p_sys->p_window =
- new InterfaceWindow( BRect( 50, 50, 400, 100 ),
+ new InterfaceWindow( rect,
VOUT_TITLE " (BeOS interface)", p_intf );
if( p_intf->p_sys->p_window == 0 )
{