HudResult

HudResult — a search result: a HudItem plus metadata about why it matched

Synopsis

                    HudResult;
guint               hud_result_get_distance             (HudResult *result,
                                                         guint max_usage);
const gchar *       hud_result_get_html_description     (HudResult *result);
HudResult *         hud_result_get_if_matched           (HudItem *item,
                                                         HudTokenList *search_tokens,
                                                         guint penalty);
HudItem *           hud_result_get_item                 (HudResult *result);
HudResult *         hud_result_new                      (HudItem *item,
                                                         HudTokenList *search_tokens,
                                                         guint penalty);

Object Hierarchy

  GObject
   +----HudResult

Description

A HudResult is a wrapper around a HudItem plus information about why (and how closely) it matched a particular search.

Details

HudResult

typedef struct _HudResult HudResult;

This is an opaque structure type.


hud_result_get_distance ()

guint               hud_result_get_distance             (HudResult *result,
                                                         guint max_usage);

Returns the "adjusted" distance of result.

If max_usage is zero then the returned value is equal to the distance between the HudItem used to create the result and the search string.

If max_usage is non-zero then it is taken to be the usage count of the most-used item in the same query as this result. The distance is adjusted for this fact to penalise less-frequently-used item.

result :

a HudResult

max_usage :

the maximum usage count we consider

Returns :

the adjusted distance

hud_result_get_html_description ()

const gchar *       hud_result_get_html_description     (HudResult *result);

Returns a textual description of result with the parts of the text that matched the search string strenghtened (ie: in bold).

result :

a HudResult

Returns :

the description

hud_result_get_if_matched ()

HudResult *         hud_result_get_if_matched           (HudItem *item,
                                                         HudTokenList *search_tokens,
                                                         guint penalty);

Creates a HudResult for item, only if the resulting unadjusted distance would be less than or equal to the maximum distance specified in the HUD settings.

This is the same as hud_result_new() except that it will return NULL if the distance is too great.

The penalty value is ignored when checking the maximum distance but will impact the distance of the created result. As a result, the returned HudResult may have an effective distance greater than the maximum distance.

item :

a HudItem

search_string :

the search string used

penalty :

a penalty value

Returns :

a new HudResult, or NULL in event of a poor match

hud_result_get_item ()

HudItem *           hud_result_get_item                 (HudResult *result);

Gets the HudItem for result.

result :

a HudResult

Returns :

a HudItem. [transfer none]

hud_result_new ()

HudResult *         hud_result_new                      (HudItem *item,
                                                         HudTokenList *search_tokens,
                                                         guint penalty);

Creates a HudResult for item as search for using search_string.

If penalty is non-zero then it is used to increase the distance of the result. This is used to decrease the ranking of matches from the indicators.

item :

a HudItem

search_string :

the search string used

penalty :

a penalty value

Returns :

the new HudResult