+ CreateNode( p_node->pp_children[i], node );
+ }
+ }
+}
+
+/* Update an item in the tree */
+void Playlist::UpdateTreeItem( wxTreeItemId item )
+{
+ if( ! item.IsOk() ) return;
+
+ wxTreeItemData *p_data = treectrl->GetItemData( item );
+ if( !p_data ) return;
+
+ LockPlaylist( p_intf->p_sys, p_playlist );
+ playlist_item_t *p_item = playlist_ItemGetById( p_playlist,
+ ((PlaylistItem *)p_data)->i_id );
+ if( !p_item ) return;
+
+ wxString msg;
+ wxString duration = wxU( "" );
+ char *psz_author = vlc_input_item_GetInfo( &p_item->input,
+ _("Meta-information"),
+ _("Artist"));
+ if( psz_author == NULL )
+ return;
+ char psz_duration[MSTRTIME_MAX_SIZE];
+ mtime_t dur = p_item->input.i_duration;
+
+ if( dur != -1 )
+ {
+ secstotimestr( psz_duration, dur/1000000 );
+ duration.Append( wxU( " ( " ) + wxString( wxU( psz_duration ) ) +
+ wxU( " )" ) );
+ }
+
+ if( !strcmp( psz_author, "" ) || p_item->input.b_fixed_name == VLC_TRUE )
+ {
+ msg.Printf( wxString( wxU( p_item->input.psz_name ) ) + duration );
+ }
+ else
+ {
+ msg.Printf( wxString(wxU( psz_author )) + wxT(" - ") +
+ wxString(wxU(p_item->input.psz_name)) + duration );
+ }
+ free( psz_author );
+ treectrl->SetItemText( item , msg );
+ treectrl->SetItemImage( item, p_item->input.i_type );
+
+ if( p_playlist->status.p_item == p_item )
+ {
+ treectrl->SetItemBold( item, true );
+ treectrl->EnsureVisible( item );
+ }
+ else
+ {
+ treectrl->SetItemBold( item, false );
+ }
+ UnlockPlaylist( p_intf->p_sys, p_playlist );
+}
+
+/* Process a AppendIt em request */
+void Playlist::AppendItem( wxCommandEvent& event )
+{
+ playlist_add_t *p_add = (playlist_add_t *)event.GetClientData();
+
+ wxTreeItemId item,node;
+
+ if( p_add->i_view != i_current_view || !p_add->p_node )
+ {
+ goto update;
+ }
+
+ node = FindItem( treectrl->GetRootItem(), p_add->p_node->input.i_id );
+ if( !node.IsOk() )
+ {
+ goto update;
+ }
+
+ item = treectrl->AppendItem( node,
+ wxL2U( p_add->p_item->input.psz_name ), -1,-1,
+ new PlaylistItem( p_add->p_item ) );
+ treectrl->SetItemImage( item, p_add->p_item->input.i_type );
+
+ if( item.IsOk() && p_add->p_item->i_children == -1 )
+ {
+ UpdateTreeItem( item );
+ }
+
+update:
+ int i_count = CountItems( treectrl->GetRootItem());
+ if( i_count != p_playlist->i_size )
+ {
+ statusbar->SetStatusText( wxString::Format( wxU(_(
+ "%i items in playlist (%i not shown)")),
+ p_playlist->i_size,
+ p_playlist->i_size - i_count ) );
+ if( !b_changed_view )
+ {
+ i_current_view = VIEW_CATEGORY;
+ b_changed_view = VLC_TRUE;
+ b_need_update = VLC_TRUE;