![]() |
![]() |
![]() |
Rhythmbox Development Reference Manual | ![]() |
---|---|---|---|---|
Top | Description | Object Hierarchy | Implemented Interfaces | Properties | Signals |
RhythmDBQueryModelRhythmDBQueryModel — a GtkTreeModel containing RhythmDBEntry items |
enum RhythmDBQueryModelLimitType; #define RHYTHMDB_QUERY_MODEL_SUGGESTED_UPDATE_CHUNK struct RhythmDBQueryModel; struct RhythmDBQueryModelClass; RhythmDBQueryModel * rhythmdb_query_model_new (RhythmDB *db
,GPtrArray *query
,GCompareDataFunc sort_func
,gpointer sort_data
,GDestroyNotify sort_data_destroy
,gboolean sort_reverse
); RhythmDBQueryModel * rhythmdb_query_model_new_empty (RhythmDB *db
); void rhythmdb_query_model_copy_contents (RhythmDBQueryModel *dest
,RhythmDBQueryModel *src
); void rhythmdb_query_model_chain (RhythmDBQueryModel *model
,RhythmDBQueryModel *base
,gboolean import_entries
); void rhythmdb_query_model_add_entry (RhythmDBQueryModel *model
,RhythmDBEntry *entry
,gint index
); gboolean rhythmdb_query_model_remove_entry (RhythmDBQueryModel *model
,RhythmDBEntry *entry
); void rhythmdb_query_model_shuffle_entries (RhythmDBQueryModel *model
); void rhythmdb_query_model_move_entry (RhythmDBQueryModel *model
,RhythmDBEntry *entry
,gint index
); guint64 rhythmdb_query_model_get_size (RhythmDBQueryModel *model
); long rhythmdb_query_model_get_duration (RhythmDBQueryModel *model
); gboolean rhythmdb_query_model_entry_to_iter (RhythmDBQueryModel *model
,RhythmDBEntry *entry
,GtkTreeIter *iter
); gboolean rhythmdb_query_model_has_pending_changes (RhythmDBQueryModel *model
); RhythmDBEntry * rhythmdb_query_model_tree_path_to_entry (RhythmDBQueryModel *model
,GtkTreePath *path
); RhythmDBEntry * rhythmdb_query_model_iter_to_entry (RhythmDBQueryModel *model
,GtkTreeIter *entry_iter
); RhythmDBEntry * rhythmdb_query_model_get_next_from_entry (RhythmDBQueryModel *model
,RhythmDBEntry *entry
); RhythmDBEntry * rhythmdb_query_model_get_previous_from_entry (RhythmDBQueryModel *model
,RhythmDBEntry *entry
); char * rhythmdb_query_model_compute_status_normal (RhythmDBQueryModel *model
,const char *singular
,const char *plural
); void rhythmdb_query_model_set_sort_order (RhythmDBQueryModel *model
,GCompareDataFunc sort_func
,gpointer sort_data
,GDestroyNotify sort_data_destroy
,gboolean sort_reverse
); void rhythmdb_query_model_reapply_query (RhythmDBQueryModel *model
,gboolean filter
); gint rhythmdb_query_model_location_sort_func (RhythmDBEntry *a
,RhythmDBEntry *b
,gpointer data
); gint rhythmdb_query_model_string_sort_func (RhythmDBEntry *a
,RhythmDBEntry *b
,gpointer data
); gint rhythmdb_query_model_title_sort_func (RhythmDBEntry *a
,RhythmDBEntry *b
,gpointer data
); gint rhythmdb_query_model_album_sort_func (RhythmDBEntry *a
,RhythmDBEntry *b
,gpointer data
); gint rhythmdb_query_model_artist_sort_func (RhythmDBEntry *a
,RhythmDBEntry *b
,gpointer data
); gint rhythmdb_query_model_genre_sort_func (RhythmDBEntry *a
,RhythmDBEntry *b
,gpointer data
); gint rhythmdb_query_model_track_sort_func (RhythmDBEntry *a
,RhythmDBEntry *b
,gpointer data
); gint rhythmdb_query_model_double_ceiling_sort_func (RhythmDBEntry *a
,RhythmDBEntry *b
,gpointer data
); gint rhythmdb_query_model_ulong_sort_func (RhythmDBEntry *a
,RhythmDBEntry *b
,gpointer data
); gint rhythmdb_query_model_bitrate_sort_func (RhythmDBEntry *a
,RhythmDBEntry *b
,gpointer data
); gint rhythmdb_query_model_date_sort_func (RhythmDBEntry *a
,RhythmDBEntry *b
,gpointer data
);
RhythmDBQueryModel implements RhythmDBQueryResults, GtkTreeModel, RbTreeDragSource and RbTreeDragDest.
"base-model" RhythmDBQueryModel* : Read / Write / Construct "db" RhythmDB* : Read / Write / Construct Only "limit-type" RhythmDBQueryModelLimitType : Read / Write / Construct Only "limit-value" GArray* : Read / Write / Construct Only "query" gpointer : Read / Write "show-hidden" gboolean : Read / Write / Construct "sort-data" gpointer : Read / Write "sort-data-destroy" gpointer : Read / Write "sort-func" gpointer : Read / Write "sort-reverse" gboolean : Read / Write
"complete" :Run Last
"entry-prop-changed" :Run Last
"entry-removed" :Run Last
"filter-entry-drop" :Run Last
"non-entry-dropped" :Run Last
"post-entry-delete" :Run Last
A RhythmDBQueryModel contains an ordered set of RhythmDBEntry items, either generated by running a query against the database, or populated by adding individual entries.
All sources use a RhythmDBQueryModel to provide their track listing. Since most sources provide a search or filtering capacity, there is usually a distinction between the source's base query model, which contains all entries for the source, and its current query model, which reflects the current search terms and filter selections.
A RhythmDBQueryModel can be populated directly from the RhythmDB, or it can be chained to another query model. Chained query models inherit the set of entries from the query model they chain to and then restrict the set using a query.
The query model consists of a GSequence, which provides ordering of entries, and a GHashTable, which allows efficient checks to see if a given entry is in the model. A side effect of this is that an entry can only be placed into a query model in one location.
In addition to the query, a RhythmDBQueryModel can have a sort order and a limit, specified in terms of file size, duration, or number of entries. A query model can only have a limit if it also has a sort order, as the sort order is required to determine which entries fall inside the limit. When a limit is applied, entries that match the query but fall outside the limit are maintained in a separate GSequence and GHashTable inside the query model.
typedef enum { RHYTHMDB_QUERY_MODEL_LIMIT_NONE, RHYTHMDB_QUERY_MODEL_LIMIT_COUNT, RHYTHMDB_QUERY_MODEL_LIMIT_SIZE, RHYTHMDB_QUERY_MODEL_LIMIT_TIME, } RhythmDBQueryModelLimitType;
#define RHYTHMDB_QUERY_MODEL_SUGGESTED_UPDATE_CHUNK 1024
struct RhythmDBQueryModelClass { GObjectClass parent; /* signals */ void (*complete) (RhythmDBQueryModel *model); void (*entry_prop_changed) (RhythmDBQueryModel *model, RhythmDBEntry *entry, RhythmDBPropType prop, const GValue *old, const GValue *new_value); void (*non_entry_dropped) (RhythmDBQueryModel *model, const char *uri, int position); void (*entry_removed) (RhythmDBQueryModel *model, RhythmDBEntry *entry); void (*post_entry_delete) (RhythmDBQueryModel *model, RhythmDBEntry *entry); gboolean (*filter_entry_drop) (RhythmDBQueryModel *model, RhythmDBEntry *entry); };
RhythmDBQueryModel * rhythmdb_query_model_new (RhythmDB *db
,GPtrArray *query
,GCompareDataFunc sort_func
,gpointer sort_data
,GDestroyNotify sort_data_destroy
,gboolean sort_reverse
);
Constructs a new RhythmDBQueryModel with the specified query and sorting parameters.
|
the RhythmDB |
|
the query for the new model |
|
the sort function for the new model |
|
data to pass to the sort function |
|
function to call when destroying the sort data |
|
if TRUE , reverse the sort order |
Returns : |
the newly constructed query model |
RhythmDBQueryModel * rhythmdb_query_model_new_empty (RhythmDB *db
);
Constructs a new empty query model with no query or sorting parameters. This should only be used when the query model will be populated by explicitly adding entries.
|
the RhythmDB |
Returns : |
the newly constructed query model |
void rhythmdb_query_model_copy_contents (RhythmDBQueryModel *dest
,RhythmDBQueryModel *src
);
Copies all entries from src
to dest
.
|
destination RhythmDBQueryModel |
|
source RhythmDBQueryModel |
void rhythmdb_query_model_chain (RhythmDBQueryModel *model
,RhythmDBQueryModel *base
,gboolean import_entries
);
Chains model
to base
. All changes made to the base model will be reflected in
the child model, and all changes made to the child model will be passed on to the
base model.
|
the RhythmDBQueryModel to chain |
|
the RhythmDBQueryModel to chain it to |
|
if TRUE , copy all existing entries from base to model
|
void rhythmdb_query_model_add_entry (RhythmDBQueryModel *model
,RhythmDBEntry *entry
,gint index
);
Adds an entry to the query model at the specified position. Does not check if the entry matches the query (if any).
|
a RhythmDBQueryModel |
|
a RhythmDBEntry to add |
|
position at which to add it, or -1 to add at the end |
gboolean rhythmdb_query_model_remove_entry (RhythmDBQueryModel *model
,RhythmDBEntry *entry
);
Removes an entry from the query model.
|
a RhythmDBQueryModel |
|
the RhythmDBEntry to remove |
Returns : |
TRUE if the entry was removed |
void rhythmdb_query_model_shuffle_entries
(RhythmDBQueryModel *model
);
Shuffles the entries in the model into a new random order.
|
a RhythmDBQueryModel |
void rhythmdb_query_model_move_entry (RhythmDBQueryModel *model
,RhythmDBEntry *entry
,gint index
);
Moves an entry to a new position in the query model. The position must be a between 0 and the number of entries in the model. Specifying -1 does not move the entry to the end of the model.
|
a RhythmDBQueryModel |
|
the RhythmDBEntry to move |
|
position to move to |
guint64 rhythmdb_query_model_get_size (RhythmDBQueryModel *model
);
Returns the total size of all entries in the model.
|
the RhythmDBQueryModel |
Returns : |
the total size (in bytes) of all entries in the model |
long rhythmdb_query_model_get_duration (RhythmDBQueryModel *model
);
Returns the total duration of all entries in the model.
|
the RhythmDBQueryModel |
Returns : |
the total duration (in seconds) of all entries in the model |
gboolean rhythmdb_query_model_entry_to_iter (RhythmDBQueryModel *model
,RhythmDBEntry *entry
,GtkTreeIter *iter
);
Creates a GtkTreeIter pointing to the specified entry in the model.
|
a RhythmDBQueryModel |
|
the RhythmDBEntry to look up |
|
holds the returned GtkTreeIter |
Returns : |
TRUE if the iterator now points to the entry |
gboolean rhythmdb_query_model_has_pending_changes
(RhythmDBQueryModel *model
);
Checks if a RhythmDBQueryModel has any outstanding changes that are yet to be processed. This is not very useful.
|
a RhythmDBQueryModel |
Returns : |
TRUE if there are outstanding changes to the model |
RhythmDBEntry * rhythmdb_query_model_tree_path_to_entry (RhythmDBQueryModel *model
,GtkTreePath *path
);
Locates the RhythmDBEntry identified by the specified path in the model. The caller owns a reference to the returned entry.
|
a RhythmDBQueryModel |
|
a GtkTreePath |
Returns : |
the RhythmDBEntry, if any |
RhythmDBEntry * rhythmdb_query_model_iter_to_entry (RhythmDBQueryModel *model
,GtkTreeIter *entry_iter
);
Locates and returns the RhythmDBEntry pointed to by the specified iterator in the model. The caller owns a reference to the returned entry.
|
a RhythmDBQueryModel |
|
a GtkTreeIter to dereference |
Returns : |
the RhythmDBEntry, if any |
RhythmDBEntry * rhythmdb_query_model_get_next_from_entry (RhythmDBQueryModel *model
,RhythmDBEntry *entry
);
Locates and returns the next RhythmDBEntry in the model after the specified entry. The caller owns a reference to the returned entry.
|
a RhythmDBQueryModel |
|
a RhythmDBEntry |
Returns : |
the next RhythmDBEntry in the model, if any |
RhythmDBEntry * rhythmdb_query_model_get_previous_from_entry (RhythmDBQueryModel *model
,RhythmDBEntry *entry
);
Locates and returns the RhythmDBEntry in the model before the specified entry. The caller owns a reference to the returned entry.
|
a RhythmDBQueryModel |
|
a RhythmDBEntry |
Returns : |
the previous RhythmDBEntry in the model, if any |
char * rhythmdb_query_model_compute_status_normal (RhythmDBQueryModel *model
,const char *singular
,const char *plural
);
Constructs a status string describing the contents of the model.
|
a RhythmDBQueryModel |
|
singular form of the pattern describing the number of entries ("d song") |
|
plural form of the pattern describing the number of entries ("d songs") |
Returns : |
allocated status string, to be freed by the caller. |
void rhythmdb_query_model_set_sort_order (RhythmDBQueryModel *model
,GCompareDataFunc sort_func
,gpointer sort_data
,GDestroyNotify sort_data_destroy
,gboolean sort_reverse
);
Sets a new sort order on the model. This reorders the entries in the model to match the new sort order.
|
a RhythmDBQueryModel |
|
new sort function |
|
data to pass to the new sort function |
|
function to call to free the sort data |
|
if TRUE , reverse the sort order |
void rhythmdb_query_model_reapply_query (RhythmDBQueryModel *model
,gboolean filter
);
Reapplies the existing query to the entries in the model. This is mostly useful when the query contains relative time criteria (such as 'not played in the last hour'). This will only remove entries that are already in the model, it will not find entries that previously did not match the query.
The 'filter' parameter should be set to TRUE when the query is being used as a filter, rather than to define a base set of entries.
|
a RhythmDBQueryModel |
|
if FALSE , emit entry-removed signals |
gint rhythmdb_query_model_location_sort_func (RhythmDBEntry *a
,RhythmDBEntry *b
,gpointer data
);
Sort function for sorting by location.
|
a RhythmDBEntry |
|
a RhythmDBEntry |
|
nothing |
Returns : |
result of sort comparison between a and b. |
gint rhythmdb_query_model_string_sort_func (RhythmDBEntry *a
,RhythmDBEntry *b
,gpointer data
);
Sort function for sorting by a single string property Falls back to location sort order if the strings are equal.
|
a RhythmDBEntry |
|
a RhythmDBEntry |
|
property to sort on |
Returns : |
result of sort comparison between a and b. |
gint rhythmdb_query_model_title_sort_func (RhythmDBEntry *a
,RhythmDBEntry *b
,gpointer data
);
Sort function for sorting by title. Falls back to sorting by location if the titles are the same.
|
a RhythmDBEntry |
|
a RhythmDBEntry |
|
nothing |
Returns : |
result of sort comparison between a and b. |
gint rhythmdb_query_model_album_sort_func (RhythmDBEntry *a
,RhythmDBEntry *b
,gpointer data
);
Sort function for sorting by album. Sorts by album, then disc number, then track number, then title.
|
a RhythmDBEntry |
|
a RhythmDBEntry |
|
nothing |
Returns : |
result of sort comparison between a and b. |
gint rhythmdb_query_model_artist_sort_func (RhythmDBEntry *a
,RhythmDBEntry *b
,gpointer data
);
Sort function for sorting by artist. Sorts by artist, then album, then disc number, then track number, then title.
|
a RhythmDBEntry |
|
a RhythmDBEntry |
|
nothing |
Returns : |
result of sort comparison between a and b. |
gint rhythmdb_query_model_genre_sort_func (RhythmDBEntry *a
,RhythmDBEntry *b
,gpointer data
);
Sort function for sorting by genre. Sorts by genre, then artist, then album, then disc number, then track number, then title.
|
a RhythmDBEntry |
|
a RhythmDBEntry |
|
nothing |
Returns : |
result of sort comparison between a and b. |
gint rhythmdb_query_model_track_sort_func (RhythmDBEntry *a
,RhythmDBEntry *b
,gpointer data
);
Sort function for sorting by track. Sorts by artist, then album, then disc number, then track number, then title.
|
a RhythmDBEntry |
|
a RhythmDBEntry |
|
nothing |
Returns : |
result of sort comparison between a and b. |
gint rhythmdb_query_model_double_ceiling_sort_func (RhythmDBEntry *a
,RhythmDBEntry *b
,gpointer data
);
Sort function for sorting by a rounded floating point value. The property value is rounded up to an integer value for sorting. If the values are the same, falls back to sorting by location.
|
a RhythmDBEntry |
|
a RhythmDBEntry |
|
property to sort on |
Returns : |
result of sort comparison between a and b. |
gint rhythmdb_query_model_ulong_sort_func (RhythmDBEntry *a
,RhythmDBEntry *b
,gpointer data
);
Sort function for sorting by an unsigned integer property value. If the values are the same, falls back to sorting by location.
|
a RhythmDBEntry |
|
a RhythmDBEntry |
|
property to sort on |
Returns : |
result of sort comparison between a and b. |
gint rhythmdb_query_model_bitrate_sort_func (RhythmDBEntry *a
,RhythmDBEntry *b
,gpointer data
);
Sort function for sorting by bitrate. Lossless encodings (as identified by media type) are considered to have the highest possible bitrate. Falls back to sorting by location for equal bitrates.
|
a RhythmDBEntry |
|
a RhythmDBEntry |
|
nothing |
Returns : |
result of sort comparison between a and b. |
gint rhythmdb_query_model_date_sort_func (RhythmDBEntry *a
,RhythmDBEntry *b
,gpointer data
);
Sort function for sorting by release date. Falls back to album sort order for equal dates.
|
a RhythmDBEntry |
|
a RhythmDBEntry |
|
nothing |
Returns : |
result of sort comparison between a and b. |
"base-model"
property"base-model" RhythmDBQueryModel* : Read / Write / Construct
base RhythmDBQueryModel.
"limit-type"
property"limit-type" RhythmDBQueryModelLimitType : Read / Write / Construct Only
type of limit.
Default value: RHYTHMDB_QUERY_MODEL_LIMIT_NONE
"show-hidden"
property"show-hidden" gboolean : Read / Write / Construct
if TRUE, include entries that are ordinarily hidden.
Default value: FALSE
"sort-data-destroy"
property"sort-data-destroy" gpointer : Read / Write
Sort data destroy function.
"sort-reverse"
property"sort-reverse" gboolean : Read / Write
Reverse sort order flag.
Default value: FALSE
"complete"
signalvoid user_function (RhythmDBQueryModel *model,
gpointer user_data) : Run Last
Emitted when the database query populating the model is complete.
|
the RhythmDBQueryModel |
|
user data set when the signal handler was connected. |
"entry-prop-changed"
signalvoid user_function (RhythmDBQueryModel *model,
RhythmDBEntry *entry,
gint prop,
gpointer old,
gpointer new_value,
gpointer user_data) : Run Last
Emitted when an entry in the query model is changed. When multiple properties are changed, the entry-prop-changed signals will be emitted in the order that the changes were made. At the point that the signal is emitted, all changes have already been applied to the RhythmDBEntry.
|
the RhythmDBQueryModel |
|
the RhythmDBEntry that changed |
|
the RhythmDBPropType that was changed |
|
the previous value for the property |
|
the new value for the property |
|
user data set when the signal handler was connected. |
"entry-removed"
signalvoid user_function (RhythmDBQueryModel *model,
RhythmDBEntry *entry,
gpointer user_data) : Run Last
Emitted when an entry is removed from the model. There is some difference between this and the GtkTreeModel row-removed signal but I don't know what it is right now.
|
the RhythmDBQueryModel |
|
the RhythmDBEntry that was removed |
|
user data set when the signal handler was connected. |
"filter-entry-drop"
signalgboolean user_function (RhythmDBQueryModel *model,
RhythmDBEntry *entry,
gpointer user_data) : Run Last
Emitted when an entry is being added to a model by drag-and-drop.
This allows the owner of the model to filter out entries that should
not be added to the model (based on entry type, for instance).
If the signal handler returns FALSE
, the entry will not be added.
|
the RhythmDBQueryModel |
|
the RhythmDBEntry being dropped |
|
user data set when the signal handler was connected. |
"non-entry-dropped"
signalvoid user_function (RhythmDBQueryModel *model,
gchar *uri,
gint position,
gpointer user_data) : Run Last
Emitted when a URI that does not match an existing RhythmDBEntry is dropped into the query model.
|
the RhythmDBQueryModel |
|
the URI that was dropped |
|
the position in the query model at which it was dropped |
|
user data set when the signal handler was connected. |
"post-entry-delete"
signalvoid user_function (RhythmDBQueryModel *model,
RhythmDBEntry *entry,
gpointer user_data) : Run Last
Emitted after an entry has been removed from the model.
|
the RhythmDBQueryModel |
|
the RhythmDBEntry that was removed |
|
user data set when the signal handler was connected. |