playlist.cpp 41.9 KB
Newer Older
1
/*****************************************************************************
gbazin's avatar
 
gbazin committed
2
 * playlist.cpp : wxWindows plugin for vlc
3
 *****************************************************************************
4
 * Copyright (C) 2000-2004 VideoLAN
zorglub's avatar
zorglub committed
5
 * $Id: playlist.cpp,v 1.36 2004/01/11 00:45:06 zorglub Exp $
6 7 8 9 10 11 12
 *
 * Authors: Olivier Teulire <ipkiss@via.ecp.fr>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
gbazin's avatar
 
gbazin committed
13
 *
14 15 16 17 18 19 20 21 22 23 24 25 26
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * 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.
 *****************************************************************************/

/*****************************************************************************
 * Preamble
 *****************************************************************************/
gbazin's avatar
 
gbazin committed
27
#include <vlc/vlc.h>
gbazin's avatar
 
gbazin committed
28
#include <vlc/intf.h>
29 30

#include "wxwindows.h"
31
#include <wx/listctrl.h>
32

gbazin's avatar
 
gbazin committed
33 34 35
/* Callback prototype */
int PlaylistChanged( vlc_object_t *p_this, const char *psz_variable,
                     vlc_value_t old_val, vlc_value_t new_val, void *param );
zorglub's avatar
zorglub committed
36 37 38 39
int PlaylistNext( vlc_object_t *p_this, const char *psz_variable,
                     vlc_value_t old_val, vlc_value_t new_val, void *param );
int ItemChanged( vlc_object_t *p_this, const char *psz_variable,
                     vlc_value_t old_val, vlc_value_t new_val, void *param );
gbazin's avatar
 
gbazin committed
40

41 42 43 44 45 46 47 48
/*****************************************************************************
 * Event Table.
 *****************************************************************************/

/* IDs for the controls and the menu commands */
enum
{
    /* menu items */
gbazin's avatar
 
gbazin committed
49 50
    AddFile_Event = 1,
    AddMRL_Event,
51
    Close_Event,
gbazin's avatar
 
gbazin committed
52 53
    Open_Event,
    Save_Event,
54

zorglub's avatar
zorglub committed
55 56 57 58 59 60
    SortTitle_Event,
    RSortTitle_Event,
    SortAuthor_Event,
    RSortAuthor_Event,
    SortGroup_Event,
    RSortGroup_Event,
zorglub's avatar
zorglub committed
61
    Randomize_Event,
zorglub's avatar
zorglub committed
62

zorglub's avatar
zorglub committed
63 64 65
    EnableSelection_Event,
    DisableSelection_Event,

66 67
    InvertSelection_Event,
    DeleteSelection_Event,
68 69
    Random_Event,
    Loop_Event,
70
    Repeat_Event,
71 72
    SelectAll_Event,

zorglub's avatar
zorglub committed
73 74
    EnableGroup_Event,
    DisableGroup_Event,
zorglub's avatar
zorglub committed
75

zorglub's avatar
zorglub committed
76 77
    Up_Event,
    Down_Event,
zorglub's avatar
zorglub committed
78 79
    Infos_Event,

zorglub's avatar
zorglub committed
80 81 82 83 84
    PopupPlay_Event,
    PopupDel_Event,
    PopupEna_Event,
    PopupInfo_Event,

zorglub's avatar
zorglub committed
85 86 87
    SearchText_Event,
    Search_Event,

88
    /* controls */
zorglub's avatar
zorglub committed
89 90 91
    ListView_Event,

    Browse_Event,  /* For export playlist */
92 93 94 95
};

BEGIN_EVENT_TABLE(Playlist, wxFrame)
    /* Menu events */
gbazin's avatar
 
gbazin committed
96
    EVT_MENU(AddFile_Event, Playlist::OnAddFile)
gbazin's avatar
 
gbazin committed
97
    EVT_MENU(AddMRL_Event, Playlist::OnAddMRL)
98
    EVT_MENU(Close_Event, Playlist::OnClose)
gbazin's avatar
 
gbazin committed
99 100
    EVT_MENU(Open_Event, Playlist::OnOpen)
    EVT_MENU(Save_Event, Playlist::OnSave)
zorglub's avatar
zorglub committed
101 102 103 104 105 106 107 108

    EVT_MENU(SortTitle_Event, Playlist::OnSort)
    EVT_MENU(RSortTitle_Event, Playlist::OnSort)
    EVT_MENU(SortAuthor_Event, Playlist::OnSort)
    EVT_MENU(RSortAuthor_Event, Playlist::OnSort)
    EVT_MENU(SortGroup_Event, Playlist::OnSort)
    EVT_MENU(RSortGroup_Event, Playlist::OnSort)

zorglub's avatar
zorglub committed
109 110
    EVT_MENU(Randomize_Event, Playlist::OnSort)

zorglub's avatar
zorglub committed
111 112
    EVT_MENU(EnableSelection_Event, Playlist::OnEnableSelection)
    EVT_MENU(DisableSelection_Event, Playlist::OnDisableSelection)
113 114 115
    EVT_MENU(InvertSelection_Event, Playlist::OnInvertSelection)
    EVT_MENU(DeleteSelection_Event, Playlist::OnDeleteSelection)
    EVT_MENU(SelectAll_Event, Playlist::OnSelectAll)
zorglub's avatar
zorglub committed
116
    EVT_MENU(Infos_Event, Playlist::OnInfos)
117
    EVT_CHECKBOX(Random_Event, Playlist::OnRandom)
118
    EVT_CHECKBOX(Repeat_Event, Playlist::OnRepeat)
119
    EVT_CHECKBOX(Loop_Event, Playlist::OnLoop)
120

zorglub's avatar
zorglub committed
121 122 123
    EVT_MENU(EnableGroup_Event, Playlist::OnEnDis)
    EVT_MENU(DisableGroup_Event, Playlist::OnEnDis)

124 125
    /* Listview events */
    EVT_LIST_ITEM_ACTIVATED(ListView_Event, Playlist::OnActivateItem)
sigmunau's avatar
sigmunau committed
126
    EVT_LIST_COL_CLICK(ListView_Event, Playlist::OnColSelect)
127
    EVT_LIST_KEY_DOWN(ListView_Event, Playlist::OnKeyDown)
zorglub's avatar
zorglub committed
128 129 130 131 132 133 134 135
    EVT_LIST_ITEM_RIGHT_CLICK(ListView_Event, Playlist::OnPopup)

    /* Popup events */
    EVT_MENU( PopupPlay_Event, Playlist::OnPopupPlay)
    EVT_MENU( PopupDel_Event, Playlist::OnPopupDel)
    EVT_MENU( PopupEna_Event, Playlist::OnPopupEna)
    EVT_MENU( PopupInfo_Event, Playlist::OnPopupInfo)

136 137

    /* Button events */
zorglub's avatar
zorglub committed
138
    EVT_BUTTON( Search_Event, Playlist::OnSearch)
gbazin's avatar
 
gbazin committed
139
    EVT_BUTTON( Save_Event, Playlist::OnSave)
zorglub's avatar
zorglub committed
140
    EVT_BUTTON( Infos_Event, Playlist::OnInfos)
141

zorglub's avatar
zorglub committed
142 143 144
    EVT_BUTTON( Up_Event, Playlist::OnUp)
    EVT_BUTTON( Down_Event, Playlist::OnDown)

zorglub's avatar
zorglub committed
145 146
    EVT_TEXT(SearchText_Event, Playlist::OnSearchTextChange)

147 148 149 150 151
    /* Special events : we don't want to destroy the window when the user
     * clicks on (X) */
    EVT_CLOSE(Playlist::OnClose)
END_EVENT_TABLE()

zorglub's avatar
zorglub committed
152 153 154 155 156 157 158

/* Event Table for the Newgroup class */
BEGIN_EVENT_TABLE(NewGroup, wxDialog)
    EVT_BUTTON( wxID_OK, NewGroup::OnOk)
    EVT_BUTTON( wxID_CANCEL, NewGroup::OnCancel)
END_EVENT_TABLE()

zorglub's avatar
zorglub committed
159 160 161 162 163 164 165 166

/* 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()

167 168 169
/*****************************************************************************
 * Constructor.
 *****************************************************************************/
gbazin's avatar
 
gbazin committed
170 171
Playlist::Playlist( intf_thread_t *_p_intf, wxWindow *p_parent ):
    wxFrame( p_parent, -1, wxU(_("Playlist")), wxDefaultPosition,
gbazin's avatar
 
gbazin committed
172
             wxDefaultSize, wxDEFAULT_FRAME_STYLE )
173 174
{
    /* Initializations */
zorglub's avatar
zorglub committed
175
    iteminfo_dialog = NULL;
176
    p_intf = _p_intf;
177
    vlc_value_t  val;
gbazin's avatar
 
gbazin committed
178
    i_update_counter = 0;
zorglub's avatar
zorglub committed
179
    i_sort_mode = MODE_NONE;
gbazin's avatar
 
gbazin committed
180 181
    b_need_update = VLC_FALSE;
    vlc_mutex_init( p_intf, &lock );
gbazin's avatar
 
gbazin committed
182
    SetIcon( *p_intf->p_sys->p_icon );
183

184 185 186 187 188
    i_title_sorted = 0;
    i_author_sorted = 0;
    i_group_sorted = 0;


189 190 191 192 193 194 195
    var_Create( p_intf, "random", VLC_VAR_BOOL );
    var_Change( p_intf, "random", VLC_VAR_INHERITVALUE, & val, NULL );
    var_Create( p_intf, "loop", VLC_VAR_BOOL );
    var_Create( p_intf, "loop", VLC_VAR_BOOL );
    var_Change( p_intf, "repeat", VLC_VAR_INHERITVALUE, & val, NULL );
    var_Change( p_intf, "repeat", VLC_VAR_INHERITVALUE, & val, NULL );

196 197
    /* Create our "Manage" menu */
    wxMenu *manage_menu = new wxMenu;
gbazin's avatar
 
gbazin committed
198
    manage_menu->Append( AddFile_Event, wxU(_("&Simple Add...")) );
gbazin's avatar
 
gbazin committed
199
    manage_menu->Append( AddMRL_Event, wxU(_("&Add MRL...")) );
zorglub's avatar
zorglub committed
200
    manage_menu->AppendSeparator();
gbazin's avatar
 
gbazin committed
201 202
    manage_menu->Append( Open_Event, wxU(_("&Open Playlist...")) );
    manage_menu->Append( Save_Event, wxU(_("&Save Playlist...")) );
203
    manage_menu->AppendSeparator();
gbazin's avatar
 
gbazin committed
204
    manage_menu->Append( Close_Event, wxU(_("&Close")) );
205

zorglub's avatar
zorglub committed
206 207
    /* Create our "Sort" menu */
    wxMenu *sort_menu = new wxMenu;
zorglub's avatar
zorglub committed
208
    sort_menu->Append( SortTitle_Event, wxU(_("Sort by &title")) );
zorglub's avatar
zorglub committed
209 210
    sort_menu->Append( RSortTitle_Event, wxU(_("&Reverse sort by title")) );
    sort_menu->AppendSeparator();
zorglub's avatar
zorglub committed
211
    sort_menu->Append( SortAuthor_Event, wxU(_("Sort by &author")) );
zorglub's avatar
zorglub committed
212 213
    sort_menu->Append( RSortAuthor_Event, wxU(_("&Reverse sort by author")) );
    sort_menu->AppendSeparator();
zorglub's avatar
zorglub committed
214
    sort_menu->Append( SortGroup_Event, wxU(_("Sort by &group")) );
zorglub's avatar
zorglub committed
215
    sort_menu->Append( RSortGroup_Event, wxU(_("&Reverse sort by group")) );
zorglub's avatar
zorglub committed
216 217
    sort_menu->AppendSeparator();
    sort_menu->Append( Randomize_Event, wxU(_("&Randomize Playlist")) );
zorglub's avatar
zorglub committed
218

219 220
    /* Create our "Selection" menu */
    wxMenu *selection_menu = new wxMenu;
zorglub's avatar
zorglub committed
221 222 223
    selection_menu->Append( EnableSelection_Event, wxU(_("&Enable")) );
    selection_menu->Append( DisableSelection_Event, wxU(_("&Disable")) );
    selection_menu->AppendSeparator();
gbazin's avatar
 
gbazin committed
224 225 226
    selection_menu->Append( InvertSelection_Event, wxU(_("&Invert")) );
    selection_menu->Append( DeleteSelection_Event, wxU(_("&Delete")) );
    selection_menu->Append( SelectAll_Event, wxU(_("&Select All")) );
227

zorglub's avatar
zorglub committed
228 229 230 231 232 233
    /* Create our "Group" menu */
    wxMenu *group_menu = new wxMenu;
    group_menu->Append( EnableGroup_Event, wxU(_("&Enable all group items")) );
    group_menu->Append( DisableGroup_Event,
                        wxU(_("&Disable all group items")) );

234 235
    /* Append the freshly created menus to the menu bar */
    wxMenuBar *menubar = new wxMenuBar( wxMB_DOCKABLE );
gbazin's avatar
 
gbazin committed
236
    menubar->Append( manage_menu, wxU(_("&Manage")) );
zorglub's avatar
zorglub committed
237
    menubar->Append( sort_menu, wxU(_("S&ort")) );
gbazin's avatar
 
gbazin committed
238
    menubar->Append( selection_menu, wxU(_("&Selection")) );
zorglub's avatar
zorglub committed
239
    menubar->Append( group_menu, wxU(_("&Groups")) );
240 241 242 243

    /* Attach the menu bar to the frame */
    SetMenuBar( menubar );

zorglub's avatar
zorglub committed
244 245 246 247 248 249
    /* Create the popup menu */
    popup_menu = new wxMenu;
    popup_menu->Append( PopupPlay_Event, wxU(_("Play item")) );
    popup_menu->Append( PopupDel_Event, wxU(_("Delete item")) );
    popup_menu->Append( PopupEna_Event, wxU(_("Toggle enabled")) );
    popup_menu->Append( PopupInfo_Event, wxU(_("Info on item")) );
zorglub's avatar
zorglub committed
250

gbazin's avatar
 
gbazin committed
251 252 253 254
    /* Create a panel to put everything in */
    wxPanel *playlist_panel = new wxPanel( this, -1 );
    playlist_panel->SetAutoLayout( TRUE );

255
    /* Create the Random checkbox */
zorglub's avatar
zorglub committed
256
    wxCheckBox *random_checkbox =
257
        new wxCheckBox( playlist_panel, Random_Event, wxU(_("Random")) );
gbazin's avatar
 
gbazin committed
258
    var_Get( p_intf, "random", &val );
259
    vlc_bool_t b_random = val.b_bool;
gbazin's avatar
 
gbazin committed
260
    random_checkbox->SetValue( b_random == VLC_FALSE ? 0 : 1 );
261 262

    /* Create the Loop Checkbox */
zorglub's avatar
zorglub committed
263
    wxCheckBox *loop_checkbox =
264
        new wxCheckBox( playlist_panel, Loop_Event, wxU(_("Loop")) );
265
    var_Get( p_intf, "loop", &val );
zorglub's avatar
zorglub committed
266
    int b_loop = val.b_bool ;
267
    loop_checkbox->SetValue( b_loop );
268

269
    /* Create the Repeat one checkbox */
zorglub's avatar
zorglub committed
270 271
    wxCheckBox *repeat_checkbox =
        new wxCheckBox( playlist_panel, Repeat_Event, wxU(_("Repeat one")) );
272
    var_Get( p_intf, "repeat", &val );
zorglub's avatar
zorglub committed
273
    int b_repeat = val.b_bool ;
274 275
    repeat_checkbox->SetValue( b_repeat );

zorglub's avatar
zorglub committed
276 277
    /* Create the Search Textbox */
    search_text =
zorglub's avatar
zorglub committed
278
        new wxTextCtrl( playlist_panel, SearchText_Event, wxT(""),
gbazin's avatar
 
gbazin committed
279
                        wxDefaultPosition, wxSize(140, -1),
zorglub's avatar
zorglub committed
280
                        wxTE_PROCESS_ENTER);
zorglub's avatar
zorglub committed
281 282

    /* Create the search button */
zorglub's avatar
zorglub committed
283 284
    search_button =
        new wxButton( playlist_panel, Search_Event, wxU(_("Search")) );
zorglub's avatar
zorglub committed
285

286

zorglub's avatar
zorglub committed
287 288 289 290 291 292 293 294 295 296 297
    /* Create the listview */
    /* FIXME: the given size is arbitrary, and prevents us from resizing
     * the window to smaller dimensions. But the sizers don't seem to adjust
     * themselves to the size of a listview, and with a wxDefaultSize the
     * playlist window is ridiculously small */
    listview = new wxListView( playlist_panel, ListView_Event,
                               wxDefaultPosition, wxSize( 500, 300 ),
                               wxLC_REPORT | wxSUNKEN_BORDER );
    listview->InsertColumn( 0, wxU(_("Name")) );
    listview->InsertColumn( 1, wxU(_("Author")) );
    listview->InsertColumn( 2, wxU(_("Group")) );
298
    listview->InsertColumn( 3, wxU(_("Duration")) );
zorglub's avatar
zorglub committed
299 300 301 302 303 304 305 306 307 308 309 310
    listview->SetColumnWidth( 0, 270 );
    listview->SetColumnWidth( 1, 150 );
    listview->SetColumnWidth( 2, 80 );

    /* Create the Up-Down buttons */
    wxButton *up_button =
        new wxButton( playlist_panel, Up_Event, wxU(_("Up") ) );

    wxButton *down_button =
        new wxButton( playlist_panel, Down_Event, wxU(_("Down") ) );

    /* Create the iteminfo button */
zorglub's avatar
zorglub committed
311
    wxButton *iteminfo_button =
Sam Hocevar's avatar
Sam Hocevar committed
312
        new wxButton( playlist_panel, Infos_Event, wxU(_("Item info") ) );
zorglub's avatar
zorglub committed
313

zorglub's avatar
zorglub committed
314 315 316
    /* Place everything in sizers */
    wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL );
    button_sizer->Add( iteminfo_button, 0, wxALIGN_CENTER|wxLEFT , 5);
317 318
    button_sizer->Layout();

zorglub's avatar
zorglub committed
319 320 321 322
    wxBoxSizer *updown_sizer = new wxBoxSizer( wxHORIZONTAL );
    updown_sizer->Add( up_button, 0, wxALIGN_LEFT|wxRIGHT, 3);
    updown_sizer->Add( down_button, 0, wxALIGN_LEFT|wxLEFT, 3);
    updown_sizer->Layout();
zorglub's avatar
zorglub committed
323 324 325

    wxBoxSizer *checkbox_sizer = new wxBoxSizer( wxHORIZONTAL );
    checkbox_sizer->Add( random_checkbox, 0,
gbazin's avatar
 
gbazin committed
326
                         wxEXPAND | wxALIGN_RIGHT | wxALL, 5);
zorglub's avatar
zorglub committed
327
    checkbox_sizer->Add( loop_checkbox, 0,
gbazin's avatar
 
gbazin committed
328
                         wxEXPAND | wxALIGN_RIGHT | wxALL, 5);
zorglub's avatar
zorglub committed
329
    checkbox_sizer->Add( repeat_checkbox, 0,
gbazin's avatar
 
gbazin committed
330
                         wxEXPAND | wxALIGN_RIGHT | wxALL, 5);
zorglub's avatar
zorglub committed
331 332 333
    checkbox_sizer->Layout();

    wxBoxSizer *search_sizer = new wxBoxSizer( wxHORIZONTAL );
zorglub's avatar
zorglub committed
334 335
    search_sizer->Add( search_text, 0, wxRIGHT|wxALIGN_CENTER, 3);
    search_sizer->Add( search_button, 0, wxLEFT|wxALIGN_CENTER, 3);
zorglub's avatar
zorglub committed
336 337
    search_sizer->Layout();

zorglub's avatar
zorglub committed
338 339
    /* The top and bottom sizers */
    wxBoxSizer *top_sizer = new wxBoxSizer( wxHORIZONTAL );
gbazin's avatar
 
gbazin committed
340 341
    top_sizer->Add( checkbox_sizer, 1, wxLEFT|wxRIGHT|wxALIGN_LEFT, 4 );
    top_sizer->Add( search_sizer, 1, wxLEFT|wxRIGHT|wxALIGN_RIGHT, 4 );
zorglub's avatar
zorglub committed
342
    top_sizer->Layout();
zorglub's avatar
zorglub committed
343

zorglub's avatar
zorglub committed
344 345 346
    wxBoxSizer *bottom_sizer = new wxBoxSizer( wxHORIZONTAL );
    bottom_sizer->Add( updown_sizer, 0, wxEXPAND |wxRIGHT | wxLEFT | wxALIGN_LEFT, 4);
    bottom_sizer->Add( button_sizer , 0, wxEXPAND|wxLEFT | wxRIGHT | wxALIGN_RIGHT, 4 );
347 348
    bottom_sizer->Layout();

349
    wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
zorglub's avatar
zorglub committed
350

gbazin's avatar
 
gbazin committed
351
    wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL );
zorglub's avatar
zorglub committed
352
    panel_sizer->Add( top_sizer, 0, wxEXPAND | wxALL, 5 );
gbazin's avatar
 
gbazin committed
353
    panel_sizer->Add( listview, 1, wxEXPAND | wxALL, 5 );
zorglub's avatar
zorglub committed
354
    panel_sizer->Add( bottom_sizer, 0 , wxEXPAND | wxALL, 5);
gbazin's avatar
 
gbazin committed
355
    panel_sizer->Layout();
zorglub's avatar
zorglub committed
356

gbazin's avatar
 
gbazin committed
357 358 359
    playlist_panel->SetSizerAndFit( panel_sizer );
    main_sizer->Add( playlist_panel, 1, wxGROW, 0 );
    main_sizer->Layout();
360
    SetSizerAndFit( main_sizer );
gbazin's avatar
 
gbazin committed
361

gbazin's avatar
 
gbazin committed
362
#if !defined(__WXX11__)
gbazin's avatar
 
gbazin committed
363
    /* Associate drop targets with the playlist */
gbazin's avatar
 
gbazin committed
364
    SetDropTarget( new DragAndDrop( p_intf, VLC_TRUE ) );
gbazin's avatar
 
gbazin committed
365
#endif
gbazin's avatar
 
gbazin committed
366

gbazin's avatar
 
gbazin committed
367 368 369 370 371 372 373 374
    playlist_t *p_playlist =
        (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                       FIND_ANYWHERE );
    if( p_playlist == NULL )
    {
        return;
    }

zorglub's avatar
zorglub committed
375
    /* We want to be noticed of playlist changes */
zorglub's avatar
zorglub committed
376 377

    /* Some global changes happened -> Rebuild all */
gbazin's avatar
 
gbazin committed
378
    var_AddCallback( p_playlist, "intf-change", PlaylistChanged, this );
zorglub's avatar
zorglub committed
379 380 381 382 383 384 385 386

    /* We went to the next item */
    var_AddCallback( p_playlist, "playlist-current", PlaylistNext, this );

    /* One item has been updated */
    var_AddCallback( p_playlist, "item-change", ItemChanged, this );


gbazin's avatar
 
gbazin committed
387 388
    vlc_object_release( p_playlist );

gbazin's avatar
 
gbazin committed
389 390
    /* Update the playlist */
    Rebuild();
391 392 393 394
}

Playlist::~Playlist()
{
gbazin's avatar
 
gbazin committed
395 396 397 398 399 400 401 402
    playlist_t *p_playlist =
        (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                       FIND_ANYWHERE );
    if( p_playlist == NULL )
    {
        return;
    }

zorglub's avatar
zorglub committed
403 404
    delete iteminfo_dialog;

gbazin's avatar
 
gbazin committed
405 406
    var_DelCallback( p_playlist, "intf-change", PlaylistChanged, this );
    vlc_object_release( p_playlist );
407 408
}

zorglub's avatar
zorglub committed
409 410 411 412 413 414 415 416 417 418 419 420
/**********************************************************************
 * Update one playlist item
 **********************************************************************/
void Playlist::UpdateItem( int i )
{
    playlist_t *p_playlist =
        (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                       FIND_ANYWHERE );
    if( p_playlist == NULL )
    {
        return;
    }
zorglub's avatar
zorglub committed
421
    if( i < 0 || i >= p_playlist->i_size || !p_playlist->pp_items[i] )
zorglub's avatar
zorglub committed
422 423 424 425 426 427
    {
        vlc_object_release(p_playlist);
        return;
    }
    listview->SetItem( i, 0, wxL2U(p_playlist->pp_items[i]->psz_name) );
    listview->SetItem( i, 1, wxL2U( playlist_GetInfo( p_playlist, i,
zorglub's avatar
zorglub committed
428 429 430
                                       _("General") , _("Author") ) ) );
    char *psz_group = playlist_FindGroup(p_playlist,p_playlist->
                                    pp_items[i]->i_group);
zorglub's avatar
zorglub committed
431
    listview->SetItem( i, 2,
zorglub's avatar
zorglub committed
432
             wxL2U( psz_group ? psz_group : _("Normal") ) );
zorglub's avatar
zorglub committed
433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463

    if( p_playlist->pp_items[i]->b_enabled == VLC_FALSE )
    {
        wxListItem listitem;
        listitem.m_itemId = i;
        listitem.SetTextColour( *wxLIGHT_GREY);
        listview->SetItem(listitem);
    }

    char psz_duration[MSTRTIME_MAX_SIZE];
    mtime_t dur = p_playlist->pp_items[i]->i_duration;
    if( dur != -1 ) secstotimestr( psz_duration, dur/1000000 );
    else memcpy( psz_duration , "-:--:--", sizeof("-:--:--") );
    listview->SetItem( i, 3, wxU(psz_duration) );

    /* Change the colour for the currenty played stream */
    wxListItem listitem;
    listitem.m_itemId = i;
    if( i == p_playlist->i_index )
    {
        listitem.SetTextColour( *wxRED );
    }
    else
    {
        listitem.SetTextColour( *wxBLACK );
    }
    listview->SetItem( listitem );

    vlc_object_release(p_playlist);
}

zorglub's avatar
zorglub committed
464 465 466
/**********************************************************************
 * Rebuild the playlist
 **********************************************************************/
467 468 469 470 471 472 473 474 475 476
void Playlist::Rebuild()
{
    playlist_t *p_playlist =
        (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                       FIND_ANYWHERE );
    if( p_playlist == NULL )
    {
        return;
    }

zorglub's avatar
zorglub committed
477 478
    int i_focused = listview->GetFocusedItem();

479 480 481 482 483 484 485
    /* Clear the list... */
    listview->DeleteAllItems();

    /* ...and rebuild it */
    vlc_mutex_lock( &p_playlist->object_lock );
    for( int i = 0; i < p_playlist->i_size; i++ )
    {
gbazin's avatar
 
gbazin committed
486
        wxString filename = wxL2U(p_playlist->pp_items[i]->psz_name);
487
        listview->InsertItem( i, filename );
zorglub's avatar
zorglub committed
488
        UpdateItem( i );
489 490 491
    }
    vlc_mutex_unlock( &p_playlist->object_lock );

zorglub's avatar
zorglub committed
492 493 494 495 496 497 498 499 500
    if( i_focused )
    {
        listview->Focus( i_focused );
        listview->Select( i_focused );
    }
    else
    {
        listview->Focus( p_playlist->i_index );
    }
501

502 503 504
    vlc_object_release( p_playlist );
}

gbazin's avatar
 
gbazin committed
505
void Playlist::ShowPlaylist( bool show )
506
{
gbazin's avatar
 
gbazin committed
507 508 509 510 511 512 513 514 515 516 517 518 519 520 521
    if( show ) Rebuild();
    Show( show );
}

void Playlist::UpdatePlaylist()
{
    vlc_bool_t b_need_update = VLC_FALSE;
    i_update_counter++;

    /* If the playlist isn't show there's no need to update it */
    if( !IsShown() ) return;

    vlc_mutex_lock( &lock );
    if( this->b_need_update )
    {
zorglub's avatar
zorglub committed
522
        b_need_update =VLC_TRUE;
gbazin's avatar
 
gbazin committed
523 524 525 526
        this->b_need_update = VLC_FALSE;
    }
    vlc_mutex_unlock( &lock );

zorglub's avatar
zorglub committed
527 528 529 530
    if( b_need_update )
    {
        Rebuild();
    }
gbazin's avatar
 
gbazin committed
531 532 533 534

    /* Updating the playing status every 0.5s is enough */
    if( i_update_counter % 5 ) return;

535 536 537 538 539 540 541 542
    playlist_t *p_playlist =
        (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                       FIND_ANYWHERE );
    if( p_playlist == NULL )
    {
        return;
    }

gbazin's avatar
 
gbazin committed
543
    /* Update the colour of items */
zorglub's avatar
zorglub committed
544

545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588
    vlc_mutex_lock( &p_playlist->object_lock );
    if( p_intf->p_sys->i_playing != p_playlist->i_index )
    {
        wxListItem listitem;
        listitem.m_itemId = p_playlist->i_index;
        listitem.SetTextColour( *wxRED );
        listview->SetItem( listitem );

        if( p_intf->p_sys->i_playing != -1 )
        {
            listitem.m_itemId = p_intf->p_sys->i_playing;
            listitem.SetTextColour( *wxBLACK );
            listview->SetItem( listitem );
        }
        p_intf->p_sys->i_playing = p_playlist->i_index;
    }
    vlc_mutex_unlock( &p_playlist->object_lock );
    vlc_object_release( p_playlist );
}

/*****************************************************************************
 * Private methods.
 *****************************************************************************/
void Playlist::DeleteItem( int item )
{
    playlist_t *p_playlist =
        (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                       FIND_ANYWHERE );
    if( p_playlist == NULL )
    {
        return;
    }

    playlist_Delete( p_playlist, item );
    listview->DeleteItem( item );

    vlc_object_release( p_playlist );
}

void Playlist::OnClose( wxCommandEvent& WXUNUSED(event) )
{
    Hide();
}

gbazin's avatar
 
gbazin committed
589 590
void Playlist::OnSave( wxCommandEvent& WXUNUSED(event) )
{
zorglub's avatar
zorglub committed
591 592 593
    ExportPlaylist *exp_pl = new ExportPlaylist( p_intf, this);
    exp_pl->ShowModal();
    delete exp_pl;
gbazin's avatar
 
gbazin committed
594 595 596
}

void Playlist::OnOpen( wxCommandEvent& WXUNUSED(event) )
597
{
gbazin's avatar
 
gbazin committed
598 599 600 601 602 603 604 605 606
    playlist_t *p_playlist =
        (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                       FIND_ANYWHERE );
    if( p_playlist == NULL )
    {
        return;
    }

    wxFileDialog dialog( this, wxU(_("Open playlist")),
gbazin's avatar
 
gbazin committed
607
                         wxT(""), wxT(""), wxT("*"), wxOPEN );
gbazin's avatar
 
gbazin committed
608 609 610

    if( dialog.ShowModal() == wxID_OK )
    {
zorglub's avatar
zorglub committed
611
        playlist_Import( p_playlist, dialog.GetPath().mb_str() );
gbazin's avatar
 
gbazin committed
612 613 614
    }

    vlc_object_release( p_playlist );
615 616
}

gbazin's avatar
 
gbazin committed
617 618
void Playlist::OnAddFile( wxCommandEvent& WXUNUSED(event) )
{
gbazin's avatar
 
gbazin committed
619
    p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_FILE_SIMPLE, 0, 0 );
gbazin's avatar
 
gbazin committed
620

gbazin's avatar
 
gbazin committed
621
#if 0
gbazin's avatar
 
gbazin committed
622
    Rebuild();
gbazin's avatar
 
gbazin committed
623
#endif
gbazin's avatar
 
gbazin committed
624 625
}

gbazin's avatar
 
gbazin committed
626
void Playlist::OnAddMRL( wxCommandEvent& WXUNUSED(event) )
627
{
gbazin's avatar
 
gbazin committed
628
    p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_FILE, 0, 0 );
gbazin's avatar
 
gbazin committed
629

gbazin's avatar
 
gbazin committed
630
#if 0
gbazin's avatar
 
gbazin committed
631
    Rebuild();
gbazin's avatar
 
gbazin committed
632
#endif
633 634
}

zorglub's avatar
zorglub committed
635 636 637 638
/********************************************************************
 * Move functions
 ********************************************************************/
void Playlist::OnUp( wxCommandEvent& event)
zorglub's avatar
zorglub committed
639 640 641 642 643 644 645 646 647
{
    playlist_t *p_playlist =
        (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                       FIND_ANYWHERE );
    if( p_playlist == NULL )
    {
        return;
    }

zorglub's avatar
zorglub committed
648
    /* We use the first selected item, so find it */
gbazin's avatar
 
gbazin committed
649 650
    long i_item = listview->GetNextItem( i_item, wxLIST_NEXT_ALL,
                                         wxLIST_STATE_SELECTED);
zorglub's avatar
zorglub committed
651 652 653 654 655 656 657 658 659 660 661 662
    if( i_item > 0 && i_item < p_playlist->i_size )
    {
        playlist_Move( p_playlist , i_item, i_item - 1);
        if( i_item > 1 )
        {
            listview->Focus( i_item - 1 );
        }
        else
        {
            listview->Focus(0);
        }
    }
zorglub's avatar
zorglub committed
663 664 665 666
    vlc_object_release( p_playlist );
    return;
}

zorglub's avatar
zorglub committed
667
void Playlist::OnDown( wxCommandEvent& event)
zorglub's avatar
zorglub committed
668 669 670 671 672 673 674 675 676
{
    playlist_t *p_playlist =
        (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                       FIND_ANYWHERE );
    if( p_playlist == NULL )
    {
        return;
    }

zorglub's avatar
zorglub committed
677
    /* We use the first selected item, so find it */
gbazin's avatar
 
gbazin committed
678 679
    long i_item = listview->GetNextItem( i_item, wxLIST_NEXT_ALL,
                                         wxLIST_STATE_SELECTED );
zorglub's avatar
zorglub committed
680 681 682 683 684 685 686 687
    if( i_item >= 0 && i_item < p_playlist->i_size - 1 )
    {
        playlist_Move( p_playlist , i_item, i_item + 2 );
        listview->Focus( i_item + 1 );
    }
    vlc_object_release( p_playlist );
    return;
}
zorglub's avatar
zorglub committed
688

zorglub's avatar
zorglub committed
689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720
/********************************************************************
 * Sorting functions
 ********************************************************************/
void Playlist::OnSort( wxCommandEvent& event )
{
    playlist_t *p_playlist =
        (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                       FIND_ANYWHERE );
    if( p_playlist == NULL )
    {
        return;
    }
    switch( event.GetId() )
    {
        case SortTitle_Event:
           playlist_SortTitle( p_playlist , 0 );
           break;
        case RSortTitle_Event:
           playlist_SortTitle( p_playlist , 1 );
           break;
        case SortAuthor_Event:
           playlist_SortAuthor(p_playlist , 0 );
           break;
        case RSortAuthor_Event:
           playlist_SortAuthor( p_playlist , 1 );
           break;
        case SortGroup_Event:
           playlist_SortGroup( p_playlist , 0 );
           break;
        case RSortGroup_Event:
           playlist_SortGroup( p_playlist , 1 );
           break;
zorglub's avatar
zorglub committed
721
        case Randomize_Event:
722
           playlist_Sort( p_playlist , SORT_RANDOM, ORDER_NORMAL );
zorglub's avatar
zorglub committed
723
           break;
zorglub's avatar
zorglub committed
724
    }
zorglub's avatar
zorglub committed
725 726 727 728 729 730 731
    vlc_object_release( p_playlist );

    Rebuild();

    return;
}

sigmunau's avatar
sigmunau committed
732 733 734 735 736 737 738 739 740 741 742 743
void Playlist::OnColSelect( wxListEvent& event )
{
    playlist_t *p_playlist =
        (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                       FIND_ANYWHERE );
    if( p_playlist == NULL )
    {
        return;
    }
    switch( event.GetColumn() )
    {
        case 0:
744 745 746 747 748 749 750 751 752 753
            if( i_title_sorted != 1 )
            {
                playlist_SortTitle( p_playlist, 0 );
                i_title_sorted = 1;
            }
            else
            {
                playlist_SortTitle( p_playlist, 1 );
                i_title_sorted = -1;
            }
sigmunau's avatar
sigmunau committed
754 755
            break;
        case 1:
756 757 758 759 760 761 762 763 764 765
            if( i_author_sorted != 1 )
            {
                playlist_SortAuthor( p_playlist, 0 );
                i_author_sorted = 1;
            }
            else
            {
                playlist_SortAuthor( p_playlist, 1 );
                i_author_sorted = -1;
            }
sigmunau's avatar
sigmunau committed
766 767
            break;
        case 2:
768 769 770 771 772 773 774 775 776 777
            if( i_group_sorted != 1 )
            {
                playlist_SortGroup( p_playlist, 0 );
                i_group_sorted = 1;
            }
            else
            {
                playlist_SortGroup( p_playlist, 1 );
                i_group_sorted = -1;
            }
sigmunau's avatar
sigmunau committed
778 779 780 781 782 783 784 785 786 787 788
            break;
        default:
            break;
    }
    vlc_object_release( p_playlist );

    Rebuild();

    return;
}

zorglub's avatar
zorglub committed
789 790 791
/**********************************************************************
 * Search functions
 **********************************************************************/
zorglub's avatar
zorglub committed
792 793
void Playlist::OnSearchTextChange( wxCommandEvent& WXUNUSED(event) )
{
zorglub's avatar
zorglub committed
794
   search_button->SetDefault();
zorglub's avatar
zorglub committed
795 796 797 798 799 800 801
}

void Playlist::OnSearch( wxCommandEvent& WXUNUSED(event) )
{
    wxString search_string= search_text->GetValue();

    int i_current;
zorglub's avatar
zorglub committed
802
    int i_first = 0 ;
zorglub's avatar
zorglub committed
803 804
    int i_item = -1;

zorglub's avatar
zorglub committed
805
    for( i_current = 0 ; i_current <= listview->GetItemCount() ; i_current++ )
zorglub's avatar
zorglub committed
806
    {
gbazin's avatar
 
gbazin committed
807
        if( listview->GetItemState( i_current, wxLIST_STATE_SELECTED )
zorglub's avatar
zorglub committed
808 809 810 811 812
                   == wxLIST_STATE_SELECTED )
        {
            i_first = i_current;
            break;
        }
zorglub's avatar
zorglub committed
813 814
    }

zorglub's avatar
zorglub committed
815
    for ( i_current = i_first + 1; i_current <= listview->GetItemCount() ;
zorglub's avatar
zorglub committed
816
          i_current++ )
zorglub's avatar
zorglub committed
817
    {
zorglub's avatar
zorglub committed
818 819 820 821 822 823 824 825
        wxListItem listitem;
        listitem.SetId( i_current );
        listview->GetItem( listitem );
        if( listitem.m_text.Lower().Contains( search_string.Lower() ) )
        {
            i_item = i_current;
            break;
        }
zorglub's avatar
zorglub committed
826 827 828 829 830
    }
    for( long item = 0; item < listview->GetItemCount(); item++ )
    {
        listview->Select( item, FALSE );
    }
zorglub's avatar
zorglub committed
831

zorglub's avatar
zorglub committed
832 833 834 835 836 837 838 839
    wxListItem listitem;
    listitem.SetId(i_item);
    listitem.m_state = wxLIST_STATE_SELECTED;
    listview->Select( i_item, TRUE );
    listview->Focus( i_item );

}

zorglub's avatar
zorglub committed
840 841 842
/**********************************************************************
 * Selection functions
 **********************************************************************/
843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864
void Playlist::OnInvertSelection( wxCommandEvent& WXUNUSED(event) )
{
    for( long item = 0; item < listview->GetItemCount(); item++ )
    {
        listview->Select( item, ! listview->IsSelected( item ) );
    }
}

void Playlist::OnDeleteSelection( wxCommandEvent& WXUNUSED(event) )
{
    /* Delete from the end to the beginning, to avoid a shift of indices */
    for( long item = listview->GetItemCount() - 1; item >= 0; item-- )
    {
        if( listview->IsSelected( item ) )
        {
            DeleteItem( item );
        }
    }

    Rebuild();
}

zorglub's avatar
zorglub committed
865 866 867 868 869 870 871 872 873 874 875 876 877 878 879
void Playlist::OnEnableSelection( wxCommandEvent& WXUNUSED(event) )
{
    playlist_t *p_playlist =
        (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                       FIND_ANYWHERE );
    if( p_playlist == NULL )
    {
        return;
    }

    for( long item = listview->GetItemCount() - 1; item >= 0; item-- )
    {
        if( listview->IsSelected( item ) )
        {
            playlist_Enable( p_playlist, item );
zorglub's avatar
zorglub committed
880
            UpdateItem( item );
zorglub's avatar
zorglub committed
881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900
        }
    }
    vlc_object_release( p_playlist);
}

void Playlist::OnDisableSelection( wxCommandEvent& WXUNUSED(event) )
{
    playlist_t *p_playlist =
        (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                       FIND_ANYWHERE );
    if( p_playlist == NULL )
    {
        return;
    }

    for( long item = listview->GetItemCount() - 1; item >= 0; item-- )
    {
        if( listview->IsSelected( item ) )
        {
            playlist_Disable( p_playlist, item );
zorglub's avatar
zorglub committed
901
            UpdateItem( item );
zorglub's avatar
zorglub committed
902 903 904 905 906
        }
    }
    vlc_object_release( p_playlist);
}

zorglub's avatar
zorglub committed
907 908 909 910 911 912 913 914 915 916 917
void Playlist::OnSelectAll( wxCommandEvent& WXUNUSED(event) )
{
    for( long item = 0; item < listview->GetItemCount(); item++ )
    {
        listview->Select( item, TRUE );
    }
}

/**********************************************************************
 * Playlist mode functions
 **********************************************************************/
918 919
void Playlist::OnRandom( wxCommandEvent& event )
{
920 921 922 923 924 925 926 927 928 929 930
    vlc_value_t val;
    val.b_bool = event.IsChecked();
    playlist_t *p_playlist =
        (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                       FIND_ANYWHERE );
    if( p_playlist == NULL )
    {
        return;
    }
    var_Set( p_playlist , "random", val);
    vlc_object_release( p_playlist );
931 932 933
}
void Playlist::OnLoop ( wxCommandEvent& event )
{
934 935 936 937 938 939 940 941 942 943 944 945
    vlc_value_t val;
    val.b_bool = event.IsChecked();
    playlist_t *p_playlist =
        (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                       FIND_ANYWHERE );
    if( p_playlist == NULL )
    {
        return;
    }
    var_Set( p_playlist , "loop", val);
    vlc_object_release( p_playlist );
}
946

947 948 949 950 951 952 953 954 955 956 957 958 959
void Playlist::OnRepeat ( wxCommandEvent& event )
{
    vlc_value_t val;
    val.b_bool = event.IsChecked();
    playlist_t *p_playlist =
        (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                       FIND_ANYWHERE );
    if( p_playlist == NULL )
    {
        return;
    }
    var_Set( p_playlist , "repeat", val);
    vlc_object_release( p_playlist );
960 961
}

zorglub's avatar
zorglub committed
962

963 964 965 966 967 968 969 970 971 972 973 974 975 976

void Playlist::OnActivateItem( wxListEvent& event )
{
    playlist_t *p_playlist =
        (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                       FIND_ANYWHERE );
    if( p_playlist == NULL )
    {
        return;
    }
    playlist_Goto( p_playlist, event.GetIndex() );

    vlc_object_release( p_playlist );
}
zorglub's avatar
zorglub committed
977

978 979 980 981 982 983 984 985 986 987
void Playlist::OnKeyDown( wxListEvent& event )
{
    long keycode = event.GetKeyCode();
    /* Delete selected items */
    if( keycode == WXK_BACK || keycode == WXK_DELETE )
    {
        /* We send a dummy event */
        OnDeleteSelection( event );
    }
}
gbazin's avatar
 
gbazin committed
988

zorglub's avatar
zorglub committed
989
void Playlist::ShowInfos( int i_item )
zorglub's avatar
zorglub committed
990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004
{
    playlist_t *p_playlist =
        (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                       FIND_ANYWHERE );
    if( p_playlist == NULL )
    {
        return;
    }
    if( iteminfo_dialog == NULL )
    {
        if( i_item >= 0 && i_item < p_playlist->i_size )
        {
            iteminfo_dialog = new ItemInfoDialog(
                              p_intf, p_playlist->pp_items[i_item], this );
            if( iteminfo_dialog->ShowModal()  == wxID_OK )
zorglub's avatar
zorglub committed
1005
                UpdateItem( i_item );
zorglub's avatar
zorglub committed
1006 1007 1008 1009 1010 1011 1012
            delete iteminfo_dialog;
            iteminfo_dialog = NULL;
        }
    }
    vlc_object_release( p_playlist );
}

zorglub's avatar
zorglub committed
1013 1014 1015 1016 1017 1018 1019 1020
void Playlist::OnInfos( wxCommandEvent& WXUNUSED(event) )
{
    /* We use the first selected item, so find it */
    long i_item = listview->GetNextItem( -1 , wxLIST_NEXT_ALL,
                                         wxLIST_STATE_SELECTED );
    ShowInfos( i_item );
}

zorglub's avatar
zorglub committed
1021
void Playlist::OnEnDis( wxCommandEvent& event )
zorglub's avatar
zorglub committed
1022 1023 1024 1025 1026 1027 1028 1029 1030
{
    playlist_t *p_playlist =
        (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                       FIND_ANYWHERE );
    if( p_playlist == NULL )
    {
        return;
    }

gbazin's avatar
 
gbazin committed
1031 1032
    long i_item = listview->GetNextItem( i_item, wxLIST_NEXT_ALL,
                                         wxLIST_STATE_SELECTED );
zorglub's avatar
zorglub committed
1033 1034 1035

    if( i_item >= 0 && i_item < p_playlist->i_size )
    {
zorglub's avatar
zorglub committed
1036 1037 1038 1039
       switch( event.GetId() )
       {
           case EnableGroup_Event:
               playlist_EnableGroup( p_playlist ,
zorglub's avatar
zorglub committed
1040
                                  p_playlist->pp_items[i_item]->i_group );
zorglub's avatar
zorglub committed
1041 1042 1043
               break;
           case DisableGroup_Event:
               playlist_DisableGroup( p_playlist ,
zorglub's avatar
zorglub committed
1044
                                  p_playlist->pp_items[i_item]->i_group );
zorglub's avatar
zorglub committed
1045 1046
               break;
       }
zorglub's avatar
zorglub committed
1047 1048 1049 1050 1051
       Rebuild();
    }

    vlc_object_release( p_playlist );
}
zorglub's avatar
zorglub committed
1052

zorglub's avatar
zorglub committed
1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108