Commit 382926a8 authored by Clément Stenac's avatar Clément Stenac

include services discovery in interface

parent e56a6361
......@@ -231,6 +231,8 @@ VLC_EXPORT( int, playlist_Clear, ( playlist_t * ) );
VLC_EXPORT( int, playlist_ServicesDiscoveryAdd, (playlist_t *, const char *));
VLC_EXPORT( void, playlist_ServicesDiscoveryRemove, (playlist_t *, const char *));
VLC_EXPORT( int, playlist_AddSDModules, (playlist_t *, char *));
VLC_EXPORT( vlc_bool_t, playlist_IsServicesDiscoveryLoaded, ( playlist_t *,const char *));
/* Item management functions (act on items) */
#define playlist_AddItem(p,pi,i1,i2) playlist_ItemAdd(p,pi,i1,i2)
......
......@@ -977,7 +977,7 @@ void MenuEvtHandler::OnMenuEvent( wxCommandEvent& event )
{
if( p_intf->p_sys->p_popup_menu )
{
p_menuitem =
p_menuitem =
p_intf->p_sys->p_popup_menu->FindItem( event.GetId() );
}
}
......
......@@ -107,7 +107,13 @@ enum
/* custom events */
UpdateItem_Event,
MenuDummy_Event = wxID_HIGHEST + 999,
FirstView_Event = wxID_HIGHEST + 1000,
LastView_Event = wxID_HIGHEST + 1100,
FirstSD_Event = wxID_HIGHEST + 2000,
LastSD_Event = wxID_HIGHEST + 2100,
};
DEFINE_LOCAL_EVENT_TYPE( wxEVT_PLAYLIST );
......@@ -205,6 +211,7 @@ Playlist::Playlist( intf_thread_t *_p_intf, wxWindow *p_parent ):
SetIcon( *p_intf->p_sys->p_icon );
p_view_menu = NULL;
p_sd_menu = SDMenu();
i_current_view = VIEW_SIMPLE;
......@@ -222,6 +229,9 @@ Playlist::Playlist( intf_thread_t *_p_intf, wxWindow *p_parent ):
manage_menu->Append( AddFile_Event, wxU(_("&Simple Add...")) );
manage_menu->Append( AddMRL_Event, wxU(_("&Add MRL...")) );
manage_menu->AppendSeparator();
manage_menu->Append( MenuDummy_Event, wxU(_("Services discovery")),
p_sd_menu );
manage_menu->AppendSeparator();
manage_menu->Append( Open_Event, wxU(_("&Open Playlist...")) );
manage_menu->Append( Save_Event, wxU(_("&Save Playlist...")) );
manage_menu->AppendSeparator();
......@@ -1090,12 +1100,6 @@ void Playlist::OnDisableSelection( wxCommandEvent& WXUNUSED(event) )
void Playlist::OnSelectAll( wxCommandEvent& WXUNUSED(event) )
{
#if 0
for( long item = 0; item < listview->GetItemCount(); item++ )
{
listview->Select( item, TRUE );
}
#endif
}
/**********************************************************************
......@@ -1203,12 +1207,6 @@ void Playlist::ShowInfos( int i_item )
void Playlist::OnInfos( wxCommandEvent& WXUNUSED(event) )
{
/* We use the first selected item, so find it */
#if 0
long i_item = listview->GetNextItem( -1, wxLIST_NEXT_ALL,
wxLIST_STATE_SELECTED );
ShowInfos( i_item );
#endif
}
void Playlist::OnEnDis( wxCommandEvent& event )
......@@ -1220,15 +1218,6 @@ void Playlist::OnEnDis( wxCommandEvent& event )
{
return;
}
#if 0
long i_item = listview->GetNextItem( -1, wxLIST_NEXT_ALL,
wxLIST_STATE_SELECTED );
if( i_item >= 0 && i_item < p_playlist->i_size )
{
Rebuild();
}
#endif
vlc_object_release( p_playlist );
}
......@@ -1266,29 +1255,46 @@ void Playlist::OnMenuEvent( wxCommandEvent& event )
event.Skip();
return;
}
else if( event.GetId() < LastView_Event )
{
int i_new_view = event.GetId() - FirstView_Event;
int i_new_view = event.GetId() - FirstView_Event;
playlist_view_t *p_view = playlist_ViewFind( p_playlist, i_new_view );
playlist_view_t *p_view = playlist_ViewFind( p_playlist, i_new_view );
if( p_view != NULL )
{
i_current_view = i_new_view;
playlist_ViewUpdate( p_playlist, i_new_view );
Rebuild();
vlc_object_release( p_playlist );
return;
}
else if( i_new_view >= VIEW_FIRST_SORTED && i_new_view <= VIEW_LAST_SORTED )
{
playlist_ViewInsert( p_playlist, i_new_view, "View" );
playlist_ViewUpdate( p_playlist, i_new_view );
if( p_view != NULL )
{
i_current_view = i_new_view;
playlist_ViewUpdate( p_playlist, i_new_view );
Rebuild();
vlc_object_release( p_playlist );
return;
}
else if( i_new_view >= VIEW_FIRST_SORTED &&
i_new_view <= VIEW_LAST_SORTED )
{
playlist_ViewInsert( p_playlist, i_new_view, "View" );
playlist_ViewUpdate( p_playlist, i_new_view );
i_current_view = i_new_view;
i_current_view = i_new_view;
Rebuild();
Rebuild();
}
}
else if( event.GetId() >= FirstSD_Event && event.GetId() < LastSD_Event )
{
if( !playlist_IsServicesDiscoveryLoaded( p_playlist,
pp_sds[event.GetId() - FirstSD_Event] ) )
{
playlist_ServicesDiscoveryAdd( p_playlist,
pp_sds[event.GetId() - FirstSD_Event] );
}
else
{
playlist_ServicesDiscoveryRemove( p_playlist,
pp_sds[event.GetId() - FirstSD_Event] );
}
}
vlc_object_release( p_playlist );
}
......@@ -1339,6 +1345,47 @@ wxMenu * Playlist::ViewMenu()
return p_view_menu;
}
wxMenu *Playlist::SDMenu()
{
playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf,
VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
if( !p_playlist )
{
return NULL;
}
vlc_value_t val, val_list, text_list;
p_sd_menu = new wxMenu;
vlc_list_t *p_list = vlc_list_find( p_playlist, VLC_OBJECT_MODULE,
FIND_ANYWHERE );
int i_number = 0;
for( int i_index = 0; i_index < p_list->i_count; i_index++ )
{
module_t * p_parser = (module_t *)p_list->p_values[i_index].p_object ;
if( !strcmp( p_parser->psz_capability, "services_discovery" ) )
{
p_sd_menu->AppendCheckItem( FirstSD_Event + i_number ,
wxU( p_parser->psz_longname ? p_parser->psz_longname :
p_parser->psz_shortname ) );
if( playlist_IsServicesDiscoveryLoaded( p_playlist,
p_parser->psz_shortname ) )
{
p_sd_menu->Check( FirstSD_Event + i_number, TRUE );
}
INSERT_ELEM( (void**)pp_sds, i_number, i_number,
(void*)p_parser->psz_shortname );
}
}
vlc_list_release( p_list );
vlc_object_release( p_playlist );
return p_sd_menu;
}
/*****************************************************************************
* Popup management functions
......
......@@ -806,6 +806,7 @@ private:
void OnMenuOpen( wxMenuEvent& event );
wxMenu *ViewMenu();
wxMenu *SDMenu();
void OnUp( wxCommandEvent& event);
void OnDown( wxCommandEvent& event);
......@@ -849,6 +850,9 @@ private:
wxMenu *popup_menu;
wxMenu *p_view_menu;
wxMenu *p_sd_menu;
char **pp_sds;
ItemInfoDialog *iteminfo_dialog;
......
......@@ -60,6 +60,7 @@ int playlist_vaControl( playlist_t * p_playlist, int i_query, va_list args );
*/
playlist_t * __playlist_Create ( vlc_object_t *p_parent )
{
int i_index;
playlist_t *p_playlist;
playlist_view_t *p_view;
vlc_value_t val;
......@@ -91,6 +92,7 @@ playlist_t * __playlist_Create ( vlc_object_t *p_parent )
val.b_bool = VLC_TRUE;
var_Set( p_playlist, "intf-show", val );
/* Variables to control playback */
var_CreateGetBool( p_playlist, "play-and-stop" );
var_CreateGetBool( p_playlist, "random" );
......@@ -923,6 +925,7 @@ static int ItemChange( vlc_object_t *p_obj, const char *psz_var,
vlc_value_t oldval, vlc_value_t newval, void *param )
{
playlist_t *p_playlist = (playlist_t *)param;
int i_index;
//p_playlist->b_need_update = VLC_TRUE;
var_SetInteger( p_playlist, "item-change", newval.i_int );
......
......@@ -113,6 +113,25 @@ void playlist_ServicesDiscoveryRemove( playlist_t * p_playlist,
return;
}
vlc_bool_t playlist_IsServicesDiscoveryLoaded( playlist_t * p_playlist,
const char *psz_module )
{
int i;
vlc_mutex_lock( &p_playlist->object_lock );
for( i = 0 ; i< p_playlist->i_sds ; i ++ )
{
if( !strcmp( psz_module, p_playlist->pp_sds[i]->psz_module ) )
{
vlc_mutex_unlock( &p_playlist->object_lock );
return VLC_TRUE;
}
}
vlc_mutex_unlock( &p_playlist->object_lock );
return VLC_FALSE;
}
/**
* Load all service discovery modules in a string
*
......
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