[Xfce4-commits] <xfce4-sensors-plugin:master> Changes in temperature scale and subsequent edits in the max/min fields respect the chosen scale now and are stored properly
Fabian Nowak
noreply at xfce.org
Mon Oct 19 23:44:01 CEST 2009
Updating branch refs/heads/master
to 499e54c38a05e6b1ccad80c35e12db9e09241ac1 (commit)
from e48c84c0406225c24e268a343a3797e7f2365fba (commit)
commit 499e54c38a05e6b1ccad80c35e12db9e09241ac1
Author: Fabian Nowak <timystery at arcor.de>
Date: Mon Oct 19 20:46:51 2009 +0200
Changes in temperature scale and subsequent edits in the max/min fields respect the chosen scale now and are stored properly
lib/sensors-interface.c | 25 +++++++++++++++++++++----
panel-plugin/sensors-plugin.c | 8 ++++++--
2 files changed, 27 insertions(+), 6 deletions(-)
diff --git a/lib/sensors-interface.c b/lib/sensors-interface.c
index 65598e0..23063c0 100644
--- a/lib/sensors-interface.c
+++ b/lib/sensors-interface.c
@@ -47,6 +47,19 @@
*/
GtkTooltips *tooltips = NULL;
+void
+produce_min_max_values (t_chipfeature *chipfeature, t_tempscale scale, float *minval, float *maxval)
+{
+ /* assume that min and max values are read from the hddtemp/lmsensors/acpi as
+ * degree celsius per default -- very sorry for the non-metric peoples */
+ if (chipfeature->class==TEMPERATURE && scale == FAHRENHEIT) {
+ *minval = chipfeature->min_value * 9/5 + 32;
+ *maxval = chipfeature->max_value * 9/5 + 32;
+ } else {
+ *minval = chipfeature->min_value;
+ *maxval = chipfeature->max_value;
+ }
+}
void
fill_gtkTreeStore (GtkTreeStore *model, t_chip *chip, t_tempscale scale, t_sensors_dialog *sd)
@@ -61,6 +74,7 @@ fill_gtkTreeStore (GtkTreeStore *model, t_chip *chip, t_tempscale scale, t_senso
GError *error = NULL;
#endif
gchar *summary, *body, *icon;
+ float minval, maxval;
summary = _("Sensors Plugin Failure");
@@ -102,6 +116,9 @@ fill_gtkTreeStore (GtkTreeStore *model, t_chip *chip, t_tempscale scale, t_senso
chipfeature->formatted_value = g_new (gchar, 0);
format_sensor_value (scale, chipfeature, sensorFeature,
&(chipfeature->formatted_value));
+
+ produce_min_max_values (chipfeature, scale, &minval, &maxval);
+
chipfeature->raw_value = sensorFeature;
gtk_tree_store_append (model, iter, NULL);
if (sd->plugin_dialog)
@@ -110,15 +127,15 @@ fill_gtkTreeStore (GtkTreeStore *model, t_chip *chip, t_tempscale scale, t_senso
1, chipfeature->formatted_value,
2, chipfeature->show,
3, chipfeature->color,
- 4, chipfeature->min_value,
- 5, chipfeature->max_value,
+ 4, minval,
+ 5, maxval,
-1);
else
gtk_tree_store_set ( model, iter,
0, chipfeature->name,
1, chipfeature->formatted_value,
- 2, chipfeature->min_value,
- 3, chipfeature->max_value,
+ 2, minval,
+ 3, maxval,
-1);
} /* end if sensors-valid */
/* g_free(iter); ??? */
diff --git a/panel-plugin/sensors-plugin.c b/panel-plugin/sensors-plugin.c
index d496524..7775712 100644
--- a/panel-plugin/sensors-plugin.c
+++ b/panel-plugin/sensors-plugin.c
@@ -1145,11 +1145,13 @@ minimum_changed (GtkCellRendererText *cellrenderertext, gchar *path_str,
/* get model iterator */
gtk_tree_model_get_iter (model, &iter, path);
- /* set new value */
+ /* set new value according to chosen scale */
gtk_tree_store_set (GTK_TREE_STORE (model), &iter, 4, value, -1);
chip = (t_chip *) g_ptr_array_index(sd->sensors->chips, gtk_combo_box_active);
chipfeature = (t_chipfeature *) g_ptr_array_index(chip->chip_features, atoi(path_str));
+ if (sd->sensors->scale==FAHRENHEIT)
+ value = (value -32 ) * 5/9;
chipfeature->min_value = value;
/* clean up */
@@ -1193,11 +1195,13 @@ maximum_changed (GtkCellRendererText *cellrenderertext, gchar *path_str,
/* get model iterator */
gtk_tree_model_get_iter (model, &iter, path);
- /* set new value */
+ /* set new value according to chosen scale */
gtk_tree_store_set (GTK_TREE_STORE (model), &iter, 5, value, -1);
chip = (t_chip *) g_ptr_array_index(sd->sensors->chips, gtk_combo_box_active);
chipfeature = (t_chipfeature *) g_ptr_array_index(chip->chip_features, atoi(path_str));
+ if (sd->sensors->scale==FAHRENHEIT)
+ value = (value -32 ) * 5/9;
chipfeature->max_value = value;
/* clean up */
More information about the Xfce4-commits
mailing list