From: Jean-Philippe Orsini Date: Sat, 18 Oct 2014 11:21:49 +0000 (+0200) Subject: Added a default high threshold for temperature X-Git-Tag: v1.2.0~70 X-Git-Url: http://git.wpitchoune.net/gitweb/?p=psensor.git;a=commitdiff_plain;h=bcc60f94fc788d774205bcf824b655ae2fb4e6fc Added a default high threshold for temperature --- diff --git a/NEWS b/NEWS index f6e58ab..5a3c078 100644 --- a/NEWS +++ b/NEWS @@ -12,6 +12,7 @@ v1.1.4 * Avoid multiple sensor preferences dialog at the same time. * Support max/min sensor information from providers. * Fixed string not translatable. (Closes: #138076). +* Added a default high threshold for temperature. v1.1.3 ------ diff --git a/src/cfg.c b/src/cfg.c index 3bd02f4..7fb6446 100644 --- a/src/cfg.c +++ b/src/cfg.c @@ -119,6 +119,9 @@ static const char *KEY_PROVIDER_LIBATASMART_ENABLED static const char *KEY_PROVIDER_NVCTRL_ENABLED = "provider-nvctrl-enabled"; static const char *KEY_PROVIDER_UDISKS2_ENABLED = "provider-udisks2-enabled"; +static const char *KEY_DEFAULT_HIGH_THRESHOLD_TEMPERATURE += "default-high-threshold-temperature"; + static GSettings *settings; static char *user_dir; @@ -353,6 +356,10 @@ void config_set_smooth_curves_enabled(bool b) set_bool(KEY_GRAPH_SMOOTH_CURVES_ENABLED, b); } +double config_get_default_high_threshold_temperature(void) +{ + return get_double(KEY_DEFAULT_HIGH_THRESHOLD_TEMPERATURE); +} static void init(void) { diff --git a/src/main.c b/src/main.c index dce4573..6d23b80 100644 --- a/src/main.c +++ b/src/main.c @@ -229,6 +229,9 @@ associate_cb_alarm_raised(struct psensor **sensors, struct ui_psensor *ui) { bool ret; struct psensor *s; + double d, high_temp; + + high_temp = config_get_default_high_threshold_temperature(); while (*sensors) { s = *sensors; @@ -239,8 +242,14 @@ associate_cb_alarm_raised(struct psensor **sensors, struct ui_psensor *ui) ret = config_get_sensor_alarm_high_threshold (s->id, &s->alarm_high_threshold); - if (!ret && s->max != UNKNOWN_DBL_VALUE) - s->alarm_high_threshold = s->max; + if (!ret) { + if (s->max == UNKNOWN_DBL_VALUE) { + if (s->type & SENSOR_TYPE_TEMP) + s->alarm_high_threshold = high_temp; + } else { + s->alarm_high_threshold = s->max; + } + } ret = config_get_sensor_alarm_low_threshold (s->id, &s->alarm_low_threshold);