]> git.sesse.net Git - vlc/blob - modules/gui/wxwindows/playlist.cpp
* src/input/control.c: added INPUT_ADD_INFO/INPUT_SET_NAME to input_Control().
[vlc] / modules / gui / wxwindows / playlist.cpp
1 /*****************************************************************************
2  * playlist.cpp : wxWindows plugin for vlc
3  *****************************************************************************
4  * Copyright (C) 2000-2004 VideoLAN
5  * $Id$
6  *
7  * Authors: Olivier Teulière <ipkiss@via.ecp.fr>
8  *
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.
13  *
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.
18  *
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  *****************************************************************************/
23
24 /*****************************************************************************
25  * Preamble
26  *****************************************************************************/
27 #include <vlc/vlc.h>
28 #include <vlc/intf.h>
29
30 #include "wxwindows.h"
31
32 /* Callback prototype */
33 int PlaylistChanged( vlc_object_t *p_this, const char *psz_variable,
34                      vlc_value_t old_val, vlc_value_t new_val, void *param );
35 int PlaylistNext( vlc_object_t *p_this, const char *psz_variable,
36                      vlc_value_t old_val, vlc_value_t new_val, void *param );
37 int ItemChanged( vlc_object_t *p_this, const char *psz_variable,
38                      vlc_value_t old_val, vlc_value_t new_val, void *param );
39
40 /*****************************************************************************
41  * Event Table.
42  *****************************************************************************/
43
44 /* IDs for the controls and the menu commands */
45 enum
46 {
47     /* menu items */
48     AddFile_Event = 1,
49     AddMRL_Event,
50     Close_Event,
51     Open_Event,
52     Save_Event,
53
54     SortTitle_Event,
55     RSortTitle_Event,
56     SortAuthor_Event,
57     RSortAuthor_Event,
58     SortGroup_Event,
59     RSortGroup_Event,
60     Randomize_Event,
61
62     EnableSelection_Event,
63     DisableSelection_Event,
64
65     InvertSelection_Event,
66     DeleteSelection_Event,
67     Random_Event,
68     Loop_Event,
69     Repeat_Event,
70     SelectAll_Event,
71
72     EnableGroup_Event,
73     DisableGroup_Event,
74
75     Up_Event,
76     Down_Event,
77     Infos_Event,
78
79     PopupPlay_Event,
80     PopupDel_Event,
81     PopupEna_Event,
82     PopupInfo_Event,
83
84     SearchText_Event,
85     Search_Event,
86
87     /* controls */
88     ListView_Event,
89
90     Browse_Event,  /* For export playlist */
91
92     /* custom events */
93     UpdateItem_Event
94 };
95
96 DEFINE_LOCAL_EVENT_TYPE( wxEVT_PLAYLIST );
97
98 BEGIN_EVENT_TABLE(Playlist, wxFrame)
99     /* Menu events */
100     EVT_MENU(AddFile_Event, Playlist::OnAddFile)
101     EVT_MENU(AddMRL_Event, Playlist::OnAddMRL)
102     EVT_MENU(Close_Event, Playlist::OnClose)
103     EVT_MENU(Open_Event, Playlist::OnOpen)
104     EVT_MENU(Save_Event, Playlist::OnSave)
105
106     EVT_MENU(SortTitle_Event, Playlist::OnSort)
107     EVT_MENU(RSortTitle_Event, Playlist::OnSort)
108     EVT_MENU(SortAuthor_Event, Playlist::OnSort)
109     EVT_MENU(RSortAuthor_Event, Playlist::OnSort)
110     EVT_MENU(SortGroup_Event, Playlist::OnSort)
111     EVT_MENU(RSortGroup_Event, Playlist::OnSort)
112
113     EVT_MENU(Randomize_Event, Playlist::OnSort)
114
115     EVT_MENU(EnableSelection_Event, Playlist::OnEnableSelection)
116     EVT_MENU(DisableSelection_Event, Playlist::OnDisableSelection)
117     EVT_MENU(InvertSelection_Event, Playlist::OnInvertSelection)
118     EVT_MENU(DeleteSelection_Event, Playlist::OnDeleteSelection)
119     EVT_MENU(SelectAll_Event, Playlist::OnSelectAll)
120     EVT_MENU(Infos_Event, Playlist::OnInfos)
121     EVT_CHECKBOX(Random_Event, Playlist::OnRandom)
122     EVT_CHECKBOX(Repeat_Event, Playlist::OnRepeat)
123     EVT_CHECKBOX(Loop_Event, Playlist::OnLoop)
124
125     EVT_MENU(EnableGroup_Event, Playlist::OnEnDis)
126     EVT_MENU(DisableGroup_Event, Playlist::OnEnDis)
127
128     /* Listview events */
129     EVT_LIST_ITEM_ACTIVATED(ListView_Event, Playlist::OnActivateItem)
130     EVT_LIST_COL_CLICK(ListView_Event, Playlist::OnColSelect)
131     EVT_LIST_KEY_DOWN(ListView_Event, Playlist::OnKeyDown)
132     EVT_LIST_ITEM_RIGHT_CLICK(ListView_Event, Playlist::OnPopup)
133
134     /* Popup events */
135     EVT_MENU( PopupPlay_Event, Playlist::OnPopupPlay)
136     EVT_MENU( PopupDel_Event, Playlist::OnPopupDel)
137     EVT_MENU( PopupEna_Event, Playlist::OnPopupEna)
138     EVT_MENU( PopupInfo_Event, Playlist::OnPopupInfo)
139
140
141     /* Button events */
142     EVT_BUTTON( Search_Event, Playlist::OnSearch)
143     EVT_BUTTON( Save_Event, Playlist::OnSave)
144     EVT_BUTTON( Infos_Event, Playlist::OnInfos)
145
146     EVT_BUTTON( Up_Event, Playlist::OnUp)
147     EVT_BUTTON( Down_Event, Playlist::OnDown)
148
149     EVT_TEXT(SearchText_Event, Playlist::OnSearchTextChange)
150
151     /* Custom events */
152     EVT_COMMAND(-1, wxEVT_PLAYLIST, Playlist::OnPlaylistEvent)
153
154     /* Special events : we don't want to destroy the window when the user
155      * clicks on (X) */
156     EVT_CLOSE(Playlist::OnClose)
157 END_EVENT_TABLE()
158
159
160 /* Event Table for the Newgroup class */
161 BEGIN_EVENT_TABLE(NewGroup, wxDialog)
162     EVT_BUTTON( wxID_OK, NewGroup::OnOk)
163     EVT_BUTTON( wxID_CANCEL, NewGroup::OnCancel)
164 END_EVENT_TABLE()
165
166
167 /*****************************************************************************
168  * Constructor.
169  *****************************************************************************/
170 Playlist::Playlist( intf_thread_t *_p_intf, wxWindow *p_parent ):
171     wxFrame( p_parent, -1, wxU(_("Playlist")), wxDefaultPosition,
172              wxDefaultSize, wxDEFAULT_FRAME_STYLE )
173 {
174     vlc_value_t val;
175
176     /* Initializations */
177     iteminfo_dialog = NULL;
178     p_intf = _p_intf;
179     i_update_counter = 0;
180     i_sort_mode = MODE_NONE;
181     b_need_update = VLC_FALSE;
182     SetIcon( *p_intf->p_sys->p_icon );
183
184     i_title_sorted = 0;
185     i_author_sorted = 0;
186     i_group_sorted = 0;
187     i_duration_sorted = 0;
188
189     var_Create( p_intf, "random", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
190     var_Create( p_intf, "loop", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
191     var_Create( p_intf, "repeat", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );;
192
193     /* Create our "Manage" menu */
194     wxMenu *manage_menu = new wxMenu;
195     manage_menu->Append( AddFile_Event, wxU(_("&Simple Add...")) );
196     manage_menu->Append( AddMRL_Event, wxU(_("&Add MRL...")) );
197     manage_menu->AppendSeparator();
198     manage_menu->Append( Open_Event, wxU(_("&Open Playlist...")) );
199     manage_menu->Append( Save_Event, wxU(_("&Save Playlist...")) );
200     manage_menu->AppendSeparator();
201     manage_menu->Append( Close_Event, wxU(_("&Close")) );
202
203     /* Create our "Sort" menu */
204     wxMenu *sort_menu = new wxMenu;
205     sort_menu->Append( SortTitle_Event, wxU(_("Sort by &title")) );
206     sort_menu->Append( RSortTitle_Event, wxU(_("&Reverse sort by title")) );
207     sort_menu->AppendSeparator();
208     sort_menu->Append( SortAuthor_Event, wxU(_("Sort by &author")) );
209     sort_menu->Append( RSortAuthor_Event, wxU(_("Reverse sort by author")) );
210     sort_menu->AppendSeparator();
211     sort_menu->Append( SortGroup_Event, wxU(_("Sort by &group")) );
212     sort_menu->Append( RSortGroup_Event, wxU(_("Reverse sort by group")) );
213     sort_menu->AppendSeparator();
214     sort_menu->Append( Randomize_Event, wxU(_("&Shuffle Playlist")) );
215
216     /* Create our "Selection" menu */
217     wxMenu *selection_menu = new wxMenu;
218     selection_menu->Append( EnableSelection_Event, wxU(_("&Enable")) );
219     selection_menu->Append( DisableSelection_Event, wxU(_("&Disable")) );
220     selection_menu->AppendSeparator();
221     selection_menu->Append( InvertSelection_Event, wxU(_("&Invert")) );
222     selection_menu->Append( DeleteSelection_Event, wxU(_("D&elete")) );
223     selection_menu->Append( SelectAll_Event, wxU(_("&Select All")) );
224
225     /* Create our "Group" menu */
226     wxMenu *group_menu = new wxMenu;
227     group_menu->Append( EnableGroup_Event, wxU(_("&Enable all group items")) );
228     group_menu->Append( DisableGroup_Event,
229                         wxU(_("&Disable all group items")) );
230
231     /* Append the freshly created menus to the menu bar */
232     wxMenuBar *menubar = new wxMenuBar( wxMB_DOCKABLE );
233     menubar->Append( manage_menu, wxU(_("&Manage")) );
234     menubar->Append( sort_menu, wxU(_("S&ort")) );
235     menubar->Append( selection_menu, wxU(_("&Selection")) );
236     menubar->Append( group_menu, wxU(_("&Groups")) );
237
238     /* Attach the menu bar to the frame */
239     SetMenuBar( menubar );
240
241     /* Create the popup menu */
242     popup_menu = new wxMenu;
243     popup_menu->Append( PopupPlay_Event, wxU(_("Play")) );
244     popup_menu->Append( PopupDel_Event, wxU(_("Delete")) );
245     popup_menu->Append( PopupEna_Event, wxU(_("Toggle enabled")) );
246     popup_menu->Append( PopupInfo_Event, wxU(_("Info")) );
247
248     /* Create a panel to put everything in */
249     wxPanel *playlist_panel = new wxPanel( this, -1 );
250     playlist_panel->SetAutoLayout( TRUE );
251
252     /* Create the Random checkbox */
253     wxCheckBox *random_checkbox =
254         new wxCheckBox( playlist_panel, Random_Event, wxU(_("Random")) );
255     var_Get( p_intf, "random", &val );
256     vlc_bool_t b_random = val.b_bool;
257     random_checkbox->SetValue( b_random == VLC_FALSE ? 0 : 1 );
258
259     /* Create the Loop Checkbox */
260     wxCheckBox *loop_checkbox =
261         new wxCheckBox( playlist_panel, Loop_Event, wxU(_("Repeat All")) );
262     var_Get( p_intf, "loop", &val );
263     int b_loop = val.b_bool ;
264     loop_checkbox->SetValue( b_loop );
265
266     /* Create the Repeat one checkbox */
267     wxCheckBox *repeat_checkbox =
268         new wxCheckBox( playlist_panel, Repeat_Event, wxU(_("Repeat One")) );
269     var_Get( p_intf, "repeat", &val );
270     int b_repeat = val.b_bool ;
271     repeat_checkbox->SetValue( b_repeat );
272
273     /* Create the Search Textbox */
274     search_text =
275         new wxTextCtrl( playlist_panel, SearchText_Event, wxT(""),
276                         wxDefaultPosition, wxSize(140, -1),
277                         wxTE_PROCESS_ENTER);
278
279     /* Create the search button */
280     search_button =
281         new wxButton( playlist_panel, Search_Event, wxU(_("Search")) );
282
283
284     /* Create the listview */
285     /* FIXME: the given size is arbitrary, and prevents us from resizing
286      * the window to smaller dimensions. But the sizers don't seem to adjust
287      * themselves to the size of a listview, and with a wxDefaultSize the
288      * playlist window is ridiculously small */
289     listview = new wxListView( playlist_panel, ListView_Event,
290                                wxDefaultPosition, wxSize( 500, 300 ),
291                                wxLC_REPORT | wxSUNKEN_BORDER );
292     listview->InsertColumn( 0, wxU(_("Name")) );
293     listview->InsertColumn( 1, wxU(_("Author")) );
294     listview->InsertColumn( 2, wxU(_("Duration")) );
295     listview->InsertColumn( 3, wxU(_("Group")) );
296     listview->SetColumnWidth( 0, 270 );
297     listview->SetColumnWidth( 1, 150 );
298     listview->SetColumnWidth( 2, 80 );
299
300     /* Create the Up-Down buttons */
301     wxButton *up_button =
302         new wxButton( playlist_panel, Up_Event, wxU(_("Up") ) );
303
304     wxButton *down_button =
305         new wxButton( playlist_panel, Down_Event, wxU(_("Down") ) );
306
307     /* Create the iteminfo button */
308     wxButton *iteminfo_button =
309         new wxButton( playlist_panel, Infos_Event, wxU(_("Item info") ) );
310
311     /* Place everything in sizers */
312     wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL );
313     button_sizer->Add( iteminfo_button, 0, wxALIGN_CENTER|wxLEFT , 5);
314     button_sizer->Layout();
315
316     wxBoxSizer *updown_sizer = new wxBoxSizer( wxHORIZONTAL );
317     updown_sizer->Add( up_button, 0, wxALIGN_LEFT|wxRIGHT, 3);
318     updown_sizer->Add( down_button, 0, wxALIGN_LEFT|wxLEFT, 3);
319     updown_sizer->Layout();
320
321     wxBoxSizer *checkbox_sizer = new wxBoxSizer( wxHORIZONTAL );
322     checkbox_sizer->Add( random_checkbox, 0,
323                          wxEXPAND | wxALIGN_RIGHT | wxALL, 5);
324     checkbox_sizer->Add( loop_checkbox, 0,
325                          wxEXPAND | wxALIGN_RIGHT | wxALL, 5);
326     checkbox_sizer->Add( repeat_checkbox, 0,
327                          wxEXPAND | wxALIGN_RIGHT | wxALL, 5);
328     checkbox_sizer->Layout();
329
330     wxBoxSizer *search_sizer = new wxBoxSizer( wxHORIZONTAL );
331     search_sizer->Add( search_text, 0, wxRIGHT|wxALIGN_CENTER, 3);
332     search_sizer->Add( search_button, 0, wxLEFT|wxALIGN_CENTER, 3);
333     search_sizer->Layout();
334
335     /* The top and bottom sizers */
336     wxBoxSizer *top_sizer = new wxBoxSizer( wxHORIZONTAL );
337     top_sizer->Add( checkbox_sizer, 1, wxLEFT|wxRIGHT|wxALIGN_LEFT, 4 );
338     top_sizer->Add( search_sizer, 1, wxLEFT|wxRIGHT|wxALIGN_RIGHT, 4 );
339     top_sizer->Layout();
340
341     wxBoxSizer *bottom_sizer = new wxBoxSizer( wxHORIZONTAL );
342     bottom_sizer->Add( updown_sizer, 0,
343                        wxEXPAND |wxRIGHT | wxLEFT | wxALIGN_LEFT, 4 );
344     bottom_sizer->Add( button_sizer , 0,
345                        wxEXPAND|wxLEFT | wxRIGHT | wxALIGN_RIGHT, 4 );
346     bottom_sizer->Layout();
347
348     wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
349
350     wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL );
351     panel_sizer->Add( top_sizer, 0, wxEXPAND | wxALL, 5 );
352     panel_sizer->Add( listview, 1, wxEXPAND | wxALL, 5 );
353     panel_sizer->Add( bottom_sizer, 0 , wxEXPAND | wxALL, 5);
354     panel_sizer->Layout();
355
356     playlist_panel->SetSizerAndFit( panel_sizer );
357     main_sizer->Add( playlist_panel, 1, wxGROW, 0 );
358     main_sizer->Layout();
359     SetSizerAndFit( main_sizer );
360
361 #if !defined(__WXX11__)
362     /* Associate drop targets with the playlist */
363     SetDropTarget( new DragAndDrop( p_intf, VLC_TRUE ) );
364 #endif
365
366     playlist_t *p_playlist =
367         (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
368                                        FIND_ANYWHERE );
369     if( p_playlist == NULL )
370     {
371         return;
372     }
373
374     /* We want to be noticed of playlist changes */
375
376     /* Some global changes happened -> Rebuild all */
377     var_AddCallback( p_playlist, "intf-change", PlaylistChanged, this );
378
379     /* We went to the next item */
380     var_AddCallback( p_playlist, "playlist-current", PlaylistNext, this );
381
382     /* One item has been updated */
383     var_AddCallback( p_playlist, "item-change", ItemChanged, this );
384
385
386     vlc_object_release( p_playlist );
387
388     /* Update the playlist */
389     Rebuild();
390 }
391
392 Playlist::~Playlist()
393 {
394     playlist_t *p_playlist =
395         (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
396                                        FIND_ANYWHERE );
397     if( p_playlist == NULL )
398     {
399         return;
400     }
401
402     delete iteminfo_dialog;
403
404     var_DelCallback( p_playlist, "item-change", ItemChanged, this );
405     var_DelCallback( p_playlist, "playlist-current", PlaylistNext, this );
406     var_DelCallback( p_playlist, "intf-change", PlaylistChanged, this );
407     vlc_object_release( p_playlist );
408 }
409
410 /**********************************************************************
411  * Update one playlist item
412  **********************************************************************/
413 void Playlist::UpdateItem( int i )
414 {
415     if( i < 0 ) return; /* Sanity check */
416
417     playlist_t *p_playlist =
418         (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
419                                        FIND_ANYWHERE );
420
421     if( p_playlist == NULL )
422     {
423         return;
424     }
425
426     playlist_item_t *p_item = playlist_ItemGetByPos( p_playlist, i );
427
428     if( !p_item )
429     {
430         vlc_object_release(p_playlist);
431         return;
432     }
433
434     listview->SetItem( i, 0, wxL2U(p_item->input.psz_name) );
435     listview->SetItem( i, 1, wxU( playlist_ItemGetInfo( p_item,
436                                        _("General") , _("Author") ) ) );
437     char *psz_group = playlist_FindGroup(p_playlist,
438                                          p_item->i_group);
439     listview->SetItem( i, 3,
440              wxL2U( psz_group ? psz_group : _("Normal") ) );
441
442     if( p_item->b_enabled == VLC_FALSE )
443     {
444         wxListItem listitem;
445         listitem.m_itemId = i;
446         listitem.SetTextColour( *wxLIGHT_GREY);
447         listview->SetItem(listitem);
448     }
449
450     char psz_duration[MSTRTIME_MAX_SIZE];
451     mtime_t dur = p_item->input.i_duration;
452     if( dur != -1 ) secstotimestr( psz_duration, dur/1000000 );
453     else memcpy( psz_duration , "-:--:--", sizeof("-:--:--") );
454     listview->SetItem( i, 2, wxU(psz_duration) );
455
456     /* Change the colour for the currenty played stream */
457     wxListItem listitem;
458     listitem.m_itemId = i;
459     if( i == p_playlist->i_index )
460     {
461         listitem.SetTextColour( *wxRED );
462     }
463     else
464     {
465         listitem.SetTextColour( *wxBLACK );
466     }
467     listview->SetItem( listitem );
468
469     vlc_object_release(p_playlist);
470 }
471
472 /**********************************************************************
473  * Rebuild the playlist
474  **********************************************************************/
475 void Playlist::Rebuild()
476 {
477     playlist_t *p_playlist =
478         (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
479                                        FIND_ANYWHERE );
480     if( p_playlist == NULL )
481     {
482         return;
483     }
484
485     int i_focused = listview->GetFocusedItem();
486
487     /* Clear the list... */
488     listview->DeleteAllItems();
489
490     /* ...and rebuild it */
491     vlc_mutex_lock( &p_playlist->object_lock );
492     for( int i = 0; i < p_playlist->i_size; i++ )
493     {
494         wxString filename = wxL2U(p_playlist->pp_items[i]->input.psz_name);
495         listview->InsertItem( i, filename );
496         UpdateItem( i );
497     }
498     vlc_mutex_unlock( &p_playlist->object_lock );
499
500     if( i_focused >= 0 && i_focused < p_playlist->i_size )
501     {
502         listview->Focus( i_focused );
503         listview->Select( i_focused );
504     }
505     else if( p_playlist->i_index >= 0 )
506     {
507         listview->Focus( p_playlist->i_index );
508     }
509
510     vlc_object_release( p_playlist );
511 }
512
513 void Playlist::ShowPlaylist( bool show )
514 {
515     if( show ) Rebuild();
516     Show( show );
517 }
518
519 void Playlist::UpdatePlaylist()
520 {
521     i_update_counter++;
522
523     /* If the playlist isn't show there's no need to update it */
524     if( !IsShown() ) return;
525
526     if( this->b_need_update )
527     {
528         this->b_need_update = VLC_FALSE;
529         Rebuild();
530     }
531
532     /* Updating the playing status every 0.5s is enough */
533     if( i_update_counter % 5 ) return;
534
535     playlist_t *p_playlist =
536         (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
537                                        FIND_ANYWHERE );
538     if( p_playlist == NULL )
539     {
540         return;
541     }
542
543     /* Update the colour of items */
544     int i_playlist_index = p_playlist->i_index;
545     if( p_intf->p_sys->i_playing != i_playlist_index )
546     {
547         wxListItem listitem;
548         listitem.m_itemId = i_playlist_index;
549         listitem.SetTextColour( *wxRED );
550         listview->SetItem( listitem );
551
552         if( p_intf->p_sys->i_playing != -1 )
553         {
554             listitem.m_itemId = p_intf->p_sys->i_playing;
555             listitem.SetTextColour( *wxBLACK );
556             listview->SetItem( listitem );
557         }
558         p_intf->p_sys->i_playing = i_playlist_index;
559     }
560
561     vlc_object_release( p_playlist );
562 }
563
564 /*****************************************************************************
565  * Private methods.
566  *****************************************************************************/
567 void Playlist::DeleteItem( int item )
568 {
569     playlist_t *p_playlist =
570         (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
571                                        FIND_ANYWHERE );
572     if( p_playlist == NULL )
573     {
574         return;
575     }
576
577     playlist_Delete( p_playlist, item );
578     listview->DeleteItem( item );
579
580     vlc_object_release( p_playlist );
581 }
582
583 void Playlist::OnClose( wxCommandEvent& WXUNUSED(event) )
584 {
585     Hide();
586 }
587
588 void Playlist::OnSave( wxCommandEvent& WXUNUSED(event) )
589 {
590     struct {
591         char *psz_desc;
592         char *psz_filter;
593         char *psz_module;
594     } formats[] = {{ _("M3U file"), "*.m3u", "export-m3u" },
595                    { _("PLS file"), "*.pls", "export-pls" }};
596     wxString filter = wxT("");
597
598     playlist_t * p_playlist =
599                 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
600                                                FIND_ANYWHERE );
601
602     if( ! p_playlist )
603     {
604         return;
605     }
606     if( p_playlist->i_size == 0 )
607     {
608         wxMessageBox( wxU(_("Playlist is empty") ), wxU(_("Can't save")),
609                       wxICON_WARNING | wxOK, this );
610         vlc_object_release( p_playlist );
611         return;
612     }
613
614     for( unsigned int i = 0; i < sizeof(formats)/sizeof(formats[0]); i++)
615     {
616         filter.Append( wxU(formats[i].psz_desc) );
617         filter.Append( wxT("|") );
618         filter.Append( wxU(formats[i].psz_filter) );
619         filter.Append( wxT("|") );
620     }
621     wxFileDialog dialog( this, wxU(_("Save playlist")),
622                          wxT(""), wxT(""), filter, wxSAVE );
623
624     if( dialog.ShowModal() == wxID_OK )
625     {
626         if( dialog.GetFilename().mb_str() )
627         {
628             playlist_Export( p_playlist, dialog.GetFilename().mb_str(),
629                              formats[dialog.GetFilterIndex()].psz_module );
630         }
631     }
632
633     vlc_object_release( p_playlist );
634
635 }
636
637 void Playlist::OnOpen( wxCommandEvent& WXUNUSED(event) )
638 {
639     playlist_t *p_playlist =
640         (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
641                                        FIND_ANYWHERE );
642     if( p_playlist == NULL )
643     {
644         return;
645     }
646
647     wxFileDialog dialog( this, wxU(_("Open playlist")), wxT(""), wxT(""),
648         wxT("All playlists|*.pls;*.m3u;*.asx;*.b4s|M3U files|*.m3u"), wxOPEN );
649
650     if( dialog.ShowModal() == wxID_OK )
651     {
652         playlist_Import( p_playlist, dialog.GetPath().mb_str() );
653     }
654
655     vlc_object_release( p_playlist );
656 }
657
658 void Playlist::OnAddFile( wxCommandEvent& WXUNUSED(event) )
659 {
660     p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_FILE_SIMPLE, 0, 0 );
661
662 #if 0
663     Rebuild();
664 #endif
665 }
666
667 void Playlist::OnAddMRL( wxCommandEvent& WXUNUSED(event) )
668 {
669     p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_FILE, 0, 0 );
670
671 #if 0
672     Rebuild();
673 #endif
674 }
675
676 /********************************************************************
677  * Move functions
678  ********************************************************************/
679 void Playlist::OnUp( wxCommandEvent& event )
680 {
681     playlist_t *p_playlist =
682         (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
683                                        FIND_ANYWHERE );
684     if( p_playlist == NULL )
685     {
686         return;
687     }
688
689     /* We use the first selected item, so find it */
690     long i_item = listview->GetNextItem( -1, wxLIST_NEXT_ALL,
691                                          wxLIST_STATE_SELECTED);
692     if( i_item > 0 && i_item < p_playlist->i_size )
693     {
694         playlist_Move( p_playlist, i_item, i_item - 1 );
695         listview->Focus( i_item - 1 );
696     }
697     vlc_object_release( p_playlist );
698     return;
699 }
700
701 void Playlist::OnDown( wxCommandEvent& event )
702 {
703     playlist_t *p_playlist =
704         (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
705                                        FIND_ANYWHERE );
706     if( p_playlist == NULL )
707     {
708         return;
709     }
710
711     /* We use the first selected item, so find it */
712     long i_item = listview->GetNextItem( -1, wxLIST_NEXT_ALL,
713                                          wxLIST_STATE_SELECTED );
714     if( i_item >= 0 && i_item < p_playlist->i_size - 1 )
715     {
716         playlist_Move( p_playlist , i_item, i_item + 2 );
717         listview->Focus( i_item + 1 );
718     }
719     vlc_object_release( p_playlist );
720     return;
721 }
722
723 /********************************************************************
724  * Sorting functions
725  ********************************************************************/
726 void Playlist::OnSort( wxCommandEvent& event )
727 {
728     playlist_t *p_playlist =
729         (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
730                                        FIND_ANYWHERE );
731     if( p_playlist == NULL )
732     {
733         return;
734     }
735     switch( event.GetId() )
736     {
737         case SortTitle_Event:
738            playlist_SortTitle( p_playlist , ORDER_NORMAL );
739            break;
740         case RSortTitle_Event:
741            playlist_SortTitle( p_playlist , ORDER_REVERSE );
742            break;
743         case SortAuthor_Event:
744            playlist_SortAuthor(p_playlist , ORDER_NORMAL );
745            break;
746         case RSortAuthor_Event:
747            playlist_SortAuthor( p_playlist , ORDER_REVERSE );
748            break;
749         case SortGroup_Event:
750            playlist_SortGroup( p_playlist , ORDER_NORMAL );
751            break;
752         case RSortGroup_Event:
753            playlist_SortGroup( p_playlist , ORDER_REVERSE );
754            break;
755         case Randomize_Event:
756            playlist_Sort( p_playlist , SORT_RANDOM, ORDER_NORMAL );
757            break;
758     }
759     vlc_object_release( p_playlist );
760
761     Rebuild();
762
763     return;
764 }
765
766 void Playlist::OnColSelect( wxListEvent& event )
767 {
768     playlist_t *p_playlist =
769         (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
770                                        FIND_ANYWHERE );
771     if( p_playlist == NULL )
772     {
773         return;
774     }
775     switch( event.GetColumn() )
776     {
777         case 0:
778             if( i_title_sorted != 1 )
779             {
780                 playlist_SortTitle( p_playlist, ORDER_NORMAL );
781                 i_title_sorted = 1;
782             }
783             else
784             {
785                 playlist_SortTitle( p_playlist, ORDER_REVERSE );
786                 i_title_sorted = -1;
787             }
788             break;
789         case 1:
790             if( i_author_sorted != 1 )
791             {
792                 playlist_SortAuthor( p_playlist, ORDER_NORMAL );
793                 i_author_sorted = 1;
794             }
795             else
796             {
797                 playlist_SortAuthor( p_playlist, ORDER_REVERSE );
798                 i_author_sorted = -1;
799             }
800             break;
801         case 2:
802             if( i_duration_sorted != 1 )
803             {
804                 playlist_Sort( p_playlist, SORT_DURATION, ORDER_NORMAL );
805                 i_duration_sorted = 1;
806             }
807             else
808             {
809                 playlist_Sort( p_playlist, SORT_DURATION, ORDER_REVERSE );
810                 i_duration_sorted = -1;
811             }
812             break;
813         case 3:
814             if( i_group_sorted != 1 )
815             {
816                 playlist_SortGroup( p_playlist, ORDER_NORMAL );
817                 i_group_sorted = 1;
818             }
819             else
820             {
821                 playlist_SortGroup( p_playlist, ORDER_REVERSE );
822                 i_group_sorted = -1;
823             }
824             break;
825         default:
826             break;
827     }
828     vlc_object_release( p_playlist );
829
830     Rebuild();
831
832     return;
833 }
834
835 /**********************************************************************
836  * Search functions
837  **********************************************************************/
838 void Playlist::OnSearchTextChange( wxCommandEvent& WXUNUSED(event) )
839 {
840    search_button->SetDefault();
841 }
842
843 void Playlist::OnSearch( wxCommandEvent& WXUNUSED(event) )
844 {
845     wxString search_string = search_text->GetValue();
846
847     bool b_ok = false;
848     int i_current;
849     int i_first = 0 ;
850     int i_item = -1;
851
852     for( i_current = 0; i_current < listview->GetItemCount(); i_current++ )
853     {
854         if( listview->GetItemState( i_current, wxLIST_STATE_SELECTED ) ==
855               wxLIST_STATE_SELECTED )
856         {
857             i_first = i_current;
858             break;
859         }
860     }
861
862     if( i_first == listview->GetItemCount() )
863     {
864         i_first = -1;
865     }
866
867     for( i_current = i_first + 1; i_current < listview->GetItemCount();
868          i_current++ )
869     {
870         wxListItem listitem;
871         listitem.SetId( i_current );
872         listview->GetItem( listitem );
873         if( listitem.m_text.Lower().Contains( search_string.Lower() ) )
874         {
875             i_item = i_current;
876             b_ok = true;
877             break;
878         }
879         listitem.SetColumn( 1 );
880         listview->GetItem( listitem );
881         if( listitem.m_text.Lower().Contains( search_string.Lower() ) )
882         {
883             i_item = i_current;
884             b_ok = true;
885             break;
886         }
887     }
888     if( !b_ok )
889     {
890         for( i_current = -1 ; i_current < i_first - 1;
891              i_current++ )
892         {
893             wxListItem listitem;
894             listitem.SetId( i_current );
895             listview->GetItem( listitem );
896             if( listitem.m_text.Lower().Contains( search_string.Lower() ) )
897             {
898                 i_item = i_current;
899                 b_ok = true;
900                 break;
901             }
902             listitem.SetColumn( 1 );
903             listview->GetItem( listitem );
904             if( listitem.m_text.Lower().Contains( search_string.Lower() ) )
905             {
906                 i_item = i_current;
907                 b_ok = true;
908                 break;
909             }
910         }
911     }
912
913     if( i_item < 0 || i_item >= listview->GetItemCount() ) return;
914
915     for( long item = 0; item < listview->GetItemCount(); item++ )
916     {
917         listview->Select( item, FALSE );
918     }
919
920     wxListItem listitem;
921     listitem.SetId(i_item);
922     listitem.m_state = wxLIST_STATE_SELECTED;
923     listview->Select( i_item, TRUE );
924     listview->Focus( i_item );
925
926 }
927
928 /**********************************************************************
929  * Selection functions
930  **********************************************************************/
931 void Playlist::OnInvertSelection( wxCommandEvent& WXUNUSED(event) )
932 {
933     for( long item = 0; item < listview->GetItemCount(); item++ )
934     {
935         listview->Select( item, ! listview->IsSelected( item ) );
936     }
937 }
938
939 void Playlist::OnDeleteSelection( wxCommandEvent& WXUNUSED(event) )
940 {
941     /* Delete from the end to the beginning, to avoid a shift of indices */
942     for( long item = listview->GetItemCount() - 1; item >= 0; item-- )
943     {
944         if( listview->IsSelected( item ) )
945         {
946             DeleteItem( item );
947         }
948     }
949
950     Rebuild();
951 }
952
953 void Playlist::OnEnableSelection( wxCommandEvent& WXUNUSED(event) )
954 {
955     playlist_t *p_playlist =
956         (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
957                                        FIND_ANYWHERE );
958     if( p_playlist == NULL )
959     {
960         return;
961     }
962
963     for( long item = listview->GetItemCount() - 1; item >= 0; item-- )
964     {
965         if( listview->IsSelected( item ) )
966         {
967             /*XXX*/
968             playlist_Enable( p_playlist, item );
969             UpdateItem( item );
970         }
971     }
972     vlc_object_release( p_playlist);
973 }
974
975 void Playlist::OnDisableSelection( wxCommandEvent& WXUNUSED(event) )
976 {
977     playlist_t *p_playlist =
978         (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
979                                        FIND_ANYWHERE );
980     if( p_playlist == NULL )
981     {
982         return;
983     }
984
985     for( long item = listview->GetItemCount() - 1; item >= 0; item-- )
986     {
987         if( listview->IsSelected( item ) )
988         {
989             /*XXX*/
990             playlist_Disable( p_playlist, item );
991             UpdateItem( item );
992         }
993     }
994     vlc_object_release( p_playlist);
995 }
996
997 void Playlist::OnSelectAll( wxCommandEvent& WXUNUSED(event) )
998 {
999     for( long item = 0; item < listview->GetItemCount(); item++ )
1000     {
1001         listview->Select( item, TRUE );
1002     }
1003 }
1004
1005 /**********************************************************************
1006  * Playlist mode functions
1007  **********************************************************************/
1008 void Playlist::OnRandom( wxCommandEvent& event )
1009 {
1010     vlc_value_t val;
1011     val.b_bool = event.IsChecked();
1012     playlist_t *p_playlist =
1013         (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
1014                                        FIND_ANYWHERE );
1015     if( p_playlist == NULL )
1016     {
1017         return;
1018     }
1019     var_Set( p_playlist , "random", val);
1020     vlc_object_release( p_playlist );
1021 }
1022
1023 void Playlist::OnLoop ( wxCommandEvent& event )
1024 {
1025     vlc_value_t val;
1026     val.b_bool = event.IsChecked();
1027     playlist_t *p_playlist =
1028         (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
1029                                        FIND_ANYWHERE );
1030     if( p_playlist == NULL )
1031     {
1032         return;
1033     }
1034     var_Set( p_playlist , "loop", val);
1035     vlc_object_release( p_playlist );
1036 }
1037
1038 void Playlist::OnRepeat ( wxCommandEvent& event )
1039 {
1040     vlc_value_t val;
1041     val.b_bool = event.IsChecked();
1042     playlist_t *p_playlist =
1043         (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
1044                                        FIND_ANYWHERE );
1045     if( p_playlist == NULL )
1046     {
1047         return;
1048     }
1049     var_Set( p_playlist , "repeat", val);
1050     vlc_object_release( p_playlist );
1051 }
1052
1053
1054
1055 void Playlist::OnActivateItem( wxListEvent& event )
1056 {
1057     playlist_t *p_playlist =
1058         (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
1059                                        FIND_ANYWHERE );
1060     if( p_playlist == NULL )
1061     {
1062         return;
1063     }
1064
1065     playlist_Goto( p_playlist, event.GetIndex() );
1066
1067     vlc_object_release( p_playlist );
1068 }
1069
1070 void Playlist::OnKeyDown( wxListEvent& event )
1071 {
1072     long keycode = event.GetKeyCode();
1073     /* Delete selected items */
1074     if( keycode == WXK_BACK || keycode == WXK_DELETE )
1075     {
1076         /* We send a dummy event */
1077         OnDeleteSelection( event );
1078     }
1079 }
1080
1081 void Playlist::ShowInfos( int i_item )
1082 {
1083     playlist_t *p_playlist =
1084         (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
1085                                        FIND_ANYWHERE );
1086     if( p_playlist == NULL )
1087     {
1088         return;
1089     }
1090    
1091     if( i_item == -1 )
1092     {
1093         return;
1094     }
1095  
1096     if( iteminfo_dialog == NULL )
1097     {
1098         vlc_mutex_lock( &p_playlist->object_lock);
1099         playlist_item_t *p_item = playlist_ItemGetByPos( p_playlist, i_item );
1100         vlc_mutex_unlock( &p_playlist->object_lock );
1101
1102         if( p_item )
1103         {
1104             iteminfo_dialog = new ItemInfoDialog(
1105                               p_intf, p_item , this );
1106             if( iteminfo_dialog->ShowModal()  == wxID_OK )
1107                 UpdateItem( i_item );
1108             delete iteminfo_dialog;
1109             iteminfo_dialog = NULL;
1110         }
1111     }
1112     vlc_object_release( p_playlist );
1113 }
1114
1115 void Playlist::OnInfos( wxCommandEvent& WXUNUSED(event) )
1116 {
1117     /* We use the first selected item, so find it */
1118     long i_item = listview->GetNextItem( -1 , wxLIST_NEXT_ALL,
1119                                          wxLIST_STATE_SELECTED );
1120     ShowInfos( i_item );
1121 }
1122
1123 void Playlist::OnEnDis( wxCommandEvent& event )
1124 {
1125     playlist_t *p_playlist =
1126         (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
1127                                        FIND_ANYWHERE );
1128     if( p_playlist == NULL )
1129     {
1130         return;
1131     }
1132
1133     long i_item = listview->GetNextItem( i_item, wxLIST_NEXT_ALL,
1134                                          wxLIST_STATE_SELECTED );
1135
1136     if( i_item >= 0 && i_item < p_playlist->i_size )
1137     {
1138        switch( event.GetId() )
1139        {
1140            case EnableGroup_Event:
1141                /*XXX*/
1142                playlist_EnableGroup( p_playlist ,
1143                                   p_playlist->pp_items[i_item]->i_group );
1144                break;
1145            case DisableGroup_Event:
1146                playlist_DisableGroup( p_playlist ,
1147                                   p_playlist->pp_items[i_item]->i_group );
1148                break;
1149        }
1150        Rebuild();
1151     }
1152
1153     vlc_object_release( p_playlist );
1154 }
1155
1156 /*****************************************************************************
1157  * Popup management functions
1158  *****************************************************************************/
1159 void Playlist::OnPopup( wxListEvent& event )
1160 {
1161     i_popup_item = event.GetIndex();
1162     Playlist::PopupMenu( popup_menu , ScreenToClient( wxGetMousePosition() ) );
1163 }
1164
1165 void Playlist::OnPopupPlay( wxMenuEvent& event )
1166 {
1167     playlist_t *p_playlist =
1168         (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
1169                                        FIND_ANYWHERE );
1170     if( p_playlist == NULL )
1171     {
1172         return;
1173     }
1174     if( i_popup_item != -1 )
1175     {
1176         playlist_Goto( p_playlist, i_popup_item );
1177     }
1178     vlc_object_release( p_playlist );
1179 }
1180
1181 void Playlist::OnPopupDel( wxMenuEvent& event )
1182 {
1183     DeleteItem( i_popup_item );
1184 }
1185
1186 void Playlist::OnPopupEna( wxMenuEvent& event )
1187 {
1188     playlist_t *p_playlist =
1189         (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
1190                                        FIND_ANYWHERE );
1191     if( p_playlist == NULL )
1192     {
1193         return;
1194     }
1195
1196     if( p_playlist->pp_items[i_popup_item]->b_enabled )
1197         //playlist_IsEnabled( p_playlist, i_popup_item ) )
1198     {
1199         playlist_Disable( p_playlist, i_popup_item );
1200     }
1201     else
1202     {
1203         playlist_Enable( p_playlist, i_popup_item );
1204     }
1205     vlc_object_release( p_playlist);
1206     UpdateItem( i_popup_item );
1207 }
1208
1209 void Playlist::OnPopupInfo( wxMenuEvent& event )
1210 {
1211     ShowInfos( i_popup_item );
1212 }
1213
1214 /*****************************************************************************
1215  * Custom events management
1216  *****************************************************************************/
1217 void Playlist::OnPlaylistEvent( wxCommandEvent& event )
1218 {
1219     switch( event.GetId() )
1220     {
1221     case UpdateItem_Event:
1222         UpdateItem( event.GetInt() );
1223         break;
1224     }
1225 }
1226
1227 /*****************************************************************************
1228  * PlaylistChanged: callback triggered by the intf-change playlist variable
1229  *  We don't rebuild the playlist directly here because we don't want the
1230  *  caller to block for a too long time.
1231  *****************************************************************************/
1232 int PlaylistChanged( vlc_object_t *p_this, const char *psz_variable,
1233                      vlc_value_t old_val, vlc_value_t new_val, void *param )
1234 {
1235     Playlist *p_playlist_dialog = (Playlist *)param;
1236     p_playlist_dialog->b_need_update = VLC_TRUE;
1237     return VLC_SUCCESS;
1238 }
1239
1240 /*****************************************************************************
1241  * Next: callback triggered by the playlist-current playlist variable
1242  *****************************************************************************/
1243 int PlaylistNext( vlc_object_t *p_this, const char *psz_variable,
1244                  vlc_value_t old_val, vlc_value_t new_val, void *param )
1245 {
1246     Playlist *p_playlist_dialog = (Playlist *)param;
1247
1248     wxCommandEvent event( wxEVT_PLAYLIST, UpdateItem_Event );
1249     event.SetInt( old_val.i_int );
1250     p_playlist_dialog->AddPendingEvent( event );
1251     event.SetInt( new_val.i_int );
1252     p_playlist_dialog->AddPendingEvent( event );
1253
1254     return 0;
1255 }
1256
1257 /*****************************************************************************
1258  * ItemChanged: callback triggered by the item-change playlist variable
1259  *****************************************************************************/
1260 int ItemChanged( vlc_object_t *p_this, const char *psz_variable,
1261                  vlc_value_t old_val, vlc_value_t new_val, void *param )
1262 {
1263     Playlist *p_playlist_dialog = (Playlist *)param;
1264
1265     wxCommandEvent event( wxEVT_PLAYLIST, UpdateItem_Event );
1266     event.SetInt( new_val.i_int );
1267     p_playlist_dialog->AddPendingEvent( event );
1268
1269     return 0;
1270 }
1271
1272 /***************************************************************************
1273  * NewGroup Class
1274  ***************************************************************************/
1275 NewGroup::NewGroup( intf_thread_t *_p_intf, wxWindow *_p_parent ):
1276     wxDialog( _p_parent, -1, wxU(_("New Group")), wxDefaultPosition,
1277              wxDefaultSize, wxDEFAULT_FRAME_STYLE )
1278 {
1279     /* Initializations */
1280     p_intf = _p_intf;
1281     psz_name = NULL;
1282     SetIcon( *p_intf->p_sys->p_icon );
1283
1284     /* Create a panel to put everything in*/
1285     wxPanel *panel = new wxPanel( this, -1 );
1286     panel->SetAutoLayout( TRUE );
1287
1288     wxStaticText *group_label =
1289             new wxStaticText( panel , -1,
1290                 wxU(_("Enter a name for the new group:")));
1291
1292     groupname = new wxTextCtrl(panel, -1, wxU(""),wxDefaultPosition,
1293                                wxSize(100,27),wxTE_PROCESS_ENTER);
1294
1295     wxButton *ok_button = new wxButton(panel, wxID_OK, wxU(_("OK")) );
1296     ok_button->SetDefault();
1297     wxButton *cancel_button = new wxButton( panel, wxID_CANCEL,
1298                                             wxU(_("Cancel")) );
1299
1300     wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL );
1301
1302     button_sizer->Add( ok_button, 0, wxALL, 5 );
1303     button_sizer->Add( cancel_button, 0, wxALL, 5 );
1304     button_sizer->Layout();
1305
1306     wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL );
1307     panel_sizer->Add( group_label, 0, wxEXPAND | wxALL, 5 );
1308     panel_sizer->Add( groupname, 0, wxEXPAND | wxALL, 5 );
1309     panel_sizer->Add( button_sizer, 0, wxEXPAND | wxALL, 5 );
1310     panel_sizer->Layout();
1311
1312     panel->SetSizerAndFit( panel_sizer );
1313
1314     wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
1315     main_sizer->Add( panel, 1, wxEXPAND, 0 );
1316     main_sizer->Layout();
1317     SetSizerAndFit( main_sizer );
1318 }
1319
1320 NewGroup::~NewGroup()
1321 {
1322 }
1323
1324 void NewGroup::OnOk( wxCommandEvent& event )
1325 {
1326     psz_name = strdup( groupname->GetLineText(0).mb_str() );
1327
1328     playlist_t * p_playlist =
1329           (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
1330                                        FIND_ANYWHERE );
1331
1332     if( p_playlist )
1333     {
1334         if( !playlist_CreateGroup( p_playlist, psz_name ) )
1335         {
1336             psz_name = NULL;
1337         }
1338         vlc_object_release( p_playlist );
1339     }
1340
1341     EndModal( wxID_OK );
1342 }
1343
1344 void NewGroup::OnCancel( wxCommandEvent& WXUNUSED(event) )
1345 {
1346     EndModal( wxID_CANCEL );
1347 }