1 /*****************************************************************************
2 * dialogs.cpp : wxWindows plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2000-2001 VideoLAN
5 * $Id: dialogs.cpp,v 1.1 2003/07/17 17:30:40 gbazin Exp $
7 * Authors: Gildas Bazin <gbazin@netcourrier.com>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
27 #include <stdlib.h> /* malloc(), free() */
28 #include <errno.h> /* ENOMEM */
29 #include <string.h> /* strerror() */
35 #ifdef WIN32 /* mingw32 hack */
40 /* Let vlc take care of the i18n stuff */
41 #define WXINTL_NO_GETTEXT_MACRO
43 #include <wx/wxprec.h>
47 #include "stream_control.h"
49 #include "wxwindows.h"
51 /* include the icon graphic */
52 #include "../../../share/vlc32x32.xpm"
54 DEFINE_LOCAL_EVENT_TYPE( wxEVT_DIALOG );
56 BEGIN_EVENT_TABLE(DialogsProvider, wxFrame)
57 /* Idle loop used to update some of the dialogs */
58 EVT_IDLE(DialogsProvider::OnIdle)
60 /* Custom wxDialog events */
61 EVT_COMMAND(INTF_DIALOG_FILE, wxEVT_DIALOG, DialogsProvider::OnOpenFile)
62 EVT_COMMAND(INTF_DIALOG_DISC, wxEVT_DIALOG, DialogsProvider::OnOpenDisc)
63 EVT_COMMAND(INTF_DIALOG_NET, wxEVT_DIALOG, DialogsProvider::OnOpenNet)
64 EVT_COMMAND(INTF_DIALOG_FILE_SIMPLE, wxEVT_DIALOG,
65 DialogsProvider::OnOpenFileSimple)
67 EVT_COMMAND(INTF_DIALOG_PLAYLIST, wxEVT_DIALOG,
68 DialogsProvider::OnPlaylist)
69 EVT_COMMAND(INTF_DIALOG_MESSAGES, wxEVT_DIALOG,
70 DialogsProvider::OnMessages)
71 EVT_COMMAND(INTF_DIALOG_PREFS, wxEVT_DIALOG,
72 DialogsProvider::OnPreferences)
73 EVT_COMMAND(INTF_DIALOG_FILEINFO, wxEVT_DIALOG,
74 DialogsProvider::OnFileInfo)
75 //EVT_COMMAND(ShowPopup_Event, wxEVT_DIALOG, DialogsProvider::OnShowPopup)
78 /*****************************************************************************
80 *****************************************************************************/
81 DialogsProvider::DialogsProvider( intf_thread_t *_p_intf, wxWindow *p_parent )
82 : wxFrame( p_parent, -1, wxT("") )
88 p_playlist_dialog = NULL;
89 p_messages_dialog = NULL;
90 p_fileinfo_dialog = NULL;
91 p_prefs_dialog = NULL;
93 /* Give our interface a nice little icon */
94 p_intf->p_sys->p_icon = new wxIcon( vlc_xpm );
96 /* Create the messages dialog so it can begin storing logs */
97 p_messages_dialog = new Messages( p_intf, p_parent ? p_parent : this );
100 DialogsProvider::~DialogsProvider()
103 if( p_open_dialog ) delete p_open_dialog;
104 if( p_prefs_dialog ) p_prefs_dialog->Destroy();
105 if( p_file_dialog ) delete p_file_dialog;
106 if( p_playlist_dialog ) delete p_playlist_dialog;
107 if( p_messages_dialog ) delete p_messages_dialog;
108 if( p_fileinfo_dialog ) delete p_fileinfo_dialog;
110 if( p_intf->p_sys->p_icon ) delete p_intf->p_sys->p_icon;
113 void DialogsProvider::OnIdle( wxIdleEvent& WXUNUSED(event) )
115 /* Update the log window */
116 if( p_messages_dialog )
117 p_messages_dialog->UpdateLog();
119 /* Update the playlist */
120 if( p_playlist_dialog )
121 p_playlist_dialog->UpdatePlaylist();
123 /* Update the fileinfo windows */
124 if( p_fileinfo_dialog )
125 p_fileinfo_dialog->UpdateFileInfo();
128 void DialogsProvider::OnPlaylist( wxCommandEvent& WXUNUSED(event) )
130 /* Show/hide the playlist window */
131 if( !p_playlist_dialog )
132 p_playlist_dialog = new Playlist( p_intf, this );
134 if( p_playlist_dialog )
136 p_playlist_dialog->ShowPlaylist( !p_playlist_dialog->IsShown() );
140 void DialogsProvider::OnMessages( wxCommandEvent& WXUNUSED(event) )
142 /* Show/hide the log window */
143 if( !p_messages_dialog )
144 p_messages_dialog = new Messages( p_intf, this );
146 if( p_messages_dialog )
148 p_messages_dialog->Show( !p_messages_dialog->IsShown() );
152 void DialogsProvider::OnFileInfo( wxCommandEvent& WXUNUSED(event) )
154 /* Show/hide the file info window */
155 if( !p_fileinfo_dialog )
156 p_fileinfo_dialog = new FileInfo( p_intf, this );
158 if( p_fileinfo_dialog )
160 p_fileinfo_dialog->Show( !p_fileinfo_dialog->IsShown() );
164 void DialogsProvider::OnPreferences( wxCommandEvent& WXUNUSED(event) )
166 /* Show/hide the open dialog */
167 if( !p_prefs_dialog )
168 p_prefs_dialog = new PrefsDialog( p_intf, this );
172 p_prefs_dialog->Show( !p_prefs_dialog->IsShown() );
176 void DialogsProvider::OnOpenFileSimple( wxCommandEvent& event )
178 playlist_t *p_playlist =
179 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
181 if( p_playlist == NULL )
186 if( p_file_dialog == NULL )
187 p_file_dialog = new wxFileDialog( this, wxU(_("Open file")),
188 wxT(""), wxT(""), wxT("*"), wxOPEN | wxMULTIPLE );
190 if( p_file_dialog && p_file_dialog->ShowModal() == wxID_OK )
194 p_file_dialog->GetPaths( paths );
196 for( size_t i = 0; i < paths.GetCount(); i++ )
198 playlist_Add( p_playlist, (const char *)paths[i].mb_str(),
199 PLAYLIST_APPEND | (i ? 0 : PLAYLIST_GO),
202 playlist_Add( p_playlist, (const char *)paths[i].mb_str(),
203 PLAYLIST_APPEND, PLAYLIST_END );
206 vlc_object_release( p_playlist );
209 void DialogsProvider::OnOpenFile( wxCommandEvent& event )
211 Open( FILE_ACCESS, event.GetInt() );
214 void DialogsProvider::OnOpenDisc( wxCommandEvent& event )
216 Open( DISC_ACCESS, event.GetInt() );
219 void DialogsProvider::OnOpenNet( wxCommandEvent& event )
221 Open( NET_ACCESS, event.GetInt() );
224 void DialogsProvider::OnOpenSat( wxCommandEvent& event )
226 Open( SAT_ACCESS, event.GetInt() );
229 void DialogsProvider::Open( int i_access_method, int i_arg )
231 /* Show/hide the open dialog */
233 p_open_dialog = new OpenDialog( p_intf, this, i_access_method, i_arg );
237 p_open_dialog->Show( i_access_method, i_arg );