You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: _posts/2019-06-22-new-release.md
+88-58Lines changed: 88 additions & 58 deletions
Original file line number
Diff line number
Diff line change
@@ -2,11 +2,92 @@
2
2
layout: post
3
3
author: Guillaume Gomez
4
4
title: New release: more complete, safer
5
-
categories: [front, crates]
5
+
categories: [front, crates, release]
6
6
date: 2019-06-22 14:00:00 +0000
7
7
---
8
8
9
-
* Write intro here *
9
+
Welcome everyone to this whole new gtk-rs release! Time to check what was added/updated in this new version.
10
+
11
+
#### Change of minimum supported Rust version
12
+
13
+
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.
14
+
15
+
#### Stepping back?
16
+
17
+
This release removes the `Into` trait implementation we added previously when a nullable type was expected. let's take an example!
18
+
19
+
Before we could do this:
20
+
21
+
```Rust
22
+
letlabel=gtk::Label::new("Hello");
23
+
letanother_label=gtk::Label::new(None);
24
+
```
25
+
26
+
Now we have to wrap our `"Hello"` into `Some()`:
27
+
28
+
```Rust
29
+
letlabel=gtk::Label::new(Some("Hello"));
30
+
letanother_label=gtk::Label::new(None);
31
+
```
32
+
33
+
There are two reasons behind going back on this feature:
34
+
35
+
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.
36
+
37
+
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:
38
+
39
+
```Rust
40
+
letlabel=gtk::Label::new("Hello");
41
+
42
+
// We remove the associated widget with mnemonic:
43
+
label.set_mnemonic_widget(None);
44
+
```
45
+
46
+
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:
47
+
48
+
```Rust
49
+
label.set_mnemonic_widget(None::<gtk::Widget>);
50
+
```
51
+
52
+
Which isn't very nice...
53
+
54
+
We talked about this change for a while and decided it was the best for our users from our point of view.
55
+
56
+
#### cairo changes
57
+
58
+
We made some changes into `cairo` type hierarchies that led to a global improvement. To sum it up very shortly (thanks to [@SimonSapin](https://github.com/SimonSapin) for providing it!):
59
+
60
+
1. Patterns: pseudo-inheritence with Deref (like surfaces already do) instead of an enum of each pattern type.
61
+
2. PDF/PS/SVG: a single surface type each instead of a public module, and restrict streams to `'static` to make them sound.
62
+
3. XBC: a struct like other surface types, instead of a trait.
63
+
4. Inherent methods instead of various extension traits
64
+
65
+
If you want the complete description, it is available in its [linked issue](https://github.com/gtk-rs/cairo/issues/258).
66
+
67
+
#### Builders
68
+
69
+
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:
70
+
71
+
```Rust
72
+
letbutton=gtk::LockButtonBuilder::new()
73
+
.text_lock("Lock")
74
+
.text_unlock("Unlock")
75
+
.build();
76
+
```
77
+
78
+
#### Futures
79
+
80
+
We now use the `std::futures`, which means that we can do now do async/await. A full example is available [here](https://github.com/gtk-rs/examples/blob/pending/src/bin/gio_futures_await.rs).
81
+
82
+
#### Other things?
83
+
84
+
Actually yes! But as you can guess, it'd be too just too long to describe them all. Let's go through them quickly:
85
+
86
+
* New types/functions were generated (`gio` is certainly the crate which benefited the most from it).
87
+
* Some methods which weren't supposed to be "inherited" aren't anymore.
88
+
* Automatically generated source code is now clearer: the trampoline functions (used for signals for examples) are now inside the function which used them.
89
+
* Crates source code has received some `rustfmt` run.
90
+
* Lot of fixes and small improvements...
10
91
11
92
### Changes
12
93
@@ -15,17 +96,13 @@ For the interested ones, here is the list of the merged pull requests:
15
96
[sys](https://github.com/gtk-rs/sys):
16
97
17
98
*[Print some additional output on macOS if pkg-config fails](https://github.com/gtk-rs/sys/pull/141)
0 commit comments