There is an example in Stackoverflow. Perhaps it can serve as a model.
This question has also been addressed in this forum:
My proposal:
// ...
GtkWidget* column_view = gtk_column_view_new(NULL);
gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(scrolled_window), column_view);
// setup sort model then overlay with columnview
GtkSorter *sorter = g_object_ref(gtk_column_view_get_sorter(GTK_COLUMN_VIEW(column_view)));
GtkSortListModel *model = gtk_sort_list_model_new(create_model(),sorter);
GtkSelectionModel* selection_model = GTK_SELECTION_MODEL(gtk_no_selection_new(G_LIST_MODEL(model)));
gtk_column_view_set_model(GTK_COLUMN_VIEW(column_view),GTK_SELECTION_MODEL(selection_model));
// ...
sorter = GTK_SORTER(gtk_custom_sorter_new(compareFunc, NULL, NULL));
// ...
The documentation says:
“The column view supports sorting that can be customized by the user by clicking on column headers. To set this up, the GtkSorter
returned by gtk_column_view_get_sorter()
must be attached to a sort model for the data that the view is showing, and the columns must have sorters attached to them by calling gtk_column_view_column_set_sorter()
. The initial sort order can be set with gtk_column_view_sort_by_column()
.”
Have fun trying.