/* Update interval of the measures of the sensors */
static const char *KEY_SENSOR_UPDATE_INTERVAL
-= "/apps/psensor/sensor/update_interval";
+= "sensor-update-interval";
/* Graph settings */
static const char *KEY_GRAPH_UPDATE_INTERVAL = "graph-update-interval";
/* Path to the script called when a notification is raised */
static const char *KEY_NOTIFICATION_SCRIPT = "notif-script";
-static GConfClient *client;
static GSettings *settings;
static char *user_dir;
static char *sensor_config_path;
+static void (*slog_enabled_cbk)(void *);
+
static char *get_string(const char *key)
{
return g_settings_get_string(settings, key);
set_bool(KEY_SLOG_ENABLED, enabled);
}
-void config_slog_enabled_notify_add(GConfClientNotifyFunc cbk, void *data)
+static void slog_enabled_changed_cbk(GSettings *settings,
+ gchar *key,
+ gpointer data)
{
- log_debug("config_slog_enabled_notify_add");
- gconf_client_add_dir(client,
- KEY_SLOG_ENABLED,
- GCONF_CLIENT_PRELOAD_NONE,
- NULL);
- gconf_client_notify_add(client,
- KEY_SLOG_ENABLED,
- cbk,
- data,
- NULL,
- NULL);
+ if (slog_enabled_cbk)
+ slog_enabled_cbk(data);
+}
+
+void config_set_slog_enabled_changed_cbk(void (*cbk)(void *), void *data)
+{
+ log_fct_enter();
+
+ slog_enabled_cbk = cbk;
+
+ g_signal_connect_after(settings,
+ "changed::slog-enabled",
+ G_CALLBACK(slog_enabled_changed_cbk),
+ data);
+
+ log_fct_exit();
}
int config_get_slog_interval()
set_bool(KEY_INTERFACE_WINDOW_KEEP_BELOW_ENABLED, enabled);
}
-/*
- * Initializes the GConf client.
- */
static void init()
{
- if (!client)
- client = gconf_client_get_default();
-
if (!settings)
settings = g_settings_new("psensor");
}
{
config_sync();
- if (client) {
- g_object_unref(client);
- client = NULL;
- }
-
if (settings) {
g_settings_sync();
g_object_unref(settings);
free(sensor_config_path);
sensor_config_path = NULL;
}
+
+ slog_enabled_cbk = NULL;
}
struct config *config_load()
c->slog_interval = config_get_slog_interval();
c->sensor_update_interval
- = gconf_client_get_int(client, KEY_SENSOR_UPDATE_INTERVAL, NULL);
+ = get_int(KEY_SENSOR_UPDATE_INTERVAL);
if (c->sensor_update_interval < 1)
c->sensor_update_interval = 1;
set_int(KEY_GRAPH_MONITORING_DURATION, c->graph_monitoring_duration);
- gconf_client_set_int(client,
- KEY_SENSOR_UPDATE_INTERVAL,
- c->sensor_update_interval, NULL);
+ set_int(KEY_SENSOR_UPDATE_INTERVAL, c->sensor_update_interval);
set_bool(KEY_INTERFACE_MENU_BAR_DISABLED, c->menu_bar_disabled);
&err);
if (!ret) {
- if (err->code == G_KEY_FILE_ERROR_NOT_FOUND) {
+ if (err->code == G_KEY_FILE_ERROR_NOT_FOUND)
log_fct(_("The configuration file "
"does not exist."));
- } else {
+ else
log_err(_("Failed to parse configuration "
"file: %s"),
path);
- }
}
}