modules/gui/wxwindows/*:

 * use a standard file dialog to export playlist
parent 972b9aa5
......@@ -2,7 +2,7 @@
* playlist.cpp : wxWindows plugin for vlc
*****************************************************************************
* Copyright (C) 2000-2004 VideoLAN
* $Id: playlist.cpp,v 1.36 2004/01/11 00:45:06 zorglub Exp $
* $Id: playlist.cpp,v 1.37 2004/01/15 21:49:07 sigmunau Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
*
......@@ -157,13 +157,6 @@ BEGIN_EVENT_TABLE(NewGroup, wxDialog)
END_EVENT_TABLE()
/* Event Table for the ExportPlaylist class */
BEGIN_EVENT_TABLE(ExportPlaylist, wxDialog)
EVT_BUTTON( wxID_OK, ExportPlaylist::OnOk)
EVT_BUTTON( wxID_CANCEL, ExportPlaylist::OnCancel)
EVT_BUTTON( Browse_Event, ExportPlaylist::OnBrowse)
END_EVENT_TABLE()
/*****************************************************************************
* Constructor.
*****************************************************************************/
......@@ -424,10 +417,10 @@ void Playlist::UpdateItem( int i )
return;
}
listview->SetItem( i, 0, wxL2U(p_playlist->pp_items[i]->psz_name) );
listview->SetItem( i, 1, wxL2U( playlist_GetInfo( p_playlist, i,
listview->SetItem( i, 1, wxU( playlist_GetInfo( p_playlist, i,
_("General") , _("Author") ) ) );
char *psz_group = playlist_FindGroup(p_playlist,p_playlist->
pp_items[i]->i_group);
char *psz_group = playlist_FindGroup(p_playlist,
p_playlist->pp_items[i]->i_group);
listview->SetItem( i, 2,
wxL2U( psz_group ? psz_group : _("Normal") ) );
......@@ -588,9 +581,42 @@ void Playlist::OnClose( wxCommandEvent& WXUNUSED(event) )
void Playlist::OnSave( wxCommandEvent& WXUNUSED(event) )
{
ExportPlaylist *exp_pl = new ExportPlaylist( p_intf, this);
exp_pl->ShowModal();
delete exp_pl;
struct {
char *psz_desc;
char *psz_filter;
char *psz_module;
} formats[] = {{ _("M3U file"), "*.m3u", "export-m3u" },
{ _("PLS file"), "*.pls", "export-pls" }};
wxString filter = wxT("");
for( unsigned int i = 0; i < sizeof(formats)/sizeof(formats[0]); i++)
{
filter.Append( wxT(formats[i].psz_desc) );
filter.Append( wxT("|") );
filter.Append( wxT(formats[i].psz_filter) );
filter.Append( wxT("|") );
}
wxFileDialog dialog( this, wxU(_("Save playlist")),
wxT(""), wxT(""), filter, wxSAVE );
if( dialog.ShowModal() == wxID_OK )
{
playlist_t * p_playlist =
(playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( p_playlist )
{
if( dialog.GetFilename().mb_str() )
{
playlist_Export( p_playlist, dialog.GetFilename().mb_str(),
formats[dialog.GetFilterIndex()].psz_module );
}
}
vlc_object_release( p_playlist );
}
}
void Playlist::OnOpen( wxCommandEvent& WXUNUSED(event) )
......@@ -604,7 +630,7 @@ void Playlist::OnOpen( wxCommandEvent& WXUNUSED(event) )
}
wxFileDialog dialog( this, wxU(_("Open playlist")),
wxT(""), wxT(""), wxT("*"), wxOPEN );
wxT(""), wxT(""), wxT("All playlists|*.pls;*.m3u;*.asx;*.b4s|M3U files|*.m3u"), wxOPEN );
if( dialog.ShowModal() == wxID_OK )
{
......@@ -1225,138 +1251,3 @@ void NewGroup::OnCancel( wxCommandEvent& WXUNUSED(event) )
{
EndModal( wxID_CANCEL );
}
/***************************************************************************
* Export playlist class
***************************************************************************/
ExportPlaylist::ExportPlaylist( intf_thread_t *_p_intf, wxWindow *_p_parent ):
wxDialog( _p_parent, -1, wxU(_("Export playlist")), wxDefaultPosition,
wxDefaultSize, wxDEFAULT_FRAME_STYLE )
{
vlc_list_t *p_list;
module_t *p_module;
/* Initializations */
p_intf = _p_intf;
SetIcon( *p_intf->p_sys->p_icon );
/* Create a panel to put everything in*/
wxPanel *panel = new wxPanel( this, -1 );
panel->SetAutoLayout( TRUE );
/* Create the file box */
wxStaticBox *file_box = new wxStaticBox( panel, -1,
wxU(_("File to save to")) );
wxStaticBoxSizer *file_sizer = new wxStaticBoxSizer( file_box,
wxHORIZONTAL );
file_text = new wxTextCtrl(panel, -1, wxU(""),wxDefaultPosition,
wxSize(250,-1),wxTE_PROCESS_ENTER);
file_text->SetToolTip( wxU(_("Enter the name of the file to export "
"the playlist to.")) );
wxButton *file_button = new wxButton( panel, Browse_Event,
wxU(_("Browse")) );
file_sizer->Add( file_text, 0, wxALL | wxALIGN_CENTER , 5 );
file_sizer->Add( file_button, 0, wxALL | wxALIGN_CENTER , 5 );
/* Create the type box */
wxStaticBox *type_box = new wxStaticBox( panel, -1,
wxU(_("Select export type")) );
wxStaticBoxSizer *type_sizer = new wxStaticBoxSizer( type_box,
wxHORIZONTAL );
type_combo = new wxComboBox( panel, -1, wxT(""), wxDefaultPosition,
wxSize(250, -1), 0, NULL );
type_sizer->Add( type_combo, 0, wxALL | wxALIGN_CENTER, 5 );
type_sizer->Layout();
wxButton *ok_button = new wxButton(panel, wxID_OK, wxU(_("OK")) );
ok_button->SetDefault();
wxButton *cancel_button = new wxButton( panel, wxID_CANCEL,
wxU(_("Cancel")) );
wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL );
button_sizer->Add( ok_button, 0, wxALL, 5 );
button_sizer->Add( cancel_button, 0, wxALL, 5 );
button_sizer->Layout();
wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL );
panel_sizer->Add( file_sizer, 0, wxEXPAND | wxALL, 5 );
panel_sizer->Add( type_sizer, 0, wxEXPAND | wxALL, 5 );
panel_sizer->Add( button_sizer, 0, wxEXPAND | wxALL, 5 );
panel_sizer->Layout();
panel->SetSizerAndFit( panel_sizer );
wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
main_sizer->Add( panel, 1, wxEXPAND, 0 );
main_sizer->Layout();
SetSizerAndFit( main_sizer );
/* build a list of available modules */
p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
for( int i_index = 0; i_index < p_list->i_count; i_index++ )
{
p_module = (module_t *)p_list->p_values[i_index].p_object ;
if( !strcmp( p_module->psz_capability, "playlist export" ) )
{
type_combo->Append( wxU(p_module->psz_longname),
p_module->pp_shortcuts[1] ?
p_module->pp_shortcuts[1] :
p_module->psz_object_name );
}
}
vlc_list_release( p_list );
}
ExportPlaylist::~ExportPlaylist()
{
}
void ExportPlaylist::OnOk( wxCommandEvent& WXUNUSED(event) )
{
playlist_t * p_playlist =
(playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( p_playlist )
{
char *psz_type = (char *)type_combo->GetClientData(
type_combo->GetSelection() );
if( file_text->GetValue().mb_str() && psz_type )
{
playlist_Export( p_playlist, file_text->GetValue().mb_str(),
psz_type );
}
}
vlc_object_release( p_playlist );
EndModal( wxID_OK );
}
void ExportPlaylist::OnCancel( wxCommandEvent& WXUNUSED(event) )
{
EndModal( wxID_CANCEL );
}
void ExportPlaylist::OnBrowse( wxCommandEvent& WXUNUSED(event) )
{
wxFileDialog dialog( this, wxU(_("Save playlist")),
wxT(""), wxT(""), wxT("*"), wxSAVE );
if( dialog.ShowModal() == wxID_OK )
{
file_text->SetValue( dialog.GetPath() );
}
}
......@@ -2,7 +2,7 @@
* wxwindows.h: private wxWindows interface description
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: wxwindows.h,v 1.84 2004/01/11 00:45:06 zorglub Exp $
* $Id: wxwindows.h,v 1.85 2004/01/15 21:49:07 sigmunau Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
......@@ -842,25 +842,6 @@ protected:
char *psz_name;
};
class ExportPlaylist: public wxDialog
{
public:
/* Constructor */
ExportPlaylist(intf_thread_t *p_intf, wxWindow *p_parent );
virtual ~ExportPlaylist();
private:
/* Event handlers (these functions should _not_ be virtual) */
void OnOk( wxCommandEvent& event );
void OnCancel( wxCommandEvent& event );
void OnBrowse( wxCommandEvent& event );
DECLARE_EVENT_TABLE();
intf_thread_t *p_intf;
wxTextCtrl *file_text;
wxComboBox *type_combo;
};
/* ItemInfo Dialog */
class ItemInfoDialog: public wxDialog
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment