GdkRGBA theme_fg_color;
};
+static struct psensor **list_filter_graph_enabled(struct psensor **sensors)
+{
+ int n, i;
+ struct psensor **result, **cur, *s;
+
+ if (!sensors)
+ return NULL;
+
+ n = psensor_list_size(sensors);
+ result = malloc((n+1) * sizeof(struct psensor *));
+
+ for (cur = sensors, i = 0; *cur; cur++) {
+ s = *cur;
+
+ if (config_is_sensor_graph_enabled(s->id))
+ result[i++] = s;
+ }
+
+ result[i] = NULL;
+
+ return result;
+}
+
/* Return the end time of the graph i.e. the more recent measure. If
* no measure are available, return 0.
* If Bezier curves are used return the measure n-3 to avoid to
if (!gtk_widget_is_drawable(w_graph))
return;
- enabled_sensors = psensor_list_filter_graph_enabled(sensors);
+ enabled_sensors = list_filter_graph_enabled(sensors);
min_rpm = get_min_rpm(enabled_sensors);
max_rpm = get_max_rpm(enabled_sensors);
psensor->color = NULL;
- psensor->graph_enabled = 1;
-
psensor->provider_data = NULL;
psensor->provider_data_free_fct = &free;
return m;
}
-double
-psensor_get_max_current_value(struct psensor **sensors, unsigned int type)
-{
- double m = UNKNOWN_DBL_VALUE;
- struct psensor **s_cur = sensors;
-
- while (*s_cur) {
- struct psensor *s = *s_cur;
-
- if (s->graph_enabled && (s->type & type)) {
- double v = psensor_get_current_value(s);
-
- if (m == UNKNOWN_DBL_VALUE || v > m)
- m = v;
- }
-
- s_cur++;
- }
-
- return m;
-}
-
double get_min_temp(struct psensor **sensors)
{
return get_min_value(sensors, SENSOR_TYPE_TEMP);
psensor_get_current_value(s),
use_celsius);
}
-
-struct psensor **psensor_list_filter_graph_enabled(struct psensor **sensors)
-{
- int n, i;
- struct psensor **result, **cur, *s;
-
- if (!sensors)
- return NULL;
-
- n = psensor_list_size(sensors);
- result = malloc((n+1) * sizeof(struct psensor *));
-
- for (cur = sensors, i = 0; *cur; cur++) {
- s = *cur;
-
- if (s->graph_enabled)
- result[i++] = s;
- }
-
- result[i] = NULL;
-
- return result;
-}
/* Color of the sensor used for the graph */
struct color *color;
- /* Whether the graph sensor is displayed. */
- bool graph_enabled;
-
/* see psensor_type */
unsigned int type;
int alarm_low_threshold;
/* Whether an alarm is raised for this sensor */
- unsigned int alarm_raised;
+ bool alarm_raised;
void (*cb_alarm_raised)(struct psensor *, void *);
void *cb_alarm_raised_data;
void psensor_list_free(struct psensor **sensors);
int psensor_list_size(struct psensor **sensors);
-struct psensor **psensor_list_filter_graph_enabled(struct psensor **);
-
struct psensor *psensor_list_get_by_id(struct psensor **sensors,
const char *id);
double get_min_rpm(struct psensor **sensors);
double get_max_rpm(struct psensor **sensors);
-/* Get the maximal current value of all sensors of a given type. */
-double
-psensor_get_max_current_value(struct psensor **sensors, unsigned int type);
-
/*
* Converts the value of a sensor to a string.
*
char *n;
struct psensor *s = *sensor_cur;
- s->graph_enabled = config_is_sensor_graph_enabled(s->id);
-
n = config_get_sensor_name(s->id);
if (n) {
gtk_list_store_set(store, &iter,
COL_NAME, s->name,
COL_COLOR_STR, scolor,
- COL_GRAPH_ENABLED, s->graph_enabled,
+ COL_GRAPH_ENABLED,
+ config_is_sensor_graph_enabled(s->id),
COL_SENSOR, s,
COL_DISPLAY_ENABLED, enabled,
-1);
GtkTreePath *path;
struct psensor *s, *s2;
gboolean valid;
+ bool b;
ui = (struct ui_psensor *)data;
fmodel = gtk_tree_view_get_model(ui->sensors_tree);
gtk_tree_model_get(fmodel, &iter, COL_SENSOR, &s, -1);
- s->graph_enabled ^= 1;
- config_set_sensor_graph_enabled(s->id, s->graph_enabled);
+ b = config_is_sensor_graph_enabled(s->id) ^ 1;
+ config_set_sensor_graph_enabled(s->id, b);
+
config_sync();
gtk_tree_path_free(path);
gtk_list_store_set(ui->sensors_store,
&iter,
COL_GRAPH_ENABLED,
- s->graph_enabled,
+ b,
-1);
valid = gtk_tree_model_iter_next(model, &iter);
}
p->sensor = s;
p->name = strdup(s->name);
- p->graph_enabled = s->graph_enabled;
+ p->graph_enabled = config_is_sensor_graph_enabled(s->id);
p->alarm_enabled = config_get_sensor_alarm_enabled(s->id);
p->color = color_dup(s->color);
p->display_enabled = config_is_sensor_enabled(s->id);
config_set_sensor_name(s->id, s->name);
}
- if (s->graph_enabled != p->graph_enabled) {
- s->graph_enabled = p->graph_enabled;
- config_set_sensor_graph_enabled(s->id, s->graph_enabled);
- }
+ config_set_sensor_graph_enabled(s->id, p->graph_enabled);
if (is_temp_type(s->type) && cfg->temperature_unit == FAHRENHEIT) {
s->alarm_high_threshold
*/
#include <unity.h>
+#include <cfg.h>
#include <temperature.h>
#include <ui_unity.h>
static UnityLauncherEntry *psensor_entry;
static unsigned int last_visible = -1;
+static double get_max_current_value(struct psensor **sensors, unsigned int type)
+{
+ double m, v;
+ struct psensor *s;
+
+ m = UNKNOWN_DBL_VALUE;
+ while (*sensors) {
+ s = *sensors;
+
+ if ((s->type & type) && config_is_sensor_graph_enabled(s->id)) {
+ v = psensor_get_current_value(s);
+
+ if (m == UNKNOWN_DBL_VALUE || v > m)
+ m = v;
+ }
+
+ sensors++;
+ }
+
+ return m;
+}
+
void ui_unity_launcher_entry_update(struct psensor **sensors,
unsigned int show,
int use_celsius)
}
if (sensors && *sensors) {
- v = psensor_get_max_current_value(sensors, SENSOR_TYPE_TEMP);
+ v = get_max_current_value(sensors, SENSOR_TYPE_TEMP);
if (!use_celsius)
v = celsius_to_fahrenheit(v);