Giter Site home page Giter Site logo

Comments (6)

diamondburned avatar diamondburned commented on July 20, 2024

There actually is a downside: a lot of weird constants in GIR utilize the fact that a gint is always 32-bit to do some cursed bitting, and using Go's int breaks that, because they're 64-bit. I've tried using int before.

The real issue here is GIR using gint for ResponseType instead of being its own enum type afaict.

from gotk4.

MJacred avatar MJacred commented on July 20, 2024

Hm… cursed

How about convenience funcs similar to func gobool(b C.cairo_bool_t) bool, but exported so that API users can access them?

from gotk4.

diamondburned avatar diamondburned commented on July 20, 2024

Eh, that's more trouble than it's worth. I think it's probably better to hard-code a special rule where all parameters with the name responseId with type int will have a type gtk.ResponseType instead.

from gotk4.

MJacred avatar MJacred commented on July 20, 2024

Hm… while it can be somewhat annoying to not be able to create custom response types in more complex dialogs, one can design around it I guess

side note: I updated the issue description with a concrete example to showcase the exact issue/use case of the cannot use response (variable of type gtk.ResponseType) as int value error.
And included a separate error constant unknown with invalid type, which is probably due to my current setup

from gotk4.

diamondburned avatar diamondburned commented on July 20, 2024

the former is currently marked as an error in my environment (probably because it's not completely set up yet): cannot use gtk.ResponseAccept (constant unknown with invalid type) as int value in argument to m.dialog.AddButton. All cgo constants from gotk4 trigger this error, though only the first case is listed in the errors list

Does this happen during development or build? It should build fine even with this error.

the latter causes the following error message:

cannot use response (variable of type gtk.ResponseType) as int value in argument to m.dialog.AddButtoncompiler[IncompatibleAssign](https://pkg.go.dev/golang.org/x/tools/internal/typesinternal#IncompatibleAssign)

Just cast it to int: int(response). You'll have to do the same for gtk.Response* constants too.

from gotk4.

MJacred avatar MJacred commented on July 20, 2024

Does this happen during development or build? It should build fine even with this error.

That was during development. A build shows an error which sounds more sensible:

vendor/github.com/diamondburned/gotk4/pkg/core/glib/paramspec.go:60:13: could not determine kind of name for C.g_param_spec_is_valid_name

That's why the IDE cannot find the type.
I need to upgrade my system first.


Just cast it to int: int(response). You'll have to do the same for gtk.Response* constants too.

Indeed… I thought I would need a more complex solution due to it involving cgo. Seems both errors have the same root cause, will close the issue.
Thank you!

from gotk4.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.