X-Git-Url: http://git.wpitchoune.net/gitweb/?a=blobdiff_plain;f=src%2Fui_sensorpref.c;h=573ac5377f7fb320f801a5e4ae30ea22a135c055;hb=a97c35b9efd831fba370e6d101c8d5d8094cc4b4;hp=2335cc14a1b5d8e0435bf0a4475759c3d0381197;hpb=0d5ce393b282c110929a5e8b65a4076358ce5d59;p=psensor.git diff --git a/src/ui_sensorpref.c b/src/ui_sensorpref.c index 2335cc1..573ac53 100644 --- a/src/ui_sensorpref.c +++ b/src/ui_sensorpref.c @@ -32,7 +32,7 @@ enum { COL_NAME = 0, - COL_SENSOR + COL_SENSOR_PREF }; struct sensor_pref { @@ -51,8 +51,8 @@ struct cb_data { GtkBuilder *builder; }; -static struct sensor_pref *sensor_pref_new(struct psensor *s, - struct config *cfg) +static struct sensor_pref * +sensor_pref_new(struct psensor *s, struct config *cfg) { struct sensor_pref *p; @@ -102,7 +102,7 @@ get_selected_sensor_pref(GtkTreeView *tree) pref = NULL; if (gtk_tree_selection_get_selected(selection, &model, &iter)) - gtk_tree_model_get(model, &iter, COL_SENSOR, &pref, -1); + gtk_tree_model_get(model, &iter, COL_SENSOR_PREF, &pref, -1); return pref; } @@ -307,7 +307,6 @@ update_pref(struct sensor_pref *p, struct config *cfg, GtkBuilder *builder) gtk_toggle_button_set_active(w_appindicator_enabled, p->appindicator_enabled); - } static void on_changed(GtkTreeSelection *selection, gpointer data) @@ -316,7 +315,7 @@ static void on_changed(GtkTreeSelection *selection, gpointer 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); @@ -348,7 +347,7 @@ select_sensor(struct psensor *s, struct psensor **sensors, GtkTreeView *tree) } } -static void apply_pref(struct sensor_pref *p, struct config *cfg) +static void apply_pref(struct sensor_pref *p, int pos, struct config *cfg) { struct psensor *s; @@ -365,8 +364,7 @@ static void apply_pref(struct sensor_pref *p, struct config *cfg) config_set_sensor_enabled(s->id, s->enabled); } - if (is_temp_type(s->type) - && cfg->temperature_unit == FAHRENHEIT) { + 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 @@ -391,6 +389,8 @@ static void apply_pref(struct sensor_pref *p, struct config *cfg) s->appindicator_enabled = p->appindicator_enabled; config_set_appindicator_enabled(s->id, s->appindicator_enabled); } + + config_set_sensor_position(s->id, pos); } static void @@ -399,12 +399,15 @@ apply_prefs(GtkTreeModel *model, struct config *cfg) gboolean valid; struct sensor_pref *spref; GtkTreeIter iter; + int i; valid = gtk_tree_model_get_iter_first(model, &iter); + i = 0; while (valid) { - gtk_tree_model_get(model, &iter, COL_SENSOR, &spref, -1); - apply_pref(spref, cfg); + gtk_tree_model_get(model, &iter, COL_SENSOR_PREF, &spref, -1); + apply_pref(spref, i, cfg); valid = gtk_tree_model_iter_next(model, &iter); + i++; } } @@ -458,7 +461,7 @@ void ui_sensorpref_dialog_run(struct psensor *sensor, struct ui_psensor *ui) spref = sensor_pref_new(s, ui->config); gtk_list_store_set(store, &iter, COL_NAME, s->name, - COL_SENSOR, spref, + COL_SENSOR_PREF, spref, -1); if (s == sensor) @@ -486,7 +489,7 @@ void ui_sensorpref_dialog_run(struct psensor *sensor, struct ui_psensor *ui) valid = gtk_tree_model_get_iter_first(model, &iter); while (valid) { - gtk_tree_model_get(model, &iter, COL_SENSOR, &spref, -1); + gtk_tree_model_get(model, &iter, COL_SENSOR_PREF, &spref, -1); sensor_pref_free(spref); valid = gtk_tree_model_iter_next(model, &iter); }