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

CompareDataFunc parameters have type nint #1180

Open
medovina opened this issue Feb 9, 2025 · 2 comments
Open

CompareDataFunc parameters have type nint #1180

medovina opened this issue Feb 9, 2025 · 2 comments

Comments

@medovina
Copy link

medovina commented Feb 9, 2025

I'd like to implement a Gtk.ColumnView with sortable columns.

One way to do this is to create a Gtk.CustomSorter object. To build one, I need to provide a CompareDataFunc, which is defined like this:

public delegate int CompareDataFunc(nint a, nint b)

If the arguments a and b had type object, I could cast them to the appropriate type and perform my own comparison. But they have type nint. Shouldn't nint be object here? Or is there some way (e.g. using unsafe code) that I can cast an nint to an object?

@badcel
Copy link
Member

badcel commented Feb 9, 2025

Unfortunately I can't tell you the best way how to solve it as I'm not a GTK dev. So I don't know the alternatives.

At least in regard to the API it is correct as it is: https://docs.gtk.org/glib/callback.CompareDataFunc.html

Perhaps there could be some optimisation later on but this would need to be thought through carefully.

There recently was a discussion. But I don't know the outcome of it.

It would be great to see a C sample how to properly sort a column. From the docs I would think it should be a ColumnViewSorter. If I have sample I could take a look what is needed to make it work as this is the 2nd request for this. But I really need more information to keep things efficient for me. If I have to do all the GTK stuff myself I prefer to do other things with less overhead first.

@badcel
Copy link
Member

badcel commented Feb 9, 2025

As nint is just a pointer you are automatically on a lower level than the regular binding as you would need to create dotnet objects from pointers first. (This is what the binding is doing all the time to make it easy to use GTK. But if the API says "the parameter is a pointer" instead of "The parameter is an object" I can't do much currently.)

Perhaps there could be some convenience API here to make life easier but then I would need to know more details:

If you manage to get the CustomSorter to work and provide a minimal sample I can figure out how to make life easier for you in a later GirCore version.

But again without any support I'm currently not willing to invest my time into it. You can check out the milestones to see the roadmap. There are more than enough points for the coming months and probably years.

So if you care to fundamentally improve the column sorter experience for GirCore let's do this together. I can support with GirCore details and support finding a solution but your part would be the analysis of the GTK column view sorter possibilities so I get an overview on how to do sorting with different c samples. Then I can verify what is needed to get it working and start working on it or even support you getting your hands dirty in GirCore if you care.

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