# HG changeset patch # User Olaf Wintermann # Date 1730117717 -3600 # Node ID cd221f1e9ff69702e9a3f9fdcd40c29f6347135b # Parent 59e94e97ba687e574f0b98bff8d53b4a9099c8d4 implement listview onselection callback (GTK) diff -r 59e94e97ba68 -r cd221f1e9ff6 ui/gtk/list.c --- a/ui/gtk/list.c Mon Oct 28 08:33:22 2024 +0100 +++ b/ui/gtk/list.c Mon Oct 28 13:15:17 2024 +0100 @@ -202,6 +202,7 @@ // bind var list->update = ui_listview_update; list->getselection = ui_listview_getselection; + list->setselection = ui_listview_setselection; list->obj = listview; // add callback @@ -508,6 +509,14 @@ return selection; } +void ui_listview_setselection(UiList *list, UiListSelection selection) { + UiListView *view = list->obj; + GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(view->widget)); + GtkTreePath *path = gtk_tree_path_new_from_indicesv(selection.rows, selection.count); + gtk_tree_selection_select_path(sel, path); + //g_object_unref(path); +} + void ui_listview_destroy(GtkWidget *w, UiListView *v) { gtk_tree_view_set_model(GTK_TREE_VIEW(w), NULL); ui_destroy_boundvar(v->obj->ctx, v->var);