X-Git-Url: https://git.wpitchoune.net/gitweb/?a=blobdiff_plain;f=src%2Fcfg.c;h=3bd02f4532c0a4848dbf6615a49706234af1eb66;hb=912b5d1986633786a656bb3361f7ae9c1263acef;hp=c493a9e5148808b29b48bffb5b9abd6102967753;hpb=de58b641143d1fb9622fa4021c2dd1ab50149dee;p=psensor.git diff --git a/src/cfg.c b/src/cfg.c index c493a9e..3bd02f4 100644 --- a/src/cfg.c +++ b/src/cfg.c @@ -608,6 +608,24 @@ static char *sensor_get_str(const char *sid, const char *att) return g_key_file_get_string(kfile, sid, att, NULL); } +static bool sensor_get_double(const char *sid, const char *att, double *d) +{ + GKeyFile *kfile; + GError *err; + double v; + + kfile = get_sensor_key_file(); + + err = NULL; + v = g_key_file_get_double(kfile, sid, att, &err); + + if (err) + return false; + + *d = v; + return true; +} + static bool sensor_get_bool(const char *sid, const char *att) { GKeyFile *kfile; @@ -663,7 +681,7 @@ void config_set_sensor_color(const char *sid, const GdkRGBA *color) g_free(str); } -static char *next_default_color(void) +static const char *next_default_color(void) { /* copied from the default colors of the gtk color color * chooser. */ @@ -697,7 +715,7 @@ static char *next_default_color(void) "#babdb6" }; static int next_idx; - char *c; + const char *c; c = default_colors[next_idx % 27]; @@ -737,9 +755,9 @@ void config_set_sensor_graph_enabled(const char *sid, bool enabled) sensor_set_bool(sid, ATT_SENSOR_GRAPH_ENABLED, enabled); } -int config_get_sensor_alarm_high_threshold(const char *sid) +bool config_get_sensor_alarm_high_threshold(const char *sid, double *v) { - return sensor_get_int(sid, ATT_SENSOR_ALARM_HIGH_THRESHOLD); + return sensor_get_double(sid, ATT_SENSOR_ALARM_HIGH_THRESHOLD, v); } void config_set_sensor_alarm_high_threshold(const char *sid, int threshold) @@ -747,9 +765,9 @@ void config_set_sensor_alarm_high_threshold(const char *sid, int threshold) sensor_set_int(sid, ATT_SENSOR_ALARM_HIGH_THRESHOLD, threshold); } -int config_get_sensor_alarm_low_threshold(const char *sid) +bool config_get_sensor_alarm_low_threshold(const char *sid, double *v) { - return sensor_get_int(sid, ATT_SENSOR_ALARM_LOW_THRESHOLD); + return sensor_get_double(sid, ATT_SENSOR_ALARM_LOW_THRESHOLD, v); } void config_set_sensor_alarm_low_threshold(const char *sid, int threshold) @@ -883,3 +901,8 @@ void config_set_udisks2_enable(bool b) { set_bool(KEY_PROVIDER_UDISKS2_ENABLED, b); } + +int config_get_sensor_unit(void) +{ + return get_int(KEY_INTERFACE_TEMPERATURE_UNIT); +}