Back to index

indicator-appmenu  12.10.0
Defines | Functions | Variables
hudsettings.c File Reference
#include "hudsettings.h"
#include <gio/gio.h>

Go to the source code of this file.

Defines

#define G_LOG_DOMAIN   "hudsettings"

Functions

static void hud_settings_refresh (GSettings *settings)
static void hud_search_settings_refresh (GSettings *settings)
void hud_settings_init (void)
 hud_settings_init:

Variables

HudSettings hud_settings
 SECTION:hudsettings : HudSettings : tunable parameters.

Define Documentation

#define G_LOG_DOMAIN   "hudsettings"

Definition at line 19 of file hudsettings.c.


Function Documentation

static void hud_search_settings_refresh ( GSettings *  settings) [static]

Definition at line 91 of file hudsettings.c.

{
  g_debug ("refreshing search settings");

  hud_settings.indicator_penalty = g_settings_get_uint (settings, "indicator-penalty");
  hud_settings.max_distance = g_settings_get_uint (settings, "max-distance");
  hud_settings.add_penalty = g_settings_get_uint (settings, "add-penalty");
  hud_settings.drop_penalty = g_settings_get_uint (settings, "drop-penalty");
  hud_settings.end_drop_penalty = g_settings_get_uint (settings, "end-drop-penalty");
  hud_settings.swap_penalty = g_settings_get_uint (settings, "swap-penalty");

  g_debug ("indicator penalty: %u, max distance: %u",
           hud_settings.indicator_penalty, hud_settings.max_distance);
  g_debug ("penalties: add:%u drop:%u end-drop:%u swap:%u", hud_settings.add_penalty,
           hud_settings.drop_penalty, hud_settings.end_drop_penalty, hud_settings.swap_penalty);
}

Here is the caller graph for this function:

void hud_settings_init ( void  )

hud_settings_init:

Initialises the #HudSettings using #GSettings and keeps it in sync.

If #GSettings indicates that the settings have changed, they will be updated.

Definition at line 117 of file hudsettings.c.

{
  GSettings *settings;

  settings = g_settings_new ("com.canonical.indicator.appmenu.hud");
  g_signal_connect (settings, "change-event", G_CALLBACK (hud_settings_refresh), NULL);
  hud_settings_refresh (settings);

  settings = g_settings_new ("com.canonical.indicator.appmenu.hud.search");
  g_signal_connect (settings, "change-event", G_CALLBACK (hud_search_settings_refresh), NULL);
  hud_search_settings_refresh (settings);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void hud_settings_refresh ( GSettings *  settings) [static]

Definition at line 81 of file hudsettings.c.

{
  g_debug ("refreshing hud settings");

  hud_settings.store_usage_data = g_settings_get_boolean (settings, "store-usage-data");

  g_debug ("store-usage-data: %s", hud_settings.store_usage_data ? "true" : "false");
}

Here is the caller graph for this function:


Variable Documentation

HudSettings hud_settings

SECTION:hudsettings : HudSettings : tunable parameters.

HudSettings is a structure that contains the value of several

tunable parameters that affect the behaviour of various components of the HUD.

This structure exists for two reasons.

The first reason is that caching these values in local variables eliminates the need to look them up from #GSettings on each use. This vastly improves the performance of the matching algorithms (as many of these values are used quite a lot from within them).

The second reason is to improve testability. The testcases are able to hardcode sane values for the settings without worrying about changes that the user may have made to their local configuration (which could otherwise cause spurious test failures). HudSettings: : if usage tracking should be performed : the percentage by which to increase the distance of indicators when sorting the results list : the maximum distance value we consider as being a matching result : the penalty incurred by a character in the search term that does not exist in the item being matched : the penalty incurred by a character missing from the search string as compared to the item being matched : the penalty incurred by a character missing from the search string as compared to the item being matched when the character is at the end of the item (ie: the search term is a prefix of the item) : the penalty incurred for the substitution of one character for another

This structure contains the value of several tunable parameters that affect the behaviour of various components of the HUD. hud_settings:

The #HudSettings in effect.

hud_settings_init() can be used to keep these values in sync with

GSettings. For testing, it may make sense to set these values

directly.

Definition at line 78 of file hudsettings.c.