A new realm is here for you to explore! I’m happy to announce Relm4 v0.4, our biggest release so far!
About Relm4
Relm4 is an idiomatic GUI library inspired by Elm and based on gtk4-rs.
We believe that GUI development should be easy, productive and delightful.
The gtk4-rs crate already provides everything you need to write modern, beautiful and cross-platform applications. Built on top of this foundation, Relm4 makes developing more idiomatic, simpler and faster and enables you to become productive in just a few hours.
What’s new?
Relm4 v0.4 brings a lot of new features and improvements. I’m excited to present to you the highlights of this release!
Macros for everyone!
In recent Relm4 releases, the macros were tightly integrated into the library itself. This limitation is now removed! Most importantly, users of gtk4-rs will be able to use the view!
macro by only pulling in relm4-macros
as dependency without the rest of Relm4. This gives you even more freedom to choose how much of Relm4’s features you want to use.
|
|
And there’s even more. The view!
macro isn’t limited to gtk4-rs. You can use it for regular Rust structures, too!
|
|
Micro components for flexibility at runtime
Regular components are relatively static, which gives you strong compile time guarantees, among other benefits. They cover most use cases, but they cannot be initialized or destructed manually at runtime.
This is where micro components have their strength. They are simpler variants of components that require a bit more manual work, with the advantage of being fully dynamic at runtime.
A code example can be found here.
Type-safe actions
Actions are used in GTK4 to simplify the handling of user interactions. Since you can always mix in as much pure gtk4-rs code into Relm4 applications as you want, actions were never a real problem. Yet, they lived outside of Rust’s type checking.
With the help of some traits and macros, it’s now quite convenient to define wrapper types for actions that enable a lot of compile time guarantees for actions. Even typos for action names are eliminated as a source of errors.
|
|
Menu macro
Often, actions are used for menus, where each entry is connected to an action. The new menu!
macro allows you to create menus conveniently with all the benefits of type-safe actions.
|
|
More macro magic
The widget
macro has been very helpful in creating readable and elegant UI definitions for regular components since the first release of Relm4.
Now, factories and micro components have received their own variants of the widget
macro!
|
|
Better support for Stack and TabView
Widgets such as Stack
or TabView
have methods that return a new widget, such as StackPage
. The returned widget was previously inaccessibly in the widget
macro and required manual code. This was addressed with a new syntax.
Cleaner dependencies
Relm4 now re-exports more crates and has more feature flags. This means you don’t have to include gtk4
, libadwaita
or relm4-macros
anymore, if you have the correct feature flags set.
|
|
Miscellaneous
- Several book improvements
- Reworked initialization process
- Some trait adjustments
- Many bug fixes, better error messages and other improvements
The full change log can be found here.
Where to get started
Note: As of writing this, the book isn’t fully ported to v0.4, but the examples in the repository are always up to date.
Special thanks
I highly appreciate feedback and contributions to Relm4 and thank those who helped me with this release:
- @euclio who contributed many fixes and features
- @mskorkowski for his contributions and work on relm4-store
- @tronta who contributed a lot to the examples and book improvements
- everyone else who gave feedback in the Matrix room or on GitHub
- the whole gtk-rs team for providing awesome Rust bindings for GTK and always being helpful