X-Git-Url: https://git.wpitchoune.net/gitweb/?a=blobdiff_plain;f=src%2Fui_sensorlist.c;h=d60652572baf1efff4d97cab871cc090e04d17e5;hb=d34cde85f716307666ea81af8349e51fd63548cd;hp=1daba909941f3d6de913e0a587998c9321379dd1;hpb=6cec5b45ac95c368e8b6ad4912f1534da9876c7d;p=psensor.git diff --git a/src/ui_sensorlist.c b/src/ui_sensorlist.c index 1daba90..d606525 100644 --- a/src/ui_sensorlist.c +++ b/src/ui_sensorlist.c @@ -114,16 +114,21 @@ void ui_sensorlist_update(struct ui_psensor *ui, bool complete) * if none. */ static struct psensor * -get_sensor_at_pos(GtkTreeView *view, int x, int y, struct psensor **sensors) +get_sensor_at_pos(GtkTreeView *view, int x, int y, struct ui_psensor *ui) { GtkTreePath *path; + GtkTreeModel *model; + GtkTreeIter iter; + struct psensor *s; gtk_tree_view_get_path_at_pos(view, x, y, &path, NULL, NULL, NULL); + model = gtk_tree_view_get_model(ui->sensors_tree); if (path) { - gint *i = gtk_tree_path_get_indices(path); - if (i) - return *(sensors + *i); + if (gtk_tree_model_get_iter(model, &iter, path)) { + gtk_tree_model_get(model, &iter, COL_SENSOR, &s, -1); + return s; + } } return NULL; } @@ -209,7 +214,7 @@ static int on_clicked(GtkWidget *widget, GdkEventButton *event, gpointer data) struct psensor *sensor = get_sensor_at_pos(view, event->x, event->y, - ui->sensors); + ui); if (sensor) { int coli = col_index_to_col(get_col_index_at_pos(view,