/** * grl_plugin_get_sources: * @plugin: a plugin * * Gets the sources belonging to @plugin. * * Returns: (transfer container) (element-type GrlSource): a #GList of * #GrlSource<!-- -->s. The content of the list should not be modified or * freed. Use g_list_free() when done using the list. * * Since: 0.2.0 **/ GList * grl_plugin_get_sources (GrlPlugin *plugin) { GrlRegistry *registry; GList *all_sources; GList *plugin_sources = NULL; GList *sources_iter; g_return_val_if_fail (GRL_IS_PLUGIN (plugin), NULL); registry = grl_registry_get_default (); all_sources = grl_registry_get_sources (registry, FALSE); for (sources_iter = all_sources; sources_iter; sources_iter = g_list_next (sources_iter)) { if (grl_source_get_plugin (GRL_SOURCE (sources_iter->data)) == plugin) { plugin_sources = g_list_prepend (plugin_sources, sources_iter->data); } } g_list_free (all_sources); return plugin_sources; }
static void grilo_source_added_cb (GrlRegistry *registry, GrlSource *grilo_source, RBGriloPlugin *plugin) { GrlPlugin *grilo_plugin; GrlSupportedOps ops; const GList *keys; RBSource *source; RBShell *shell; int i; if (!(grl_source_get_supported_media (grilo_source) & GRL_MEDIA_TYPE_AUDIO)) { rb_debug ("grilo source %s doesn't support audio", grl_source_get_name (grilo_source)); goto ignore; } grilo_plugin = grl_source_get_plugin (grilo_source); for (i = 0; i < G_N_ELEMENTS (ignored_plugins); i++) { if (g_str_equal (ignored_plugins[i], grl_plugin_get_id (grilo_plugin))) { rb_debug ("grilo source %s is blacklisted", grl_source_get_name (grilo_source)); goto ignore; } } ops = grl_source_supported_operations (grilo_source); if (((ops & GRL_OP_BROWSE) == 0) && ((ops & GRL_OP_SEARCH) == 0)) { rb_debug ("grilo source %s is not interesting", grl_source_get_name (grilo_source)); goto ignore; } keys = grl_source_supported_keys (grilo_source); if (g_list_find ((GList *)keys, GINT_TO_POINTER (GRL_METADATA_KEY_URL)) == NULL) { rb_debug ("grilo source %s doesn't do urls", grl_source_get_name (grilo_source)); goto ignore; } rb_debug ("new grilo source: %s", grl_source_get_name (grilo_source)); source = rb_grilo_source_new (G_OBJECT (plugin), grilo_source); g_hash_table_insert (plugin->sources, g_object_ref (grilo_source), g_object_ref_sink (source)); /* probably put some sources under 'shared', some under 'stores'? */ g_object_get (plugin, "object", &shell, NULL); rb_shell_append_display_page (shell, RB_DISPLAY_PAGE (source), RB_DISPLAY_PAGE_GROUP_SHARED); g_object_unref (shell); return; ignore: grl_registry_unregister_source (registry, grilo_source, NULL); }