Across the line!
Hi everyone!
It’s time for a new release! Main adds/changes this time are:
- We added the generation of the
Atk
crate. - We now generate functions taking callback as parameters.
- We improved the channels handling in
GLib
. - The whole new
GString
type! - The minimum Rust version supported is now the
1.31
. - The minimum version of all libraries has been changed to GNOME
3.14
. - The maximum version of all libraries has been upgraded to GNOME
3.30
. - Added subclassing support in GLib.
- Even more bindings generated.
Let’s see those in details.
Atk §
The Atk crate is about accessibility. We thought it was a miss not having it considering how important accessibility is. Now it’s fixed! You can find more information directly on the Atk
repository or in the accessibility example.
Callbacks? §
We already implemented by hand a lot of these functions but the big new thing in here is that they’re now automatically generated.
To present this, let’s use the foreach
method of TreeModel
:
The C version looks like this:
void gtk_tree_model_foreach(
GtkTreeModel *model,
GtkTreeModelForeachFunc func,
gpointer user_data
);
Nothing fancy here: it takes the object we’re running this function upon, a callback and some user data. Now here’s the Rust version:
fn foreach<P: FnMut(&TreeModel, &TreePath, &TreeIter) -> bool>(
&self,
func: P,
);
No more user data since closures can capture their environment, just the object and the callback (aka closure). Makes things a bit simpler and nicer to use.
GLib channels §
Instead of rewriting something fully in here, I’ll just show you what it looks like and recommend you to go read the excellent Sebastian’s blog post about it: https://coaxion.net/blog/2019/02/mpsc-channel-api-for-painless-usage-of-threads-with-gtk-in-rust/
enum Message {
UpdateLabel(String),
}
[...]
let label = gtk::Label::new("not finished");
[...]
// Create a new sender/receiver pair with default priority
let (sender, receiver) = glib::MainContext::channel(glib::PRIORITY_DEFAULT);
// Spawn the thread and move the sender in there
thread::spawn(move || {
thread::sleep(time::Duration::from_secs(10));
// Sending fails if the receiver is closed
let _ = sender.send(Message::UpdateLabel(String::from("finished")));
});
// Attach the receiver to the default main context (None)
// and on every message update the label accordingly.
let label_clone = label.clone();
receiver.attach(None, move |msg| {
match msg {
Message::UpdateLabel(text) => label_clone.set_text(text.as_str()),
}
// Returning false here would close the receiver
// and have senders fail
glib::Continue(true)
});
GString
type? §
This type has been created in order to prevent some useless copies to improve performances. It’s used in case a function returns a String
while fully transferring it. In such cases, we now just wrap it instead of cloning it.
This is part of our performance focus. More to come in the next release!
Minimum Rust version supported §
We moved it to 1.31.0
mainly because imports handling is much easier starting this version. We still need to update macros though (an issue about it is already open).
subclassing support in GLib §
This is a strongly asked feature and we now have it in GLib. A lot of work remains to be done, but it’s mostly polishing. At its current state, it can be used already. Take a look at the listbox_model if you want to see how it works.
Even more bindings generated §
Just like usual, with the improvements of our gir crate, we are able to generate more and more parts of all the GNOME libraries we wrote bindings for.
Conclusion §
That’s it for this release! Don’t forget to take a look at our brand new F.A.Q. section.
And again: thanks a lot to all of our contributors! This project lives thanks to their awesome work!
Changes §
For the interested ones, here is the list of the merged pull requests:
sys:
- Install libmount-dev
- Update versions in Travis/AppVeyor configuration
- Update to GNOME 3.14 versions
- Include missing headers for ABI checks.
- Fix generating array of pointers
- Fix GtkIconSize usage
glib:
- For setting properties and the return value of signal handlers relax …
- Re-implement MainContext channel around a manual channel
- Add test for checking if MainContext Senders return errors when the R…
- Install libmount-dev
- subclassing: move parent invocation fnct in Ext trait
- Fix up some Source API to work with SourceId instead of raw u32
- Add variants for GSource/MainContext functions without Send bound
- Update Travis to Ubuntu Xenial
- Minor subclass API usability improvements
- Various signal subclass improvements
- Remove leftover testing usage of features for glib/gobject-sys
- Update to GNOME 3.14 versions
- Add ObjectType trait to prelude
- Add support for defining new interfaces and other minor things
- Only box data passed to Bytes::from_owned() once
- Update for signals using the concrete closure type instead of double-…
- Add new Object::connect_unsafe(), Object::connect_notify_unsafe() and…
- Derive clone for BoolError
- Implement equivalents to mpsc::channel() and ::sync_channel() for the MainContext
- generate from_glib_borrow implementation for const pointers
- Replace deprecated tempdir crate
- Implement DerefMut for class structs too
- Clean up glib_wrapper! macro and IsA<_>, Wrapper traits and their impls
- GString: Avoid copy for From<GString> for String impl
- BoolError: allow owning the message
- Implement ToGlib for InitializingType
- Ci tests
- Add API for implementing GObject interfaces generically
- Make ObjectType::new() optional too
- Fixes compilation on aarch64
- Don’t duplicate property name in subclass::Property type
- gstring: Specify a lifetime for the From<str> impl
- Introduce GString
- Implement Value traits manually
- return correct type for Variant::get_type()
- Add signal::connect_raw() working on raw c_char pointers for the sign…
- Add subclassing test for registering signals, action signals, emittin…
- Add function to get the implementation from an instance
- Replace unwrap calls with “more explicit” expect
- Require fewer trait bounds for WeakRef and the ObjectExt trait
- Rename glib_boxed_get_type! to glib_boxed_type! for consistency
- Remove the glib_object_get_type! macro
- Don’t require specific traits or namespaces in scope for the glib_wra…
- Add support for safely registering boxed types for Rust types
- Add API for getting the instance from the object implementation
- Add a second constructor to ObjectSubclass that provides the class st…
- Run tests on travis with the subclassing feature
- Migrate subclassing infrastructure to glib-rs
- Fix regen_check
- Force 1.28 check
- Add bindings for GOptionArg and GOptionFlags
- Use ptr::add(i) instead of ptr::offset(i as isize)
- Remove python unlinking in travis config
- Remove wrong connect_xxx_notify
- Implement Display and Debug traits
- Add missing 1.12 items
- Install libmount-dev for CI
- Fix syntax error bis repetita
- Fix syntax error
- Add missing types and version features
- Update Travis/AppVeyor configuration to test/build more different fea…
- Finalize PDF, SVG, PS work from #234
- Refactor interface in PDF
- Update rust version
- Make Surface methods &self from &mut self, remove Send impls
- Add surface scale functions
- Add get/set_device_offset methods
- Improve tests file handling
- Improvements
- Expose include dirs to other build scripts
- Implement Context::path_extents()
- impl Default for Matrix with an identity matrix
- Add get_mime_data(), set_mime_data() and supports_mime_type() to cario surface
- Add cairo_font_type_t
- Enum rework
- add get/set_document_unit() to svg surface
- Add check for 1.28
- Better support for PDF, SVG and PostScript.
- Remove python unlinking in travis config
- Add check for 1.28
- Remove connect_xxx_notify for ConstructOnly properties
- Improve cargo file a bit
- Fragile
atk:
- Check for any sneaked in LGPL docs
- Bring Travis and AppVeyor configurations in sync with the GLib one
- Update to GNOME 3.14 versions
- Update rustc version
- improve travis checkup a bit
- Fix for 1.28
- Split into crate branch
- Add missing feature
- remove unneeded dependencies
- Update appveyor badge url
- Generate a lot of things
gio:
- Install libmount-dev
- Check if any LGPL docs sneaked in
- Bring Travis and AppVeyor configurations in sync with the GLib one
- Update to GNOME 3.14 versions
- Define manual traits
- Enable InetAddress{Mask}::equal() and to_string()
- Don’t box callbacks and other generic parameters twice in async funct…
- Gstring support
- Fix socket.rs build with –features dox
- Mark functions to create a socket from raw fd/socket as unsafe
- Add impls for new std::io::{Read,Write} structs
- Add check for 1.28
- Add std::io::{Read,Write} wrappers
- Regen
- Update crate version
- Command-line option support for gio::Application
- New release
- Install libmount-dev
- Bring Travis and AppVeyor configurations in sync with the GLib one
- Update to GNOME 3.14 versions
- Gstring support
- Add check for 1.28
- Remove python unlinking in travis config
- Install libmount-dev
- Run regen check when building for 3.14
- Bring Travis and AppVeyor configurations in sync with the GLib one
- Update to GNOME 3.14 versions
- Fix CI
- Don’t box closures in async functions twice
- GdkPixbuf::new return Option
- Change PixBuf::from_vec() to PixBuf::from_mut_slice() and allow any A…
- GString support
- Add check for 1.28
- Remove python unlinking in travis config
- Remove wrong connect_xxx_notify
gdk:
- Install libmount-dev
- Check if any LGPL docs sneaked in
- Bring Travis and AppVeyor configurations in sync with the GLib one
- Remove useless gio feature dependencies from Cargo.toml
- Update to GNOME 3.14 versions
- Update rust version
- Define manual traits
- Don’t box closures twice
- Replace atom borrow
- Add missing FromGlibBorrow implementation
- Support const array of gdk::Atom
- GString support
- Fix missing cairo conversion
- Add check for 1.28
- FrameTimings: use an
Option
when returning refresh_interval - FrameTimings: use an
Option
when returning presentation time - Remove python unlinking in travis config
- Remove connect_xxx_notify for ConstructOnly properties
- Implement Event::downcast_ref() and Event::downcast_mut()
- FrameClock: fix segmentation fault after getting
FrameTimings
gtk:
- Install libmount-dev
- Run regen check when building for 3.14
- Bring Travis and AppVeyor configurations in sync with the GLib one
- Acquire the default MainContext when initializing GTK
- Update to GNOME 3.14 versions
- Tree model sort
- Define manual traits
- Support non-GNU versions of make
- Remove ListBoxExtManual and autogenerate all remaining functions from it
- Don’t box signal callbacks twice
- Fix CI
- use &self for SelectionData::set(), fix #747
- Rename SelectionData get_data_with_length method to get_data
- Add pango-sys
- GString support
- Ignore some more problematic functions
- Update BoolError constructions
- Generate ComboBox::set_active by hand
- Add check for 1.28
- Rename socket trait
- Add Atk
- Into
- Update doc example
- Fix response type
- Update ResponseType
- Fix GtkIconSize usage
- Allow the create-context signal for GLArea to return null
- Remove python unlinking in travis config
- Rename MenuItemExt trait to GtkMenuItemExt
- Rename MenuExt trait to GtkMenuExt to avoid conflict with gio
- Make WidgetExt::get_style_context() non nullable
- Remove connect_xxx_notify for ConstructOnly properties
- Remove property
events
getter and setter as we already have normal … - Widget::get_events() / add_events() / set_events() should take a gdk:…
- Install libmount-dev
- Bring Travis and AppVeyor configurations in sync with the GLib one
- Update to GNOME 3.14 versions
- Update rust version
- Fix usage of Cairo.FontType
- Add check for 1.28
- Remove python unlinking in travis config
All this was possible thanks to the gtk-rs/gir project as well:
- Fixed deriving Copy trait for struct with function with varargs
- Update dependencies
- Remove into bound for user callbacks
- Want some more user-callbacks?
- Create fewer boxes for closures
- Correctly generate signal connector function arguments
- Few improvements on user callback generation
- Add manual traits
- Use nullable attribute on constructor return value
- Add imports for async out parameters
- Remove references from TypeId usage
- handle aliases better
- Fix unstable super_callback’s list for g_vfs_register_uri_scheme
- Check for known subtypes when deciding if a type is a final type
- Fix invalid gboolean generation
- Start of user callbacks generation
- Add missing ObjectType import for notify-only properties
- Implement configuration/detection for final types and use that inform…
- Remove useless files
- Correctly cast pointers in property getters/setters if no trait is to…
- Fix unused bounds in futures
- Update code generation for glib_wrapper! macro and IsA<_>, etc cleanup
- Codegen: use new glib macro for BoolError
- Mark autogenerated files as such
- Fix some clippy warnings
- Expose include paths to other build scripts
- Remove special generation for enums with a single member
- They weren’t meant to be bit fields
- Generate code using CStringHolder instead of String
- Add missing “glib” use statement for property setters
- Various minor fixes
- WIP: Don’t generate any but the main IsA<_> bound for extension traits
- Remove now unneeded use statements for the glib_wrapper! macro
- Implement basics for subclassing
- Default generate_display_trait
- Fix display and strengthen CI
- Generate Display impl for enums
- Add pub for modules to use them from the gir library
- Fix missing glib
- Cast enum/bitfield values to gint/guint for sys tests
- Don’t trim constants themselves when testing for their value
- Use inner c:type for arrays with fixed size in sys mode
- Fix adding
use IsA
for properties - sys: generate cfg_condition for records
- Generate cfg_condition on sys mode
- Into wrapping
- Add underscore to enum and bitflags member starting with digits
- Don’t generare notify for ConstructOnly properties
- Partial properties generation
Thanks to all of our contributors for their (awesome!) work for this release: