]> git.sesse.net Git - vlc/commitdiff
src/control: Implement flat_media_list_view construction.
authorPierre d'Herbemont <pdherbemont@videolan.org>
Mon, 19 Nov 2007 14:06:52 +0000 (14:06 +0000)
committerPierre d'Herbemont <pdherbemont@videolan.org>
Mon, 19 Nov 2007 14:06:52 +0000 (14:06 +0000)
src/control/flat_media_list_view.c
src/control/libvlc_internal.h
src/control/media_list_view.c

index d493ac7c12bf1f8072e54c89f63b8967f7a4df60..9c3942d82ac5d8659f1be1adcd0b84041c2dbd5a 100644 (file)
@@ -42,8 +42,32 @@ struct libvlc_media_list_view_private_t
 /*
  * Private functions
  */
-static void flat_media_list_view_release( libvlc_media_list_view_t * p_mlv );
 
+/**************************************************************************
+ *       ml_item_added  (private) (Callback from media_list_view item_added)
+ **************************************************************************/
+static void
+ml_item_added( const libvlc_event_t * p_event, libvlc_media_list_view_t * p_mlv )
+{
+    libvlc_media_descriptor_t * p_md = p_event->u.media_list_item_added.item;
+    libvlc_media_descriptor_retain( p_md );
+    vlc_array_append( &p_mlv->p_this_view_data->array, p_md );
+}
+
+/**************************************************************************
+ *       ml_item_removed  (private) (Callback from media_list_view)
+ **************************************************************************/
+static void
+ml_item_removed( const libvlc_event_t * p_event, libvlc_media_list_view_t * p_mlv )
+{
+    libvlc_media_descriptor_t * p_md = p_event->u.media_list_item_deleted.item;
+    int i = vlc_array_index_of_item( &p_mlv->p_this_view_data->array, p_md );
+    if( i >= 0 )
+    {
+        vlc_array_remove( &p_mlv->p_this_view_data->array, i );
+        libvlc_media_descriptor_release( p_md );
+    }
+}
 
 /**************************************************************************
  *       flat_media_list_view_count  (private)
@@ -120,5 +144,9 @@ libvlc_media_list_flat_view( libvlc_media_list_t * p_mlist,
                                         flat_media_list_view_release,
                                         p_this_view_data,
                                         p_e );
+    libvlc_media_list_view_set_ml_notification_callback( p_mlv,
+        ml_item_added,
+        ml_item_removed );
+
     return p_mlv;
 }
index 79d230e26c7ac8439a011b1472af5eaf007791e0..5d271850f4fbc9b9892be721bd257b525ea17c3a 100644 (file)
@@ -304,8 +304,8 @@ VLC_EXPORT ( libvlc_media_list_view_t *, libvlc_media_list_view_new,
 
 VLC_EXPORT ( void, libvlc_media_list_view_set_ml_notification_callback, (
                 libvlc_media_list_view_t * p_mlv,
-                void (*item_added)(const libvlc_event_t *, void *),
-                void (*item_removed)(const libvlc_event_t *, void *) ));
+                void (*item_added)(const libvlc_event_t *, libvlc_media_list_view_t *),
+                void (*item_removed)(const libvlc_event_t *, libvlc_media_list_view_t *) ));
 
 /* Events */
 VLC_EXPORT (libvlc_event_manager_t *, libvlc_event_manager_new, ( void * p_obj, libvlc_instance_t * p_libvlc_inst, libvlc_exception_t *p_e ) );
index c562a151e71aca87ea398a629b1f3733448c2d6b..35ce6a6bd8d60f8f28de3ab8c18c37830e4a9e25 100644 (file)
@@ -56,7 +56,7 @@ media_list_item_added( const libvlc_event_t * p_event, void * p_user_data )
                              libvlc_MediaListItemDeleted,
                              media_list_item_removed, p_mlv, NULL );
     }
-    if( p_mlv->pf_ml_item_added ) p_mlv->pf_ml_item_added( p_event, p_user_data );
+    if( p_mlv->pf_ml_item_added ) p_mlv->pf_ml_item_added( p_event, p_mlv );
 }
 
 static void
@@ -74,7 +74,7 @@ media_list_item_removed( const libvlc_event_t * p_event, void * p_user_data )
                              libvlc_MediaListItemDeleted,
                              media_list_item_removed, p_mlv, NULL );
     }
-    if( p_mlv->pf_ml_item_removed ) p_mlv->pf_ml_item_removed( p_event, p_user_data );
+    if( p_mlv->pf_ml_item_removed ) p_mlv->pf_ml_item_removed( p_event, p_mlv );
 }
 
 
@@ -84,8 +84,8 @@ media_list_item_removed( const libvlc_event_t * p_event, void * p_user_data )
 void
 libvlc_media_list_view_set_ml_notification_callback(
                 libvlc_media_list_view_t * p_mlv,
-                void (*item_added)(const libvlc_event_t *, void *),
-                void (*item_removed)(const libvlc_event_t *, void *) )
+                void (*item_added)(const libvlc_event_t *, libvlc_media_list_view_t *),
+                void (*item_removed)(const libvlc_event_t *, libvlc_media_list_view_t *) )
 {
     p_mlv->pf_ml_item_added = item_added;
     p_mlv->pf_ml_item_removed = item_removed;