Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in Filtering of GtkTreeView #58

Closed
zkk960317 opened this issue Apr 16, 2024 · 3 comments
Closed

Bug in Filtering of GtkTreeView #58

zkk960317 opened this issue Apr 16, 2024 · 3 comments

Comments

@zkk960317
Copy link

using Gtk4

ls = GtkListStore(String, Int, Bool, Bool)
push!(ls,("Peter",20,false,true))
push!(ls,("Paul",30,false,true))
push!(ls,("Mary",25,true,true))
insert!(ls, 2, ("Susanne",35,true,true))

rTxt = GtkCellRendererText()
rTog = GtkCellRendererToggle()

c1 = GtkTreeViewColumn("Name", rTxt, Dict([("text",0)]), sort_column_id=0)
c2 = GtkTreeViewColumn("Age", rTxt, Dict([("text",1)]), sort_column_id=1)

tmFiltered = GtkTreeModelFilter(ls)
Gtk4.visible_column(tmFiltered,2)
tv = GtkTreeView(GtkTreeModel(tmFiltered))
push!(tv, c1, c2)

selection = Gtk4.selection(tv)

signal_connect(selection, "changed") do widget
  if hasselection(selection)
    currentIt = selected(selection)

    println("Name: ", GtkTreeModel(tmFiltered)[currentIt,1],
            " Age: ", GtkTreeModel(tmFiltered)[currentIt,1])
  end
end

ent = GtkEntry()

signal_connect(ent, "changed") do widget
  searchText = get_gtk_property(ent, :text, String)

  for l=1:length(ls)
    showMe = true

    if length(searchText) > 0
      showMe = showMe && occursin(lowercase(searchText), lowercase(ls[l,1]))
    end

    ls[l,4] = showMe
  end
end

vbox = GtkBox(:v)
push!(vbox,ent,tv)

win = GtkWindow(vbox, "List View with Filter")

The above codes in document show an error:

ERROR: MethodError: no method matching GtkTreeViewColumn(::String, ::GtkCellRendererTextLeaf, ::Dict{String, Int64}; sort_column_id::Int64)

Closest candidates are:
  GtkTreeViewColumn(::AbstractString, ::GtkCellRenderer, ::Any) got unsupported keyword argument "sort_column_id"
   @ Gtk4 C:\Users\zkk\.julia\packages\Gtk4\7UvLz\src\tree.jl:474
  GtkTreeViewColumn(::GtkCellRenderer, ::Any) got unsupported keyword argument "sort_column_id"
   @ Gtk4 C:\Users\zkk\.julia\packages\Gtk4\7UvLz\src\tree.jl:465
@zkk960317
Copy link
Author

Bug also appears in the Builder part of document.

b = GtkBuilder("path/to/myapp.ui")

The code runs an error:

(process:24376): Gtk-ERROR **: 13:09:35.704: 
failed to add UI from file myapp.ui: myapp.ui:8:49 Invalid property: GtkButton.use_action_appearance

@zkk960317
Copy link
Author

zkk960317 commented Apr 16, 2024

It seems the examples in the document are adapted from Gtk.jl, it may not be compatible with gtk4.jl. When I use the example in the source code, there are really no bugs generated. However, there seems to be a very serious performance issue in Lists, its scrolling, collapsing and filtering operations are very slow. By the way, my platform is windows 10 + Ryzen 2700 + RX 580, not sure if this problem exists on Linux systems.

@jwahlstrand
Copy link
Member

Thanks for pointing this out, the documentation is fixed on the main branch and the example code for GtkTreeView will work in the next released version.

Regarding the performance issue, I use this package on both Linux and Windows and do notice a difference in performance, not just of the Gtk4 listview widgets but all Julia code. I've always thought that this is because the Windows computers I use are encumbered with a bunch of background processes I can't turn off. Generally I find the performance on Windows acceptable, and I don't ever display trees as large as the examples do -- it should be better for smaller trees and lists.

I do agree that the performance of the listviews for large lists and trees is not great, and I think it has to do with the "bind" callbacks, which are impossible (in the case of trees in particular) to make type stable. I am not sure how to improve this right now. At some point when I am less busy I will open an issue with some details on this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants