Use the services_discovery_GetServicesNames() function in the qt4 and wxwidgets (i don't compile the wxwidgets module so there might be a few warnings/errors). This removes comprehension of how VLC modules work from the interface plugins. This change still needs to be done in the modules/gui/macosx/playlist.m file.

This commit is contained in:
Antoine Cellerier 2007-11-11 21:08:36 +00:00
parent ffc3180d5c
commit acbd355a0b
4 changed files with 40 additions and 70 deletions

View File

@ -62,7 +62,9 @@ struct services_discovery_t
/* Get the services discovery modules names to use in Create(), in a null /* Get the services discovery modules names to use in Create(), in a null
* terminated string array. Array and string must be freed after use. */ * terminated string array. Array and string must be freed after use. */
VLC_EXPORT( char **, services_discovery_GetServicesNames, ( vlc_object_t * p_super, char ***pppsz_longnames ) ); VLC_EXPORT( char **, __services_discovery_GetServicesNames, ( vlc_object_t * p_super, char ***pppsz_longnames ) );
#define services_discovery_GetServicesNames(a,b) \
__services_discovery_GetServicesNames(VLC_OBJECT(a),b)
/* Creation of a service_discovery object */ /* Creation of a service_discovery object */
VLC_EXPORT( services_discovery_t *, services_discovery_Create, ( vlc_object_t * p_super, const char * psz_service_name ) ); VLC_EXPORT( services_discovery_t *, services_discovery_Create, ( vlc_object_t * p_super, const char * psz_service_name ) );

View File

@ -213,15 +213,15 @@ QMenu *QVLCMenu::PlaylistMenu( intf_thread_t *p_intf, MainInterface *mi )
{ {
QMenu *menu = new QMenu(); QMenu *menu = new QMenu();
menu->addMenu( SDMenu( p_intf ) ); menu->addMenu( SDMenu( p_intf ) );
menu->addAction ( QIcon( ":/pixmaps/playlist_16px.png" ), menu->addAction( QIcon( ":/pixmaps/playlist_16px.png" ),
qtr( "Show Playlist" ), mi, SLOT( togglePlaylist() ) ); qtr( "Show Playlist" ), mi, SLOT( togglePlaylist() ) );
menu->addSeparator(); menu->addSeparator();
DP_SADD( menu, qtr( I_PL_LOAD ), "", "", openPlaylist(), "Ctrl+X" ); DP_SADD( menu, qtr( I_PL_LOAD ), "", "", openPlaylist(), "Ctrl+X" );
DP_SADD( menu, qtr( I_PL_SAVE ), "", "", savePlaylist(), "Ctrl+Y" ); DP_SADD( menu, qtr( I_PL_SAVE ), "", "", savePlaylist(), "Ctrl+Y" );
menu->addSeparator(); menu->addSeparator();
menu->addAction( qtr( "Undock from interface" ), mi, menu->addAction( qtr( "Undock from interface" ), mi,
SLOT( undockPlaylist() ), qtr( "Ctrl+U" ) ); SLOT( undockPlaylist() ), qtr( "Ctrl+U" ) );
return menu; return menu;
} }
@ -412,45 +412,32 @@ QMenu *QVLCMenu::SDMenu( intf_thread_t *p_intf )
{ {
QMenu *menu = new QMenu(); QMenu *menu = new QMenu();
menu->setTitle( qtr( I_PL_SD ) ); menu->setTitle( qtr( I_PL_SD ) );
vlc_list_t *p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, char **ppsz_longnames;
FIND_ANYWHERE ); char **ppsz_names = services_discovery_GetServicesNames( p_intf,
int i_num = 0; &ppsz_longnames );
for( int i_index = 0 ; i_index < p_list->i_count; i_index++ ) char **ppsz_name = ppsz_names, **ppsz_longname = ppsz_longnames;
for( ; *ppsz_name; ppsz_name++, ppsz_longname++ )
{ {
module_t * p_parser = ( module_t * )p_list->p_values[i_index].p_object ; QAction *a = new QAction( qfu( *ppsz_longname ), menu );
if( module_IsCapable( p_parser, "services_discovery" ) )
i_num++;
}
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( !module_IsCapable( p_parser, "services_discovery" ) )
continue;
QAction *a = new QAction( qfu( module_GetLongName( p_parser ) ), menu );
a->setCheckable( true ); a->setCheckable( true );
/* hack to handle submodules properly */ if( playlist_IsServicesDiscoveryLoaded( THEPL, *ppsz_name ) )
int i = -1;
while( p_parser->pp_shortcuts[++i] != NULL );
i--;
if( playlist_IsServicesDiscoveryLoaded( THEPL,
i>=0?p_parser->pp_shortcuts[i]
: module_GetObjName( p_parser ) ) )
a->setChecked( true ); a->setChecked( true );
CONNECT( a , triggered(), THEDP->SDMapper, map() ); CONNECT( a , triggered(), THEDP->SDMapper, map() );
THEDP->SDMapper->setMapping( a, i>=0? p_parser->pp_shortcuts[i] : THEDP->SDMapper->setMapping( a, QString( *ppsz_name ) );
module_GetObjName( p_parser ) );
menu->addAction( a ); menu->addAction( a );
if( !strcmp( p_parser->psz_object_name, "podcast" ) ) if( !strcmp( *ppsz_name, "podcast" ) )
{ {
QAction *b = new QAction( qfu( "Configure podcasts..." ), menu ); QAction *b = new QAction( qfu( "Configure podcasts..." ), menu );
//b->setEnabled( a->isChecked() ); //b->setEnabled( a->isChecked() );
menu->addAction( b ); menu->addAction( b );
CONNECT( b, triggered(), THEDP, podcastConfigureDialog() ); CONNECT( b, triggered(), THEDP, podcastConfigureDialog() );
} }
free( *ppsz_name );
free( *ppsz_longname );
} }
vlc_list_release( p_list ); free( ppsz_names );
free( ppsz_longnames );
return menu; return menu;
} }
/** /**

View File

@ -411,7 +411,12 @@ Playlist::Playlist( intf_thread_t *_p_intf, wxWindow *p_parent ):
Playlist::~Playlist() Playlist::~Playlist()
{ {
if( pp_sds != NULL ) free( pp_sds ); if( pp_sds != NULL )
{
char **pp_sd = pp_sds;
for( ; *pp_sd; pp_sd++ ) free( *pp_sd );
free( pp_sds );
}
if( p_playlist == NULL ) return; if( p_playlist == NULL ) return;
@ -1400,47 +1405,23 @@ wxMenu *Playlist::SDMenu()
{ {
p_sd_menu = new wxMenu; p_sd_menu = new wxMenu;
vlc_list_t *p_list = vlc_list_find( p_playlist, VLC_OBJECT_MODULE, char **ppsz_longnames;
FIND_ANYWHERE ); char **ppsz_names = services_discovery_GetServicesNames( p_playlist,
&ppsz_longnames );
char **ppsz_name = ppsz_names, **ppsz_longname = ppsz_longnames;
int i_number = 0; for( ; *ppsz_name; ppsz_name++, ppsz_longname++ )
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 ; p_sd_menu->AppendCheckItem( FirstSD_Event + i_number ,
wxU( *ppsz_longname ) );
if( !strcmp( p_parser->psz_capability, "services_discovery" ) ) if( playlist_IsServicesDiscoveryLoaded( p_playlist, *ppsz_name ) )
i_number++; p_sd_menu->Check( FirstSD_Event + i_number, TRUE );
free( *ppsz_longname );
} }
if( i_number ) pp_sds = (const char **)calloc( i_number, sizeof(void *) ); pp_sds = ppsz_names;
free( ppsz_longnames );
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 ?
p_parser->psz_shortname : p_parser->psz_object_name) ) );
/* hack to handle submodules properly */
int i = -1;
while( p_parser->pp_shortcuts[++i] != NULL );
i--;
if( playlist_IsServicesDiscoveryLoaded( p_playlist,
i>=0?p_parser->pp_shortcuts[i]
:p_parser->psz_object_name ) )
{
p_sd_menu->Check( FirstSD_Event + i_number, TRUE );
}
pp_sds[i_number++] = i>=0?p_parser->pp_shortcuts[i]
:p_parser->psz_object_name;
}
}
vlc_list_release( p_list );
return p_sd_menu; return p_sd_menu;
} }

View File

@ -37,8 +37,8 @@ static void RunSD( services_discovery_t *p_sd );
/*********************************************************************** /***********************************************************************
* GetServicesNames * GetServicesNames
***********************************************************************/ ***********************************************************************/
char ** services_discovery_GetServicesNames( vlc_object_t * p_super, char ** __services_discovery_GetServicesNames( vlc_object_t * p_super,
char ***pppsz_longnames ) char ***pppsz_longnames )
{ {
return module_GetModulesNamesForCapability( p_super, "services_discovery", return module_GetModulesNamesForCapability( p_super, "services_discovery",
pppsz_longnames ); pppsz_longnames );