## RBAutoPlaylistSource RBAutoPlaylistSource — automatic playlist source, based on a database query |

## Synopsis

    struct              RBAutoPlaylistSource;
    struct              RBAutoPlaylistSourceClass;
    RBSource *          rb_auto_playlist_source_new         (RBShell *shell,
                                                             const char *name,
                                                             gboolean local);
    RBSource *          rb_auto_playlist_source_new_from_xml
                                                            (RBShell *shell,
                                                             xmlNodePtr node);
    void                rb_auto_playlist_source_set_query   (RBAutoPlaylistSource *source,
                                                             GPtrArray *query,
                                                             RhythmDBQueryModelLimitType limit_type,
                                                             GValueArray *limit_value,
                                                             const char *sort_key,
                                                             gint sort_order);
    void                rb_auto_playlist_source_get_query   (RBAutoPlaylistSource *source,
                                                             GPtrArray **query,
                                                             RhythmDBQueryModelLimitType *limit_type,
                                                             GValueArray **limit_value,
                                                             char **sort_key,
                                                             gint *sort_order);

## Object Hierarchy

      GObject
       +----GInitiallyUnowned
             +----GtkWidget
                   +----GtkContainer
                         +----GtkBox
                               +----GtkHBox
                                     +----RBDisplayPage
                                           +----RBSource
                                                 +----RBPlaylistSource
                                                       +----RBAutoPlaylistSource

## Implemented Interfaces

RBAutoPlaylistSource implements AtkImplementorIface, GtkBuildable and GtkOrientable.

## Description

A playlist populated with the results of a database query.

The query, limit, and sort settings are saved to the playlists file, so they are persistent.

Searching is implemented by appending the query criteria generated from the search text to the query. Browsing is implemented by using the base query model (or a query model using the query generated from the search text, there is some) as the input to a RBLibraryBrowser.

If the user has not set a sort order as part of the playlist definition, the entry view columns are made clickable to allow the user to sort the results.

## Details

### struct RBAutoPlaylistSource

    struct RBAutoPlaylistSource;

### struct RBAutoPlaylistSourceClass

    struct RBAutoPlaylistSourceClass {
    	RBPlaylistSourceClass parent;

    	GtkActionGroup *action_group;
    };

### rb_auto_playlist_source_new ()

    RBSource *          rb_auto_playlist_source_new         (RBShell *shell,
                                                             const char *name,
                                                             gboolean local);

Creates a new automatic playlist source, initially with an empty query.

`shell` : | the RBShell instance
`name` : | the name of the new playlist
`local` : | if TRUE, the playlist will be considered local
Returns : | the new source

### rb_auto_playlist_source_new_from_xml ()

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

Creates a new auto playlist source by parsing an XML-encoded query.

`shell` : | the RBShell instance
`node` : | libxml node containing the playlist
Returns : | the new source

### rb_auto_playlist_source_set_query ()

    void                rb_auto_playlist_source_set_query   (RBAutoPlaylistSource *source,
                                                             GPtrArray *query,
                                                             RhythmDBQueryModelLimitType limit_type,
                                                             GValueArray *limit_value,
                                                             const char *sort_key,
                                                             gint sort_order);

Sets the database query used to populate the playlist, and also the limit on playlist size, and the sorting type used.

`source` : | the RBAutoPlaylistSource
`query` : | the new database query. [transfer none]
`limit_type` : | the playlist limit type
`limit_value` : | the playlist limit value
`sort_key` : | the sorting key
`sort_order` : | the sorting direction (as a GtkSortType)

### rb_auto_playlist_source_get_query ()

    void                rb_auto_playlist_source_get_query   (RBAutoPlaylistSource *source,
                                                             GPtrArray **query,
                                                             RhythmDBQueryModelLimitType *limit_type,
                                                             GValueArray **limit_value,
                                                             char **sort_key,
                                                             gint *sort_order);

Extracts the current query, playlist limit, and sorting settings for the playlist.

`source` : | the RBAutoPlaylistSource
`query` : | returns the database query for the playlist. [out caller-allocates][transfer full]
`limit_type` : | returns the playlist limit type. [out callee-allocates]
`limit_value` : | returns the playlist limit value. [out callee-allocates]
`sort_key` : | returns the playlist sorting key. [out callee-allocates][transfer full]
`sort_order` : | returns the playlist sorting direction (as a GtkSortType). [out callee-allocates]