Welcome everyone to this whole new gtk-rs release! Time to check what was added/updated in this new version.

Change of minimum supported Rust version

Important information: the minimal gtk-rs supported Rust version is now the 1.34 . We now use the TryFrom trait which was stabilized in this version.

Stepping back?

This release removes the Into trait implementation we added previously when a nullable type was expected. let’s take an example!

Before we could do this:

let label = gtk::Label::new("Hello"); let another_label = gtk::Label::new(None);

Now we have to wrap our "Hello" into Some() :

let label = gtk::Label::new(Some("Hello")); let another_label = gtk::Label::new(None);

There are two reasons behind going back on this feature:

The first one is about the Rust compiler error messages. In some cases, you were forced to provide generics because it couldn’t infer them itself and then led to annoying situations where you had to try to figure out what was going on.

The second one is to go back to some Rust fundamentals: being explicit. Reading code where some obscure transformations occur internally to the API is clearly slowing down the code comprehension process. For example, when the API was expecting a generic type:

let label = gtk::Label::new("Hello"); // We remove the associated widget with mnemonic: label.set_mnemonic_widget(None);

If you try this code, you’ll see the compiler complaining about the fact that it cannot determine what is the generic type None . If you want to fix this code, you had to do:

label.set_mnemonic_widget(None::<gtk::Widget>);

Which isn’t very nice…

We talked about this change for a while and decided it was the best for our users from our point of view.

cairo changes

We made some changes into cairo type hierarchies that led to a global improvement. To sum it up very shortly (thanks to @SimonSapin for providing it!):

Patterns: pseudo-inheritence with Deref (like surfaces already do) instead of an enum of each pattern type. PDF/PS/SVG: a single surface type each instead of a public module, and restrict streams to 'static to make them sound. XBC: a struct like other surface types, instead of a trait. Inherent methods instead of various extension traits

If you want the complete description, it is available in its linked issue.

Builders

Another big add to this release was the generation of builders for widgets. Builders allow to set construct-only properties and other construct properties when creating the widget. For example:

let button = gtk::LockButtonBuilder::new() .text_lock("Lock") .text_unlock("Unlock") .build();

Futures

We now use the std::futures , which means that we can do now do async/await. A full example is available here.

Other things?

Actually yes! But as you can guess, it’d be too just too long to describe them all. Let’s go through them quickly:

New types/functions were generated ( gio is certainly the crate which benefited the most from it).

is certainly the crate which benefited the most from it). Some methods which weren’t supposed to be “inherited” aren’t anymore.

Automatically generated source code is now clearer: the trampoline functions (used for signals for examples) are now inside the function which used them.

Crates source code has received some rustfmt run.

run. Lot of fixes and small improvements…

Changes

For the interested ones, here is the list of the merged pull requests:

sys:

glib:

cairo:

sourceview:

atk:

gio:

pango:

gdk-pixbuf:

gdk:

gtk:

pangocairo:

All this was possible thanks to the gtk-rs/gir project as well:

Thanks to all of our contributors for their (awesome!) work on this release: