How can I remove the selection from the already selected and processed row in the list displayed in the window?
ls = GtkListStore(String, Int, Bool)
push!(ls,("Peter",20,false))
push!(ls,("Paul",30,false))
push!(ls,("Mary",25,true))
tv = GtkTreeView(GtkTreeModel(ls))
rTxt = GtkCellRendererText()
rTog = GtkCellRendererToggle()
c1 = GtkTreeViewColumn("Name", rTxt, Dict([("text",0)]))
c2 = GtkTreeViewColumn("Age", rTxt, Dict([("text",1)]))
c3 = GtkTreeViewColumn("Female", rTog, Dict([("active",2)]))
push!(tv, c1, c2, c3)
win = GtkWindow(tv, "List View")
showall(win)
selection = GAccessor.selection(tv)
signal_connect(selection, "changed") do widget
if hasselection(selection)
currentIt = selected(selection)
println("Name: ", ls[currentIt,1], " Age: ", ls[currentIt,1])
end
end
For example I have this code, and I want to disable the activation of a row after it'll show the window and print "Name: ", ls[currentIt,1], " Age: ", ls[currentIt,1]. Is there any way I can do this?
There's an unselect!
function that Gtk.jl exports for this. However, directly calling it from within the signal_connect
's do
block leads to a Segmentation fault.
As the last part of this Gtk.jl manual page recommends, changing the call to be an @async
call or using Gtk.GLib.@sigatom
on it avoids the segfault:
if hasselection(selection)
currentIt = selected(selection)
@async unselect!(selection, currentIt)
println("Name: ", ls[currentIt,1], " Age: ", ls[currentIt,1])
end