Welcome to the Ultimate GTK4 + Crystal Guide!
GTK is a free and open-source cross-platform widget toolkit for creating graphical user interfaces.
Crystal, in combination with GObject Introspection, is able to generate bindings for any GObject based library, including the latest version of GTK, GTK4!
GTK development is very similar to web dev, so while reading this guide you might find some small sections comparing the current topic with the web dev one.
Goals
After reading this guide, you should be able to:
- Build premium applications
- Package them
- Use build systems
- Generate bindings for third-party GObject based libraries
- & More
WARNING
The guide might NOT be correct or follow best practices at times. Please don't blindly follow it and look around for other guides, blog posts, docs etc. that confirm or contradict it.
Credits
In classic Crystal fashion, this is a community effort. There's not an org that manages all the shards, but there's a decentralized approach.
Most notably however, there are two main shards that are responsible for the great quality of the bindings made by Hugo Parente Lima:
- GI Crystal - Tool to generate Crystal bindings and user API for glib-based libraries
- gtk4.cr - GTK4 bindings for Crystal
Important docs
Why Crystal?
- It's very fast
- It's memory and type safe
- Its syntax is inspired by Ruby's, often described as one of the cleanest, easiest to understand and most efficient to write
- Macros, Concurrency, Parallelism, C bindings & more
New to Crystal?
- Crystal for Rubyists - Free book to bootstrap your Crystal journey
- Crystal Mastery - Screencasts for learning Crystal
- crystal-koans - Learn Crystal by writing unit tests
- crystal-lang.org - Official language site
- devdocs.io - API Documentation Browser with Crystal support
- Programming Crystal - PragProg book to start your Crystal journey
INFO
Not interested?
There are many other GUI toolkits with Crystal bindings or alternative shards and ways to use GTK, here's some:
- crystal-gobject - GTK3 bindings & different binding generation (+ maintenance)
- Layout - Build Native (not webview) GTK3 apps using web technologies (HTML, CSS, JS)
- libui.cr - Bindings for the cross platform GUI toolkit, libui
- qt5.cr - Qt5 bindings