]> git.sesse.net Git - vlc/blob - modules/gui/beos/PlayListWindow.cpp
* ./modules/*: moved plugins to the new tree. Yet untested builds include
[vlc] / modules / gui / beos / PlayListWindow.cpp
1 /*****************************************************************************
2  * PlayListWindow.cpp: beos interface
3  *****************************************************************************
4  * Copyright (C) 1999, 2000, 2001 VideoLAN
5  * $Id: PlayListWindow.cpp,v 1.1 2002/08/04 17:23:43 sam Exp $
6  *
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  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 2 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
25  *****************************************************************************/
26
27 /* System headers */
28 #include <InterfaceKit.h>
29 #include <StorageKit.h>
30 #include <SupportKit.h>
31 #include <string.h>
32
33 /* VLC headers */
34 #include <vlc/vlc.h>
35 #include <vlc/intf.h>
36
37 /* BeOS interface headers */
38 #include "VlcWrapper.h"
39 #include "InterfaceWindow.h"
40 #include "MsgVals.h"
41 #include "PlayListWindow.h"
42
43 /*****************************************************************************
44  * PlayListWindow
45  *****************************************************************************/
46 PlayListWindow *PlayListWindow::getPlayList( BRect frame, const char *name,
47                                   playlist_t *p_pl)
48 {
49     static PlayListWindow *one_playlist;
50     if (one_playlist == NULL)
51     {
52        one_playlist = new PlayListWindow(frame, name, p_pl);
53     }
54     return one_playlist;
55 }
56
57 PlayListWindow::PlayListWindow( BRect frame, const char *name,
58                                   playlist_t *p_pl)
59     : BWindow( frame, name, B_FLOATING_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
60                 B_WILL_ACCEPT_FIRST_CLICK | B_ASYNCHRONOUS_CONTROLS )
61 {
62     SetName( "playlist" );
63     SetTitle(name);
64     p_playlist = p_pl;
65
66     /* set up the main menu */
67     BMenuBar *menu_bar;
68     menu_bar = new BMenuBar(BRect(0,0,0,0), "main menu");
69     AddChild( menu_bar );
70
71     BMenu *mFile;
72     /* Add the file Menu */
73     BMenuItem *mItem;
74     menu_bar->AddItem( mFile = new BMenu( "File" ) );
75     menu_bar->ResizeToPreferred();
76     mFile->AddItem( mItem = new BMenuItem( "Open File" B_UTF8_ELLIPSIS,
77                                            new BMessage(OPEN_FILE), 'O') );
78     
79     CDMenu *cd_menu = new CDMenu( "Open Disc" );
80     mFile->AddItem( cd_menu );
81     
82     BRect rect = Bounds();
83     rect.top += menu_bar->Bounds().IntegerHeight() + 1;
84     BView *p_view = new BView(rect, NULL, B_FOLLOW_ALL_SIDES, B_WILL_DRAW);
85     
86     p_listview = new BListView(rect, "PlayList", 
87                                     B_MULTIPLE_SELECTION_LIST);
88     for (int i=0; i < p_playlist->i_size; i++)
89     {
90         p_listview->AddItem(new BStringItem(p_playlist->pp_items[i]->psz_name)); 
91     }
92     p_view->AddChild(new BScrollView("scroll_playlist", p_listview,
93              B_FOLLOW_LEFT | B_FOLLOW_TOP, 0, false, true)); 
94              
95     AddChild(p_view);
96 }
97
98 PlayListWindow::~PlayListWindow()
99 {
100 }
101
102 /*****************************************************************************
103  * PlayListWindow::MessageReceived
104  *****************************************************************************/
105 void PlayListWindow::MessageReceived( BMessage * p_message )
106 {
107     Activate();
108
109     switch( p_message->what )
110     {
111     case OPEN_FILE:
112         if( file_panel )
113         {
114             file_panel->Show();
115             break;
116         }
117         file_panel = new BFilePanel();
118         file_panel->SetTarget( this );
119         file_panel->Show();
120         break;
121
122     case OPEN_DVD:
123         {
124             const char *psz_device;
125             BString type("dvd");
126             if( p_message->FindString("device", &psz_device) != B_ERROR )
127             {
128                 BString device(psz_device);
129 //                p_vlc_wrapper->openDisc(type, device, 0,0);
130                 p_listview->AddItem(new BStringItem(psz_device));
131             }
132         }
133         break;
134    case B_REFS_RECEIVED:
135     case B_SIMPLE_DATA:
136         {
137             entry_ref ref;
138             BList* files = new BList();
139
140             int i = 0;
141             while( p_message->FindRef( "refs", i, &ref ) == B_OK )
142             {
143                 BPath path( &ref );
144
145                 files->AddItem(new BString((char*)path.Path()) );
146                 p_listview->AddItem(new BStringItem((char*)path.Path()));
147                 i++;
148             }
149 //            p_vlc_wrapper->openFiles(files);
150             delete files;
151         }
152         break;
153     default:
154         BWindow::MessageReceived( p_message );
155         break;
156     }
157 }
158
159 bool PlayListWindow::QuitRequested()
160 {
161     Hide(); 
162     return false;
163 }
164
165 void PlayListWindow::ReallyQuit()
166 {
167     Hide(); 
168     Lock();
169     Quit();
170 }