Commit ffd08a58 authored by Jonathan Matthew's avatar Jonathan Matthew

grilo: finish porting to grilo 0.2

parent 214fe121
......@@ -95,43 +95,53 @@ rb_grilo_plugin_init (RBGriloPlugin *plugin)
static void
rb_grilo_plugin_source_deleted (RBGriloSource *source, RBGriloPlugin *plugin)
{
GrlSource *media_source;
GrlSource *grilo_source;
g_object_get (source, "media-source", &media_source, NULL);
g_hash_table_remove (plugin->sources, media_source);
g_object_unref (media_source);
g_object_get (source, "media-source", &grilo_source, NULL);
g_hash_table_remove (plugin->sources, grilo_source);
g_object_unref (grilo_source);
}
static void
grilo_source_added_cb (GrlRegistry *registry, GrlPlugin *grilo_plugin, RBGriloPlugin *plugin)
grilo_source_added_cb (GrlRegistry *registry, GrlSource *grilo_source, RBGriloPlugin *plugin)
{
RBSource *grilo_source;
GrlPlugin *grilo_plugin;
GrlSupportedOps ops;
const GList *keys;
RBSource *source;
RBShell *shell;
int i;
if (GRL_IS_MEDIA_SOURCE (grilo_plugin) == FALSE) {
/* TODO use metadata sources for album art and lyrics */
rb_debug ("grilo source %s is not interesting",
grl_media_plugin_get_name (grilo_plugin));
return;
}
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_media_plugin_get_id (grilo_plugin))) {
if (g_str_equal (ignored_plugins[i], grl_plugin_get_id (grilo_plugin))) {
rb_debug ("grilo source %s is blacklisted",
grl_media_plugin_get_name (grilo_plugin));
grl_source_get_name (grilo_source));
return;
}
}
rb_debug ("new grilo source: %s", grl_media_plugin_get_name (grilo_plugin));
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));
return;
}
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));
return;
}
rb_debug ("new grilo source: %s", grl_source_get_name (grilo_source));
grilo_source = rb_grilo_source_new (G_OBJECT (plugin), GRL_MEDIA_SOURCE (grilo_plugin));
g_hash_table_insert (plugin->sources, grilo_plugin, grilo_source);
source = rb_grilo_source_new (G_OBJECT (plugin), grilo_source);
g_hash_table_insert (plugin->sources, grilo_source, 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 (grilo_source), RB_DISPLAY_PAGE_GROUP_SHARED);
rb_shell_append_display_page (shell, RB_DISPLAY_PAGE (source), RB_DISPLAY_PAGE_GROUP_SHARED);
g_object_unref (shell);
}
......@@ -179,9 +189,9 @@ impl_activate (PeasActivatable *plugin)
g_object_unref);
grl_init (0, NULL);
pi->registry = grl_plugin_registry_get_default ();
pi->registry = grl_registry_get_default ();
g_signal_connect (pi->registry, "source-added", G_CALLBACK (grilo_source_added_cb), pi);
if (grl_plugin_registry_load_all (pi->registry, &error) == FALSE) {
if (grl_registry_load_all_plugins (pi->registry, &error) == FALSE) {
g_warning ("Failed to load Grilo plugins: %s", error->message);
g_clear_error (&error);
}
......@@ -196,8 +206,8 @@ impl_activate (PeasActivatable *plugin)
}
static void
_delete_cb (GVolume *volume,
RBSource *source,
_delete_cb (GrlSource *grilo_source,
RBSource *source,
RBGriloPlugin *plugin)
{
/* block the source deleted handler so we don't modify the hash table
......
......@@ -286,7 +286,7 @@ rb_grilo_source_constructed (GObject *object)
G_CALLBACK (notify_sort_order_cb),
source);
source_keys = grl_metadata_source_supported_keys (GRL_METADATA_SOURCE (source->priv->grilo_source));
source_keys = grl_source_supported_keys (source->priv->grilo_source);
if (g_list_find ((GList *)source_keys, GUINT_TO_POINTER(GRL_METADATA_KEY_TRACK_NUMBER))) {
rb_entry_view_append_column (source->priv->entry_view, RB_ENTRY_VIEW_COL_TRACK_NUMBER, FALSE);
......@@ -365,7 +365,7 @@ rb_grilo_source_constructed (GObject *object)
browserbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
/* search bar (if the source supports searching) */
if (grl_metadata_source_supported_operations (GRL_METADATA_SOURCE (source->priv->grilo_source)) & GRL_OP_SEARCH) {
if (grl_source_supported_operations (source->priv->grilo_source) & GRL_OP_SEARCH) {
source->priv->search_entry = rb_search_entry_new (FALSE);
g_object_set (source->priv->search_entry, "explicit-mode", TRUE, NULL);
g_signal_connect (source->priv->search_entry, "search", G_CALLBACK (search_cb), source);
......@@ -414,7 +414,7 @@ rb_grilo_source_new (GObject *plugin, GrlSource *grilo_source)
RhythmDB *db;
char *name;
name = g_strdup_printf ("grilo:%s", grl_media_plugin_get_id (GRL_MEDIA_PLUGIN (grilo_source)));
name = g_strdup_printf ("grilo:%s", grl_source_get_id (grilo_source));
g_object_get (plugin, "object", &shell, NULL);
g_object_get (shell, "db", &db, NULL);
......@@ -431,7 +431,7 @@ rb_grilo_source_new (GObject *plugin, GrlSource *grilo_source)
settings = g_settings_new ("org.gnome.rhythmbox.plugins.grilo");
source = g_object_new (RB_TYPE_GRILO_SOURCE,
"name", grl_metadata_source_get_name (GRL_METADATA_SOURCE (grilo_source)),
"name", grl_source_get_name (grilo_source),
"entry-type", entry_type,
"shell", shell,
"plugin", plugin,
......@@ -506,6 +506,24 @@ _rb_grilo_source_register_type (GTypeModule *module)
rb_grilo_entry_type_register_type (module);
}
static GrlOperationOptions *
make_operation_options (RBGriloSource *source, GrlSupportedOps op, int position)
{
GrlOperationOptions *options;
GrlCaps *caps;
caps = grl_source_get_caps (source->priv->grilo_source, op);
options = grl_operation_options_new (caps);
grl_operation_options_set_skip (options, position);
grl_operation_options_set_count (options,
CONTAINER_FETCH_SIZE);
grl_operation_options_set_type_filter (options, GRL_TYPE_FILTER_AUDIO);
grl_operation_options_set_flags (options, GRL_RESOLVE_NORMAL);
return options;
}
/* grilo media -> rhythmdb entry */
static void
......@@ -651,7 +669,8 @@ grilo_browse_cb (GrlSource *grilo_source, guint operation_id, GrlMedia *media, g
if (error != NULL) {
/* do something? */
rb_debug ("got error for %s: %s", grl_metadata_source_get_name (GRL_METADATA_SOURCE (grilo_source)), error->message);
rb_debug ("got error for %s: %s", grl_source_get_name (grilo_source), error->message);
source->priv->browse_op = 0;
return;
}
......@@ -741,24 +760,24 @@ grilo_browse_cb (GrlSource *grilo_source, guint operation_id, GrlMedia *media, g
static void
browse_next (RBGriloSource *source)
{
GrlOperationOptions *options;
rb_debug ("next browse op for %s (%d)",
grl_metadata_source_get_name (GRL_METADATA_SOURCE (source->priv->grilo_source)),
grl_source_get_name (source->priv->grilo_source),
source->priv->browse_position);
source->priv->browse_got_results = FALSE;
source->priv->browse_op = grl_media_source_browse (source->priv->grilo_source,
source->priv->browse_container,
source->priv->grilo_keys,
source->priv->browse_position,
CONTAINER_FETCH_SIZE,
GRL_RESOLVE_NORMAL,
(GrlSourceResultCb) grilo_browse_cb,
source);
options = make_operation_options (source, GRL_OP_BROWSE, source->priv->browse_position);
source->priv->browse_op = grl_source_browse (source->priv->grilo_source,
source->priv->browse_container,
source->priv->grilo_keys,
options,
(GrlSourceResultCb) grilo_browse_cb,
source);
}
static void
start_browse (RBGriloSource *source, GrlMedia *container, GtkTreeIter *container_iter, int position)
{
rb_debug ("starting browse op for %s", grl_metadata_source_get_name (GRL_METADATA_SOURCE (source->priv->grilo_source)));
rb_debug ("starting browse op for %s", grl_source_get_name (source->priv->grilo_source));
/* cancel existing operation? */
if (source->priv->browse_op != 0) {
......@@ -793,7 +812,7 @@ grilo_media_browse_cb (GrlSource *grilo_source, guint operation_id, GrlMedia *me
if (error != NULL) {
/* do something? */
rb_debug ("got error for %s: %s",
grl_metadata_source_get_name (GRL_METADATA_SOURCE (grilo_source)),
grl_source_get_name (grilo_source),
error->message);
return;
}
......@@ -858,31 +877,35 @@ grilo_media_browse_cb (GrlSource *grilo_source, guint operation_id, GrlMedia *me
static void
media_browse_next (RBGriloSource *source)
{
GrlOperationOptions *options;
rb_debug ("next media_browse op for %s (%d)",
grl_metadata_source_get_name (GRL_METADATA_SOURCE (source->priv->grilo_source)),
grl_source_get_name (source->priv->grilo_source),
source->priv->media_browse_position);
source->priv->media_browse_got_results = FALSE;
if (source->priv->media_browse_container != NULL) {
options = make_operation_options (source,
GRL_OP_BROWSE,
source->priv->media_browse_position);
source->priv->media_browse_op =
grl_media_source_browse (source->priv->grilo_source,
source->priv->media_browse_container,
source->priv->grilo_keys,
source->priv->media_browse_position,
CONTAINER_FETCH_SIZE,
GRL_RESOLVE_NORMAL,
(GrlSourceResultCb) grilo_media_browse_cb,
source);
grl_source_browse (source->priv->grilo_source,
source->priv->media_browse_container,
source->priv->grilo_keys,
options,
(GrlSourceResultCb) grilo_media_browse_cb,
source);
} else {
options = make_operation_options (source,
GRL_OP_SEARCH,
source->priv->media_browse_position);
source->priv->media_browse_op =
grl_media_source_search (source->priv->grilo_source,
source->priv->search_text,
source->priv->grilo_keys,
source->priv->media_browse_position,
CONTAINER_FETCH_SIZE,
GRL_RESOLVE_NORMAL,
(GrlSourceResultCb) grilo_media_browse_cb,
source);
grl_source_search (source->priv->grilo_source,
source->priv->search_text,
source->priv->grilo_keys,
options,
(GrlSourceResultCb) grilo_media_browse_cb,
source);
}
}
......@@ -890,7 +913,7 @@ static void
start_media_browse (RBGriloSource *source, GrlMedia *container, GtkTreeIter *container_iter, guint limit)
{
rb_debug ("starting media browse for %s",
grl_metadata_source_get_name (GRL_METADATA_SOURCE (source->priv->grilo_source)));
grl_source_get_name (source->priv->grilo_source));
/* cancel existing operation? */
if (source->priv->media_browse_op != 0) {
......
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