-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add GtkCustomFilter constructor and filtered list view example #36
Conversation
Codecov Report
❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more. @@ Coverage Diff @@
## main #36 +/- ##
==========================================
- Coverage 84.29% 84.21% -0.08%
==========================================
Files 43 43
Lines 4304 4308 +4
==========================================
Hits 3628 3628
- Misses 676 680 +4
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
This is great, I didn't know about CustomFilter! I've also been struggling to use the filters for the new list views -- I think the missing piece is supporting GtkExpression. I'm going to merge this now because it's so useful, but down the line I will look into why there's no GI constructor being generated for CustomFilter. Garbage collection for the filter function should be handled properly by the GI code now, so these types of functions with callbacks can be used. Thanks! |
When you pass in callbacks you have to worry about keeping them from getting garbage collected, and the right way to do it is by passing the function in through a closure. Much of the tedium of this can be handled by GObject introspection and this was added in a rough way in #35, but this one didn't get generated for some reason. I'll look into it when I get a chance. |
Parts of my issues are probably still unrelated to the callback. For example, I also misjudged/misunderstood when bind and unbind are called. The widgets that I am displaying are created once for each setting parameter and "exists" outside of the list. In the bind call I originally then add them to a container. And then I mistakenly though unbind gets called when I remove items from my model or filter them. I just noticed though that unbind gets called pretty frequently, even just when selecting an element from my list. So I had to properly empty the container and re-add the settings-widget. I probably have one or two more of these misconceptions in my code that could cause my errors. I'm trying to expand the example I added until I stumble upon the similar issues, but so far it remains stable |
Hey, I found an issue with the introspection code for some methods with GObject inputs. This is now fixed on master. List view methods were affected the most and I'm wondering if this is the source of your segfaults. Did it help? |
I'm still getting a segfault. Unfortunately, I haven't managed to produce a MWE yet. For my use-case I switched to a listbox for now, but with the filtering there I'm also getting segfaults or illegal instructions. I'm probably still doing something iffy with GTK 😅 |
Heads up, I just modified the constructor for |
Hello again! I just tried out the 0.6 release and on an initial try I seem to be able to filter without getting any segfaults, I'll try to implement the rest of the filtering conditions for my use-case and see if things remain stable but I'm definitely further than I was before 👍 |
Good to hear! The issue was adding a reference to GObjects so that the library doesn't free them. The list views behave pretty differently from the rest of the API. |
Hello! I'm currently working a bit of larger GUI for configuring a tree of settings and I'm trying to use (or rather struggling with my understanding of) the new Gtk4 List API.
I've been following the provided list view example and the recommendations from this issue: #29. So far I've managed to display overview of the tree-nodes with TreeListModel and a seperate ListModel, both with custom sub-widgets. Most of it is still a bit unstable and I run into frequent segmentation faults.
To get filtering to work I had to add a GtkCustomFilter constructor, because the (automatically?) generated constructor could not find CustomFilter_new. I've also added a small example that shows the filtering in action. This PR adds both these changes. If I get the reminder of my GUI to be stable, I could later also add an example for a tree