rpms/gnome-applet-sensors/devel sensors-applet-1.8.1-get-min-max-from-libsensors.patch, NONE, 1.1
Hans de Goede (jwrdegoede)
fedora-extras-commits at redhat.com
Mon Jul 16 11:28:14 UTC 2007
Author: jwrdegoede
Update of /cvs/extras/rpms/gnome-applet-sensors/devel
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv501
Added Files:
sensors-applet-1.8.1-get-min-max-from-libsensors.patch
Log Message:
* Sun Jul 15 2007 Hans de Goede <j.w.r.degoede at hhs.nl> 1.8.1-1
- New upstream release 1.8.1 (fixes bz 235655, 190509)
- Add gtk-icon-update-cache to post scripts (fixes bz 206529)
- Pass proper directory for omf files to scrollkeeper-update in post script
- Initialize sensors low and high tresholds from libsensors settings
- Various specfile cleanups
sensors-applet-1.8.1-get-min-max-from-libsensors.patch:
--- NEW FILE sensors-applet-1.8.1-get-min-max-from-libsensors.patch ---
diff -up sensors-applet-1.8.1/src/sensors-applet.c.minmax sensors-applet-1.8.1/src/sensors-applet.c
--- sensors-applet-1.8.1/src/sensors-applet.c.minmax 2007-07-03 13:05:48.000000000 +0200
+++ sensors-applet-1.8.1/src/sensors-applet.c 2007-07-15 09:43:04.000000000 +0200
@@ -63,7 +63,6 @@
#include "about-dialog.h"
#define SENSORS_APPLET_MENU_FILE "SensorsApplet.xml"
-#define DEFAULT_GRAPH_COLOR "#ff0000"
#define DEFAULT_APPLET_SIZE 24 /* initially set as
* sensors_applet->size to ensure a
* real value is stored */
@@ -1177,6 +1176,25 @@ static ActiveSensor *sensors_applet_find
}
+void sensors_applet_get_default_limits(SensorType type,
+ gdouble *low_value,
+ gdouble *high_value) {
+ switch (type) {
+ case TEMP_SENSOR:
+ *low_value = 20.0;
+ *high_value = 60.0;
+ break;
+ case FAN_SENSOR:
+ *low_value = 600.0;
+ *high_value = 3000.0;
+ break;
+ default:
+ *low_value = 0.0;
+ *high_value = 0.0;
+ }
+}
+
+
/* path should be the full path to a file representing the sensor (eg
* /dev/hda or /sys/devices/platform/i2c-0/0-0290/temp1_input) */
gboolean sensors_applet_add_sensor(SensorsApplet *sensors_applet,
@@ -1191,21 +1209,9 @@ gboolean sensors_applet_add_sensor(Senso
gdouble low_value, high_value;
g_assert(sensors_applet);
+
+ sensors_applet_get_default_limits(type, &low_value, &high_value);
- switch (type) {
- case TEMP_SENSOR:
- low_value = 20.0;
- high_value = 60.0;
- break;
- case FAN_SENSOR:
- low_value = 600.0;
- high_value = 3000.0;
- break;
- default:
- low_value = 0.0;
- high_value = 0.0;
- }
-
return sensors_applet_add_sensor_full_details(sensors_applet,
path,
id,
diff -up sensors-applet-1.8.1/src/sensors-applet.h.minmax sensors-applet-1.8.1/src/sensors-applet.h
--- sensors-applet-1.8.1/src/sensors-applet.h.minmax 2007-07-04 13:02:08.000000000 +0200
+++ sensors-applet-1.8.1/src/sensors-applet.h 2007-07-15 09:43:04.000000000 +0200
@@ -37,6 +37,7 @@ typedef struct _ActiveSensor ActiveSenso
#define GRAPH_FRAME_EXTRA_WIDTH 6
#define SENSORS_APPLET_ICON "sensors-applet"
+#define DEFAULT_GRAPH_COLOR "#ff0000"
/* device icons */
typedef enum {
@@ -250,6 +251,10 @@ gboolean sensors_applet_add_sensor(Senso
SensorType type,
IconType icon);
+void sensors_applet_get_default_limits(SensorType type,
+ gdouble *low_value,
+ gdouble *high_value);
+
/**
* to be called by things like prefs dialog to turn off a sensor alarm
*/
diff -up sensors-applet-1.8.1/src/libsensors-sensors-interface.c.minmax sensors-applet-1.8.1/src/libsensors-sensors-interface.c
--- sensors-applet-1.8.1/src/libsensors-sensors-interface.c.minmax 2007-07-02 15:36:08.000000000 +0200
+++ sensors-applet-1.8.1/src/libsensors-sensors-interface.c 2007-07-15 09:46:06.000000000 +0200
@@ -181,6 +181,26 @@ static char *get_sensor_interesting_labe
return NULL;
}
+static void get_sensor_min_max(const sensors_chip_name *chip, int n1, int n2,
+ int number, gdouble *low_value,
+ gdouble *high_value) {
+ const sensors_feature_data *data;
+ double value;
+
+ /* The sub features are returned directly after the main feature by
+ sensors_get_all_features(), so no need to iterate over all features */
+ while ((data = sensors_get_all_features (*chip, &n1, &n2)) != NULL &&
+ data->mapping == number) {
+ if ((data->mode & SENSORS_MODE_R) &&
+ (sensors_get_feature(*chip, data->number, &value) == 0)) {
+ if (!strcmp(data->name + strlen(data->name) - 4, "_min"))
+ *low_value = value;
+ if (!strcmp(data->name + strlen(data->name) - 4, "_max"))
+ *high_value = value;
+ }
+ }
+}
+
static void libsensors_sensors_interface_get_sensors(SensorsApplet *sensors_applet) {
FILE *file;
const sensors_chip_name *chip;
@@ -225,6 +245,7 @@ static void libsensors_sensors_interface
SensorType type;
gboolean visible;
IconType icon;
+ gdouble low_value, high_value;
gchar *url;
@@ -235,12 +256,21 @@ static void libsensors_sensors_interface
// the 'path' contains all the information we need to
// identify this sensor later
url = g_strdup_printf ("sensor://%s/%d", chip_name, data->number);
+
+ // get low and high values
+ sensors_applet_get_default_limits(type,
+ &low_value, &high_value);
+ get_sensor_min_max(chip, n1, n2, data->number,
+ &low_value, &high_value);
// the id identifies a particular sensor for the user;
// we default to the label returned by libsensors
- sensors_applet_add_sensor (sensors_applet,
- url, label, label,
- LIBSENSORS, visible, type, icon);
+ sensors_applet_add_sensor_full_details(
+ sensors_applet, url, label, label,
+ LIBSENSORS, type, visible,
+ low_value, high_value, FALSE,
+ "", "", 0, 1.0, 0.0, icon,
+ DEFAULT_GRAPH_COLOR);
g_free (url);
}
More information about the scm-commits
mailing list