Gtk-rs: Newest and future developments
FOSDEM 2019 - Rust devroom
Guillaume Gomez < guillaume1.gomez@gmail.com >
## Who am I?
Rust reviewer and contributor.
Gtk-rs organization owner.
## Let's start with the newest developments!
## New library generated: Atk
It's an accessibility toolkit library. It felt like a miss not having it. Now it's fixed.
## New crate to test UIs
We called it `gtk-test`. It's very nice and easy to use to help you testing your UIs.
## Example
```rust
let button = Button::new();
button.set_label("button");
button.connect_clicked(|b| {
b.set_label("clicked!");
});
// ...
gtk_test::click(&button);
gtk_test::wait(1000);
assert_label!(button, "clicked!");
```
## Added continuous integration for MacOS
## API improvements
* More functions generated
* Improved `Debug` implementation
* Added support of `Future` for async functions
* Huge improvement of glib's channels
* Lots of bug fixes
## But also...
More `Into` bounds:
```rust
fn set_comments<'a, P: Into<Option<&'a str>>>(
&self,
comments: P,
);
fn append<'a, P: Into<Option<&'a TreeIter>>>(
&self,
parent: P,
) -> TreeIter;
```
## And also...
Add of `Display` implementation:
```rust
let widget = gtk::Button::new_with_label("hello");
println!("This is a {}!", widget);
```
Which gives:
```text
This is a Button!
```
You can disable its generation with the `generate_display_trait` flag.
## More and more GNOME applications are being written with Gtk-rs
* Fractal
* Podcasts
* Gradio (work in progress)
* NewsFlash (rewritten from FeedReader, work in progress)
* ...
Who said F.A.Q.?
## More API improvements!
* Functions with callback generation (not signals!)
* Less clones of `String` thanks to `GString` type
* Object inheritance
### Functions with callback?
Coming from this:
```C
void
gtk_assistant_set_forward_page_func(
GtkAssistant *assistant,
GtkAssistantPageFunc page_func,
gpointer data,
GDestroyNotify destroy)
```
To this:
```rust
fn set_forward_page_func(
&self,
page_func: Option<Box<dyn Fn(i32) -> i32 + 'static>>)
```
### Functions with callback?
Few things different from C:
* Don't allow user to pass a `destroy` closure
* Remove "user data" parameters
* Handle lifetimes nicely
* Handle concurrency nicely
## The almighty gir
* Corner stone of the Gtk-rs project
* Lot of contributors (10) and contributions (~310 commits since last FOSDEM!)
* More and more projects depending on it
## Gtk-rs environment
About continuous integration and tools.
## A few numbers
* 29 crates (and we're not counting gstreamer crates!)
* 27 repositories
* 2 new releases since last FOSDEM
## More automation
A bot to handle:
* Merge queues
* Auto-regeneration
* Help to new contributors
* ... And much more! (to be determined)
## Continuous integration
Currently, not wonderful because of Gtk-rs strong inter-dependencies.
Solution: make it more clever when updating any crate.
## What about 1.0 release?
Things to be done:
* Full inheritance support
* Continue to work on performance
* Improve internals (gir really needs it!)
* Maybe better documentation? (but more tutorials for sure!)
(Yes, we're getting close!)