Back to index

indicator-appmenu  12.10.0
Defines | Typedefs | Functions
hudresult.h File Reference
#include "huditem.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define HUD_TYPE_RESULT   (hud_result_get_type ())
#define HUD_RESULT(inst)
#define HUD_IS_RESULT(inst)

Typedefs

typedef struct _HudResult

Functions

GType hud_result_get_type (void)
HudResult * hud_result_new (HudItem *item, HudTokenList *search_tokens, guint penalty)
 hud_result_new: : a #HudItem : the search string used : a penalty value
HudResult * hud_result_get_if_matched (HudItem *item, HudTokenList *search_tokens, guint penalty)
 hud_result_get_if_matched: : a #HudItem : the search string used : a penalty value
HudItem * hud_result_get_item (HudResult *result)
 hud_result_get_item:
guint hud_result_get_distance (HudResult *result, guint max_usage)
 hud_result_get_distance:
const gchar * hud_result_get_html_description (HudResult *result)
 hud_result_get_html_description:

Define Documentation

#define HUD_IS_RESULT (   inst)
Value:
(G_TYPE_CHECK_INSTANCE_TYPE ((inst),                     \
                                                             HUD_TYPE_RESULT))

Definition at line 27 of file hudresult.h.

#define HUD_RESULT (   inst)
Value:
(G_TYPE_CHECK_INSTANCE_CAST ((inst),                     \
                                                             HUD_TYPE_RESULT, HudResult))

Definition at line 25 of file hudresult.h.

Definition at line 24 of file hudresult.h.


Typedef Documentation

typedef struct _HudResult

Definition at line 30 of file hudresult.h.


Function Documentation

guint hud_result_get_distance ( HudResult *  result,
guint  max_usage 
)

hud_result_get_distance:

Returns:
: a #HudResult : the maximum usage count we consider

Returns the "adjusted" distance of

Returns:
.

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

If 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.

Returns: the adjusted distance

Definition at line 228 of file hudresult.c.

{
  guint distance;

  g_return_val_if_fail (HUD_IS_RESULT (result), G_MAXINT);

  distance = result->distance;

  if (max_usage != 0)
    {
      guint usage, inverse_usage;

      usage = hud_item_get_usage (result->item);
      inverse_usage = max_usage - usage;
      distance += (distance * inverse_usage) / max_usage;
    }

  return distance;
}

Here is the call graph for this function:

Here is the caller graph for this function:

const gchar* hud_result_get_html_description ( HudResult *  result)

hud_result_get_html_description:

Returns:
: a #HudResult

Returns a textual description of

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

Returns: the description

Definition at line 273 of file hudresult.c.

{
  return result->description;
}

Here is the caller graph for this function:

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

hud_result_get_if_matched: : a #HudItem : the search string used : a penalty value

Creates a #HudResult for , 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.

Returns: a new #HudResult, or NULL in event of a poor match

Definition at line 102 of file hudresult.c.

{
  if (!hud_item_get_enabled (item))
    return NULL;

  /* ignore the penalty in the max-distance calculation */
  if (hud_token_list_distance (hud_item_get_token_list (item), search_tokens, NULL) <= hud_settings.max_distance)
    return hud_result_new (item, search_tokens, penalty);
  else
    return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

HudItem* hud_result_get_item ( HudResult *  result)

hud_result_get_item:

Returns:
: a #HudResult

Gets the #HudItem for

Returns:
.

Returns: (transfer none): a #HudItem

Definition at line 258 of file hudresult.c.

{
  return result->item;
}

Here is the caller graph for this function:

GType hud_result_get_type ( void  )
HudResult* hud_result_new ( HudItem *  item,
HudTokenList *  search_tokens,
guint  penalty 
)

hud_result_new: : a #HudItem : the search string used : a penalty value

Creates a #HudResult for as search for using .

If 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.

Returns: the new #HudResult

Definition at line 188 of file hudresult.c.

{
  HudResult *result;

  g_return_val_if_fail (HUD_IS_ITEM (item), NULL);
  g_return_val_if_fail (search_tokens != NULL, NULL);

  result = g_object_new (HUD_TYPE_RESULT, NULL);
  result->item = g_object_ref (item);
  result->distance = hud_token_list_distance (hud_item_get_token_list (item), search_tokens, &result->matched);
  hud_result_format_description (result);

  result->distance += (result->distance * penalty) / 100;

  if (result->distance == 0 && penalty > 0)
    result->distance = 1;

  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function: