It worked. I updated the code with TreeListModel
and TreeListRowSorter
.
The code worked after TreeListModel
is added. But sorting order is not correct after TreeListRowSorter
is added. I have read the example in the GTK tutorial.
I do not know C. There may be mistakes.
Example in the tutorial:
column_sorter = gtk_column_view_get_sorter (view);
sorter = gtk_tree_list_row_sorter_new (g_object_ref (column_sorter));
sort_model = gtk_sort_list_model_new (tree_model, sorter);
selection = gtk_single_selection_new (sort_model);
gtk_column_view_set_model (view, G_LIST_MODEL (selection));
What is the problem here?
self.model = Gio.ListStore()
tree_list_model = Gtk.TreeListModel.new(self.model, True, True, self.model_func)
column_view_sorter = self.cv.get_sorter()
tree_list_row_sorter = Gtk.TreeListRowSorter.new(column_view_sorter)
sorter_model = Gtk.SortListModel(model=tree_list_model, sorter=tree_list_row_sorter)
selection = Gtk.SingleSelection.new(model=sorter_model)
self.cv.set_model(selection)
Note: model_func
is empty (pass
) and rows do not have child rows.