]> git.sesse.net Git - vlc/blobdiff - modules/gui/wxwidgets/dialogs/playlist.cpp
Input access locking. Part one
[vlc] / modules / gui / wxwidgets / dialogs / playlist.cpp
index 017b1e216921165fc20929ff174ab3a61de7ec51..5d384caa35dee98fa7ac7f7f53426eaac9e82cc6 100644 (file)
@@ -226,9 +226,8 @@ Playlist::Playlist( intf_thread_t *_p_intf, wxWindow *p_parent ):
     p_view_menu = NULL;
     p_sd_menu = SDMenu();
 
-//    i_current_view = VIEW_ONELEVEL;
-    p_current_viewroot = p_playlist->p_root_onelevel;
-    p_current_treeroot = p_playlist->p_local_onelevel;
+    p_current_viewroot = p_playlist->p_root_category;
+    p_current_treeroot = NULL;
 
     i_title_sorted = 0;
     i_group_sorted = 0;
@@ -367,8 +366,6 @@ Playlist::Playlist( intf_thread_t *_p_intf, wxWindow *p_parent ):
     p_images->Add( wxIcon( type_node_xpm ) );
     treectrl->AssignImageList( p_images );
 
-    treectrl->AddRoot( wxU(_("root" )), -1, -1, NULL );
-
     /* Reduce font size */
     wxFont font= treectrl->GetFont();
     font.SetPointSize(9);
@@ -408,8 +405,8 @@ Playlist::Playlist( intf_thread_t *_p_intf, wxWindow *p_parent ):
     var_AddCallback( p_playlist, "item-deleted", ItemDeleted, this );
 
     /* Update the playlist */
+    p_current_treeroot = p_playlist->p_local_category;
     Rebuild( VLC_TRUE );
-
 }
 
 Playlist::~Playlist()
@@ -516,14 +513,7 @@ void Playlist::UpdateTreeItem( wxTreeItemId item )
     wxString duration = wxU( "" );
 
     char *psz_artist;
-    if( p_item->p_input->p_meta )
-    {
-        psz_artist= p_item->p_input->p_meta->psz_artist ?
-                        strdup( p_item->p_input->p_meta->psz_artist ) :
-                        strdup("");
-    }
-    else
-        psz_artist = strdup( "" );
+    psz_artist = input_item_GetArtist( p_item->p_input );
 
     char psz_duration[MSTRTIME_MAX_SIZE];
     mtime_t dur = p_item->p_input->i_duration;
@@ -799,19 +789,8 @@ void Playlist::Rebuild( vlc_bool_t b_root )
 {
     i_items_to_append = 0;
 
-    /* We can remove the callbacks before locking, anyway, we won't
-     * miss anything */
-    if( b_root )
-    {
-        var_DelCallback( p_playlist, "item-change", ItemChanged, this );
-        var_DelCallback( p_playlist, "playlist-current", PlaylistNext, this );
-        var_DelCallback( p_playlist, "intf-change", PlaylistChanged, this );
-        var_DelCallback( p_playlist, "item-append", ItemAppended, this );
-        var_DelCallback( p_playlist, "item-deleted", ItemDeleted, this );
+    LockPlaylist( p_intf->p_sys, p_playlist );
 
-        /* ...and rebuild it */
-        LockPlaylist( p_intf->p_sys, p_playlist );
-    }
     /* Invalidate cache */
     i_saved_id = -1;
     i_saved_input_id = -1;
@@ -834,8 +813,6 @@ void Playlist::Rebuild( vlc_bool_t b_root )
                          new PlaylistItem( p_current_treeroot ) );
 
     wxTreeItemId root = treectrl->GetRootItem();
-    //UpdateNode( p_current_treeroot, root );
-    //CreateNode( p_current_treeroot, root );
     UpdateNodeChildren( p_current_treeroot, root );
 
     int i_count = CountItems( treectrl->GetRootItem() );
@@ -843,17 +820,7 @@ void Playlist::Rebuild( vlc_bool_t b_root )
     statusbar->SetStatusText( wxString::Format( wxU(_(
                               "%i items in playlist")), i_count ), 0 );
 
-    if( b_root )
-    {
-        /* Put callbacks back online */
-        var_AddCallback( p_playlist, "intf-change", PlaylistChanged, this );
-        var_AddCallback( p_playlist, "playlist-current", PlaylistNext, this );
-        var_AddCallback( p_playlist, "item-change", ItemChanged, this );
-        var_AddCallback( p_playlist, "item-append", ItemAppended, this );
-        var_AddCallback( p_playlist, "item-deleted", ItemDeleted, this );
-
-        UnlockPlaylist( p_intf->p_sys, p_playlist );
-    }
+    UnlockPlaylist( p_intf->p_sys, p_playlist );
 }
 
 void Playlist::ShowPlaylist( bool show )
@@ -1316,7 +1283,7 @@ bool PlaylistFileDropTarget::OnDropFiles( wxCoord x, wxCoord y,
         input_item_t *p_input = input_ItemNew( p->p_playlist,
                                               psz_utf8, psz_utf8 );
         playlist_NodeAddInput( p->p_playlist, p_input,
-                               p_dest, PLAYLIST_PREPARSE, i_pos );
+                               p_dest, PLAYLIST_PREPARSE, i_pos, VLC_FALSE );
         wxDnDLocaleFree( psz_utf8 );
     }
 
@@ -1442,7 +1409,7 @@ wxMenu *Playlist::SDMenu()
         if( !strcmp( p_parser->psz_capability, "services_discovery" ) )
             i_number++;
     }
-    if( i_number ) pp_sds = (char **)calloc( i_number, sizeof(void *) );
+    if( i_number ) pp_sds = (const char **)calloc( i_number, sizeof(void *) );
 
     i_number = 0;
     for( int i_index = 0; i_index < p_list->i_count; i_index++ )
@@ -1636,7 +1603,7 @@ void Playlist::OnPopupAddNode( wxCommandEvent& event )
 
     p_item = playlist_ItemGetById( p_playlist, p_wxitem->i_id, VLC_TRUE );
 
-    playlist_NodeCreate( p_playlist, psz_name, p_item );
+    playlist_NodeCreate( p_playlist, psz_name, p_item, 0 );
 
     UnlockPlaylist( p_intf->p_sys, p_playlist );
     Rebuild( VLC_TRUE );
@@ -1648,7 +1615,7 @@ void Playlist::OnSourceSelected( wxListEvent &event )
 {
    int i_id = event.GetData();
 
-   if( p_current_treeroot && i_id != p_current_treeroot->i_id )
+   if( !p_current_treeroot || i_id != p_current_treeroot->i_id )
    {
        playlist_item_t *p_item = playlist_ItemGetById( p_playlist, i_id,
                                                        VLC_TRUE );