Crates meet automation (gtk 0.0.4)
What’s new with the latest batch of crates and the reason for some incompatible changes? More automation.
No more features
You don’t have to set the target library versions in your Cargo.toml
.
The build script will query the installed library versions from pkg-config
and instruct rustc
via cfg
arguments to compile the appropriate set of APIs.
All the APIs available in the installed library will just work but if you attempt to use newer ones, the build will fail. Presently, Rust doesn’t allow to generate custom error messages so there doesn’t appear to be a way to make such errors more friendly.
Note that a cargo issue will prevent cargo doc
from generating the
documentation or at least cause it to be incomplete.
Migration
Remove any features
and default-features
directives relating to Gtk-rs
crates from your Cargo.toml
.
Introducing autogenerated sys crates
From now on, the FFI definitions crates (except cairo-sys
) don’t have to
be maintained manually. They’re being generated from GObject introspection
metadata. Take a look at the sys repo if you’re interested in details.
This fixes incorrectly transcribed definitions and should avoid such human
mistakes in the future.
The impact is converting many enum
s to bitflags
they should have been
from the beginning and some spelling changes.
Migration
- Notable enum variants and consts that have effectively been renamed:
WindowType::TopLevel
->WindowType::Toplevel
(changed the capitalization of ‘level’),DialogFlags::Modal
->DIALOG_MODAL
(a constant instead of an enum variant),
IconSize
has to be cast toi32
until it’s replaced with a proper enum.
These regular expressions should take care of renaming:
s/WindowType::TopLevel/WindowType::Toplevel/
s/DialogFlags::Modal/DIALOG_MODAL/
s/(IconSize::\w+)/$1 as i32/