static void rb_static_playlist_source_add_location_internal (RBStaticPlaylistSource *source, const char *location, gint index) { RhythmDB *db; RhythmDBEntry *entry; RBPlaylistSource *psource = RB_PLAYLIST_SOURCE (source); if (rb_playlist_source_location_in_map (psource, location)) return; db = rb_playlist_source_get_db (psource); entry = rhythmdb_entry_lookup_by_location (db, location); if (entry) { RBStaticPlaylistSourcePrivate *priv = RB_STATIC_PLAYLIST_SOURCE_GET_PRIVATE (source); if (_rb_source_check_entry_type (RB_SOURCE (source), entry)) { rhythmdb_entry_ref (entry); rhythmdb_query_model_add_entry (priv->base_model, entry, index); rhythmdb_entry_unref (entry); } } rb_playlist_source_add_to_map (psource, location); rb_playlist_source_mark_dirty (psource); }
static void rb_playlist_source_entry_added_cb (RhythmDB *db, RhythmDBEntry *entry, RBPlaylistSource *source) { RBRefString *location; location = rhythmdb_entry_get_refstring (entry, RHYTHMDB_PROP_LOCATION); if (g_hash_table_lookup (source->priv->entries, location)) { if (_rb_source_check_entry_type (RB_SOURCE (source), entry)) { rhythmdb_query_model_add_entry (source->priv->model, entry, -1); source->priv->dirty = TRUE; } else { g_hash_table_remove (source->priv->entries, location); } } rb_refstring_unref (location); }
END_TEST /* this tests that chained query models, where the base shows hidden entries * forwards visibility changes correctly. This is basically what static playlists do */ START_TEST (test_hidden_chain_filter) { RhythmDBQueryModel *base_model; RhythmDBQueryModel *filter_model; RhythmDBQuery *query; RhythmDBEntry *entry; GtkTreeIter iter; GValue val = {0,}; start_test_case (); /* setup */ base_model = rhythmdb_query_model_new_empty (db); g_object_set (base_model, "show-hidden", TRUE, NULL); filter_model = rhythmdb_query_model_new_empty (db); g_object_set (filter_model, "base-model", base_model, NULL); query = g_ptr_array_new (); g_object_set (filter_model, "query", query, NULL); rhythmdb_query_free (query); entry = rhythmdb_entry_new (db, RHYTHMDB_ENTRY_TYPE_IGNORE, "file:///whee.ogg"); rhythmdb_commit (db); g_value_init (&val, G_TYPE_BOOLEAN); /* add entry to base, should be in both */ rhythmdb_query_model_add_entry (base_model, entry, -1); fail_unless (rhythmdb_query_model_entry_to_iter (base_model, entry, &iter)); fail_unless (rhythmdb_query_model_entry_to_iter (filter_model, entry, &iter)); end_step (); /* hide entry, should be in base and not filtered */ g_value_set_boolean (&val, TRUE); set_waiting_signal (G_OBJECT (db), "entry-changed"); rhythmdb_entry_set (db, entry, RHYTHMDB_PROP_HIDDEN, &val); rhythmdb_commit (db); wait_for_signal (); fail_unless (rhythmdb_query_model_entry_to_iter (base_model, entry, &iter)); fail_if (rhythmdb_query_model_entry_to_iter (filter_model, entry, &iter)); end_step (); /* show entry again, should be in both */ g_value_set_boolean (&val, FALSE); set_waiting_signal (G_OBJECT (db), "entry-changed"); rhythmdb_entry_set (db, entry, RHYTHMDB_PROP_HIDDEN, &val); rhythmdb_commit (db); wait_for_signal (); fail_unless (rhythmdb_query_model_entry_to_iter (base_model, entry, &iter)); fail_unless (rhythmdb_query_model_entry_to_iter (filter_model, entry, &iter)); end_step (); /* tidy up */ rhythmdb_entry_delete (db, entry); g_object_unref (base_model); g_object_unref (filter_model); g_value_unset (&val); end_test_case (); }
static void grilo_media_browse_cb (GrlSource *grilo_source, guint operation_id, GrlMedia *media, guint remaining, RBGriloSource *source, const GError *error) { if (operation_id != source->priv->media_browse_op) { return; } if (error != NULL) { /* do something? */ rb_debug ("got error for %s: %s", grl_source_get_name (grilo_source), error->message); return; } GDK_THREADS_ENTER (); if (media != NULL) { source->priv->media_browse_got_results = TRUE; source->priv->media_browse_position++; if (GRL_IS_MEDIA_AUDIO (media)) { RhythmDBEntry *entry; entry = create_entry_for_media (source->priv->db, source->priv->entry_type, GRL_DATA (media), GRL_DATA (source->priv->browse_container)); if (entry != NULL) { rhythmdb_query_model_add_entry (source->priv->query_model, entry, -1); } } else if (GRL_IS_MEDIA_BOX (media)) { source->priv->media_browse_got_containers = TRUE; } } if (remaining == 0) { source->priv->media_browse_op = 0; if (gtk_tree_model_iter_n_children (GTK_TREE_MODEL (source->priv->query_model), NULL) == 0 && source->priv->media_browse_position >= CONTAINER_GIVE_UP_POINT) { /* if we don't find any media within the first 100 or so results, * assume this container doesn't have any. otherwise we'd load * the entire thing when it got selected, which would suck. */ rb_debug ("didn't find any media in %s, giving up", grl_media_get_title (source->priv->media_browse_container)); gtk_tree_store_set (source->priv->browser_model, &source->priv->media_browse_container_iter, 2, CONTAINER_NO_MEDIA, -1); } else if (source->priv->media_browse_got_results) { if (source->priv->media_browse_position < source->priv->media_browse_limit) { media_browse_next (source); } else { char *text; text = g_strdup_printf (ngettext ("Only showing %d result", "Only showing %d results", source->priv->media_browse_position), source->priv->media_browse_position); gtk_label_set_text (GTK_LABEL (source->priv->info_bar_label), text); g_free (text); gtk_widget_show (source->priv->info_bar); } } else if (source->priv->media_browse_got_containers == FALSE && source->priv->media_browse_container != NULL) { /* make sure there's no marker row for this container */ delete_marker_row (source, &source->priv->media_browse_container_iter); } } GDK_THREADS_LEAVE (); }