renamed alarm_limit to alarm_high_thresold
authorJean-Philippe Orsini <jeanfi@gmail.com>
Sat, 28 Apr 2012 21:59:15 +0000 (21:59 +0000)
committerJean-Philippe Orsini <jeanfi@gmail.com>
Sat, 28 Apr 2012 21:59:15 +0000 (21:59 +0000)
src/cfg.c
src/cfg.h
src/lib/psensor.c
src/lib/psensor.h
src/main.c
src/ui_sensorpref.c

index ce9d5f8..c93c7d3 100644 (file)
--- a/src/cfg.c
+++ b/src/cfg.c
@@ -261,7 +261,7 @@ void config_set_sensor_color(const char *sid, const struct color *color)
        free(key);
 }
 
-int config_get_sensor_alarm_limit(const char *sid, int dft)
+int config_get_sensor_alarm_high_thresold(const char *sid)
 {
        int res;
        char *key;
@@ -270,15 +270,16 @@ int config_get_sensor_alarm_limit(const char *sid, int dft)
        res = gconf_client_get_int(client, key, NULL);
        free(key);
 
-       return res ? res : dft;
+       return res;
 }
 
-void config_set_sensor_alarm_limit(const char *sid, int alarm_limit)
+void
+config_set_sensor_alarm_high_thresold(const char *sid, int thresold)
 {
        char *key;
 
        key = get_sensor_att_key(sid, "alarmlimit");
-       gconf_client_set_int(client, key, alarm_limit, NULL);
+       gconf_client_set_int(client, key, thresold, NULL);
        free(key);
 }
 
index 272cd7c..e076d02 100644 (file)
--- a/src/cfg.h
+++ b/src/cfg.h
@@ -85,8 +85,8 @@ void config_cleanup();
 struct color *config_get_sensor_color(const char *sid, const struct color *);
 void config_set_sensor_color(const char *sid, const struct color *);
 
-int config_get_sensor_alarm_limit(const char *, int);
-void config_set_sensor_alarm_limit(const char *, int);
+int config_get_sensor_alarm_high_thresold(const char *);
+void config_set_sensor_alarm_high_thresold(const char *, int);
 
 int config_get_sensor_alarm_enabled(const char *);
 void config_set_sensor_alarm_enabled(const char *, int);
index ab54c6c..76a250d 100644 (file)
@@ -49,14 +49,13 @@ struct psensor *psensor_create(char *id, char *name,
        psensor->values_max_length = values_max_length;
        psensor->measures = measures_dbl_create(values_max_length);
 
-       psensor->alarm_limit = 0;
+       psensor->alarm_enabled = 0;
+       psensor->alarm_high_thresold = 0;
 
        psensor->cb_alarm_raised = NULL;
        psensor->cb_alarm_raised_data = NULL;
        psensor->alarm_raised = 0;
 
-       psensor->alarm_enabled = 0;
-
        psensor->url = NULL;
 
        psensor->color = NULL;
@@ -271,8 +270,8 @@ psensor_set_current_measure(struct psensor *s,
        if (s->max == UNKNOWN_DBL_VALUE || v > s->max)
                s->max = v;
 
-       if (s->alarm_limit && s->alarm_enabled) {
-               if (v > s->alarm_limit) {
+       if (s->alarm_enabled) {
+               if (v > s->alarm_high_thresold) {
                        if (!s->alarm_raised && s->cb_alarm_raised)
                                s->cb_alarm_raised(s,
                                                   s->cb_alarm_raised_data);
index 8f110ec..8d798e5 100644 (file)
@@ -84,18 +84,12 @@ struct psensor {
        /* The minimum detected value of the sensor */
        double min;
 
-       /*
-          Whether alarm alerts is enabled for this sensor
-        */
-       int alarm_enabled;
-
-       /*
-          An alarm is raised if the current sensor value is bigger. 0
-          means no limit
-        */
-       double alarm_limit;
-
-       /* Whether the current value is bigger than 'alarm_limit'.  */
+       /* Whether alarm alert is enabled for this sensor */
+       unsigned int alarm_enabled;
+
+       int alarm_high_thresold;
+
+       /* Whether the current value is bigger than 'alarm_high_thresold'. */
        int alarm_raised;
 
        void (*cb_alarm_raised) (struct psensor *, void *);
index 1781038..0698dd3 100644 (file)
@@ -292,12 +292,12 @@ associate_cb_alarm_raised(struct psensor **sensors, struct ui_psensor *ui)
                s->cb_alarm_raised_data = ui;
 
                if (is_temp_type(s->type)) {
-                       s->alarm_limit
-                           = config_get_sensor_alarm_limit(s->id, 60);
+                       s->alarm_high_thresold
+                           = config_get_sensor_alarm_high_thresold(s->id);
                        s->alarm_enabled
                            = config_get_sensor_alarm_enabled(s->id);
                } else {
-                       s->alarm_limit = 0;
+                       s->alarm_high_thresold = 0;
                        s->alarm_enabled = 0;
                }
 
index 331fef3..286b25f 100644 (file)
@@ -32,7 +32,7 @@ struct sensor_pref {
        int enabled;
        struct color *color;
        int alarm_enabled;
-       double alarm_limit;
+       int alarm_high_thresold;
 };
 
 struct cb_data {
@@ -54,9 +54,10 @@ static struct sensor_pref *sensor_pref_new(struct psensor *s,
        p->color = color_dup(s->color);
 
        if (cfg->temperature_unit == CELCIUS)
-               p->alarm_limit = s->alarm_limit;
+               p->alarm_high_thresold = s->alarm_high_thresold;
        else
-               p->alarm_limit = celcius_to_fahrenheit(s->alarm_limit);
+               p->alarm_high_thresold
+                       = celcius_to_fahrenheit(s->alarm_high_thresold);
 
        return p;
 }
@@ -208,7 +209,7 @@ static void on_temp_limit_changed(GtkSpinButton *btn, gpointer data)
        p = get_selected_sensor_pref(cbdata->builder, cbdata->prefs);
 
        if (p)
-               p->alarm_limit = gtk_spin_button_get_value(btn);
+               p->alarm_high_thresold = gtk_spin_button_get_value(btn);
 }
 
 static void connect_signals(GtkBuilder *builder, struct cb_data *cbdata)
@@ -280,7 +281,7 @@ update_pref(struct psensor *s,
 
        if (is_temp_type(s->type)) {
                gtk_toggle_button_set_active(w_alarm, p->alarm_enabled);
-               gtk_spin_button_set_value(w_temp_limit, p->alarm_limit);
+               gtk_spin_button_set_value(w_temp_limit, p->alarm_high_thresold);
                gtk_widget_set_sensitive(GTK_WIDGET(w_alarm), TRUE);
                gtk_widget_set_sensitive(GTK_WIDGET(w_temp_limit), TRUE);
        } else {
@@ -361,13 +362,13 @@ apply_prefs(struct sensor_pref **prefs,
                }
 
                if (cfg->temperature_unit == CELCIUS)
-                       s->alarm_limit = p->alarm_limit;
+                       s->alarm_high_thresold = p->alarm_high_thresold;
                else
-                       s->alarm_limit = fahrenheit_to_celcius
-                               (p->alarm_limit);
+                       s->alarm_high_thresold = fahrenheit_to_celcius
+                               (p->alarm_high_thresold);
 
-               config_set_sensor_alarm_limit(s->id,
-                                             s->alarm_limit);
+               config_set_sensor_alarm_high_thresold(s->id,
+                                                     s->alarm_high_thresold);
 
                if (s->alarm_enabled != p->alarm_enabled) {
                        s->alarm_enabled = p->alarm_enabled;