Skip to content

Conversation

@BigBoyBarney
Copy link

@BigBoyBarney BigBoyBarney commented Nov 14, 2025

Hi!

This sort of resolves #2, except for one issue that I couldn't figure out.

Template children binding currently does not work, and segfaults.
I am using all the correct functions, but it just doesn't work.
Ah well. Maybe I, or someone smarter than me, can figure it out in the future!

See my 2nd comment in this issue! Everything works now! 🥳

In the meantime, I think this is a decent starting point for others to see how templates work when we have no access to the macros virtually all C examples rely on 😄

Subclassing widgets is almost identical to this as well, so I think this will be useful.

Screencast.From.2025-11-15.21-53-42.mp4

Aparte: this also includes a manual fix in glib.odin#L368 as mentioned in #7 and odin-lang/Odin#5929.

Eventually, a compile fix will be merged, but in the meantime we must remove the alias, otherwise it cannot compile.

Cheers!

PollFD :: _GPollFD
PollFunc :: #type proc "c" (ufds: [^]PollFD, nfsd: uint_, timeout_: int_) -> int_
SList :: _GSList
_GSList :: struct {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This throws the compiler into an infinite loop.

@BigBoyBarney BigBoyBarney changed the title Added template example and workaround fix for compiler error Added template helpers, examples and fix for compiler error Nov 15, 2025
@BigBoyBarney
Copy link
Author

BigBoyBarney commented Nov 15, 2025

I figured out the issues, this should be fine now.

Added a couple of template helpers in place of the C macros and made them a bit more odin-esque. If you have a different vision about the templating API, I'm completely open to suggestions :D

I also added 2 examples:

  • a fully manual one where everything is explicitly typed out
  • one using the new helper procs

@BigBoyBarney
Copy link
Author

Alright, I think this is as feature complete as it's going to get.

Supports (and has examples for) pretty much everything GTK templates can do.

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

Successfully merging this pull request may close these issues.

[Question] How to use template files?

1 participant