+ gtk_toggle_button_set_active(w_appindicator_label_enabled,
+ p->appindicator_label_enabled);
+}
+
+static void on_changed(GtkTreeSelection *selection, gpointer data)
+{
+ struct cb_data *cbdata = data;
+ struct ui_psensor *ui = cbdata->ui;
+ struct sensor_pref *p;
+ GtkTreeView *tree;
+
+ tree = GTK_TREE_VIEW(gtk_builder_get_object(cbdata->builder,
+ "sensors_list"));
+ p = get_selected_sensor_pref(tree);
+ update_pref(p, ui->config, cbdata->builder);
+}
+
+static void
+select_sensor(struct psensor *s, struct psensor **sensors, GtkTreeView *tree)
+{
+ struct psensor **s_cur;
+ int i;
+ GtkTreePath *p;
+
+ p = NULL;
+ for (s_cur = sensors, i = 0; *s_cur; s_cur++, i++)
+ if (s == *s_cur) {
+ p = gtk_tree_path_new_from_indices(i, -1);
+ break;
+ }
+
+ if (p) {
+ GtkTreeSelection *s = gtk_tree_view_get_selection(tree);
+
+ gtk_tree_selection_select_path(s, p);
+ gtk_tree_path_free(p);
+ }
+}
+
+static void apply_pref(struct sensor_pref *p, int pos, struct config *cfg)
+{
+ struct psensor *s;
+
+ s = p->sensor;
+
+ if (strcmp(p->name, s->name)) {
+ free(s->name);
+ s->name = strdup(p->name);
+ config_set_sensor_name(s->id, s->name);
+ }
+
+ if (s->graph_enabled != p->enabled) {
+ s->graph_enabled = p->enabled;
+ config_set_sensor_enabled(s->id, s->graph_enabled);
+ }
+
+ if (is_temp_type(s->type) && cfg->temperature_unit == FAHRENHEIT) {
+ s->alarm_high_threshold
+ = fahrenheit_to_celcius(p->alarm_high_threshold);
+ s->alarm_low_threshold
+ = fahrenheit_to_celcius(p->alarm_low_threshold);
+ } else {
+ s->alarm_high_threshold = p->alarm_high_threshold;
+ s->alarm_low_threshold = p->alarm_low_threshold;
+ }
+
+ config_set_sensor_alarm_high_threshold(s->id, s->alarm_high_threshold);
+ config_set_sensor_alarm_low_threshold(s->id, s->alarm_low_threshold);
+
+ if (s->alarm_enabled != p->alarm_enabled) {
+ s->alarm_enabled = p->alarm_enabled;
+ config_set_sensor_alarm_enabled(s->id, s->alarm_enabled);
+ }