fossfreedom / coverart-browser

Browse your cover-art albums in Rhythmbox v2.96 - 3.0+
http://xpressubuntu.wordpress.com/
GNU General Public License v3.0
74 stars 19 forks source link

make the playsource persistent #347

Closed fossfreedom closed 9 years ago

fossfreedom commented 9 years ago

At the moment the playing items are visible through the play-source - click on the turntable on the entry view.

These playing items are not persistent between rhythmbox sessions.

Lets look at making this persistent - maybe using RB.PlaylistSource instead of RB.Source. This means reworking not to use the EntryView.

Alternatively - maybe more easily - save the items in the model to a cached file - loaded on restart

fossfreedom commented 9 years ago

save code:

static void
impl_save_contents_to_xml (RBPlaylistSource *source,
               xmlNodePtr node)
{
    RBStaticPlaylistSourcePrivate *priv = RB_STATIC_PLAYLIST_SOURCE_GET_PRIVATE (source);
    GtkTreeIter iter;
    xmlSetProp (node, RB_PLAYLIST_TYPE, RB_PLAYLIST_STATIC);
    if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (priv->base_model), &iter))
        return;
    do {
        xmlNodePtr child_node = xmlNewChild (node, NULL, RB_PLAYLIST_LOCATION, NULL);
        RhythmDBEntry *entry;
        xmlChar *encoded;
        const char *location;
        gtk_tree_model_get (GTK_TREE_MODEL (priv->base_model), &iter, 0, &entry, -1);
        location = rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_LOCATION);
        encoded = xmlEncodeEntitiesReentrant (NULL, BAD_CAST location);
        xmlNodeSetContent (child_node, encoded);
        g_free (encoded);
        rhythmdb_entry_unref (entry);
    } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (priv->base_model), &iter));
}

likewise load is the opposite finding entries via location

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);
        }
    }