## RBPlaylistSource

RBPlaylistSource — Base class for playlist sources

## Functions

RBSource * | rb_playlist_source_new_from_xml ()
void | rb_playlist_source_save_playlist ()
void | rb_playlist_source_save_to_xml ()
void | rb_playlist_source_set_query_model ()
RhythmDBQueryModel * | rb_playlist_source_get_query_model ()
RhythmDB * | rb_playlist_source_get_db ()
void | rb_playlist_source_mark_dirty ()
gboolean | rb_playlist_source_location_in_map ()
gboolean | rb_playlist_source_add_to_map ()

## Properties

RhythmDB * | db | Read
gboolean | dirty | Read
gboolean | is-local | Read / Write / Construct Only

## Types and Values

struct | RBPlaylistSource
struct | RBPlaylistSourceClass

## Object Hierarchy

        GObject
        ╰── GInitiallyUnowned
            ╰── GtkWidget
                ╰── GtkContainer
                    ╰── GtkBox
                        ╰── RBDisplayPage
                            ╰── RBSource
                                ╰── RBPlaylistSource
                                    ├── RBAutoPlaylistSource
                                    ╰── RBStaticPlaylistSource

## Implemented Interfaces

RBPlaylistSource implements AtkImplementorIface, GtkBuildable and GtkOrientable.

## Description

This class provides some common infrastructure for playlist sources. A playlist, in this context, is a persistent user-defined selection from a set of songs. Playlists (static and auto) based on the main library are saved to the playlists.xml file stored alongside the rhythmdb.xml file. Playlists on portable music players are saved on the device in the format the player itself supports.

This class provides most of the source UI (excluding the search bar), holds some of the framework for loading and saving the playlists.xml file, and records which playlists need to be saved.

## Functions

### rb_playlist_source_new_from_xml ()

    RBSource *
    rb_playlist_source_new_from_xml (RBShell *shell,
                                     xmlNodePtr node);

Constructs a playlist source instance from the XML serialized format. This function knows about all the playlist types that can be saved to disk, and it hands off the XML node to the appropriate constructor based on the 'type' attribute of the root node of the playlist.

#### Parameters

shell | the RBShell instance |
node | libxml node containing the playlist |

#### Returns

the playlist

### rb_playlist_source_save_playlist ()

    void
    rb_playlist_source_save_playlist (RBPlaylistSource *source,
                                      const char *uri,
                                      RBPlaylistExportType export_type);

Saves the playlist to an external file in a standard format (M3U, PLS, or XSPF).

#### Parameters

source | a RBPlaylistSource |
uri | destination URI |
export_type | format to save in |

### rb_playlist_source_save_to_xml ()

    void
    rb_playlist_source_save_to_xml (RBPlaylistSource *source,
                                    xmlNodePtr parent_node);

Converts the playlist to XML format, below the specified parent node.

#### Parameters

source | the playlist source to save |
parent_node | libxml node below which to save the playlist |

### rb_playlist_source_set_query_model ()

    void
    rb_playlist_source_set_query_model (RBPlaylistSource *source,
                                        RhythmDBQueryModel *model);

Sets a new query model for the playlist. This updates the entry view to use the new query model and also updates the source query-model property.

This needs to be called when the playlist subclass creates a new query model.

#### Parameters

source | the RBPlaylistSource |
model | the new RhythmDBQueryModel |

### rb_playlist_source_get_query_model ()

    RhythmDBQueryModel *
    rb_playlist_source_get_query_model (RBPlaylistSource *source);

Returns the current RhythmDBQueryModel for the playlist. The caller must not unref the object once finished with it.

#### Parameters

source | a RBPlaylistSource |

#### Returns

the current RhythmDBQueryModel.

[transfer none]

### rb_playlist_source_get_db ()

    RhythmDB *
    rb_playlist_source_get_db (RBPlaylistSource *source);

Returns the RhythmDB instance. The caller must not unref the object once finished with it.

#### Parameters

source | a RBPlaylistSource |

#### Returns

the RhythmDB instance.

[transfer none]

### rb_playlist_source_mark_dirty ()

    void
    rb_playlist_source_mark_dirty (RBPlaylistSource *source);

Marks the playlist dirty. This generally means that the playlist will be saved to disk fairly soon, but the exact meaning can vary between playlist types.

#### Parameters

source | a RBPlaylistSource |

### rb_playlist_source_location_in_map ()

    gboolean
    rb_playlist_source_location_in_map (RBPlaylistSource *source,
                                        const char *location);

Returns TRUE if the specified URI is in the playlist entry map

#### Parameters

source | a RBPlaylistSource |
location | a URI to check |

#### Returns

`TRUE` if the URI is present

### rb_playlist_source_add_to_map ()

    gboolean
    rb_playlist_source_add_to_map (RBPlaylistSource *source,
                                   const char *location);

Adds a URI to the playlist's entry map. This is useful when the URI is being added to the database, but no entry exists for it yet. When the entry is created, it will be added to the query model.

#### Parameters

source | a RBPlaylistSource |
location | a URI to add |

#### Returns

TRUE if the URI was added to the entry map, FALSE if it was already there.

## Types and Values

### struct RBPlaylistSource

    struct RBPlaylistSource;

### struct RBPlaylistSourceClass

    struct RBPlaylistSourceClass {
    	RBSourceClass parent;

    	/* methods */
    	void (*show_entry_view_popup) (RBPlaylistSource *source, RBEntryView *view, gboolean over_entry);
    	void (*save_contents_to_xml) (RBPlaylistSource *source, xmlNodePtr node);
    	void (*mark_dirty)		(RBPlaylistSource *source);
    };

## Property Details

### The `“db”` property

      “db”                       RhythmDB *

The RhythmDB instance

Flags: Read

### The `“dirty”` property

      “dirty”                    gboolean

Whether the playlist has been changed since it was last saved to disk.

Flags: Read

Default value: FALSE

### The `“is-local”` property

      “is-local”                 gboolean

Whether the playlist is attached to the local library. Remote DAAP playlists, for example, are not local.

Flags: Read / Write / Construct Only

Default value: TRUE