X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fgui%2Fwxwidgets%2Fplaylist_manager.cpp;h=ce2628b13c5d6db3431accedd696db3943875547;hb=7ca4e3eb624251feb1f97cfc25104cce473e04a0;hp=00802a55ee1c6255b552543f101ca302cf1e1f3b;hpb=c4c65e064a6a1e6db423aa157d2d4b940336e654;p=vlc diff --git a/modules/gui/wxwidgets/playlist_manager.cpp b/modules/gui/wxwidgets/playlist_manager.cpp index 00802a55ee..ce2628b13c 100644 --- a/modules/gui/wxwidgets/playlist_manager.cpp +++ b/modules/gui/wxwidgets/playlist_manager.cpp @@ -4,8 +4,8 @@ * Copyright (C) 2000-2005 the VideoLAN team * $Id$ * - * Authors: Olivier Teulière - * Clément Stenac + * Authors: Olivier Teulière + * Clément Stenac * Gildas Bazin * * This program is free software; you can redistribute it and/OR MODIFy @@ -20,7 +20,7 @@ * * 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. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ /***************************************************************************** @@ -42,6 +42,7 @@ #include #include +#include "vlc_meta.h" namespace wxvlc { /* Callback prototype */ @@ -86,8 +87,15 @@ END_EVENT_TABLE() class PlaylistItem : public wxTreeItemData { public: - PlaylistItem( playlist_item_t *p_item ) : i_id(p_item->input.i_id) {} + PlaylistItem( playlist_item_t *p_item ) : wxTreeItemData() + { + i_id = p_item->i_id; + i_input_id = p_item->p_input->i_id; + } +protected: + int i_input_id; int i_id; +friend class PlaylistManager; }; /***************************************************************************** @@ -98,13 +106,12 @@ PlaylistManager::PlaylistManager( intf_thread_t *_p_intf, wxWindow *p_parent ): { /* Initializations */ p_intf = _p_intf; - b_need_update = VLC_FALSE; + b_need_update = false; i_items_to_append = 0; i_cached_item_id = -1; i_update_counter = 0; - p_playlist = (playlist_t *) - vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); + p_playlist = pl_Yield( p_intf ); if( p_playlist == NULL ) return; var_Create( p_intf, "random", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); @@ -148,11 +155,11 @@ PlaylistManager::PlaylistManager( intf_thread_t *_p_intf, wxWindow *p_parent ): #if wxUSE_DRAG_AND_DROP /* Associate drop targets with the playlist */ - SetDropTarget( new DragAndDrop( p_intf, VLC_TRUE ) ); + SetDropTarget( new DragAndDrop( p_intf, true ) ); #endif /* Update the playlist */ - Rebuild( VLC_TRUE ); + Rebuild( true ); /* * We want to be notified of playlist changes @@ -192,7 +199,7 @@ static int PlaylistChanged( vlc_object_t *p_this, const char *psz_variable, vlc_value_t oval, vlc_value_t nval, void *param ) { PlaylistManager *p_playlist = (PlaylistManager *)param; - p_playlist->b_need_update = VLC_TRUE; + p_playlist->b_need_update = true; return VLC_SUCCESS; } @@ -219,9 +226,9 @@ static int PlaylistNext( vlc_object_t *p_this, const char *psz_variable, void PlaylistManager::CreateNode( playlist_item_t *p_node, wxTreeItemId parent) { wxTreeItemId node = - treectrl->AppendItem( parent, wxL2U( p_node->input.psz_name ), -1, -1, + treectrl->AppendItem( parent, wxL2U( p_node->p_input->psz_name ), -1, -1, new PlaylistItem( p_node ) ); - treectrl->SetItemImage( node, p_node->input.i_type ); + treectrl->SetItemImage( node, p_node->p_input->i_type ); UpdateNodeChildren( p_node, node ); } @@ -245,7 +252,7 @@ void PlaylistManager::UpdateNode( playlist_item_t *p_node, wxTreeItemId node ) } } - treectrl->SetItemImage( node, p_node->input.i_type ); + treectrl->SetItemImage( node, p_node->p_input->i_type ); } @@ -259,7 +266,7 @@ void PlaylistManager::UpdateNodeChildren( playlist_item_t *p_node, { wxTreeItemId item = treectrl->AppendItem( node, - wxL2U( p_node->pp_children[i]->input.psz_name ), -1,-1, + wxL2U( p_node->pp_children[i]->p_input->psz_name ), -1,-1, new PlaylistItem( p_node->pp_children[i]) ); UpdateTreeItem( item ); @@ -280,7 +287,8 @@ void PlaylistManager::UpdateTreeItem( wxTreeItemId item ) LockPlaylist( p_intf->p_sys, p_playlist ); playlist_item_t *p_item = - playlist_ItemGetById( p_playlist, ((PlaylistItem *)p_data)->i_id ); + playlist_ItemGetById( p_playlist, ((PlaylistItem *)p_data)->i_id, + true ); if( !p_item ) { UnlockPlaylist( p_intf->p_sys, p_playlist ); @@ -289,17 +297,17 @@ void PlaylistManager::UpdateTreeItem( wxTreeItemId item ) wxString msg; wxString duration = wxU( "" ); - char *psz_author = - vlc_input_item_GetInfo( &p_item->input, - _("Meta-information"), _("Artist")); - if( !psz_author ) - { - UnlockPlaylist( p_intf->p_sys, p_playlist ); - return; - } + + char *psz_artist = input_item_GetArtist( p_item->p_input ); + if( !psz_artist ) + psz_artist = strdup( "" ); + + char *psz_name = input_item_GetName( p_item->p_input ); + if( !psz_name ) + psz_name = strdup( "" ); char psz_duration[MSTRTIME_MAX_SIZE]; - mtime_t dur = p_item->input.i_duration; + mtime_t dur = input_item_GetDuration( p_item->p_input ); if( dur != -1 ) { @@ -308,18 +316,19 @@ void PlaylistManager::UpdateTreeItem( wxTreeItemId item ) wxU( " )" ) ); } - if( !strcmp( psz_author, "" ) || p_item->input.b_fixed_name == VLC_TRUE ) + if( !strcmp( psz_artist, "" ) || p_item->p_input->b_fixed_name == true ) { - msg = wxString( wxU( p_item->input.psz_name ) ) + duration; + msg = wxString( wxU( psz_name ) ) + duration; } else { - msg = wxString(wxU( psz_author )) + wxT(" - ") + - wxString(wxU(p_item->input.psz_name)) + duration; + msg = wxString(wxU( psz_artist )) + wxT(" - ") + + wxString(wxU(psz_name)) + duration; } - free( psz_author ); + free( psz_artist ); + free( psz_name ); treectrl->SetItemText( item , msg ); - treectrl->SetItemImage( item, p_item->input.i_type ); + treectrl->SetItemImage( item, p_item->p_input->i_type ); if( p_playlist->status.p_item == p_item ) { @@ -353,15 +362,15 @@ void PlaylistManager::AppendItem( wxCommandEvent& event ) node = FindItem( treectrl->GetRootItem(), p_add->i_node ); if( !node.IsOk() ) goto update; - p_item = playlist_ItemGetById( p_playlist, p_add->i_item ); + p_item = playlist_ItemGetById( p_playlist, p_add->i_item, false ); if( !p_item ) goto update; item = FindItem( treectrl->GetRootItem(), p_add->i_item ); if( item.IsOk() ) goto update; - item = treectrl->AppendItem( node, wxL2U( p_item->input.psz_name ), -1,-1, + item = treectrl->AppendItem( node, wxL2U( p_item->p_input->psz_name ), -1,-1, new PlaylistItem( p_item ) ); - treectrl->SetItemImage( item, p_item->input.i_type ); + treectrl->SetItemImage( item, p_item->p_input->i_type ); if( item.IsOk() && p_item->i_children == -1 ) UpdateTreeItem( item ); @@ -401,8 +410,8 @@ void PlaylistManager::Update() if( this->b_need_update ) { - this->b_need_update = VLC_FALSE; - Rebuild( VLC_TRUE ); + this->b_need_update = false; + Rebuild( true ); } /* Updating the playing status every 0.5s is enough */ @@ -412,21 +421,17 @@ void PlaylistManager::Update() /********************************************************************** * Rebuild the playlist **********************************************************************/ -void PlaylistManager::Rebuild( vlc_bool_t b_root ) +void PlaylistManager::Rebuild( bool b_root ) { - playlist_view_t *p_view; - i_items_to_append = 0; i_cached_item_id = -1; - p_view = playlist_ViewFind( p_playlist, VIEW_CATEGORY ); - treectrl->DeleteAllItems(); treectrl->AddRoot( wxU(_("root" )), -1, -1, - new PlaylistItem( p_view->p_root ) ); + new PlaylistItem( p_playlist->p_root_category ) ); wxTreeItemId root = treectrl->GetRootItem(); - UpdateNode( p_view->p_root, root ); + UpdateNode( p_playlist->p_root_category, root ); } /********************************************************************** @@ -498,16 +503,14 @@ void PlaylistManager::OnActivateItem( wxTreeEvent& event ) if( !p_wxparent ) return; LockPlaylist( p_intf->p_sys, p_playlist ); - p_item = playlist_ItemGetById( p_playlist, p_wxitem->i_id ); - p_node = playlist_ItemGetById( p_playlist, p_wxparent->i_id ); + p_item = playlist_ItemGetById( p_playlist, p_wxitem->i_id, true ); + p_node = playlist_ItemGetById( p_playlist, p_wxparent->i_id, true ); if( !p_item || p_item->i_children >= 0 ) { p_node = p_item; p_item = NULL; } - - playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, VIEW_CATEGORY, - p_node, p_item ); + playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, true, p_node, p_item ); UnlockPlaylist( p_intf->p_sys, p_playlist ); } @@ -561,11 +564,11 @@ static int ItemAppended( vlc_object_t *p_this, const char *psz_variable, playlist_add_t *p_add = (playlist_add_t *)malloc(sizeof( playlist_add_t)); memcpy( p_add, nval.p_address, sizeof( playlist_add_t ) ); - if( p_playlist->i_items_to_append++ > 50 ) + if( ++p_playlist->i_items_to_append >= 50 ) { /* Too many items waiting to be added, it will be quicker to rebuild * the whole playlist */ - p_playlist->b_need_update = VLC_TRUE; + p_playlist->b_need_update = true; return VLC_SUCCESS; }