X-Git-Url: https://git.wpitchoune.net/gitweb/?p=psensor.git;a=blobdiff_plain;f=src%2Fcfg.c;h=19f99ba837da2f040f7f99542eadf716ecc18f24;hp=f0fbd8ae00065973b9ffce01b26546cbd4ff69ad;hb=66aa25bbb5834e9278226680087f4e8b325f23e7;hpb=66bad742624f6d23713a1a614a01fc39bc36db92 diff --git a/src/cfg.c b/src/cfg.c index f0fbd8a..19f99ba 100644 --- a/src/cfg.c +++ b/src/cfg.c @@ -328,22 +328,22 @@ static void set_slog_interval(int interval) set_int(KEY_SLOG_INTERVAL, interval); } -static bool is_window_decoration_enabled(void) +bool config_is_window_decoration_enabled(void) { return !get_bool(KEY_INTERFACE_WINDOW_DECORATION_DISABLED); } -static bool is_window_keep_below_enabled(void) +bool config_is_window_keep_below_enabled(void) { return get_bool(KEY_INTERFACE_WINDOW_KEEP_BELOW_ENABLED); } -static void set_window_decoration_enabled(bool enabled) +void config_set_window_decoration_enabled(bool enabled) { set_bool(KEY_INTERFACE_WINDOW_DECORATION_DISABLED, !enabled); } -static void set_window_keep_below_enabled(bool enabled) +void config_set_window_keep_below_enabled(bool enabled) { set_bool(KEY_INTERFACE_WINDOW_KEEP_BELOW_ENABLED, enabled); } @@ -419,8 +419,6 @@ struct config *config_load(void) c->graph_bg_alpha = get_graph_background_alpha(); c->alpha_channel_enabled = is_alpha_channel_enabled(); c->sensorlist_position = get_sensorlist_position(); - c->window_decoration_enabled = is_window_decoration_enabled(); - c->window_keep_below_enabled = is_window_keep_below_enabled(); c->slog_enabled = is_slog_enabled(); c->slog_interval = config_get_slog_interval(); @@ -474,8 +472,6 @@ void config_save(const struct config *c) set_foreground_color(c->graph_fgcolor); set_graph_background_alpha(c->graph_bg_alpha); set_sensorlist_position(c->sensorlist_position); - set_window_decoration_enabled(c->window_decoration_enabled); - set_window_keep_below_enabled(c->window_keep_below_enabled); set_slog_enabled(c->slog_enabled); set_slog_interval(c->slog_interval); @@ -566,10 +562,12 @@ static GKeyFile *get_sensor_key_file(void) | G_KEY_FILE_KEEP_TRANSLATIONS, &err); - if (!ret) + if (!ret) { log_warn(_("Failed to load configuration file %s: %s"), path, err->message); + g_error_free(err); + } } return key_file; @@ -633,8 +631,13 @@ static bool sensor_get_double(const char *sid, const char *att, double *d) err = NULL; v = g_key_file_get_double(kfile, sid, att, &err); - if (err) + if (err) { + log_err(err->message); + + g_error_free(err); + return false; + } *d = v; return true; @@ -647,15 +650,18 @@ static bool sensor_get_bool(const char *sid, const char *att, bool dft) bool ret; kfile = get_sensor_key_file(); - err = NULL; + err = NULL; ret = g_key_file_get_boolean(kfile, sid, att, &err); - if (err && err->code == G_KEY_FILE_ERROR_KEY_NOT_FOUND) - ret = dft; + if (err) { + if (err->code == G_KEY_FILE_ERROR_KEY_NOT_FOUND) + ret = dft; + else + log_err(err->message); - if (err) g_error_free(err); + } return ret; }