Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 84380b5

Browse files
committedJul 17, 2024·
Add new gtk-rs-core 0.20 / gtk4-rs 0.9 release
1 parent f1fa9a4 commit 84380b5

File tree

1 file changed

+294
-0
lines changed

1 file changed

+294
-0
lines changed
 

‎_posts/2024-07-17-new-release.md

+294
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,294 @@
1+
---
2+
layout: post
3+
author: gtk-rs developers
4+
title: New Release
5+
categories: [front, crates]
6+
date: 2024-07-17 09:00:00 +0000
7+
---
8+
9+
gtk4-rs `0.9` and gtk-rs-core `0.20` were just freshly released, just in time
10+
for also being included in the GNOME 47 release.
11+
12+
This release is again relatively small, mostly providing bindings to new APIs
13+
and improvements to the `glib::clone!` and `glib::closure!` macros to work
14+
better with `cargo fmt` and rust-analyzer.
15+
16+
As usual, at the same time gstreamer-rs `0.23` and gst-plugins-rs `0.13`,
17+
libadwaita `0.7` and other related crates got a new release compatible with
18+
the new gtk4-rs and gtk-rs-core releases and their own set of changes.
19+
20+
### gtk-rs-core
21+
22+
#### New syntax for `glib::clone!` and `glib::closure!`
23+
24+
The syntax for the `clone!` and `closure!` macros was updated to look more
25+
like valid Rust code, and as a side effect it is also handled correctly by
26+
`cargo fmt`, rust-analyzer and other tooling now.
27+
28+
The old syntax is still supported but will give a deprecation warning.
29+
30+
To get an idea of the change, what previously looked like
31+
32+
```rust
33+
clone!(@strong self as obj, @weak v => @default-return false, move |x| {
34+
println!("obj: {}, v: {}, x: {}", obj, v, x);
35+
true
36+
})
37+
```
38+
39+
would now look like this
40+
41+
```rust
42+
clone!(
43+
#[strong(rename_to = obj)]
44+
self,
45+
#[weak]
46+
v,
47+
#[upgrade_or]
48+
false,
49+
move |x| {
50+
println!("obj: {}, v: {}, x: {}", obj, v, x);
51+
true
52+
},
53+
);
54+
```
55+
56+
Check the [documentation](https://gtk-rs.org/gtk-rs-core/stable/0.20/docs/glib/macro.clone.html) for more details about the new syntax.
57+
58+
#### GLib 2.82 APIs
59+
60+
New GLib and GIO 2.82 APIs are supported with this release. GLib 2.56 is still
61+
the minimum version supported by the bindings.
62+
63+
#### Trait re-organization for defining new GObject interfaces
64+
65+
The traits for defining new GObject interfaces were slightly re-organized to
66+
make them more similar with the ones for defining new GObjects.
67+
68+
Previously one would write
69+
70+
```rust
71+
#[derive(Clone, Copy)]
72+
#[repr(C)]
73+
pub struct MyStaticInterface {
74+
parent: glib::gobject_ffi::GTypeInterface,
75+
}
76+
77+
#[glib::object_interface]
78+
unsafe impl ObjectInterface for MyStaticInterface {
79+
const NAME: &'static str = "MyStaticInterface";
80+
}
81+
```
82+
83+
This would now become
84+
85+
```rust
86+
#[derive(Clone, Copy)]
87+
#[repr(C)]
88+
pub struct MyStaticInterfaceClass {
89+
parent: glib::gobject_ffi::GTypeInterface,
90+
}
91+
92+
unsafe impl InterfaceStruct for MyStaticInterfaceClass {
93+
type Type = MyStaticInterface;
94+
}
95+
96+
pub enum MyStaticInterface {}
97+
98+
#[glib::object_interface]
99+
impl ObjectInterface for MyStaticInterface {
100+
const NAME: &'static str = "MyStaticInterface";
101+
102+
type Interface = MyStaticInterfaceClass;
103+
}
104+
```
105+
106+
While it is a bit more code, this is almost the same as for GObjects now.
107+
108+
#### Safer borrowing of GObjects and other types from FFI code
109+
110+
It is possible to directly borrow GObjects and other types in FFI code without
111+
additional refcounting or copying. In previous releases the API for that was
112+
completely based on pointers, which allowed to accidentally create dangling
113+
pointers without the compiler being able to help.
114+
115+
```rust
116+
let obj = {
117+
let mut ptr: *mut glib::ffi::GObject = ...;
118+
let obj: &glib::Object = glib::Object::from_glib_ptr_borrow(&mut ptr);
119+
obj
120+
};
121+
// At this point `obj` is pointing at a stack frame that does not exist anymore
122+
```
123+
124+
Starting with this release, a reference to a pointer is used instead to avoid
125+
this from happening. The above code would not compile anymore. Previously the
126+
lifetime of the returned object would be arbitrary, now it is bound strictly
127+
to the lifetime of the pointer.
128+
129+
Code using this API likely does not need any changes unless the code was
130+
previously wrong.
131+
132+
### gtk4-rs
133+
134+
#### GTK 4.16 APIs
135+
136+
New GTK 4.16 APIs are supported with this release. GTK 4.0 is still the
137+
minimum version supported by the bindings.
138+
139+
### Changes
140+
141+
For the interested ones, here is the list of the merged pull requests:
142+
143+
[gtk4-rs](https://github.com/gtk-rs/gtk4-rs):
144+
145+
* [Regenerate with new gir/gir-files](https://github.com/gtk-rs/gtk4-rs/pull/1792)
146+
* [Update to new clone! macro syntax](https://github.com/gtk-rs/gtk4-rs/pull/1773)
147+
* [book: Fix typo](https://github.com/gtk-rs/gtk4-rs/pull/1769)
148+
* [Remove unnecessary upcast from examples/squeezer\_bin/main.rs](https://github.com/gtk-rs/gtk4-rs/pull/1763)
149+
* [typos: Ignore versions.txt file](https://github.com/gtk-rs/gtk4-rs/pull/1762)
150+
* [examples/squeezer\_bin: Mark properties as writable](https://github.com/gtk-rs/gtk4-rs/pull/1761)
151+
* [Fix `SqueezerBin::size\_allocate()` in example](https://github.com/gtk-rs/gtk4-rs/pull/1760)
152+
* [Regen bindings with new gir {g,s}etter annotations](https://github.com/gtk-rs/gtk4-rs/pull/1759)
153+
* [Stop renaming ffi crates](https://github.com/gtk-rs/gtk4-rs/pull/1758)
154+
* [custom\_orientable: Fix interface property override](https://github.com/gtk-rs/gtk4-rs/pull/1755)
155+
* [gtk: Implement Downgrade for TemplateChild<T>](https://github.com/gtk-rs/gtk4-rs/pull/1750)
156+
* [Update list\_widgets.md](https://github.com/gtk-rs/gtk4-rs/pull/1742)
157+
* [examples: Support GL >= 3.1 and GLES >= 3.0 in the glium example](https://github.com/gtk-rs/gtk4-rs/pull/1733)
158+
* [Fix nightly clippy warnings](https://github.com/gtk-rs/gtk4-rs/pull/1730)
159+
* [Update link for Cogitri/Health to World/Health](https://github.com/gtk-rs/gtk4-rs/pull/1725)
160+
* [Simplify reading file contents to a String](https://github.com/gtk-rs/gtk4-rs/pull/1719)
161+
* [Update dependencies](https://github.com/gtk-rs/gtk4-rs/pull/1717)
162+
* [macros: Drop anyhow dependency](https://github.com/gtk-rs/gtk4-rs/pull/1708)
163+
* [Fix typo in todo\_1.md](https://github.com/gtk-rs/gtk4-rs/pull/1707)
164+
* [gtk4: Manually implement `GraphicsOffload` constructor for now](https://github.com/gtk-rs/gtk4-rs/pull/1705)
165+
* [gtk4: Require GDK 4.14 when enabling the `v4\_14` feature](https://github.com/gtk-rs/gtk4-rs/pull/1704)
166+
* [macros: Drop macro-proc-error and upgrade syn to 2.0](https://github.com/gtk-rs/gtk4-rs/pull/1688)
167+
* [dockerfile: Update libadwaita to 1.5](https://github.com/gtk-rs/gtk4-rs/pull/1687)
168+
* [book: Update dependencies](https://github.com/gtk-rs/gtk4-rs/pull/1686)
169+
* [Regenerate with latest gir](https://github.com/gtk-rs/gtk4-rs/pull/1678)
170+
* [docs: fix `Path` setting on windows](https://github.com/gtk-rs/gtk4-rs/pull/1675)
171+
* [Correctly handle `NULL` `GError\*\*` out parameters](https://github.com/gtk-rs/gtk4-rs/pull/1672)
172+
* [Fix nightly clippy warnings](https://github.com/gtk-rs/gtk4-rs/pull/1670)
173+
* [Replace simple `impl Debug` with derived `Debug` in tokio example](https://github.com/gtk-rs/gtk4-rs/pull/1663)
174+
* [Simplify library configuration step for Windows](https://github.com/gtk-rs/gtk4-rs/pull/1644)
175+
* [Regenerate with latest gir-files](https://github.com/gtk-rs/gtk4-rs/pull/1637)
176+
* [cargo-deny: Remove libloading dependencies](https://github.com/gtk-rs/gtk4-rs/pull/1633)
177+
178+
[gtk-rs-core](https://github.com/gtk-rs/gtk-rs-core):
179+
180+
* [ci: Fix docs release tag handling](https://github.com/gtk-rs/gtk-rs-core/pull/1457)
181+
* [docs: Run on our container image](https://github.com/gtk-rs/gtk-rs-core/pull/1455)
182+
* [gio: Add a method to get a stream of incoming connections to SocketListener](https://github.com/gtk-rs/gtk-rs-core/pull/1454)
183+
* [Update gir files](https://github.com/gtk-rs/gtk-rs-core/pull/1453)
184+
* [glib: Add support for registering GTypes with name conflicts](https://github.com/gtk-rs/gtk-rs-core/pull/1451)
185+
* [glib: Make `TypeData` struct fields private](https://github.com/gtk-rs/gtk-rs-core/pull/1449)
186+
* [Update gir files & regenerate](https://github.com/gtk-rs/gtk-rs-core/pull/1448)
187+
* [glib-macros: Don't produce unnecessary braces in `clone!(async move {…](https://github.com/gtk-rs/gtk-rs-core/pull/1443)
188+
* [Update to system-deps 7](https://github.com/gtk-rs/gtk-rs-core/pull/1440)
189+
* [glib-macros: Fix unit return in `closure!()` macro](https://github.com/gtk-rs/gtk-rs-core/pull/1438)
190+
* [strv: add From implementation from a String array](https://github.com/gtk-rs/gtk-rs-core/pull/1432)
191+
* [Derive TransparentPtrType trait for Boxed](https://github.com/gtk-rs/gtk-rs-core/pull/1431)
192+
* [gio: Properly export Win32InputStream / Win32OutputStream traits](https://github.com/gtk-rs/gtk-rs-core/pull/1429)
193+
* [ci: bump gvsbuild](https://github.com/gtk-rs/gtk-rs-core/pull/1427)
194+
* [Update `clone!` and `closure!` macro to new syntax](https://github.com/gtk-rs/gtk-rs-core/pull/1424)
195+
* [Stop renaming ffi crates](https://github.com/gtk-rs/gtk-rs-core/pull/1423)
196+
* [gio: remove Send + Sync requirements from DBusConnection::register\_ob…](https://github.com/gtk-rs/gtk-rs-core/pull/1422)
197+
* [Fix various nightly clippy warnings](https://github.com/gtk-rs/gtk-rs-core/pull/1421)
198+
* [Regenerate with latest gir/gir-files](https://github.com/gtk-rs/gtk-rs-core/pull/1420)
199+
* [spell fix](https://github.com/gtk-rs/gtk-rs-core/pull/1419)
200+
* [gio: make DBusConnection::register\_object take optional clousures](https://github.com/gtk-rs/gtk-rs-core/pull/1417)
201+
* [glib: Add unsafe `Value::into\_send\_value()`](https://github.com/gtk-rs/gtk-rs-core/pull/1413)
202+
* [glib: Improve `ValueArray` API, add tests and assertions for invalid …](https://github.com/gtk-rs/gtk-rs-core/pull/1411)
203+
* [glib: Fix `MatchInfo::next()` handling of returning `FALSE`](https://github.com/gtk-rs/gtk-rs-core/pull/1410)
204+
* [glib/functions: add compute\_checksum\_for\_string](https://github.com/gtk-rs/gtk-rs-core/pull/1406)
205+
* [glib: Add bindings for `g\_value\_set\_static\_string()`](https://github.com/gtk-rs/gtk-rs-core/pull/1400)
206+
* [docs: Fix broken links / cleanup README](https://github.com/gtk-rs/gtk-rs-core/pull/1395)
207+
* [Fix clippy warnings](https://github.com/gtk-rs/gtk-rs-core/pull/1393)
208+
* [glib: Implement Sync for ThreadGuard](https://github.com/gtk-rs/gtk-rs-core/pull/1388)
209+
* [glib: Only implement Send on JoinHandle if the result is Send](https://github.com/gtk-rs/gtk-rs-core/pull/1387)
210+
* [glib: Decouple ObjectInterface impl from interface class struct](https://github.com/gtk-rs/gtk-rs-core/pull/1384)
211+
* [glib: Add missing Send bound to the output type of the `spawn\_from\_within()` future](https://github.com/gtk-rs/gtk-rs-core/pull/1383)
212+
* [glib-macros: Refactor parsing code of object\_subclass/object\_interface](https://github.com/gtk-rs/gtk-rs-core/pull/1379)
213+
* [examples: Add example for custom class structs and virtual methods](https://github.com/gtk-rs/gtk-rs-core/pull/1378)
214+
* [ObjectBuilder: add property\_if(), property\_if\_some(), property\_from\_iter() ...](https://github.com/gtk-rs/gtk-rs-core/pull/1377)
215+
* [glib: Don't use `g\_object\_list\_properties()` for setting properties](https://github.com/gtk-rs/gtk-rs-core/pull/1376)
216+
* [glib: Use a reference to a pointer of correct mutability for from\_gli…](https://github.com/gtk-rs/gtk-rs-core/pull/1375)
217+
* [glib: Re-add and rename manual Win32 API additions](https://github.com/gtk-rs/gtk-rs-core/pull/1372)
218+
* [glib-macros/properties: Allow structs with no properties](https://github.com/gtk-rs/gtk-rs-core/pull/1370)
219+
* [glib::wrapper: Add docs for impls generated by the wrapper macro](https://github.com/gtk-rs/gtk-rs-core/pull/1369)
220+
* [ci: Enable glib-sys / gobject-sys tests](https://github.com/gtk-rs/gtk-rs-core/pull/1368)
221+
* [glib-sys: Add missing includes in `manual.h`](https://github.com/gtk-rs/gtk-rs-core/pull/1361)
222+
* [glib-sys: fix struct size mismatches](https://github.com/gtk-rs/gtk-rs-core/pull/1360)
223+
* [glib: Freeze property notifications while setting multiple properties](https://github.com/gtk-rs/gtk-rs-core/pull/1355)
224+
* [glib-macros: Improve error message when `Properties` struct doesn't have at least one `#\[property(…)\]`](https://github.com/gtk-rs/gtk-rs-core/pull/1352)
225+
* [Update gir / gir-files and update for `time\_t`](https://github.com/gtk-rs/gtk-rs-core/pull/1349)
226+
* [Fix nightly clippy warnings](https://github.com/gtk-rs/gtk-rs-core/pull/1348)
227+
* [docs: `construct` attribute for `glib::Properties`](https://github.com/gtk-rs/gtk-rs-core/pull/1344)
228+
* [glib: fix UB in VariantStrIter::impl\_get](https://github.com/gtk-rs/gtk-rs-core/pull/1343)
229+
* [Fix glib compiletest expected output for Rust 1.77](https://github.com/gtk-rs/gtk-rs-core/pull/1342)
230+
* [glib: Don't misuse `slice::get\_unchecked()`](https://github.com/gtk-rs/gtk-rs-core/pull/1337)
231+
* [gio: correctly free argument list items](https://github.com/gtk-rs/gtk-rs-core/pull/1331)
232+
* [glib: Optimize string collation bindings a bit](https://github.com/gtk-rs/gtk-rs-core/pull/1329)
233+
* [glib: Drop the main context future return value sender on finalize](https://github.com/gtk-rs/gtk-rs-core/pull/1328)
234+
* [pango: add some missing AttrInt constructors.](https://github.com/gtk-rs/gtk-rs-core/pull/1325)
235+
* [Regenerate with latest gir files](https://github.com/gtk-rs/gtk-rs-core/pull/1324)
236+
* [glib: Embed docs for ParamSpec types](https://github.com/gtk-rs/gtk-rs-core/pull/1323)
237+
* [glib: Requires Upgrade on Downgrade::Weak type](https://github.com/gtk-rs/gtk-rs-core/pull/1321)
238+
* [macros: allow to specify #\[default\] for glib::flags](https://github.com/gtk-rs/gtk-rs-core/pull/1316)
239+
* [Update Cargo.lock](https://github.com/gtk-rs/gtk-rs-core/pull/1313)
240+
* [glib: Add `Quark::from\_static\_str()`](https://github.com/gtk-rs/gtk-rs-core/pull/1312)
241+
* [docs: Move metadata back to packages](https://github.com/gtk-rs/gtk-rs-core/pull/1311)
242+
* [cairo: Fix version of the v1\_18 feature](https://github.com/gtk-rs/gtk-rs-core/pull/1310)
243+
* [glib: Fix expected error output of compiletests for 1.76](https://github.com/gtk-rs/gtk-rs-core/pull/1308)
244+
* [Document values of Continue and Break](https://github.com/gtk-rs/gtk-rs-core/pull/1304)
245+
246+
All this was possible thanks to the [gtk-rs/gir](https://github.com/gtk-rs/gir) project as well:
247+
248+
* [Minor cleanup to use `is\_some\_and(...)` instead of `map\_or(false, ...)`](https://github.com/gtk-rs/gir/pull/1584)
249+
* [Update to system-deps 7](https://github.com/gtk-rs/gir/pull/1583)
250+
* [More docs improvements](https://github.com/gtk-rs/gir/pull/1576)
251+
* [codegen: Handle mangled types names](https://github.com/gtk-rs/gir/pull/1575)
252+
* [members: drop useless alias config](https://github.com/gtk-rs/gir/pull/1574)
253+
* [Various properties fixes](https://github.com/gtk-rs/gir/pull/1573)
254+
* [codegen: Avoid double alias on badly annotated fn](https://github.com/gtk-rs/gir/pull/1572)
255+
* [Use getter and setter annotations](https://github.com/gtk-rs/gir/pull/1571)
256+
* [Support finish-func annotation](https://github.com/gtk-rs/gir/pull/1570)
257+
* [codegen: Stop renaming ffi crate](https://github.com/gtk-rs/gir/pull/1569)
258+
* [Use final annotation](https://github.com/gtk-rs/gir/pull/1568)
259+
* [Codegen clippy fixes](https://github.com/gtk-rs/gir/pull/1566)
260+
* [Add support for `libc::time\_t` and related types](https://github.com/gtk-rs/gir/pull/1562)
261+
* [Revert Automatically assume that win32\_ and unix\_ should use the related cfg](https://github.com/gtk-rs/gir/pull/1547)
262+
* [Correctly generate cfg condition for ABI tests](https://github.com/gtk-rs/gir/pull/1546)
263+
* [Generate cfgs with `update\_cfgs` on enums as well](https://github.com/gtk-rs/gir/pull/1545)
264+
265+
Thanks to all of our contributors for their (awesome!) work on this release:
266+
267+
* [@A6GibKm](https://github.com/A6GibKm)
268+
* [@alatiera](https://github.com/alatiera)
269+
* [@amyspark](https://github.com/amyspark)
270+
* [@bilelmoussaoui](https://github.com/bilelmoussaoui)
271+
* [@carlosmn](https://github.com/carlosmn)
272+
* [@DaKnig](https://github.com/DaKnig)
273+
* [@decathorpe](https://github.com/decathorpe)
274+
* [@ellnix](https://github.com/ellnix)
275+
* [@enaut](https://github.com/enaut)
276+
* [@exi](https://github.com/exi)
277+
* [@felinira](https://github.com/felinira)
278+
* [@fengalin](https://github.com/fengalin)
279+
* [@GuillaumeGomez](https://github.com/GuillaumeGomez)
280+
* [@Hofer-Julian](https://github.com/Hofer-Julian)
281+
* [@liushuyu](https://github.com/liushuyu)
282+
* [@marcinjahn](https://github.com/marcinjahn)
283+
* [@misson20000](https://github.com/misson20000)
284+
* [@mjgarton](https://github.com/mjgarton)
285+
* [@mokurin000](https://github.com/mokurin000)
286+
* [@mtilda](https://github.com/mtilda)
287+
* [@nazar-pc](https://github.com/nazar-pc)
288+
* [@pbor](https://github.com/pbor)
289+
* [@pranjalkole](https://github.com/pranjalkole)
290+
* [@sdroege](https://github.com/sdroege)
291+
* [@vhakulinen](https://github.com/vhakulinen)
292+
* [@woelfman](https://github.com/woelfman)
293+
* [@ystreet](https://github.com/ystreet)
294+
* [@zecakeh](https://github.com/zecakeh)

0 commit comments

Comments
 (0)
Please sign in to comment.