/*****************************************************************************
- * dialogs.cpp : wxWindows plugin for vlc
+ * dialogs.cpp : wxWidgets plugin for vlc
*****************************************************************************
* Copyright (C) 2000-2004 the VideoLAN team
* $Id$
*
* 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.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
-#include <stdlib.h> /* malloc(), free() */
#include <errno.h> /* ENOMEM */
-#include <string.h> /* strerror() */
-#include <stdio.h>
-#include <vlc/vlc.h>
-#include <vlc/aout.h>
-#include <vlc/intf.h>
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
-#include "wxwindows.h"
+#include <vlc/vlc.h>
+#include <vlc_aout.h>
+#include <vlc_interface.h>
+
+#include "vlc_charset.h"
+
+//#include "dialogs/vlm/vlm_panel.hpp"
+#include "dialogs/bookmarks.hpp"
+#include "dialogs/wizard.hpp"
+#include "dialogs/playlist.hpp"
+#include "dialogs/open.hpp"
+#include "dialogs/updatevlc.hpp"
+#include "dialogs/fileinfo.hpp"
+#include "dialogs/iteminfo.hpp"
+#include "dialogs/preferences.hpp"
+#include "dialogs/messages.hpp"
+#include "dialogs/interaction.hpp"
+#include "interface.hpp"
/* include the icon graphic */
#include "../../../share/vlc32x32.xpm"
+
/* Dialogs Provider */
+namespace wxvlc
+{
class DialogsProvider: public wxFrame
{
public:
void Open( int i_access_method, int i_arg );
/* Event handlers (these functions should _not_ be virtual) */
+#ifdef UPDATE_CHECK
void OnUpdateVLC( wxCommandEvent& event );
+#endif
+ //void OnVLM( wxCommandEvent& event );
+ void OnInteraction( wxCommandEvent& event );
void OnExit( wxCommandEvent& event );
void OnPlaylist( wxCommandEvent& event );
void OnMessages( wxCommandEvent& event );
void OnOpenSat( wxCommandEvent& event );
void OnPopupMenu( wxCommandEvent& event );
+ void OnAudioPopupMenu( wxCommandEvent& event );
+ void OnVideoPopupMenu( wxCommandEvent& event );
+ void OnMiscPopupMenu( wxCommandEvent& event );
void OnIdle( wxIdleEvent& event );
wxFrame *p_prefs_dialog;
wxFrame *p_bookmarks_dialog;
wxFileDialog *p_file_generic_dialog;
+#ifdef UPDATE_CHECK
UpdateVLC *p_updatevlc_dialog;
+#endif
+ //VLMFrame *p_vlm_dialog;
};
+}
DEFINE_LOCAL_EVENT_TYPE( wxEVT_DIALOG );
DialogsProvider::OnFileInfo)
EVT_COMMAND(INTF_DIALOG_BOOKMARKS, wxEVT_DIALOG,
DialogsProvider::OnBookmarks)
+
EVT_COMMAND(INTF_DIALOG_POPUPMENU, wxEVT_DIALOG,
DialogsProvider::OnPopupMenu)
+ EVT_COMMAND(INTF_DIALOG_AUDIOPOPUPMENU, wxEVT_DIALOG,
+ DialogsProvider::OnAudioPopupMenu)
+ EVT_COMMAND(INTF_DIALOG_VIDEOPOPUPMENU, wxEVT_DIALOG,
+ DialogsProvider::OnVideoPopupMenu)
+ EVT_COMMAND(INTF_DIALOG_MISCPOPUPMENU, wxEVT_DIALOG,
+ DialogsProvider::OnMiscPopupMenu)
+
EVT_COMMAND(INTF_DIALOG_EXIT, wxEVT_DIALOG,
DialogsProvider::OnExitThread)
+#ifdef UPDATE_CHECK
EVT_COMMAND(INTF_DIALOG_UPDATEVLC, wxEVT_DIALOG,
DialogsProvider::OnUpdateVLC)
+#endif
+#if 0
+ EVT_COMMAND(INTF_DIALOG_VLM, wxEVT_DIALOG,
+ DialogsProvider::OnVLM)
+#endif
+ EVT_COMMAND( INTF_DIALOG_INTERACTION, wxEVT_DIALOG,
+ DialogsProvider::OnInteraction )
END_EVENT_TABLE()
wxWindow *CreateDialogsProvider( intf_thread_t *p_intf, wxWindow *p_parent )
p_wizard_dialog = NULL;
p_bookmarks_dialog = NULL;
p_dir_dialog = NULL;
+#ifdef UPDATE_CHECK
p_updatevlc_dialog = NULL;
+#endif
+ //p_vlm_dialog = NULL;
/* Give our interface a nice little icon */
- p_intf->p_sys->p_icon = new wxIcon( vlc_xpm );
+ p_intf->p_sys->p_icon = new wxIcon( (const char**) vlc_xpm );
/* Create the messages dialog so it can begin storing logs */
p_messages_dialog = new Messages( p_intf, p_parent ? p_parent : this );
/* Check if user wants to show the bookmarks dialog by default */
wxCommandEvent dummy_event;
- if( config_GetInt( p_intf, "wxwin-bookmarks" ) )
+ if( config_GetInt( p_intf, "wx-bookmarks" ) )
OnBookmarks( dummy_event );
/* Intercept all menu events in our custom event handler */
INIT( ID_PLAYLIST, p_playlist_dialog, new Playlist(p_intf,this), ShowPlaylist );
INIT( ID_MESSAGES, p_messages_dialog, new Messages(p_intf,this), Show );
INIT( ID_FILE_INFO, p_fileinfo_dialog, new FileInfo(p_intf,this), Show );
- INIT( ID_BOOKMARKS, p_bookmarks_dialog, BookmarksDialog(p_intf,this), Show);
+ INIT( ID_BOOKMARKS, p_bookmarks_dialog, new BookmarksDialog(p_intf,this), Show);
#undef INIT
}
#undef UPDATE
+ PopEventHandler(true);
+
/* Clean up */
if( p_open_dialog ) delete p_open_dialog;
if( p_prefs_dialog ) p_prefs_dialog->Destroy();
if( p_file_generic_dialog ) delete p_file_generic_dialog;
if( p_wizard_dialog ) delete p_wizard_dialog;
if( p_bookmarks_dialog ) delete p_bookmarks_dialog;
+#ifdef UPDATE_CHECK
if( p_updatevlc_dialog ) delete p_updatevlc_dialog;
+#endif
+ //if( p_vlm_dialog ) delete p_vlm_dialog;
if( p_intf->p_sys->p_icon ) delete p_intf->p_sys->p_icon;
/* Update the fileinfo windows */
if( p_fileinfo_dialog )
- p_fileinfo_dialog->UpdateFileInfo();
+ p_fileinfo_dialog->Update();
}
void DialogsProvider::OnPlaylist( wxCommandEvent& WXUNUSED(event) )
{
/* Show/hide the open dialog */
if( !p_bookmarks_dialog )
- p_bookmarks_dialog = BookmarksDialog( p_intf, this );
+ p_bookmarks_dialog = new BookmarksDialog( p_intf, this );
if( p_bookmarks_dialog )
{
{
p_file_generic_dialog->SetMessage( wxU(p_arg->psz_title) );
p_file_generic_dialog->SetWildcard( wxU(p_arg->psz_extensions) );
- p_file_generic_dialog->SetStyle( (p_arg->b_save ? wxSAVE : wxOPEN) |
- (p_arg->b_multiple ? wxMULTIPLE:0) );
+ p_file_generic_dialog->SetWindowStyle( (p_arg->b_save ? wxSAVE : wxOPEN) |
+ (p_arg->b_multiple ? wxMULTIPLE:0) );
}
if( p_file_generic_dialog &&
sizeof(char *) );
for( size_t i = 0; i < paths.GetCount(); i++ )
{
- p_arg->psz_results[i] = strdup( paths[i].mb_str() );
+ p_arg->psz_results[i] = strdup( paths[i].mb_str(wxConvUTF8) );
}
}
}
free( p_arg->psz_results );
}
- if( p_arg->psz_title ) free( p_arg->psz_title );
- if( p_arg->psz_extensions ) free( p_arg->psz_extensions );
+ free( p_arg->psz_title );
+ free( p_arg->psz_extensions );
free( p_arg );
}
p_file_dialog = new wxFileDialog( NULL, wxU(_("Open File")),
wxT(""), wxT(""), wxT("*"), wxOPEN | wxMULTIPLE );
+ p_file_dialog->SetWildcard(wxU(_("All Files (*.*)|*"
+ "|Sound Files (*.mp3, *.ogg, etc.)|" EXTENSIONS_AUDIO
+ "|Video Files (*.avi, *.mpg, etc.)|" EXTENSIONS_VIDEO
+ "|Playlist Files (*.m3u, *.pls, etc.)|" EXTENSIONS_PLAYLIST
+ "|Subtitle Files (*.srt, *.sub, etc.)|" EXTENSIONS_SUBTITLE)));
+
if( p_file_dialog && p_file_dialog->ShowModal() == wxID_OK )
{
wxArrayString paths;
p_file_dialog->GetPaths( paths );
for( size_t i = 0; i < paths.GetCount(); i++ )
+ {
+ char *psz_utf8 = wxFromLocale( paths[i] );
if( event.GetInt() )
- playlist_Add( p_playlist, (const char *)paths[i].mb_str(),
- (const char *)paths[i].mb_str(),
- PLAYLIST_APPEND | (i ? 0 : PLAYLIST_GO),
- PLAYLIST_END );
+ playlist_Add( p_playlist, psz_utf8, NULL,
+ PLAYLIST_APPEND | (i ? 0 : PLAYLIST_GO) |
+ (i ? PLAYLIST_PREPARSE : 0 ),
+ PLAYLIST_END, VLC_TRUE, VLC_FALSE );
else
- playlist_Add( p_playlist, (const char *)paths[i].mb_str(),
- (const char *)paths[i].mb_str(),
- PLAYLIST_APPEND, PLAYLIST_END );
+ playlist_Add( p_playlist, psz_utf8, NULL,
+ PLAYLIST_APPEND | PLAYLIST_PREPARSE , PLAYLIST_END , VLC_TRUE, VLC_FALSE );
+ wxLocaleFree( psz_utf8 );
+ }
}
vlc_object_release( p_playlist );
}
if( p_dir_dialog == NULL )
- p_dir_dialog = new wxDirDialog( NULL );
+ p_dir_dialog = new wxDirDialog( NULL, wxU(_("Select a directory")) );
if( p_dir_dialog && p_dir_dialog->ShowModal() == wxID_OK )
{
wxString path = p_dir_dialog->GetPath();
-
- playlist_Add( p_playlist, (const char *)path.mb_str(),
- (const char *)path.mb_str(),
+ char *psz_utf8 = wxFromLocale( path );
+ playlist_Add( p_playlist, psz_utf8, NULL,
PLAYLIST_APPEND | (event.GetInt() ? PLAYLIST_GO : 0),
- PLAYLIST_END );
+ PLAYLIST_END, VLC_TRUE, VLC_FALSE );
+ wxLocaleFree( psz_utf8 );
}
vlc_object_release( p_playlist );
::PopupMenu( p_intf, this, mousepos );
}
+void DialogsProvider::OnAudioPopupMenu( wxCommandEvent& event )
+{
+ wxPoint mousepos = ScreenToClient( wxGetMousePosition() );
+ ::AudioPopupMenu( p_intf, this, mousepos );
+}
+void DialogsProvider::OnVideoPopupMenu( wxCommandEvent& event )
+{
+ wxPoint mousepos = ScreenToClient( wxGetMousePosition() );
+ ::VideoPopupMenu( p_intf, this, mousepos );
+}
+void DialogsProvider::OnMiscPopupMenu( wxCommandEvent& event )
+{
+ wxPoint mousepos = ScreenToClient( wxGetMousePosition() );
+ ::MiscPopupMenu( p_intf, this, mousepos );
+}
+
void DialogsProvider::OnExitThread( wxCommandEvent& WXUNUSED(event) )
{
wxTheApp->ExitMainLoop();
}
+#ifdef UPDATE_CHECK
void DialogsProvider::OnUpdateVLC( wxCommandEvent& WXUNUSED(event) )
{
/* Show/hide the file info window */
p_updatevlc_dialog->Show( !p_updatevlc_dialog->IsShown() );
}
}
+#endif
+
+#if 0
+void DialogsProvider::OnVLM( wxCommandEvent& WXUNUSED(event) )
+{
+ /* Show/hide the file info window */
+ if( !p_vlm_dialog )
+ p_vlm_dialog = new VLMFrame( p_intf, this );
+
+ if( p_vlm_dialog )
+ {
+ p_vlm_dialog->Show( !p_vlm_dialog->IsShown() );
+ }
+}
+#endif
+
+void DialogsProvider::OnInteraction( wxCommandEvent& event )
+{
+ intf_dialog_args_t *p_arg = (intf_dialog_args_t *)event.GetClientData();
+ interaction_dialog_t *p_dialog;
+ InteractionDialog *p_wxdialog;
+
+ return;
+
+ if( p_arg == NULL )
+ {
+ msg_Dbg( p_intf, "OnInteraction() called with NULL arg" );
+ return;
+ }
+ p_dialog = p_arg->p_dialog;
+
+ /** \bug We store the interface object for the dialog in the p_private
+ * field of the core dialog object. This is not safe if we change
+ * interface while a dialog is loaded */
+
+ switch( p_dialog->i_action )
+ {
+ case INTERACT_NEW:
+ p_wxdialog = new InteractionDialog( p_intf, this, p_dialog );
+ p_dialog->p_private = (void*)p_wxdialog;
+ p_wxdialog->Show();
+ break;
+ case INTERACT_UPDATE:
+ p_wxdialog = (InteractionDialog*)(p_dialog->p_private);
+ if( p_wxdialog)
+ p_wxdialog->Update();
+ break;
+ case INTERACT_HIDE:
+ p_wxdialog = (InteractionDialog*)(p_dialog->p_private);
+ if( p_wxdialog )
+ p_wxdialog->Hide();
+ p_dialog->i_status = HIDDEN_DIALOG;
+ break;
+ case INTERACT_DESTROY:
+ p_wxdialog = (InteractionDialog*)(p_dialog->p_private);
+ /// \todo
+ p_dialog->i_status = DESTROYED_DIALOG;
+ break;
+ }
+}