Skip to main content

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 adw::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
Legal
AboutWindowDeprecatedv1_2
Use AboutDialog.
ActionRow
When used together with the .monospace style class, only the subtitle becomes monospace, not the title or any extra widgets.
AlertDialogv1_5
Animation
A base class for animations.
AnimationTarget
Represents a value Animation can animate.
Application
accelerator for it.
ApplicationWindow
Avatar
Avatar is a widget that shows a round avatar.
Bannerv1_3
CSS nodes
Bin
The Bin widget has only one child, set with the child property.
BottomSheetv1_6
` element, and the bottom bar by specifying “bottom-bar”. Specifying “content” or omitting the child type results in setting the content child.
Breakpointv1_4
BreakpointBinv1_4
BreakpointConditionv1_4
Describes condition for an Breakpoint.
ButtonContent
ButtonRowv1_6
/picture
CallbackAnimationTarget
An AnimationTarget that calls a given callback during the animation.
Carousel
The Carousel widget can be used to display a set of pages with swipe-based navigation between them.
CarouselIndicatorDots
The CarouselIndicatorDots widget shows a set of dots for each page of a given Carousel. The dot representing the carousel’s active page is larger and more opaque than the others, the transition to the active and inactive state is gradual to match the carousel’s position.
CarouselIndicatorLines
The CarouselIndicatorLines widget shows a set of lines for each page of a given Carousel. The carousel’s active page is shown as another line that moves between them to match the carousel’s position.
Clamp
The Clamp widget constrains the size of the widget it contains to a given maximum size. It will constrain the width if it is horizontal, or the height if it is vertical. The expansion of the child from its minimum to its maximum size is eased out for a smooth transition.
ClampLayout
ClampLayout constraints the size of the widgets it contains to a given maximum size. It will constrain the width if it is horizontal, or the height if it is vertical. The expansion of the children from their minimum to their maximum size is eased out for a smooth transition.
ClampScrollable
A scrollable Clamp.
ComboRow
CssClassBindingv1_10
A binding between a glib::Object property and a CSS class on a gtk::Widget.
Dialogv1_5
Dialog is similar to a window, but is shown within another window. It can be used with Window and ApplicationWindow, use AdwDialogExt::present() to show it.
EntryRowv1_2
element.
EnumListItemDeprecated
Use Gtk::EnumListItem. EnumListItem is the type of items in a EnumListModel.
EnumListModelDeprecated
Use Gtk::EnumList. A gio::ListModel representing values of a given enum.
ExpanderRow
element.
FlapDeprecated
See the migration guide ` element, and separator by specifying “separator”. Specifying “content” child type or omitting it results in setting the content child.
HeaderBar
HeaderBar is similar to gtk::HeaderBar, but provides additional features compared to it. Refer to gtk::HeaderBar for details. It is typically used as a top bar within ToolbarView.
InlineViewSwitcherv1_7
Accessibility
Layoutv1_6
An individual layout in MultiLayoutView.
LayoutSlotv1_6
A child slot within Layout.
LeafletDeprecated
See the migration guide
LeafletPageDeprecated
See the migration guide An auxiliary class used by Leaflet.
MessageDialogDeprecatedv1_2
Use AlertDialog.
MultiLayoutViewv1_6
NavigationPagev1_4
A page within NavigationView or NavigationSplitView.
NavigationSplitViewv1_4
` element, Specifying “content” child type or omitting it results in setting the content widget.
NavigationViewv1_4
CSS nodes
NoneAnimationTargetv1_9
An AnimationTarget that doesn’t do anything.
OverlaySplitViewv1_4
` element, Specifying “content” child type or omitting it results in setting the content widget.
PasswordEntryRowv1_2
It does not show its contents in clear text, does not allow to copy it to the clipboard, and shows a warning when Caps Lock is engaged. If the underlying platform allows it, PasswordEntryRow will also place the text in a non-pageable memory area, to avoid it being written out to disk by the operating system.
PreferencesDialogv1_5
The PreferencesDialog widget presents an application’s preferences gathered into pages and groups. The preferences are searchable by the user.
PreferencesGroup
An PreferencesGroup represents a group or tightly related preferences, which in turn are represented by PreferencesRow.
PreferencesPage
The PreferencesPage widget gathers preferences groups into a single page of a preferences window.
PreferencesRow
A gtk::ListBoxRow used to present preferences.
PreferencesWindowDeprecated
Use PreferencesDialog.
PropertyAnimationTargetv1_2
An AnimationTarget changing the value of a property of a glib::Object instance.
ShortcutLabelv1_8
amp;` when used in UI files.
ShortcutsDialogv1_8
The recommended way to use ShortcutsDialog is via Application’s automatic resource loading.
ShortcutsItemv1_8
An object representing an individual shortcut in ShortcutsSection.
ShortcutsSectionv1_8
An object representing a section in ShortcutsDialog.
Sidebarv1_9
SidebarItemv1_9
An item within SidebarSection.
SidebarSectionv1_9
/picture
SpinRowv1_4
Spinnerv1_6
SpinnerPaintablev1_6
SplitButton
├── separator ╰── menubutton ╰── button.toggle ╰── arrow
SpringAnimation
A spring-based Animation.
SpringParams
Physical parameters of a spring for SpringAnimation.
SqueezerDeprecated
See the migration guide
SqueezerPageDeprecated
See the migration guide An auxiliary class used by Squeezer.
StatusPage
/picture
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
TabBar
/picture
TabButtonv1_3
TabOverviewv1_3
TabOverview is a widget that can display tabs from an TabView in a grid.
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
/picture
ToastOverlay
Much like Gtk::Overlay, ToastOverlay is a container with a single main child, on top of which it can display a Toast, overlaid. Toasts can be shown with add_toast().
Togglev1_7
A toggle within ToggleGroup.
ToggleGroupv1_7
Accessibility
ToolbarViewv1_4
` element, or adding a bottom bar by specifying “bottom”.
ViewStack
ViewStackPage
An auxiliary class used by ViewStack.
ViewStackPagesv1_4
An auxiliary class used by ViewStack.
ViewSwitcher
ViewSwitcherBar
ViewSwitcherSidebarv1_9
Connect to the activated signal to run code when an item has been activated. This can be used to toggle the visible pane when used in a split view.
ViewSwitcherTitleDeprecated
See the migration guide
Window
, and controlled via the adaptive-preview property.
WindowTitle
WindowTitle shows a title and subtitle. It’s intended to be used as the title child of gtk::HeaderBar or HeaderBar.
WrapBoxv1_7
WrapBox is similar to Gtk::Box, but can wrap lines when the widgets cannot fit otherwise. Unlike Gtk::FlowBox, the children aren’t arranged into a grid and behave more like words in a wrapping label.
WrapLayoutv1_7
WrapLayout is similar to Gtk::BoxLayout, but can wrap lines when the widgets cannot fit otherwise. Unlike Gtk::FlowBox, the children aren’t arranged into a grid and behave more like words in a wrapping label.

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
/picture
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.
SidebarModev1_9
Determines how an Sidebar should look and behave.
SqueezerTransitionTypeDeprecated
Describes the possible transitions in a Squeezer widget.
ToastPriority
Toast behavior when another toast is already displayed.
ToolbarStylev1_4
See top-bar-style and bottom-bar-style.
ViewSwitcherPolicy
Describes the adaptive modes of ViewSwitcher.
WrapPolicyv1_7
Describes line wrapping behavior in a WrapLayout or WrapBox.

Functions§

bind_property_to_css_classv1_10
Creates a binding between a property on @source and a CSS class on @target.
bind_property_to_css_class_fullv1_10
Creates a binding between a property on @source and a CSS class on @target with a custom mapping.
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.