Commit b269d0ed authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

src/control/media_list_view.c: Facilities to send WillAdd/Added WillDelete/Deleted events.

parent 9bf66bda
...@@ -310,6 +310,11 @@ typedef enum libvlc_event_type_t { ...@@ -310,6 +310,11 @@ typedef enum libvlc_event_type_t {
libvlc_MediaListItemDeleted, libvlc_MediaListItemDeleted,
libvlc_MediaListWillDeleteItem, libvlc_MediaListWillDeleteItem,
libvlc_MediaListViewItemAdded,
libvlc_MediaListViewWillAddItem,
libvlc_MediaListViewItemDeleted,
libvlc_MediaListViewWillDeleteItem,
libvlc_MediaListPlayerPlayed, libvlc_MediaListPlayerPlayed,
libvlc_MediaListPlayerNextItemSet, libvlc_MediaListPlayerNextItemSet,
libvlc_MediaListPlayerStopped, libvlc_MediaListPlayerStopped,
...@@ -378,6 +383,28 @@ typedef struct libvlc_event_t ...@@ -378,6 +383,28 @@ typedef struct libvlc_event_t
libvlc_media_descriptor_t * item; libvlc_media_descriptor_t * item;
int index; int index;
} media_list_will_delete_item; } media_list_will_delete_item;
/* media list view */
struct
{
libvlc_media_descriptor_t * item;
int index;
} media_list_view_item_added;
struct
{
libvlc_media_descriptor_t * item;
int index;
} media_list_view_will_add_item;
struct
{
libvlc_media_descriptor_t * item;
int index;
} media_list_view_item_deleted;
struct
{
libvlc_media_descriptor_t * item;
int index;
} media_list_view_will_delete_item;
} u; } u;
} libvlc_event_t; } libvlc_event_t;
......
...@@ -307,6 +307,19 @@ VLC_EXPORT ( void, libvlc_media_list_view_set_ml_notification_callback, ( ...@@ -307,6 +307,19 @@ VLC_EXPORT ( void, libvlc_media_list_view_set_ml_notification_callback, (
void (*item_added)(const libvlc_event_t *, libvlc_media_list_view_t *), void (*item_added)(const libvlc_event_t *, libvlc_media_list_view_t *),
void (*item_removed)(const libvlc_event_t *, libvlc_media_list_view_t *) )); void (*item_removed)(const libvlc_event_t *, libvlc_media_list_view_t *) ));
VLC_EXPORT ( void, libvlc_media_list_view_will_delete_item, ( libvlc_media_list_view_t * p_mlv,
libvlc_media_descriptor_t * p_item,
int index ));
VLC_EXPORT ( void, libvlc_media_list_view_item_deleted, ( libvlc_media_list_view_t * p_mlv,
libvlc_media_descriptor_t * p_item,
int index ));
VLC_EXPORT ( void, libvlc_media_list_view_will_add_item, ( libvlc_media_list_view_t * p_mlv,
libvlc_media_descriptor_t * p_item,
int index ));
VLC_EXPORT ( void, libvlc_media_list_view_item_added, ( libvlc_media_list_view_t * p_mlv,
libvlc_media_descriptor_t * p_item,
int index ));
/* Events */ /* 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 ) ); VLC_EXPORT (libvlc_event_manager_t *, libvlc_event_manager_new, ( void * p_obj, libvlc_instance_t * p_libvlc_inst, libvlc_exception_t *p_e ) );
......
...@@ -81,6 +81,9 @@ media_list_item_removed( const libvlc_event_t * p_event, void * p_user_data ) ...@@ -81,6 +81,9 @@ media_list_item_removed( const libvlc_event_t * p_event, void * p_user_data )
/* /*
* LibVLC Internal functions * LibVLC Internal functions
*/ */
/**************************************************************************
* libvlc_media_list_view_set_ml_notification_callback (Internal)
**************************************************************************/
void void
libvlc_media_list_view_set_ml_notification_callback( libvlc_media_list_view_set_ml_notification_callback(
libvlc_media_list_view_t * p_mlv, libvlc_media_list_view_t * p_mlv,
...@@ -97,6 +100,86 @@ libvlc_media_list_view_set_ml_notification_callback( ...@@ -97,6 +100,86 @@ libvlc_media_list_view_set_ml_notification_callback(
media_list_item_removed, p_mlv, NULL ); media_list_item_removed, p_mlv, NULL );
} }
/**************************************************************************
* libvlc_media_list_view_notify_deletion (Internal)
**************************************************************************/
void
libvlc_media_list_view_will_delete_item(
libvlc_media_list_view_t * p_mlv,
libvlc_media_descriptor_t * p_item,
int index )
{
libvlc_event_t event;
/* Construct the event */
event.type = libvlc_MediaListViewWillDeleteItem;
event.u.media_list_view_will_delete_item.item = p_item;
event.u.media_list_view_will_delete_item.index = index;
/* Send the event */
libvlc_event_send( p_mlv->p_event_manager, &event );
}
/**************************************************************************
* libvlc_media_list_view_item_deleted (Internal)
**************************************************************************/
void
libvlc_media_list_view_item_deleted(
libvlc_media_list_view_t * p_mlv,
libvlc_media_descriptor_t * p_item,
int index )
{
libvlc_event_t event;
/* Construct the event */
event.type = libvlc_MediaListViewItemDeleted;
event.u.media_list_view_item_deleted.item = p_item;
event.u.media_list_view_item_deleted.index = index;
/* Send the event */
libvlc_event_send( p_mlv->p_event_manager, &event );
}
/**************************************************************************
* libvlc_media_list_view_will_add_item (Internal)
**************************************************************************/
void
libvlc_media_list_view_will_add_item(
libvlc_media_list_view_t * p_mlv,
libvlc_media_descriptor_t * p_item,
int index )
{
libvlc_event_t event;
/* Construct the event */
event.type = libvlc_MediaListViewWillAddItem;
event.u.media_list_view_will_add_item.item = p_item;
event.u.media_list_view_will_add_item.index = index;
/* Send the event */
libvlc_event_send( p_mlv->p_event_manager, &event );
}
/**************************************************************************
* libvlc_media_list_view_item_added (Internal)
**************************************************************************/
void
libvlc_media_list_view_item_added(
libvlc_media_list_view_t * p_mlv,
libvlc_media_descriptor_t * p_item,
int index )
{
libvlc_event_t event;
/* Construct the event */
event.type = libvlc_MediaListViewItemAdded;
event.u.media_list_view_item_added.item = p_item;
event.u.media_list_view_item_added.index = index;
/* Send the event */
libvlc_event_send( p_mlv->p_event_manager, &event );
}
/************************************************************************** /**************************************************************************
* libvlc_media_list_view_new (Internal) * libvlc_media_list_view_new (Internal)
**************************************************************************/ **************************************************************************/
...@@ -171,14 +254,14 @@ libvlc_media_list_view_release( libvlc_media_list_view_t * p_mlv ) ...@@ -171,14 +254,14 @@ libvlc_media_list_view_release( libvlc_media_list_view_t * p_mlv )
{ {
libvlc_event_detach( p_mlv->p_mlist->p_event_manager, libvlc_event_detach( p_mlv->p_mlist->p_event_manager,
libvlc_MediaListItemAdded, libvlc_MediaListItemAdded,
p_mlv->pf_ml_item_added, p_mlv, NULL ); (void (*)(const libvlc_event_t *, void*))p_mlv->pf_ml_item_added, p_mlv, NULL );
/* XXX: descend the whole tree and remove observer */ /* XXX: descend the whole tree and remove observer */
} }
if( p_mlv->pf_ml_item_removed ) if( p_mlv->pf_ml_item_removed )
{ {
libvlc_event_detach( p_mlv->p_mlist->p_event_manager, libvlc_event_detach( p_mlv->p_mlist->p_event_manager,
libvlc_MediaListItemDeleted, libvlc_MediaListItemDeleted,
p_mlv->pf_ml_item_removed, p_mlv, NULL ); (void (*)(const libvlc_event_t *, void*))p_mlv->pf_ml_item_removed, p_mlv, NULL );
/* XXX: descend the whole tree and remove observer */ /* XXX: descend the whole tree and remove observer */
} }
......
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