GithubHelp home page GithubHelp logo

Enum idiosyncrasies about gir HOT 8 CLOSED

gtk-rs avatar gtk-rs commented on June 14, 2024
Enum idiosyncrasies

from gir.

Comments (8)

EPashkin avatar EPashkin commented on June 14, 2024

Can we just add to this enum next values: Other(int) and DontScale=-1?

from gir.

gkoz avatar gkoz commented on June 14, 2024

Yes but in the automation context the more interesting question is if it's possible to detect such enums and divine the required additional variants. The "don't scale" case might be better reflected with Option::<IconSize>::None.

from gir.

EPashkin avatar EPashkin commented on June 14, 2024

After better looking I found that we need find solution only for 3 functions gtk_icon_set_render_icon, gtk_style_render_icon, gtk_widget_render_icon that accepts -1.
All other function accepts only registered values, so user can just store value returned by get_icon_register and use it in function calls.
Only possible problem with IconSize matching but IMHO it mostly unneeded or can be solved direct comparing with stored value.
For 3 problem function we really can use optional size parameter, but it can't be detected automatically and need some config.
Also we needed solve difference in <type name="gint" c:type="GtkIconSize"/> but IMHO it can be applied to all enums.

from gir.

EPashkin avatar EPashkin commented on June 14, 2024

Updated previous comment.

from gir.

EPashkin avatar EPashkin commented on June 14, 2024

When checking for <type name="gint" c:type="GtkIconSize"/> found many
<type name="gint" c:type="int"/>
and only 2 other ginted ctypes: cairo_format_t and pid_t.
GUinted ctypes uid_t with some unsigned or unsigned int.

from gir.

gkoz avatar gkoz commented on June 14, 2024

So this issue is extremely rare? Good. We could implement the conversions manually and let the generator assume they exist.

It's not clear why cairo_format_t is replaced with an int. Manually adding conversions to/from int would take care of that I expect.

<type name="gint" c:type="int"/> is weird but probably harmless, the rest seem like integers too.

from gir.

gkoz avatar gkoz commented on June 14, 2024

So, the current assumption in the code that enums are passed directly is problematic in light of these exceptions.

What do we do with GType? There's enum Type in glib so the generator should ideally treat it as a converted enum as well.

from gir.

GuillaumeGomez avatar GuillaumeGomez commented on June 14, 2024

I think we can close this issue now.

from gir.

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.