143
/* recurse so that we can avoid having to prepend the string */
145
hud_result_format_tokens (GString *string,
146
HudStringList *tokens)
151
tail = hud_string_list_get_tail (tokens);
155
hud_result_format_tokens (string, tail);
156
g_string_append (string, " > ");
159
escaped = g_markup_escape_text (hud_string_list_get_head (tokens), -1);
160
g_string_append (string, escaped);
165
hud_result_format_description (HudResult *result)
167
GString *description;
170
description = g_string_new (NULL);
171
hud_result_format_tokens (description, hud_item_get_tokens (result->item));
173
for (i = 0; result->matched[i]; i++)
178
escaped = g_markup_escape_text (result->matched[i], -1);
179
match = strstr (description->str, escaped);
185
start = match - description->str;
186
end = start + strlen (escaped);
188
/* modify the end first so that the modification to the start
189
* doesn't change the offset of the end */
190
g_string_insert (description, end, "</b>");
191
g_string_insert (description, start, "<b>");
197
result->description = g_string_free (description, FALSE);
142
201
* hud_result_new:
143
202
* @item: a #HudItem
165
224
result = g_object_new (HUD_TYPE_RESULT, NULL);
166
225
result->item = g_object_ref (item);
167
226
result->distance = calculate_distance_from_list (search_string, hud_item_get_tokens (item), &result->matched);
168
result->description = hud_string_list_pretty_print (hud_item_get_tokens (result->item));
227
hud_result_format_description (result);
170
229
result->distance += (result->distance * penalty) / 100;