Back to index

indicator-appmenu  12.10.0
hudsettings.c
Go to the documentation of this file.
00001 /*
00002  * Copyright © 2012 Canonical Ltd.
00003  *
00004  * This program is free software: you can redistribute it and/or modify it
00005  * under the terms of the GNU General Public License version 3, as
00006  * published by the Free Software Foundation.
00007  *
00008  * This program is distributed in the hope that it will be useful, but
00009  * WITHOUT ANY WARRANTY; without even the implied warranties of
00010  * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
00011  * PURPOSE.  See the GNU General Public License for more details.
00012  *
00013  * You should have received a copy of the GNU General Public License along
00014  * with this program.  If not, see <http://www.gnu.org/licenses/>.
00015  *
00016  * Author: Ryan Lortie <desrt@desrt.ca>
00017  */
00018 
00019 #define G_LOG_DOMAIN "hudsettings"
00020 
00021 #include "hudsettings.h"
00022 
00023 #include <gio/gio.h>
00024 
00078 HudSettings hud_settings;
00079 
00080 static void
00081 hud_settings_refresh (GSettings *settings)
00082 {
00083   g_debug ("refreshing hud settings");
00084 
00085   hud_settings.store_usage_data = g_settings_get_boolean (settings, "store-usage-data");
00086 
00087   g_debug ("store-usage-data: %s", hud_settings.store_usage_data ? "true" : "false");
00088 }
00089 
00090 static void
00091 hud_search_settings_refresh (GSettings *settings)
00092 {
00093   g_debug ("refreshing search settings");
00094 
00095   hud_settings.indicator_penalty = g_settings_get_uint (settings, "indicator-penalty");
00096   hud_settings.max_distance = g_settings_get_uint (settings, "max-distance");
00097   hud_settings.add_penalty = g_settings_get_uint (settings, "add-penalty");
00098   hud_settings.drop_penalty = g_settings_get_uint (settings, "drop-penalty");
00099   hud_settings.end_drop_penalty = g_settings_get_uint (settings, "end-drop-penalty");
00100   hud_settings.swap_penalty = g_settings_get_uint (settings, "swap-penalty");
00101 
00102   g_debug ("indicator penalty: %u, max distance: %u",
00103            hud_settings.indicator_penalty, hud_settings.max_distance);
00104   g_debug ("penalties: add:%u drop:%u end-drop:%u swap:%u", hud_settings.add_penalty,
00105            hud_settings.drop_penalty, hud_settings.end_drop_penalty, hud_settings.swap_penalty);
00106 }
00107 
00116 void
00117 hud_settings_init (void)
00118 {
00119   GSettings *settings;
00120 
00121   settings = g_settings_new ("com.canonical.indicator.appmenu.hud");
00122   g_signal_connect (settings, "change-event", G_CALLBACK (hud_settings_refresh), NULL);
00123   hud_settings_refresh (settings);
00124 
00125   settings = g_settings_new ("com.canonical.indicator.appmenu.hud.search");
00126   g_signal_connect (settings, "change-event", G_CALLBACK (hud_search_settings_refresh), NULL);
00127   hud_search_settings_refresh (settings);
00128 }