]> git.sesse.net Git - vlc/blobdiff - modules/gui/wxwidgets/dialogs/playlist.cpp
* Remove some unneeded complexity in playlist and directory
[vlc] / modules / gui / wxwidgets / dialogs / playlist.cpp
index c15e050bca7c3a28c6fce32296f7a835dacf6a37..d33886077cb04bb1ce055cc56ed9cd163cea08d0 100644 (file)
@@ -339,9 +339,9 @@ Playlist::Playlist( intf_thread_t *_p_intf, wxWindow *p_parent ):
     toolbar->Realize();
 
     /* Create teh source selector */
-    source_sel = new wxListCtrl( playlist_panel, Source_Event,
-                                wxDefaultPosition, wxDefaultSize,
-                                wxLC_AUTOARRANGE|wxLC_SINGLE_SEL );
+    source_sel = new wxListView( playlist_panel, Source_Event,
+                                 wxDefaultPosition, wxDefaultSize,
+                                 wxLC_AUTOARRANGE|wxLC_SINGLE_SEL );
 
     /* Create the tree */
     treectrl = new wxTreeCtrl( playlist_panel, TreeCtrl_Event,
@@ -515,15 +515,15 @@ void Playlist::UpdateTreeItem( wxTreeItemId item )
     wxString msg;
     wxString duration = wxU( "" );
 
-    char *psz_author;
+    char *psz_artist;
     if( p_item->p_input->p_meta )
     {
-        psz_author= p_item->p_input->p_meta->psz_artist ?
+        psz_artist= p_item->p_input->p_meta->psz_artist ?
                         strdup( p_item->p_input->p_meta->psz_artist ) :
                         strdup("");
     }
     else
-        psz_author = strdup( "" );
+        psz_artist = strdup( "" );
 
     char psz_duration[MSTRTIME_MAX_SIZE];
     mtime_t dur = p_item->p_input->i_duration;
@@ -535,16 +535,16 @@ void Playlist::UpdateTreeItem( wxTreeItemId item )
                          wxU( " )" ) );
     }
 
-    if( !strcmp( psz_author, "" ) || p_item->p_input->b_fixed_name == VLC_TRUE )
+    if( !strcmp( psz_artist, "" ) || p_item->p_input->b_fixed_name == VLC_TRUE )
     {
         msg = wxString( wxU( p_item->p_input->psz_name ) ) + duration;
     }
     else
     {
-        msg = wxString(wxU( psz_author )) + wxT(" - ") +
+        msg = wxString(wxU( psz_artist )) + wxT(" - ") +
               wxString(wxU(p_item->p_input->psz_name)) + duration;
     }
-    free( psz_author );
+    free( psz_artist );
     treectrl->SetItemText( item , msg );
     treectrl->SetItemImage( item, p_item->p_input->i_type );
 
@@ -932,13 +932,13 @@ void Playlist::OnSave( wxCommandEvent& WXUNUSED(event) )
         char *psz_desc;
         char *psz_filter;
         char *psz_module;
-    } formats[] = {{ _("M3U file"), "*.m3u", "export-m3u" },
+    } formats[] = {//{ _("M3U file"), "*.m3u", "export-m3u" },
                    { _("XSPF playlist"), "*.xspf", "export-xspf"}
     };
 
     wxString filter = wxT("");
 
-    if( p_playlist->i_size == 0 )
+    if( playlist_IsEmpty( p_playlist ) )
     {
         wxMessageBox( wxU(_("Playlist is empty") ), wxU(_("Can't save")),
                       wxICON_WARNING | wxOK, this );
@@ -959,10 +959,13 @@ void Playlist::OnSave( wxCommandEvent& WXUNUSED(event) )
     {
         if( dialog.GetPath().mb_str() )
         {
-              abort();
-//            playlist_Export( p_playlist, dialog.GetPath().mb_str(),
-//                             /* ROOT */
-//                             formats[dialog.GetFilterIndex()].psz_module );
+            /* what root should we export? */
+            if( p_playlist->p_root_category->i_children > 0 )
+            {
+                playlist_Export( p_playlist, dialog.GetPath().mb_str(),
+                                 p_playlist->p_root_category->pp_children[0],
+                                 formats[dialog.GetFilterIndex()].psz_module );
+            }
         }
     }
 
@@ -971,7 +974,7 @@ void Playlist::OnSave( wxCommandEvent& WXUNUSED(event) )
 void Playlist::OnOpen( wxCommandEvent& WXUNUSED(event) )
 {
     wxFileDialog dialog( this, wxU(_("Open playlist")), wxT(""), wxT(""),
-        wxT("All playlists|*.pls;*.m3u;*.asx;*.b4s;*.xspf|XSPF playlist|*.xspf|M3U files|*.m3u"), wxOPEN );
+        wxT("All playlists|" EXTENSIONS_PLAYLIST "|XSPF playlist|*.xspf|M3U files|*.m3u"), wxOPEN );
 
     if( dialog.ShowModal() == wxID_OK )
     {
@@ -1124,8 +1127,7 @@ void Playlist::OnActivateItem( wxTreeEvent& event )
 
     if( p_parent )
     {
-        playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, 1242,
-                          p_parent, p_item );
+        playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, p_parent, p_item );
     }
     UnlockPlaylist( p_intf->p_sys, p_playlist );
 }
@@ -1168,7 +1170,7 @@ void Playlist::OnDragItemEnd( wxTreeEvent& event )
 
     if( !dest_tree_item.IsOk() ) return;
 
-    /* check that we're not trying to move a node into one of it's children */
+    /* check that we're not trying to move a node into one of its children */
     wxTreeItemId parent = dest_tree_item;
     while( parent != treectrl->GetRootItem() )
     {
@@ -1271,7 +1273,7 @@ bool PlaylistFileDropTarget::OnDropFiles( wxCoord x, wxCoord y,
         {
             /* This is a leaf. Append right after it
              * We thus need to find the parrent node and the position of the
-             * leaf in it's children list */
+             * leaf in its children list */
             wxTreeItemId parent = p->treectrl->GetItemParent( item );
             PlaylistItem *p_parent =
                 (PlaylistItem *)p->treectrl->GetItemData( parent );
@@ -1300,7 +1302,7 @@ bool PlaylistFileDropTarget::OnDropFiles( wxCoord x, wxCoord y,
     /* Put the items in the playlist node */
     for( size_t i = 0; i < filenames.GetCount(); i++ )
     {
-        const char *psz_utf8 = wxDnDFromLocale( filenames[i] );
+        char *psz_utf8 = wxDnDFromLocale( filenames[i] );
         input_item_t *p_input = input_ItemNew( p->p_playlist,
                                               psz_utf8, psz_utf8 );
         playlist_NodeAddInput( p->p_playlist, p_input,
@@ -1522,8 +1524,8 @@ void Playlist::OnPopupPlay( wxCommandEvent& event )
 
     if( p_popup_parent )
     {
-        playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, 1242,
-                          p_popup_parent, p_popup_item );
+        playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, p_popup_parent,
+                          p_popup_item );
     }
     UnlockPlaylist( p_intf->p_sys, p_playlist );
 }
@@ -1650,16 +1652,12 @@ void Playlist::OnPlaylistEvent( wxCommandEvent& event )
     switch( event.GetId() )
     {
         case UpdateItem_Event:
-            fprintf( stderr,"Update input item id %i\n", event.GetInt() );
             UpdateItem( event.GetInt() );
             break;
         case AppendItem_Event:
-            fprintf( stderr,"Append item id %i\n",
-                         ((playlist_add_t*)event.GetClientData())->i_item );
             AppendItem( event );
             break;
         case RemoveItem_Event:
-            fprintf( stderr,"Remove item id %i\n", event.GetInt() );
             RemoveItem( event.GetInt() );
             break;
     }