display min/max values
authorJean-Philippe Orsini <jeanfi@gmail.com>
Thu, 9 Oct 2014 06:56:35 +0000 (08:56 +0200)
committerJean-Philippe Orsini <jeanfi@gmail.com>
Thu, 9 Oct 2014 06:56:35 +0000 (08:56 +0200)
src/glade/sensor-edit.glade
src/lib/lmsensor.c
src/lib/psensor.c
src/lib/psensor.h
src/ui_sensorpref.c

index 67fa6fe..69ef482 100644 (file)
                       <object class="GtkLabel" id="label3">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
+                        <property name="margin_left">4</property>
+                        <property name="margin_right">4</property>
+                        <property name="margin_top">4</property>
+                        <property name="margin_bottom">4</property>
                         <property name="xalign">0</property>
                         <property name="xpad">4</property>
                         <property name="label" translatable="yes">Name:</property>
                         <property name="height">1</property>
                       </packing>
                     </child>
+                    <child>
+                      <object class="GtkLabel" id="label5">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="margin_left">4</property>
+                        <property name="margin_right">4</property>
+                        <property name="margin_top">4</property>
+                        <property name="margin_bottom">4</property>
+                        <property name="xalign">0</property>
+                        <property name="xpad">4</property>
+                        <property name="label" translatable="yes">Min:</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">4</property>
+                        <property name="width">1</property>
+                        <property name="height">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="label6">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="margin_left">4</property>
+                        <property name="margin_right">4</property>
+                        <property name="margin_top">4</property>
+                        <property name="margin_bottom">4</property>
+                        <property name="xalign">0</property>
+                        <property name="xpad">4</property>
+                        <property name="label" translatable="yes">Max:</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">5</property>
+                        <property name="width">1</property>
+                        <property name="height">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="sensor_min">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="margin_left">4</property>
+                        <property name="margin_right">4</property>
+                        <property name="margin_top">4</property>
+                        <property name="margin_bottom">4</property>
+                        <property name="xalign">0</property>
+                        <property name="label" translatable="yes">label</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">4</property>
+                        <property name="width">1</property>
+                        <property name="height">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="sensor_max">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="margin_left">4</property>
+                        <property name="margin_right">4</property>
+                        <property name="margin_top">4</property>
+                        <property name="margin_bottom">4</property>
+                        <property name="xalign">0</property>
+                        <property name="label" translatable="yes">label</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">5</property>
+                        <property name="width">1</property>
+                        <property name="height">1</property>
+                      </packing>
+                    </child>
                   </object>
                 </child>
                 <child type="tab">
index d72da3e..32785b6 100644 (file)
@@ -211,6 +211,15 @@ lmsensor_psensor_create(const sensors_chip_name *chip,
 
        psensor = psensor_create(id, label, cname, type, values_max_length);
 
+
+       sf = sensors_get_subfeature(chip, feature, SENSORS_SUBFEATURE_TEMP_MAX);
+       if (sf)
+               psensor->max = get_value(chip, sf);
+
+       sf = sensors_get_subfeature(chip, feature, SENSORS_SUBFEATURE_TEMP_MIN);
+       if (sf)
+               psensor->min = get_value(chip, sf);
+
        lmsensor_data_set(psensor, chip, feature);
 
        if (feature->type == SENSORS_FEATURE_TEMP
index 415af89..c5e412b 100644 (file)
@@ -45,6 +45,9 @@ struct psensor *psensor_create(char *id,
        psensor->sess_lowest = UNKNOWN_DBL_VALUE;
        psensor->sess_highest = UNKNOWN_DBL_VALUE;
 
+       psensor->min = UNKNOWN_DBL_VALUE;
+       psensor->max = UNKNOWN_DBL_VALUE;
+
        psensor->type = type;
 
        psensor->values_max_length = values_max_length;
index 11805f9..cf5dc24 100644 (file)
@@ -80,6 +80,10 @@ struct psensor {
        /* see psensor_type */
        unsigned int type;
 
+       double max;
+
+       double min;
+
        /* The highest value detected during this session. */
        double sess_highest;
 
index 25fff3c..5ed1e49 100644 (file)
@@ -38,6 +38,8 @@ static GtkDialog *w_dialog;
 static GtkLabel *w_sensor_id;
 static GtkLabel *w_sensor_type;
 static GtkLabel *w_sensor_chipname;
+static GtkLabel *w_sensor_min;
+static GtkLabel *w_sensor_max;
 static GtkLabel *w_sensor_low_threshold_unit;
 static GtkLabel *w_sensor_high_threshold_unit;
 static GtkEntry *w_sensor_name;
@@ -271,6 +273,7 @@ static void update_pref(struct psensor *s)
        int use_celsius, threshold;
        GdkRGBA *color;
        const char *chip;
+       char *smin, *smax;
 
        if (!s)
                return;
@@ -287,6 +290,23 @@ static void update_pref(struct psensor *s)
                chip = _("Unknown");
        gtk_label_set_text(w_sensor_chipname, chip);
 
+       use_celsius = config_get_sensor_unit() == CELSIUS ? 1 : 0;
+
+       if (s->min == UNKNOWN_DBL_VALUE)
+               smin = strdup(_("Unknown"));
+       else
+               smin = psensor_value_to_str(s->type, s->min, use_celsius);
+
+       gtk_label_set_text(w_sensor_min, smin);
+       free(smin);
+
+       if (s->max == UNKNOWN_DBL_VALUE)
+               smax = strdup(_("Unknown"));
+       else
+               smax = psensor_value_to_str(s->type, s->max, use_celsius);
+       gtk_label_set_text(w_sensor_max, smax);
+       free(smax);
+
        gtk_toggle_button_set_active(w_sensor_draw,
                                     config_is_sensor_graph_enabled(s->id));
 
@@ -297,7 +317,6 @@ static void update_pref(struct psensor *s)
        gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(w_sensor_color), color);
        gdk_rgba_free(color);
 
-       use_celsius = config_get_sensor_unit() == CELSIUS ? 1 : 0;
        gtk_label_set_text(w_sensor_high_threshold_unit,
                           psensor_type_to_unit_str(s->type, use_celsius));
        gtk_label_set_text(w_sensor_low_threshold_unit,
@@ -416,6 +435,10 @@ static GtkBuilder *load_ui(struct ui_psensor *ui)
                (gtk_builder_get_object(builder, "sensor_name"));
        w_sensor_chipname = GTK_LABEL
                (gtk_builder_get_object(builder, "chip_name"));
+       w_sensor_min = GTK_LABEL
+               (gtk_builder_get_object(builder, "sensor_min"));
+       w_sensor_max = GTK_LABEL
+               (gtk_builder_get_object(builder, "sensor_max"));
        w_sensor_draw = GTK_TOGGLE_BUTTON
                (gtk_builder_get_object(builder, "sensor_draw"));
        w_sensor_display = GTK_TOGGLE_BUTTON