Mon, 28 Oct 2024 13:15:17 +0100
implement listview onselection callback (GTK)
ui/gtk/list.c | file | annotate | diff | comparison | revisions |
--- 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);