25 releases

0.7.1 Oct 31, 2024
0.7.0 Jul 10, 2024
0.6.1 Sep 22, 2023
0.6.0 Feb 4, 2024
0.1.0-alpha-2 Jul 12, 2021

#14 in GUI

Download history 9279/week @ 2024-07-31 9242/week @ 2024-08-07 8655/week @ 2024-08-14 9938/week @ 2024-08-21 9435/week @ 2024-08-28 9878/week @ 2024-09-04 9804/week @ 2024-09-11 14227/week @ 2024-09-18 16229/week @ 2024-09-25 12675/week @ 2024-10-02 13650/week @ 2024-10-09 10598/week @ 2024-10-16 8144/week @ 2024-10-23 10887/week @ 2024-10-30 7957/week @ 2024-11-06 8623/week @ 2024-11-13

36,860 downloads per month
Used in 39 crates (27 directly)

MIT license

2MB
49K SLoC

libadwaita-rs

The Rust bindings of libadwaita

Website: https://world.pages.gitlab.gnome.org/Rust/libadwaita-rs

Documentation


lib.rs:

Rust Adwaita bindings

This library contains safe Rust bindings for Adwaita, a library that offers building blocks for modern GNOME applications.

See also

Example

Adwaita needs to be initialized before use. This can be done by either:

The libadwaita crate is usually renamed to adw. You can do this globally in your Cargo.toml file:

[dependencies.adw]
package = "libadwaita"
version = "0.x.y"
use adw::prelude::*;

use adw::{ActionRow, Application, ApplicationWindow, HeaderBar};
use gtk::{Box, ListBox, Orientation, SelectionMode};

fn main() {
    let application = Application::builder()
        .application_id("com.example.FirstAdwaitaApp")
        .build();

    application.connect_activate(|app| {
        // ActionRows are only available in Adwaita
        let row = ActionRow::builder()
            .activatable(true)
            .title("Click me")
            .build();
        row.connect_activated(|_| {
            eprintln!("Clicked!");
        });

        let list = ListBox::builder()
            .margin_top(32)
            .margin_end(32)
            .margin_bottom(32)
            .margin_start(32)
            .selection_mode(SelectionMode::None)
            // makes the list look nicer
            .css_classes(vec![String::from("boxed-list")])
            .build();
        list.append(&row);

        // Combine the content in a box
        let content = Box::new(Orientation::Vertical, 0);
        // Adwaitas' ApplicationWindow does not include a HeaderBar
        content.append(&HeaderBar::new());
        content.append(&list);

        let window = ApplicationWindow::builder()
            .application(app)
            .title("First App")
            .default_width(350)
            // add content to window
            .content(&content)
            .build();
        window.present();
    });

    application.run();
}

Dependencies

~15–23MB
~438K SLoC