Rust bindings for GTK+ 3, Cairo, GtkSourceView and other GLib-compatible libraries
Using
Prepare your system: Requirements
Include gtk
in your Cargo.toml
and set the minimal GTK version required by your project:
[dependencies.gtk]
version = "0.6.0"
features = ["v3_10"]
The APIs aren’t stable yet. Watch the Announcements box above for breaking changes to the crates!
Import the gtk
crate and its traits:
extern crate gtk;
use gtk::prelude::*;
Create a window, etc.
use gtk::{Button, Window, WindowType};
fn main() {
if gtk::init().is_err() {
println!("Failed to initialize GTK.");
return;
}
let window = Window::new(WindowType::Toplevel);
window.set_title("First GTK+ Program");
window.set_default_size(350, 70);
let button = Button::new_with_label("Click me!");
window.add(&button);
window.show_all();
window.connect_delete_event(|_, _| {
gtk::main_quit();
Inhibit(false)
});
button.connect_clicked(|_| {
println!("Clicked!");
});
gtk::main();
}
Using latest, not published version
Include gtk
in your Cargo.toml
not as crate but from git:
[dependencies.gtk]
git = "https://github.com/gtk-rs/gtk"
features = ["v3_10"]
Projects using gtk-rs
- BrewStillery
- Epicwar Downloader
- Font Finder
- Fractal
- Garta
- Gattii
- glide
- gpsami
- gxi
- Marmoset
- mcmmtk
- media-toc
- noaa-apt
- pcatk
- PNMixer-rs
- Podcasts
- Popsicle
- process-viewer
- relm
- rrun
- SolidOak
- systemd-manager
- tv-renamer
- Way Cooler
- Whatschanging
If you want yours to be added to this list, please create a Pull Request for it!