Commit 9b8c613d authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

src/control: Implement flat_media_list_view construction.

parent 3d958c18
......@@ -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;
}
......@@ -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 ) );
......
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment