Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Keep names sorted by name in the tree of repobrowser sample

  • Loading branch information...
commit 330e0711210155a6ff84b661f89b9002cbf2b422 1 parent 9ea1656
@pavouk authored
Showing with 11 additions and 2 deletions.
  1. +11 −2 samples/repobrowser.lua
View
13 samples/repobrowser.lua
@@ -57,10 +57,19 @@ local function RepoBrowser()
end
-- Create treeview widget with columns.
+ local sorted = Gtk.TreeModelSort { model = model }
+ sorted:set_sort_func(column.NAME, function(model, a, b)
+ a = model[a][column.NAME]
+ b = model[b][column.NAME]
+ if a == b then return 0
+ elseif a < b then return -1
+ else return 1 end
+ end)
+ sorted:set_sort_column_id(column.NAME, Gtk.SortType.ASCENDING)
self.view = Gtk.TreeView {
- model = model,
+ model = sorted,
Gtk.TreeViewColumn {
- title = "Name", resizable = true,
+ title = "Name", resizable = true, sort_column_id = column.NAME,
{ Gtk.CellRendererText(), expand = true, { text = column.NAME } },
},
Gtk.TreeViewColumn {
Please sign in to comment.
Something went wrong with that request. Please try again.