1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
|
/*****************************************************************************
* PlayListWindow.cpp: beos interface
*****************************************************************************
* Copyright (C) 1999, 2000, 2001 VideoLAN
* $Id: PlayListWindow.cpp,v 1.4 2001/12/07 18:33:07 sam Exp $
*
* Authors: Jean-Marc Dressler <polux@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
* Tony Castley <tony@castley.net>
* Richard Shepherd <richard@rshepherd.demon.co.uk>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
#include "defs.h"
/* System headers */
#include <InterfaceKit.h>
#include <StorageKit.h>
#include <string.h>
/* VLC headers */
extern "C"
{
#include "common.h"
#include "intf_msg.h"
#include "threads.h"
#include "mtime.h"
#include "tests.h"
#include "stream_control.h"
#include "input_ext-intf.h"
#include "interface.h"
#include "intf_playlist.h"
}
/* BeOS interface headers */
#include "InterfaceWindow.h"
#include "PlayListWindow.h"
#include "MsgVals.h"
/*****************************************************************************
* PlayListWindow
*****************************************************************************/
PlayListWindow::PlayListWindow( BRect frame, const char *name,
playlist_t *p_pl)
: BWindow( frame, name, B_FLOATING_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
B_WILL_ACCEPT_FIRST_CLICK | B_ASYNCHRONOUS_CONTROLS )
{
SetName( "playlist" );
SetTitle(name);
p_playlist = p_pl;
/* set up the main menu */
BMenuBar *menu_bar;
menu_bar = new BMenuBar(BRect(0,0,0,0), "main menu");
AddChild( menu_bar );
BMenu *mFile;
/* Add the file Menu */
BMenuItem *mItem;
menu_bar->AddItem( mFile = new BMenu( "File" ) );
menu_bar->ResizeToPreferred();
mFile->AddItem( mItem = new BMenuItem( "Open File" B_UTF8_ELLIPSIS,
new BMessage(OPEN_FILE), 'O') );
CDMenu *cd_menu = new CDMenu( "Open Disc" );
mFile->AddItem( cd_menu );
BRect rect = Bounds();
rect.top += menu_bar->Bounds().IntegerHeight() + 1;
BView *p_view = new BView(rect, NULL, B_FOLLOW_ALL_SIDES, B_WILL_DRAW);
p_listview = new BListView(rect, "PlayList",
B_MULTIPLE_SELECTION_LIST);
for (int i=0; i < p_playlist->i_size; i++)
{
p_listview->AddItem(new BStringItem(p_playlist->p_item[i].psz_name));
}
p_view->AddChild(new BScrollView("scroll_playlist", p_listview,
B_FOLLOW_LEFT | B_FOLLOW_TOP, 0, false, true));
AddChild(p_view);
}
PlayListWindow::~PlayListWindow()
{
}
/*****************************************************************************
* PlayListWindow::MessageReceived
*****************************************************************************/
void PlayListWindow::MessageReceived( BMessage * p_message )
{
Activate();
switch( p_message->what )
{
case OPEN_FILE:
if( file_panel )
{
file_panel->Show();
break;
}
file_panel = new BFilePanel();
file_panel->SetTarget( this );
file_panel->Show();
break;
case OPEN_DVD:
const char *psz_device;
char psz_source[ B_FILE_NAME_LENGTH + 4 ];
if( p_message->FindString("device", &psz_device) != B_ERROR )
{
snprintf( psz_source, B_FILE_NAME_LENGTH + 4,
"dvd:%s", psz_device );
psz_source[ strlen(psz_source) ] = '\0';
intf_PlaylistAdd( p_playlist, PLAYLIST_END, (char*)psz_source );
p_listview->AddItem(new BStringItem((char*)psz_source));
}
case B_REFS_RECEIVED:
case B_SIMPLE_DATA:
{
entry_ref ref;
if( p_message->FindRef( "refs", &ref ) == B_OK )
{
BPath path( &ref );
intf_PlaylistAdd( p_playlist,
PLAYLIST_END, (char*)path.Path() );
p_listview->AddItem(new BStringItem((char*)path.Path()));
}
}
break;
default:
BWindow::MessageReceived( p_message );
break;
}
}
|