Added a default high threshold for temperature
authorJean-Philippe Orsini <jeanfi@gmail.com>
Sat, 18 Oct 2014 11:21:49 +0000 (13:21 +0200)
committerJean-Philippe Orsini <jeanfi@gmail.com>
Sat, 18 Oct 2014 11:21:49 +0000 (13:21 +0200)
NEWS
src/cfg.c
src/main.c

diff --git a/NEWS b/NEWS
index f6e58ab..5a3c078 100644 (file)
--- 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
 ------
index 3bd02f4..7fb6446 100644 (file)
--- 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)
 {
index dce4573..6d23b80 100644 (file)
@@ -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);