X-Git-Url: http://git.wpitchoune.net/gitweb/?a=blobdiff_plain;f=src%2Fui_sensorpref.c;h=c9f31b3cbc95022ae299a2fc59012723f3845014;hb=2a05d2c097a57b33c203e9e14fe51887c7456ead;hp=9c17475e9c0c34f87e19d46e134a0c29f1cc6aa8;hpb=861ae367cfe3456c91e0d5b8d0e57ac64a179583;p=psensor.git diff --git a/src/ui_sensorpref.c b/src/ui_sensorpref.c index 9c17475..c9f31b3 100644 --- a/src/ui_sensorpref.c +++ b/src/ui_sensorpref.c @@ -30,6 +30,11 @@ #include "ui_appindicator.h" #endif +enum { + COL_NAME = 0, + COL_SENSOR +}; + struct sensor_pref { struct psensor *sensor; char *name; @@ -486,15 +491,14 @@ void ui_sensorpref_dialog_run(struct psensor *sensor, struct ui_psensor *ui) GError *error = NULL; GtkTreeView *w_sensors_list; guint ok; - GtkCellRenderer *renderer; GtkListStore *store; - struct psensor **s_cur; + struct psensor **s_cur, *s; GtkTreeSelection *selection; struct cb_data cbdata; + GtkTreeIter iter; cbdata.ui = ui; - cbdata.prefs = sensor_pref_list_new(ui->sensors, - ui->config); + cbdata.prefs = sensor_pref_list_new(ui->sensors, ui->config); builder = gtk_builder_new(); cbdata.builder = builder; @@ -517,24 +521,16 @@ void ui_sensorpref_dialog_run(struct psensor *sensor, struct ui_psensor *ui) = GTK_TREE_VIEW(gtk_builder_get_object(builder, "sensors_list")); - renderer = gtk_cell_renderer_text_new(); - gtk_tree_view_insert_column_with_attributes(w_sensors_list, - -1, - _("Sensor Name"), - renderer, - "text", 0, NULL); - - store = GTK_LIST_STORE(gtk_tree_view_get_model(w_sensors_list)); - - s_cur = ui->sensors; - while (*s_cur) { - GtkTreeIter iter; - struct psensor *s = *s_cur; + store = GTK_LIST_STORE(gtk_builder_get_object(builder, + "sensors_liststore")); + for (s_cur = ui->sensors; *s_cur; s_cur++) { + s = *s_cur; gtk_list_store_append(store, &iter); - gtk_list_store_set(store, &iter, 0, s->name, -1); - - s_cur++; + gtk_list_store_set(store, &iter, + COL_NAME, s->name, + COL_SENSOR, s, + -1); } selection = gtk_tree_view_get_selection(w_sensors_list);