]> git.sesse.net Git - vlc/blobdiff - modules/gui/wince/playlist.cpp
playlist_DeleteFromInput: pass the input item rather than its ID
[vlc] / modules / gui / wince / playlist.cpp
index dca6f6c10ea5feeed4d6f6f32b5b9cf254fea678..8eebda56a780f0c1dfc2c98d9dd227870b9d5a03 100644 (file)
@@ -31,6 +31,7 @@
 
 #include <vlc_common.h>
 #include <vlc_interface.h>
+#include <vlc_playlist.h>
 
 #include "wince.h"
 
@@ -80,21 +81,21 @@ enum
 // The TBBUTTON structure contains information the toolbar buttons.
 static TBBUTTON tbButton2[] =
 {
-  {0, ID_MANAGE_OPENPL,        TBSTATE_ENABLED, TBSTYLE_BUTTON},
-  {1, ID_MANAGE_SAVEPL,       TBSTATE_ENABLED, TBSTYLE_BUTTON},
-  {0, 0,              TBSTATE_ENABLED, TBSTYLE_SEP},
-  {2, ID_MANAGE_ADDFILE,       TBSTATE_ENABLED, TBSTYLE_BUTTON},
-  {3, ID_MANAGE_ADDMRL,        TBSTATE_ENABLED, TBSTYLE_BUTTON},
-  {4, ID_SEL_DELETE,       TBSTATE_ENABLED, TBSTYLE_BUTTON},
-  {0, 0,              TBSTATE_ENABLED, TBSTYLE_SEP},
-  {5, Infos_Event,      TBSTATE_ENABLED, TBSTYLE_BUTTON},
-  {0, 0,              TBSTATE_ENABLED, TBSTYLE_SEP},
-  {6, Up_Event,      TBSTATE_ENABLED, TBSTYLE_BUTTON},
-  {7, Down_Event,      TBSTATE_ENABLED, TBSTYLE_BUTTON},
-  {0, 0,              TBSTATE_ENABLED, TBSTYLE_SEP},
-  {8, Random_Event,      TBSTATE_ENABLED, TBSTYLE_CHECK},
-  {9, Loop_Event,       TBSTATE_ENABLED, TBSTYLE_CHECK},
-  {10, Repeat_Event,       TBSTATE_ENABLED, TBSTYLE_CHECK}
+  {0,  ID_MANAGE_OPENPL,        TBSTATE_ENABLED, TBSTYLE_BUTTON },
+  {1,  ID_MANAGE_SAVEPL,        TBSTATE_ENABLED, TBSTYLE_BUTTON },
+  {0,  0,                       TBSTATE_ENABLED, TBSTYLE_SEP    },
+  {2,  ID_MANAGE_ADDFILE,       TBSTATE_ENABLED, TBSTYLE_BUTTON },
+  {3,  ID_MANAGE_ADDMRL,        TBSTATE_ENABLED, TBSTYLE_BUTTON },
+  {4,  ID_SEL_DELETE,           TBSTATE_ENABLED, TBSTYLE_BUTTON },
+  {0,  0,                       TBSTATE_ENABLED, TBSTYLE_SEP    },
+  {5,  Infos_Event,             TBSTATE_ENABLED, TBSTYLE_BUTTON },
+  {0,  0,                       TBSTATE_ENABLED, TBSTYLE_SEP    },
+  {6,  Up_Event,                TBSTATE_ENABLED, TBSTYLE_BUTTON },
+  {7,  Down_Event,              TBSTATE_ENABLED, TBSTYLE_BUTTON },
+  {0,  0,                       TBSTATE_ENABLED, TBSTYLE_SEP    },
+  {8,  Random_Event,            TBSTATE_ENABLED, TBSTYLE_CHECK  },
+  {9,  Loop_Event,              TBSTATE_ENABLED, TBSTYLE_CHECK  },
+  {10, Repeat_Event,            TBSTATE_ENABLED, TBSTYLE_CHECK  }
 };
 
 // Toolbar ToolTips
@@ -288,7 +289,7 @@ LRESULT Playlist::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
 
         // random, loop, repeat buttons states
         vlc_value_t val;
-        p_playlist = pl_Yield( p_intf );
+        p_playlist = pl_Hold( p_intf );
         if( !p_playlist ) break;
 
         var_Get( p_playlist , "random", &val );
@@ -303,7 +304,7 @@ LRESULT Playlist::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
         bState = val.b_bool ? TBSTATE_CHECKED : 0;
         SendMessage( hwndTB, TB_SETSTATE, Repeat_Event,
                      MAKELONG(bState | TBSTATE_ENABLED, 0) );
-        pl_Release( p_playlist );
+        pl_Release( p_intf );
 
         GetClientRect( hwnd, &rect );
         hListView = CreateWindow( WC_LISTVIEW, NULL, WS_VISIBLE | WS_CHILD |
@@ -516,29 +517,33 @@ LRESULT Playlist::ProcessCustomDraw( LPARAM lParam )
         return CDRF_NOTIFYITEMDRAW;
 
     case CDDS_ITEMPREPAINT: //Before an item is drawn
-        playlist_t *p_playlist = pl_Yield( p_intf );
+        playlist_t *p_playlist = pl_Hold( p_intf );
         if( p_playlist == NULL ) return CDRF_DODEFAULT;
-        if( (int)lplvcd->nmcd.dwItemSpec == p_playlist->i_index )
+        if( (int)lplvcd->nmcd.dwItemSpec == p_playlist->i_current_index )
         {
             lplvcd->clrText = RGB(255,0,0);
-            pl_Release( p_playlist );
+            pl_Release( p_intf );
             return CDRF_NEWFONT;
         }
-        playlist_item_t *p_item = playlist_ItemGetByPos( p_playlist,
+
+        PL_LOCK;
+        playlist_item_t *p_item = playlist_ItemGetById( p_playlist,
                                         (int)lplvcd->nmcd.dwItemSpec );
         if( !p_item )
         {
-            pl_Release( p_playlist );
+            PL_UNLOCK;
+            pl_Release( p_intf );
             return CDRF_DODEFAULT;
         }
-        if( p_item->b_enabled == false )
+        if( p_item->i_flags & PLAYLIST_DBL_FLAG )
         {
             lplvcd->clrText = RGB(192,192,192);
-            pl_Release( p_playlist );
+            PL_UNLOCK;
+            pl_Release( p_intf );
             return CDRF_NEWFONT;
         }
-        pl_Release( p_playlist );
+        PL_UNLOCK;
+        pl_Release( p_intf );
     }
 
     return CDRF_DODEFAULT;
@@ -588,23 +593,23 @@ void Playlist::UpdatePlaylist()
         b_need_update = false;
     }
  
-    playlist_t *p_playlist = pl_Yield( p_intf );
+    playlist_t *p_playlist = pl_Hold( p_intf );
     if( p_playlist == NULL ) return;
  
     /* Update the colour of items */
 
-    vlc_object_lock( p_playlist );
-    if( p_intf->p_sys->i_playing != p_playlist->i_index )
+    PL_LOCK;
+    if( p_intf->p_sys->i_playing != playlist_CurrentSize( p_playlist ) )
     {
         // p_playlist->i_index in RED
         Rebuild();
 
         // if exists, p_intf->p_sys->i_playing in BLACK
-        p_intf->p_sys->i_playing = p_playlist->i_index;
+        p_intf->p_sys->i_playing = p_playlist->i_current_index;
     }
-    vlc_object_unlock( p_playlist );
+    PL_UNLOCK;
 
-    pl_Release( p_playlist );
+    pl_Release( p_intf );
 }
 
 /**********************************************************************
@@ -612,7 +617,7 @@ void Playlist::UpdatePlaylist()
  **********************************************************************/
 void Playlist::Rebuild()
 {
-    playlist_t *p_playlist = pl_Yield( p_intf );
+    playlist_t *p_playlist = pl_Hold( p_intf );
     if( p_playlist == NULL ) return;
 
     int i_focused =
@@ -622,21 +627,28 @@ void Playlist::Rebuild()
     ListView_DeleteAllItems( hListView );
 
     /* ...and rebuild it */
-    vlc_object_lock( p_playlist );
-    for( int i = 0; i < p_playlist->i_size; i++ )
+    PL_LOCK;
+    playlist_item_t * p_root = p_playlist->p_local_onelevel;
+    playlist_item_t * p_child = NULL;
+
+    int iItem = 0;
+
+    while( ( p_child = playlist_GetNextLeaf( p_playlist, p_root, p_child, FALSE, FALSE ) ) )
     {
         LVITEM lv;
         lv.mask = LVIF_TEXT;
         lv.pszText = _T("");
         lv.cchTextMax = 1;
         lv.iSubItem = 0;
-        lv.iItem = i;
+        lv.iItem = iItem;
         ListView_InsertItem( hListView, &lv );
         ListView_SetItemText( hListView, lv.iItem, 0,
-            _FROMMB(p_playlist->pp_items[i]->input.psz_name) );
-        UpdateItem( i );
+            _FROMMB(p_child->p_input->psz_name) );
+
+        UpdateItem( p_child->i_id );
+        iItem++;
     }
-    vlc_object_unlock( p_playlist );
+    PL_UNLOCK;
 
     if ( i_focused )
         ListView_SetItemState( hListView, i_focused, LVIS_FOCUSED |
@@ -645,7 +657,7 @@ void Playlist::Rebuild()
         ListView_SetItemState( hListView, i_focused, LVIS_FOCUSED,
                                LVIS_STATEIMAGEMASK );
 
-    pl_Release( p_playlist );
+    pl_Release( p_intf );
 }
 
 /**********************************************************************
@@ -653,45 +665,50 @@ void Playlist::Rebuild()
  **********************************************************************/
 void Playlist::UpdateItem( int i )
 {
-    playlist_t *p_playlist = pl_Yield( p_intf );
+    playlist_t *p_playlist = pl_Hold( p_intf );
 
     if( p_playlist == NULL ) return;
 
-    playlist_item_t *p_item = playlist_ItemGetByPos( p_playlist, i );
+    PL_LOCK;
+    playlist_item_t *p_item = playlist_ItemGetById( p_playlist, i );
 
     if( !p_item )
     {
-        pl_Release(p_playlist);
+        PL_UNLOCK;
+        pl_Release( p_intf );
         return;
     }
 
-    ListView_SetItemText( hListView, i, 0, _FROMMB(p_item->input.psz_name) );
+    ListView_SetItemText( hListView, i, 0, _FROMMB(p_item->p_input->psz_name) );
+
     ListView_SetItemText( hListView, i, 1,
-                          _FROMMB( input_ItemGetInfo( &p_item->input,
+                          _FROMMB( input_item_GetInfo( p_item->p_input,
                                    _("General") , _("Author") ) ) );
 
     char psz_duration[MSTRTIME_MAX_SIZE];
-    mtime_t dur = input_item_GetDuration( p_item );
+    mtime_t dur = input_item_GetDuration( p_item->p_input );
+    PL_UNLOCK;
+
     if( dur != -1 ) secstotimestr( psz_duration, dur/1000000 );
     else memcpy( psz_duration , "-:--:--", sizeof("-:--:--") );
 
-    ListView_SetItemText( hListView, i, 3, _FROMMB(psz_duration) );
+    ListView_SetItemText( hListView, i, 2, _FROMMB(psz_duration) );
 
-    pl_Release(p_playlist);
+    pl_Release( p_intf );
 }
 
 /**********************************************************************
  * Private functions
  **********************************************************************/
-void Playlist::DeleteItem( initem )
+void Playlist::DeleteItem( input_item_t *item )
 {
-    playlist_t *p_playlist = pl_Yield( p_intf );
+    playlist_t *p_playlist = pl_Hold( p_intf );
     if( p_playlist == NULL ) return;
 
-    playlist_Delete( p_playlist, item );
+    playlist_DeleteFromInput( p_playlist, item, FALSE );
     ListView_DeleteItem( hListView, item );
 
-    pl_Release( p_playlist );
+    pl_Release( p_intf );
 }
 
 /**********************************************************************
@@ -703,12 +720,12 @@ static void OnOpenCB( intf_dialog_args_t *p_arg )
 
     if( p_arg->i_results && p_arg->psz_results[0] )
     {
-        playlist_t * p_playlist = pl_Yield( p_intf );
+        playlist_t * p_playlist = pl_Hold( p_intf );
 
         if( p_playlist )
         {
             playlist_Import( p_playlist, p_arg->psz_results[0] );
-            pl_Release( p_playlist );
+            pl_Release( p_intf );
         }
     }
 }
@@ -735,7 +752,7 @@ static void OnSaveCB( intf_dialog_args_t *p_arg )
 
     if( p_arg->i_results && p_arg->psz_results[0] )
     {
-        playlist_t * p_playlist = pl_Yield( p_intf );
+        playlist_t * p_playlist = pl_Hold( p_intf );
 
         if( p_playlist )
         {
@@ -746,8 +763,8 @@ static void OnSaveCB( intf_dialog_args_t *p_arg )
                 psz_export = "export-pls";
             else psz_export = "export-m3u";
 
-            playlist_Export( p_playlist, p_arg->psz_results[0], psz_export );
-            pl_Release( p_playlist );
+            playlist_Export( p_playlist, p_arg->psz_results[0], p_playlist->p_local_onelevel, psz_export );
+            pl_Release( p_intf );
         }
     }
 }
@@ -800,7 +817,7 @@ void Playlist::OnInvertSelection()
 
 void Playlist::OnEnableSelection()
 {
-    playlist_t *p_playlist = pl_Yield( p_intf );
+    playlist_t *p_playlist = pl_Hold( p_intf );
     if( p_playlist == NULL ) return;
 
     for( long item = ListView_GetItemCount( hListView ) - 1;
@@ -808,18 +825,19 @@ void Playlist::OnEnableSelection()
     {
         if( ListView_GetItemState( hListView, item, LVIS_SELECTED ) )
         {
-            playlist_item_t *p_item =
-                playlist_ItemGetByPos( p_playlist, item );
-            playlist_Enable( p_playlist, p_item );
+            PL_LOCK;
+            playlist_item_t *p_item = playlist_ItemGetById( p_playlist, item );
+            p_item->i_flags ^= PLAYLIST_DBL_FLAG;
+            PL_UNLOCK;
             UpdateItem( item );
         }
     }
-    pl_Release( p_playlist);
+    pl_Release( p_intf );
 }
 
 void Playlist::OnDisableSelection()
 {
-    playlist_t *p_playlist = pl_Yield( p_intf );
+    playlist_t *p_playlist = pl_Hold( p_intf );
     if( p_playlist == NULL ) return;
 
     for( long item = ListView_GetItemCount( hListView ) - 1;
@@ -827,14 +845,14 @@ void Playlist::OnDisableSelection()
     {
         if( ListView_GetItemState( hListView, item, LVIS_SELECTED ) )
         {
-            /*XXX*/
-            playlist_item_t *p_item =
-                playlist_ItemGetByPos( p_playlist, item );
-            playlist_Disable( p_playlist, p_item );
+            PL_LOCK;
+            playlist_item_t *p_item = playlist_ItemGetById( p_playlist, item );
+            p_item->i_flags |= PLAYLIST_DBL_FLAG;
+            PL_UNLOCK;
             UpdateItem( item );
         }
     }
-    pl_Release( p_playlist);
+    pl_Release( p_intf );
 }
 
 void Playlist::OnSelectAll()
@@ -848,33 +866,32 @@ void Playlist::OnSelectAll()
 
 void Playlist::OnActivateItem( int i_item )
 {
-    playlist_t *p_playlist = pl_Yield( p_intf );
+    playlist_t *p_playlist = pl_Hold( p_intf );
     if( p_playlist == NULL ) return;
 
-    playlist_Goto( p_playlist, i_item );
+    playlist_Skip( p_playlist, i_item - p_playlist->i_current_index );
 
-    pl_Release( p_playlist );
+    pl_Release( p_intf );
 }
 
 void Playlist::ShowInfos( HWND hwnd, int i_item )
 {
-    playlist_t *p_playlist = pl_Yield( p_intf );
+    playlist_t *p_playlist = pl_Hold( p_intf );
     if( p_playlist == NULL ) return;
 
-    vlc_object_lock( p_playlist);
-    playlist_item_t *p_item = playlist_ItemGetByPos( p_playlist, i_item );
-    vlc_object_unlock( p_playlist );
-
+    PL_LOCK;
+    playlist_item_t *p_item = playlist_ItemGetById( p_playlist, i_item );
     if( p_item )
     {
         ItemInfoDialog *iteminfo_dialog =
             new ItemInfoDialog( p_intf, this, hInst, p_item );
+        PL_UNLOCK;
         CreateDialogBox( hwnd, iteminfo_dialog );
         UpdateItem( i_item );
         delete iteminfo_dialog;
     }
 
-    pl_Release( p_playlist );
+    pl_Release( p_intf );
 }
 
 /********************************************************************
@@ -882,16 +899,16 @@ void Playlist::ShowInfos( HWND hwnd, int i_item )
  ********************************************************************/
 void Playlist::OnUp()
 {
-    playlist_t *p_playlist = pl_Yield( p_intf );
+    playlist_t *p_playlist = pl_Hold( p_intf );
     if( p_playlist == NULL ) return;
 
     /* We use the first selected item, so find it */
     long i_item =
         ListView_GetNextItem( hListView, -1, LVIS_SELECTED | LVNI_ALL );
 
-    if( i_item > 0 && i_item < p_playlist->i_size )
+    if( i_item > 0 && i_item < playlist_CurrentSize( p_playlist ) )
     {
-        playlist_Move( p_playlist , i_item, i_item - 1);
+        playlist_Prev( p_playlist );
         if( i_item > 1 )
         {
             ListView_SetItemState( hListView, i_item - 1, LVIS_FOCUSED,
@@ -903,27 +920,27 @@ void Playlist::OnUp()
                                    LVIS_STATEIMAGEMASK );
         }
     }
-    pl_Release( p_playlist );
+    pl_Release( p_intf );
 
     return;
 }
 
 void Playlist::OnDown()
 {
-    playlist_t *p_playlist = pl_Yield( p_intf );
+    playlist_t *p_playlist = pl_Hold( p_intf );
     if( p_playlist == NULL ) return;
 
     /* We use the first selected item, so find it */
     long i_item =
         ListView_GetNextItem( hListView, -1, LVIS_SELECTED | LVNI_ALL );
 
-    if( i_item >= 0 && i_item < p_playlist->i_size - 1 )
+    if( i_item >= 0 && i_item < playlist_CurrentSize( p_playlist ) - 1 )
     {
-        playlist_Move( p_playlist , i_item, i_item + 2 );
+        playlist_Next( p_playlist );
         ListView_SetItemState( hListView, i_item + 1, LVIS_FOCUSED,
                                LVIS_STATEIMAGEMASK );
     }
-    pl_Release( p_playlist );
+    pl_Release( p_intf );
 
     return;
 }
@@ -937,11 +954,11 @@ void Playlist::OnRandom()
     int bState = SendMessage( hwndTB, TB_GETSTATE, Random_Event, 0 );
     val.b_bool = (bState & TBSTATE_CHECKED) ? true : false;
 
-    playlist_t *p_playlist = pl_Yield( p_intf );
+    playlist_t *p_playlist = pl_Hold( p_intf );
     if( p_playlist == NULL ) return;
 
     var_Set( p_playlist , "random", val );
-    pl_Release( p_playlist );
+    pl_Release( p_intf );
 }
 
 void Playlist::OnLoop ()
@@ -950,11 +967,11 @@ void Playlist::OnLoop ()
     int bState = SendMessage( hwndTB, TB_GETSTATE, Loop_Event, 0 );
     val.b_bool = (bState & TBSTATE_CHECKED) ? true : false;
 
-    playlist_t *p_playlist = pl_Yield( p_intf );
+    playlist_t *p_playlist = pl_Hold( p_intf );
     if( p_playlist == NULL ) return;
 
     var_Set( p_playlist , "loop", val );
-    pl_Release( p_playlist );
+    pl_Release( p_intf );
 }
 
 void Playlist::OnRepeat ()
@@ -963,11 +980,11 @@ void Playlist::OnRepeat ()
     int bState = SendMessage( hwndTB, TB_GETSTATE, Repeat_Event, 0 );
     val.b_bool = (bState & TBSTATE_CHECKED) ? true : false;
 
-    playlist_t *p_playlist = pl_Yield( p_intf );
+    playlist_t *p_playlist = pl_Hold( p_intf );
     if( p_playlist == NULL ) return;
 
     var_Set( p_playlist , "repeat", val );
-    pl_Release( p_playlist );
+    pl_Release( p_intf );
 }
 
 /********************************************************************
@@ -975,29 +992,34 @@ void Playlist::OnRepeat ()
  ********************************************************************/
 void Playlist::OnSort( UINT event )
 {
-    playlist_t *p_playlist = pl_Yield( p_intf );
+    playlist_t *p_playlist = pl_Hold( p_intf );
     if( p_playlist == NULL ) return;
 
     switch( event )
     {
     case ID_SORT_TITLE:
-        playlist_SortTitle( p_playlist , ORDER_NORMAL );
+        playlist_RecursiveNodeSort(p_playlist , p_playlist->p_root_onelevel,
+                                    SORT_TITLE, ORDER_NORMAL);
         break;
     case ID_SORT_RTITLE:
-        playlist_SortTitle( p_playlist , ORDER_REVERSE );
+        playlist_RecursiveNodeSort(p_playlist , p_playlist->p_root_onelevel,
+                                    SORT_TITLE, ORDER_REVERSE );
         break;
     case ID_SORT_AUTHOR:
-        playlist_SortAuthor(p_playlist , ORDER_NORMAL );
+        playlist_RecursiveNodeSort(p_playlist , p_playlist->p_root_onelevel,
+                                    SORT_ARTIST, ORDER_NORMAL);
         break;
     case ID_SORT_RAUTHOR:
-        playlist_SortAuthor( p_playlist , ORDER_REVERSE );
+        playlist_RecursiveNodeSort(p_playlist , p_playlist->p_root_onelevel,
+                                    SORT_ARTIST, ORDER_REVERSE);
         break;
     case ID_SORT_SHUFFLE:
-        playlist_Sort( p_playlist , SORT_RANDOM, ORDER_NORMAL );
+        playlist_RecursiveNodeSort(p_playlist , p_playlist->p_root_onelevel,
+                                    SORT_RANDOM, ORDER_NORMAL);
         break;
     }
 
-    pl_Release( p_playlist );
+    pl_Release( p_intf );
 
     b_need_update = true;
 
@@ -1006,7 +1028,7 @@ void Playlist::OnSort( UINT event )
 
 void Playlist::OnColSelect( int iSubItem )
 {
-    playlist_t *p_playlist = pl_Yield( p_intf );
+    playlist_t *p_playlist = pl_Hold( p_intf );
     if( p_playlist == NULL ) return;
 
     switch( iSubItem )
@@ -1014,24 +1036,28 @@ void Playlist::OnColSelect( int iSubItem )
     case 0:
         if( i_title_sorted != 1 )
         {
-            playlist_SortTitle( p_playlist, ORDER_NORMAL );
+            playlist_RecursiveNodeSort(p_playlist , p_playlist->p_root_onelevel,
+                                    SORT_TITLE, ORDER_NORMAL);
             i_title_sorted = 1;
         }
         else
         {
-            playlist_SortTitle( p_playlist, ORDER_REVERSE );
+            playlist_RecursiveNodeSort(p_playlist , p_playlist->p_root_onelevel,
+                                    SORT_TITLE, ORDER_REVERSE );
             i_title_sorted = -1;
         }
         break;
     case 1:
         if( i_author_sorted != 1 )
         {
-            playlist_SortAuthor( p_playlist, ORDER_NORMAL );
+            playlist_RecursiveNodeSort(p_playlist , p_playlist->p_root_onelevel,
+                                    SORT_ARTIST, ORDER_NORMAL);
             i_author_sorted = 1;
         }
         else
         {
-            playlist_SortAuthor( p_playlist, ORDER_REVERSE );
+            playlist_RecursiveNodeSort(p_playlist , p_playlist->p_root_onelevel,
+                                    SORT_ARTIST, ORDER_REVERSE);
             i_author_sorted = -1;
         }
         break;
@@ -1039,7 +1065,7 @@ void Playlist::OnColSelect( int iSubItem )
         break;
     }
 
-    pl_Release( p_playlist );
+    pl_Release( p_intf );
 
     b_need_update = true;
 
@@ -1054,15 +1080,15 @@ void Playlist::OnPopupPlay()
     int i_popup_item =
         ListView_GetNextItem( hListView, -1, LVIS_SELECTED | LVNI_ALL );
 
-    playlist_t *p_playlist = pl_Yield( p_intf );
+    playlist_t *p_playlist = pl_Hold( p_intf );
     if( p_playlist == NULL ) return;
 
     if( i_popup_item != -1 )
     {
-        playlist_Goto( p_playlist, i_popup_item );
+        playlist_Skip( p_playlist, i_popup_item - p_playlist->i_current_index );
     }
 
-    pl_Release( p_playlist );
+    pl_Release( p_intf );
 }
 
 void Playlist::OnPopupDel()
@@ -1078,23 +1104,24 @@ void Playlist::OnPopupEna()
     int i_popup_item =
         ListView_GetNextItem( hListView, -1, LVIS_SELECTED | LVNI_ALL );
 
-    playlist_t *p_playlist = pl_Yield( p_intf );
+    playlist_t *p_playlist = pl_Hold( p_intf );
     if( p_playlist == NULL ) return;
 
-    playlist_item_t *p_item =
-        playlist_ItemGetByPos( p_playlist, i_popup_item );
+    PL_LOCK;
+    playlist_item_t *p_item = playlist_ItemGetById( p_playlist, i_popup_item );
 
-    if( p_playlist->pp_items[i_popup_item]->b_enabled )
+    if( !(p_playlist->items.p_elems[i_popup_item]->i_flags & PLAYLIST_DBL_FLAG) )
         //playlist_IsEnabled( p_playlist, i_popup_item ) )
     {
-        playlist_Disable( p_playlist, p_item );
+        p_item->i_flags |= PLAYLIST_DBL_FLAG;
     }
     else
     {
-        playlist_Enable( p_playlist, p_item );
+        p_item->i_flags ^= PLAYLIST_DBL_FLAG;
     }
 
-    pl_Release( p_playlist);
+    PL_UNLOCK;
+    pl_Release( p_intf );
     UpdateItem( i_popup_item );
 }