Settings
Help

Crate libadwaita

Crate libadwaita 

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

    application.run();
}

Re-exports§

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

Modules§

builders
prelude
subclass

Structs§

AboutDialogv1_5
A dialog showing information about the application.
AboutWindowDeprecatedv1_2
Use AboutDialog. A window showing information about the application.
ActionRow
A gtk::ListBoxRow used to present actions.
AlertDialogv1_5
A dialog presenting a message or a question.
Animation
A base class for animations.
AnimationTarget
Represents a value Animation can animate.
Application
A base class for Adwaita applications.
ApplicationWindow
A freeform application window.
Avatar
A widget displaying an image, with a generated fallback.
Bannerv1_3
A bar with contextual information.
Bin
A widget with one child.
BottomSheetv1_6
A bottom sheet with an optional bottom bar.
Breakpointv1_4
Describes a breakpoint for Window or Dialog.
BreakpointBinv1_4
A widget that changes layout based on available size.
BreakpointConditionv1_4
Describes condition for an Breakpoint.
ButtonContent
A helper widget for creating buttons.
ButtonRowv1_6
A gtk::ListBoxRow that looks like a button.
CallbackAnimationTarget
An AnimationTarget that calls a given callback during the animation.
Carousel
A paginated scrolling widget.
CarouselIndicatorDots
A dots indicator for Carousel.
CarouselIndicatorLines
A lines indicator for Carousel.
Clamp
A widget constraining its child to a given size.
ClampLayout
A layout manager constraining its children to a given size.
ClampScrollable
A scrollable Clamp.
ComboRow
A gtk::ListBoxRow used to choose from a list of items.
Dialogv1_5
An adaptive dialog container.
EntryRowv1_2
A gtk::ListBoxRow with an embedded text entry.
EnumListItem
EnumListItem is the type of items in a EnumListModel.
EnumListModel
A gio::ListModel representing values of a given enum.
ExpanderRow
A gtk::ListBoxRow used to reveal widgets.
FlapDeprecated
See the migration guide An adaptive container acting like a box or an overlay.
HeaderBar
A title bar widget.
InlineViewSwitcherv1_7
A view switcher that uses a toggle group.
Layoutv1_6
An individual layout in MultiLayoutView.
LayoutSlotv1_6
A child slot within Layout.
LeafletDeprecated
See the migration guide An adaptive container acting like a box or a stack.
LeafletPageDeprecated
See the migration guide An auxiliary class used by Leaflet.
MessageDialogDeprecatedv1_2
Use AlertDialog. A dialog presenting a message or a question.
MultiLayoutViewv1_6
A widget for switching between different layouts.
NavigationPagev1_4
A page within NavigationView or NavigationSplitView.
NavigationSplitViewv1_4
A widget presenting sidebar and content side by side or as a navigation view.
NavigationViewv1_4
A page-based navigation container.
OverlaySplitViewv1_4
A widget presenting sidebar and content side by side or as an overlay.
PasswordEntryRowv1_2
A EntryRow tailored for entering secrets.
PreferencesDialogv1_5
A dialog showing application’s preferences.
PreferencesGroup
A group of preference rows.
PreferencesPage
A page from PreferencesDialog.
PreferencesRow
A gtk::ListBoxRow used to present preferences.
PreferencesWindowDeprecated
Use PreferencesDialog. A window to present an application’s preferences.
PropertyAnimationTargetv1_2
An AnimationTarget changing the value of a property of a glib::Object instance.
ShortcutLabelv1_8
A widget that displays a keyboard shortcut.
ShortcutsDialogv1_8
A dialog that displays application’s keyboard shortcuts.
ShortcutsItemv1_8
An object representing an individual shortcut in ShortcutsSection.
ShortcutsSectionv1_8
An object representing a section in ShortcutsDialog.
SpinRowv1_4
An ActionRow with an embedded spin button.
Spinnerv1_6
A widget showing a loading spinner.
SpinnerPaintablev1_6
A paintable showing a loading spinner.
SplitButton
A combined button and dropdown widget.
SpringAnimation
A spring-based Animation.
SpringParams
Physical parameters of a spring for SpringAnimation.
SqueezerDeprecated
See the migration guide A best fit container.
SqueezerPageDeprecated
See the migration guide An auxiliary class used by Squeezer.
StatusPage
A page used for empty/error states and similar use-cases.
StyleManager
A class for managing application-wide styling.
SwipeTracker
A swipe tracker used in Carousel, NavigationView and OverlaySplitView.
Swipeable
An interface for swipeable widgets.
SwitchRowv1_4
A gtk::ListBoxRow used to represent two states.
TabBar
A tab bar for TabView.
TabButtonv1_3
A button that displays the number of TabView pages.
TabOverviewv1_3
A tab overview for TabView.
TabPage
An auxiliary class used by TabView.
TabView
A dynamic tabbed container.
TabViewShortcutsv1_2
Describes available shortcuts in an TabView.
TimedAnimation
A time-based Animation.
Toast
A helper object for ToastOverlay.
ToastOverlay
A widget showing toasts above its content.
Togglev1_7
A toggle within ToggleGroup.
ToggleGroupv1_7
A group of exclusive toggles.
ToolbarViewv1_4
A widget containing a page, as well as top and/or bottom bars.
ViewStack
A view container for ViewSwitcher.
ViewStackPage
An auxiliary class used by ViewStack.
ViewStackPagesv1_4
An auxiliary class used by ViewStack.
ViewSwitcher
An adaptive view switcher.
ViewSwitcherBar
A view switcher action bar.
ViewSwitcherTitleDeprecated
See the migration guide A view switcher title.
Window
A freeform window.
WindowTitle
A helper widget for setting a window’s title and subtitle.
WrapBoxv1_7
A box-like widget that can wrap into multiple lines.
WrapLayoutv1_7
A box-like layout that can wrap into multiple lines.

Enums§

AccentColorv1_6
Describes the available system accent colors.
AnimationState
Describes the possible states of an Animation.
BannerButtonStylev1_7
Describes the available button styles for Banner.
BreakpointConditionLengthTypev1_4
Describes length types for BreakpointCondition.
BreakpointConditionRatioTypev1_4
Describes ratio types for BreakpointCondition.
CenteringPolicy
Describes title centering behavior of a HeaderBar widget.
ColorScheme
Application color schemes for color-scheme.
DialogPresentationModev1_5
Describes the available presentation modes for Dialog.
Easing
Describes the available easing functions for use with TimedAnimation.
FlapFoldPolicyDeprecated
Describes the possible folding behavior of a Flap widget.
FlapTransitionTypeDeprecated
Describes transitions types of a Flap widget.
FoldThresholdPolicyDeprecated
Determines when Flap and Leaflet will fold.
InlineViewSwitcherDisplayModev1_7
Describes what InlineViewSwitcher toggles display.
JustifyModev1_7
Describes line justify behaviors in a WrapLayout or WrapBox.
LeafletTransitionTypeDeprecated
Describes the possible transitions in a Leaflet widget.
LengthUnitv1_4
Describes length units.
NavigationDirection
Describes the direction of a swipe navigation gesture.
PackDirectionv1_7
Describes child packing behavior in a WrapLayout or WrapBox.
ResponseAppearancev1_2
Describes the possible styles of AlertDialog response buttons.
SqueezerTransitionTypeDeprecated
Describes the possible transitions in a Squeezer widget.
ToastPriority
Toast behavior when another toast is already displayed.
ToolbarStylev1_4
Describes the possible top or bottom bar styles in an ToolbarView widget.
ViewSwitcherPolicy
Describes the adaptive modes of ViewSwitcher.
WrapPolicyv1_7
Describes line wrapping behavior in a WrapLayout or WrapBox.

Functions§

init
Initializes Libadwaita.
is_animations_enabled
Checks whether animations are enabled for @widget.
is_initialized
Use this function to check if libadwaita has been initialized with init().
lerp
Computes the linear interpolation between @a and @b for @t.
major_version
Returns the major version number of the Adwaita library.
micro_version
Returns the micro version number of the Adwaita library.
minor_version
Returns the minor version number of the Adwaita library.
rgba_to_standalonev1_6
Adjusts @rgba to be suitable as a standalone color.