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
- GTK 4 Rust bindings documentation
- Libadwaita documentation
- gtk-rs project overview
- Report bindings related issues
- Report upstream libadwaita issues
§Example
Adwaita needs to be initialized before use. This can be done by either:
- using
adw::Applicationinstead ofgtk::Application, or by - calling
initonstartup.
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§
Modules§
Structs§
- About
Dialog v1_5 - Legal
- About
Window Deprecated v1_2 - Use
AboutDialog. - Action
Row - When used together with the
.monospacestyle class, only the subtitle becomes monospace, not the title or any extra widgets. - Alert
Dialog v1_5 - Animation
- A base class for animations.
- Animation
Target - Represents a value
Animationcan animate. - Application
- accelerator for it.
- Application
Window - Avatar
Avataris a widget that shows a round avatar.- Banner
v1_3 - CSS nodes
- Bin
- The
Binwidget has only one child, set with thechildproperty. - Bottom
Sheet v1_6 - ` element, and the bottom bar by specifying “bottom-bar”. Specifying “content” or omitting the child type results in setting the content child.
- Breakpoint
v1_4 - Breakpoint
Bin v1_4 - Breakpoint
Condition v1_4 - Describes condition for an
Breakpoint. - Button
Content - Button
Row v1_6 - /picture
- Callback
Animation Target - An
AnimationTargetthat calls a given callback during the animation. - Carousel
- The
Carouselwidget can be used to display a set of pages with swipe-based navigation between them. - Carousel
Indicator Dots - The
CarouselIndicatorDotswidget shows a set of dots for each page of a givenCarousel. 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. - Carousel
Indicator Lines - The
CarouselIndicatorLineswidget shows a set of lines for each page of a givenCarousel. The carousel’s active page is shown as another line that moves between them to match the carousel’s position. - Clamp
- The
Clampwidget 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. - Clamp
Layout ClampLayoutconstraints 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.- Clamp
Scrollable - A scrollable
Clamp. - Combo
Row - CssClass
Binding v1_10 - A binding between a
glib::Objectproperty and a CSS class on agtk::Widget. - Dialog
v1_5 Dialogis similar to a window, but is shown within another window. It can be used withWindowandApplicationWindow, useAdwDialogExt::present()to show it.- Entry
Row v1_2 - element.
- Enum
List Item Deprecated - Use
Gtk::EnumListItem.EnumListItemis the type of items in aEnumListModel. - Enum
List Model Deprecated - Use
Gtk::EnumList. Agio::ListModelrepresenting values of a given enum. - Expander
Row - element.
- Flap
Deprecated - See the migration guide ` element, and separator by specifying “separator”. Specifying “content” child type or omitting it results in setting the content child.
- Header
Bar HeaderBaris similar togtk::HeaderBar, but provides additional features compared to it. Refer togtk::HeaderBarfor details. It is typically used as a top bar withinToolbarView.- Inline
View Switcher v1_7 - Accessibility
- Layout
v1_6 - An individual layout in
MultiLayoutView. - Layout
Slot v1_6 - A child slot within
Layout. - Leaflet
Deprecated - See the migration guide
- Leaflet
Page Deprecated - See the migration guide
An auxiliary class used by
Leaflet. - Message
Dialog Deprecated v1_2 - Use
AlertDialog. - Multi
Layout View v1_6 - Navigation
Page v1_4 - A page within
NavigationVieworNavigationSplitView. - Navigation
Split View v1_4 - ` element, Specifying “content” child type or omitting it results in setting the content widget.
- Navigation
View v1_4 - CSS nodes
- None
Animation Target v1_9 - An
AnimationTargetthat doesn’t do anything. - Overlay
Split View v1_4 - ` element, Specifying “content” child type or omitting it results in setting the content widget.
- Password
Entry Row v1_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,
PasswordEntryRowwill also place the text in a non-pageable memory area, to avoid it being written out to disk by the operating system. - Preferences
Dialog v1_5 - The
PreferencesDialogwidget presents an application’s preferences gathered into pages and groups. The preferences are searchable by the user. - Preferences
Group - An
PreferencesGrouprepresents a group or tightly related preferences, which in turn are represented byPreferencesRow. - Preferences
Page - The
PreferencesPagewidget gathers preferences groups into a single page of a preferences window. - Preferences
Row - A
gtk::ListBoxRowused to present preferences. - Preferences
Window Deprecated - Use
PreferencesDialog. - Property
Animation Target v1_2 - An
AnimationTargetchanging the value of a property of aglib::Objectinstance. - Shortcut
Label v1_8 - amp;` when used in UI files.
- Shortcuts
Dialog v1_8 - The recommended way to use
ShortcutsDialogis viaApplication’s automatic resource loading. - Shortcuts
Item v1_8 - An object representing an individual shortcut in
ShortcutsSection. - Shortcuts
Section v1_8 - An object representing a section in
ShortcutsDialog. - Sidebar
v1_9 - Sidebar
Item v1_9 - An item within
SidebarSection. - Sidebar
Section v1_9 - /picture
- SpinRow
v1_4 - Spinner
v1_6 - Spinner
Paintable v1_6 - Split
Button - ├── separator ╰── menubutton ╰── button.toggle ╰── arrow
- Spring
Animation - A spring-based
Animation. - Spring
Params - Physical parameters of a spring for
SpringAnimation. - Squeezer
Deprecated - See the migration guide
- Squeezer
Page Deprecated - See the migration guide
An auxiliary class used by
Squeezer. - Status
Page - /picture
- Style
Manager - A class for managing application-wide styling.
- Swipe
Tracker - A swipe tracker used in
Carousel,NavigationViewandOverlaySplitView. - Swipeable
- An interface for swipeable widgets.
- Switch
Row v1_4 - TabBar
- /picture
- TabButton
v1_3 - TabOverview
v1_3 TabOverviewis a widget that can display tabs from anTabViewin a grid.- TabPage
- An auxiliary class used by
TabView. - TabView
- A dynamic tabbed container.
- TabView
Shortcuts v1_2 - Describes available shortcuts in an
TabView. - Timed
Animation - A time-based
Animation. - Toast
- /picture
- Toast
Overlay - Much like
Gtk::Overlay,ToastOverlayis a container with a single main child, on top of which it can display aToast, overlaid. Toasts can be shown withadd_toast(). - Toggle
v1_7 - A toggle within
ToggleGroup. - Toggle
Group v1_7 - Accessibility
- Toolbar
View v1_4 - ` element, or adding a bottom bar by specifying “bottom”.
- View
Stack - View
Stack Page - An auxiliary class used by
ViewStack. - View
Stack Pages v1_4 - An auxiliary class used by
ViewStack. - View
Switcher - View
Switcher Bar - View
Switcher Sidebar v1_9 - Connect to the
activatedsignal to run code when an item has been activated. This can be used to toggle the visible pane when used in a split view. - View
Switcher Title Deprecated - See the migration guide
- Window
- ,
and controlled via the
adaptive-previewproperty. - Window
Title WindowTitleshows a title and subtitle. It’s intended to be used as the title child ofgtk::HeaderBarorHeaderBar.- WrapBox
v1_7 WrapBoxis similar toGtk::Box, but can wrap lines when the widgets cannot fit otherwise. UnlikeGtk::FlowBox, the children aren’t arranged into a grid and behave more like words in a wrapping label.- Wrap
Layout v1_7 WrapLayoutis similar toGtk::BoxLayout, but can wrap lines when the widgets cannot fit otherwise. UnlikeGtk::FlowBox, the children aren’t arranged into a grid and behave more like words in a wrapping label.
Enums§
- Accent
Color v1_6 - Describes the available system accent colors.
- Animation
State - Describes the possible states of an
Animation. - Banner
Button Style v1_7 - Describes the available button styles for
Banner. - Breakpoint
Condition Length Type v1_4 - Describes length types for
BreakpointCondition. - Breakpoint
Condition Ratio Type v1_4 - Describes ratio types for
BreakpointCondition. - Centering
Policy - Describes title centering behavior of a
HeaderBarwidget. - Color
Scheme - Application color schemes for
color-scheme. - Dialog
Presentation Mode v1_5 - Describes the available presentation modes for
Dialog. - Easing
- Describes the available easing functions for use with
TimedAnimation. - Flap
Fold Policy Deprecated - Describes the possible folding behavior of a
Flapwidget. - Flap
Transition Type Deprecated - Describes transitions types of a
Flapwidget. - Fold
Threshold Policy Deprecated - Determines when
FlapandLeafletwill fold. - Inline
View Switcher Display Mode v1_7 - /picture
- Justify
Mode v1_7 - Describes line justify behaviors in a
WrapLayoutorWrapBox. - Leaflet
Transition Type Deprecated - Describes the possible transitions in a
Leafletwidget. - Length
Unit v1_4 - Describes length units.
- Navigation
Direction - Describes the direction of a swipe navigation gesture.
- Pack
Direction v1_7 - Describes child packing behavior in a
WrapLayoutorWrapBox. - Response
Appearance v1_2 - Describes the possible styles of
AlertDialogresponse buttons. - Sidebar
Mode v1_9 - Determines how an
Sidebarshould look and behave. - Squeezer
Transition Type Deprecated - Describes the possible transitions in a
Squeezerwidget. - Toast
Priority Toastbehavior when another toast is already displayed.- Toolbar
Style v1_4 - See
top-bar-styleandbottom-bar-style. - View
Switcher Policy - Describes the adaptive modes of
ViewSwitcher. - Wrap
Policy v1_7 - Describes line wrapping behavior in a
WrapLayoutorWrapBox.
Functions§
- bind_
property_ to_ css_ class v1_10 - Creates a binding between a property on @source and a CSS class on @target.
- bind_
property_ to_ css_ class_ full v1_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_ standalone v1_6 - Adjusts @rgba to be suitable as a standalone color.