RBSourceSearch

RBSourceSearch — Base class for source search implementations

Synopsis

struct              RBSourceSearch;
struct              RBSourceSearchClass;
gboolean            rb_source_search_is_subset          (RBSourceSearch *search,
                                                         const char *current,
                                                         const char *next);
RhythmDBQuery *	    rb_source_search_create_query       (RBSourceSearch *search,
                                                         RhythmDB *db,
                                                         const char *search_text);
void                rb_source_search_action_attach      (RBSourceSearch *search,
                                                         GObject *action);
RBSourceSearch *    rb_source_search_get_from_action    (GObject *action);

Object Hierarchy

  GObject
   +----RBSourceSearch
         +----RBSourceSearchBasic

Description

These translate the text in the search entry box into a RhythmDBQuery. The basic implementation will return a query like RHYTHMDB_QUERY_PROP_LIKE, RHYTHMDB_PROP_SEARCH_MATCH, text. Simple variants can restrict the search to single properties (artist, album, genre). More complicated searches could implement something like the Xesam User Query spec.

The source header finds the search instance to use by looking for the 'rb-source-search' data item on the active search action.

Details

struct RBSourceSearch

struct RBSourceSearch;


struct RBSourceSearchClass

struct RBSourceSearchClass {
	GObjectClass parent_class;

	/* virtual functions */
	gboolean       (*is_subset) (RBSourceSearch *search,
					 const char *current,
					 const char *next);
	RhythmDBQuery *(*create_query) (RBSourceSearch *search,
					 RhythmDB *db,
					 const char *search_text);
};


rb_source_search_is_subset ()

gboolean            rb_source_search_is_subset          (RBSourceSearch *search,
                                                         const char *current,
                                                         const char *next);

Determines whether the new search text will result in a subset of entries matched by the previous search. This is used to optimise the search query.

search :

a RBSourceSearch

current :

the current search text (or NULL if the current search was done with a different search implementation and so cannot be considered)

next :

the new search text

Returns :

TRUE iff the new search text will match a subset of those matched by the current search.

rb_source_search_create_query ()

RhythmDBQuery *	    rb_source_search_create_query       (RBSourceSearch *search,
                                                         RhythmDB *db,
                                                         const char *search_text);

Creates a RhythmDBQuery from the user's search text.

search :

a RBSourceSearch

db :

the RhythmDB

search_text :

the search text

Returns :

RhythmDBQuery for the source to use

rb_source_search_action_attach ()

void                rb_source_search_action_attach      (RBSourceSearch *search,
                                                         GObject *action);

Attaches a RBSourceSearch to a UI action so that the search implementation will be used when the action is active.

search :

RBSourceSearch to associate with the action

action :

UI action to associate the search with

rb_source_search_get_from_action ()

RBSourceSearch *    rb_source_search_get_from_action    (GObject *action);

Returns the RBSourceSearch associated with the specified UI action.

action :

the action to find the RBSourceSearch for

Returns :

associated RBSourceSearch