fixed nvidia fan values display.
authorJean-Philippe Orsini <jeanfi@gmail.com>
Tue, 9 Sep 2014 06:33:32 +0000 (08:33 +0200)
committerJean-Philippe Orsini <jeanfi@gmail.com>
Tue, 9 Sep 2014 06:33:32 +0000 (08:33 +0200)
added support of alarm for sensors expressed as percent.

NEWS
NEWS.html
src/graph.c
src/lib/psensor.c
src/lib/psensor.h
src/main.c
src/ui_appindicator.c
src/ui_notify.c
src/ui_sensorpref.c

diff --git a/NEWS b/NEWS
index 2bf623e..faba488 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -17,6 +17,7 @@ v1.1.2
 * Added 'Hide' menu item in the contextual menu of the list of
   sensors.
 * Added free memory support.
+* Added alarm support of sensors expressed as percent.
 
 v1.1.1
 ------
index 6c70496..7996419 100644 (file)
--- a/NEWS.html
+++ b/NEWS.html
@@ -437,6 +437,11 @@ Added <em>Hide</em> menu item in the contextual menu of the list of
 Added free memory support.\r
 </p>\r
 </li>\r
+<li>\r
+<p>\r
+Added alarm support of sensors expressed as percent.\r
+</p>\r
+</li>\r
 </ul></div>\r
 </div>\r
 </div>\r
@@ -2789,7 +2794,7 @@ Fixed BR1: crash when no temperature sensor is available
 <div id="footnotes"><hr /></div>\r
 <div id="footer">\r
 <div id="footer-text">\r
-Last updated 2014-09-08 21:59:03 CEST\r
+Last updated 2014-09-09 08:33:08 CEST\r
 </div>\r
 </div>\r
 </body>\r
index dd367f6..578ad73 100644 (file)
@@ -361,7 +361,7 @@ graph_update(struct psensor **sensors,
                        struct psensor *s = *sensor_cur;
 
                        no_graphs = 0;
-                       if (is_fan_type(s->type)) {
+                       if (s->type & SENSOR_TYPE_RPM) {
                                min = min_rpm;
                                max = max_rpm;
                        } else if (s->type & SENSOR_TYPE_PERCENT) {
@@ -391,7 +391,6 @@ graph_update(struct psensor **sensors,
        cr_pixmap = gdk_cairo_create(gtk_widget_get_window(w_graph));
 
        if (cr_pixmap) {
-
                if (config->alpha_channel_enabled)
                        cairo_set_operator(cr_pixmap, CAIRO_OPERATOR_SOURCE);
 
index badd6d6..c37dc58 100644 (file)
@@ -224,11 +224,6 @@ int is_temp_type(unsigned int type)
        return type & SENSOR_TYPE_TEMP;
 }
 
-int is_fan_type(unsigned int type)
-{
-       return type & SENSOR_TYPE_FAN;
-}
-
 char *
 psensor_value_to_str(unsigned int type, double value, int use_celsius)
 {
@@ -507,9 +502,9 @@ const char *psensor_type_to_unit_str(unsigned int type, int use_celsius)
                        return "\302\260C";
                else
                        return "\302\260F";
-       } else if (is_fan_type(type)) {
+       } else if (type & SENSOR_TYPE_RPM) {
                return _("RPM");
-       } else if (type & SENSOR_TYPE_CPU_USAGE) {
+       } else if (type & SENSOR_TYPE_PERCENT) {
                return _("%");
        } else {
                return _("N/A");
index 3d1013b..99e4c91 100644 (file)
@@ -153,7 +153,6 @@ struct psensor *psensor_list_get_by_id(struct psensor **sensors,
 int psensor_list_contains_type(struct psensor **sensors, unsigned int type);
 
 int is_temp_type(unsigned int type);
-int is_fan_type(unsigned int type);
 
 double get_min_temp(struct psensor **sensors);
 double get_max_temp(struct psensor **sensors);
index e9b10b2..98fc729 100644 (file)
@@ -294,13 +294,8 @@ associate_cb_alarm_raised(struct psensor **sensors, struct ui_psensor *ui)
                s->alarm_low_threshold
                        = config_get_sensor_alarm_low_threshold(s->id);
 
-               if (is_temp_type(s->type) || is_fan_type(s->type)) {
-                       s->alarm_enabled
+               s->alarm_enabled
                            = config_get_sensor_alarm_enabled(s->id);
-               } else {
-                       s->alarm_high_threshold = 0;
-                       s->alarm_enabled = 0;
-               }
 
                sensor_cur++;
        }
index c8887c2..84483cd 100644 (file)
@@ -199,9 +199,9 @@ static void update_label(struct ui_psensor *ui)
 
                        if (is_temp_type((*p)->type))
                                str = "999UUU";
-                       else if (is_fan_type((*p)->type))
+                       else if ((*p)->type & SENSOR_TYPE_RPM)
                                str = "999UUU";
-                       else /* cpu load */
+                       else /* percent */
                                str = "999%";
 
                        if (guide == NULL) {
index 6361f06..e829ed4 100644 (file)
@@ -75,8 +75,8 @@ void ui_notify(struct psensor *sensor, struct ui_psensor *ui)
 
                if (is_temp_type(sensor->type))
                        summary = _("Temperature alert");
-               else if (is_fan_type(sensor->type))
-                       summary = _("Fan alert");
+               else if (sensor->type & SENSOR_TYPE_RPM)
+                       summary = _("Fan speed alert");
                else
                        summary = _("N/A");
 
index 126f33c..d9a909c 100644 (file)
@@ -290,23 +290,12 @@ update_pref(struct sensor_pref *p, struct config *cfg, GtkBuilder *builder)
        w_appindicator_label_enabled = GTK_TOGGLE_BUTTON
                (gtk_builder_get_object(builder, "indicator_label_checkbox"));
 
-       if (is_temp_type(s->type) || is_fan_type(s->type)) {
-               gtk_toggle_button_set_active(w_alarm, p->alarm_enabled);
-               gtk_spin_button_set_value(w_high_threshold,
-                                         p->alarm_high_threshold);
-               gtk_spin_button_set_value(w_low_threshold,
-                                         p->alarm_low_threshold);
-               gtk_widget_set_sensitive(GTK_WIDGET(w_alarm), TRUE);
-               gtk_widget_set_sensitive(GTK_WIDGET(w_high_threshold), TRUE);
-               gtk_widget_set_sensitive(GTK_WIDGET(w_low_threshold), TRUE);
-       } else {
-               gtk_toggle_button_set_active(w_alarm, 0);
-               gtk_spin_button_set_value(w_high_threshold, 0);
-               gtk_spin_button_set_value(w_low_threshold, 0);
-               gtk_widget_set_sensitive(GTK_WIDGET(w_alarm), FALSE);
-               gtk_widget_set_sensitive(GTK_WIDGET(w_high_threshold), FALSE);
-               gtk_widget_set_sensitive(GTK_WIDGET(w_low_threshold), FALSE);
-       }
+       gtk_toggle_button_set_active(w_alarm, p->alarm_enabled);
+       gtk_spin_button_set_value(w_high_threshold, p->alarm_high_threshold);
+       gtk_spin_button_set_value(w_low_threshold, p->alarm_low_threshold);
+       gtk_widget_set_sensitive(GTK_WIDGET(w_alarm), TRUE);
+       gtk_widget_set_sensitive(GTK_WIDGET(w_high_threshold), TRUE);
+       gtk_widget_set_sensitive(GTK_WIDGET(w_low_threshold), TRUE);
 
        gtk_toggle_button_set_active(w_appindicator_enabled,
                                     p->appindicator_enabled);