Thanks to @brainblasted the Rust GTK bindings now have support for subclassing various GTK widget classes, namely GtkWidget itself, GtkContainer, GtkBox and GtkEventBox.

We're slowly getting to full API coverage, good work!

@slomo @brainblasted how come to calls to the parent_class' function f() isn't the only thing that's (that needs to be?) in usafe { } ?

@hirojin @brainblasted In the `parent_XXX` functions? All those lines are unsafe, they do C/Rust translation in both directions and work on raw pointers. They have to poke into the C structs for finding the function pointer, then convert all the Rust types to something C can handle (raw pointers, enums to integers, etc), then call the C function pointer, then convert any return values (or out parameters) back to the corresponding Rust types. Each of these steps is unsafe.

They're the other side of the `unsafe extern` trampoline functions at the end of the file, which are called from C, have to do the FFI translations, call the Rust code, translate back to whatever C wants.

@hirojin @brainblasted Sure no problem! Feel free to ask more questions if something's not clear

Sign in to participate in the conversation

The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!