logo
Expand description

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.show();
    });

    application.run();
}

Re-exports

pub use ffi;
pub use gdk;
pub use gio;
pub use glib;
pub use gtk;

Modules

Structs

A window showing information about the application.
A gtk::ListBoxRow used to present actions.
A base class for animations.
Represents a value Animation can animate.
A base class for Adwaita applications.
A freeform application window.
A widget displaying an image, with a generated fallback.
A widget with one child.
A helper widget for creating buttons.
An AnimationTarget that calls a given callback during the animation.
A paginated scrolling widget.
A dots indicator for Carousel.
A lines indicator for Carousel.
A widget constraining its child to a given size.
A layout manager constraining its children to a given size.
A scrollable Clamp.
A gtk::ListBoxRow used to choose from a list of items.
A gtk::ListBoxRow with an embedded text entry.
EnumListItem is the type of items in a EnumListModel.
A gio::ListModel representing values of a given enum.
A gtk::ListBoxRow used to reveal widgets.
An adaptive container acting like a box or an overlay.
A title bar widget.
An adaptive container acting like a box or a stack.
An auxiliary class used by Leaflet.
A dialog presenting a message or a question.
A EntryRow tailored for entering secrets.
A group of preference rows.
A gtk::ListBoxRow used to present preferences.
A window to present an application’s preferences.
An AnimationTarget changing the value of a property of a glib::Object instance.
A combined button and dropdown widget.
A spring-based Animation.
Physical parameters of a spring for SpringAnimation.
A best fit container.
An auxiliary class used by Squeezer.
A page used for empty/error states and similar use-cases.
A class for managing application-wide styling.
A swipe tracker used in Carousel, Flap and Leaflet.
An interface for swipeable widgets.
A tab bar for TabView.
An auxiliary class used by TabView.
A dynamic tabbed container.
Describes available shortcuts in an TabView.
A helper object for ToastOverlay.
A widget showing toasts above its content.
A view container for ViewSwitcher.
An auxiliary class used by ViewStack.
An adaptive view switcher.
A view switcher action bar.
A view switcher title.
A freeform window.
A helper widget for setting a window’s title and subtitle.

Enums

Describes the possible states of an Animation.
Describes title centering behavior of a HeaderBar widget.
Application color schemes for property::StyleManager::color-scheme.
Describes the available easing functions for use with TimedAnimation.
Describes the possible folding behavior of a Flap widget.
Describes transitions types of a Flap widget.
Determines when Flap and Leaflet will fold.
Describes the possible transitions in a Leaflet widget.
Describes the direction of a swipe navigation gesture.
Describes the possible styles of MessageDialog response buttons.
Describes the possible transitions in a Squeezer widget.
Toast behavior when another toast is already displayed.
Describes the adaptive modes of ViewSwitcher.

Functions

Initializes Libadwaita.
Checks whether animations are enabled for @widget.
Use this function to check if libadwaita has been initialized with init().
Computes the linear interpolation between @a and @b for @t.
Returns the major version number of the Adwaita library.
Returns the micro version number of the Adwaita library.
Returns the minor version number of the Adwaita library.