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 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 - A dialog showing information about the application.
- About
Window Deprecated v1_2 - Use
AboutDialog. A window showing information about the application. - Action
Row - A
gtk::ListBoxRowused to present actions. - Alert
Dialog v1_5 - A dialog presenting a message or a question.
- Animation
- A base class for animations.
- Animation
Target - Represents a value
Animationcan animate. - Application
- A base class for Adwaita applications.
- Application
Window - A freeform application window.
- Avatar
- A widget displaying an image, with a generated fallback.
- Banner
v1_3 - A bar with contextual information.
- Bin
- A widget with one child.
- Bottom
Sheet v1_6 - A bottom sheet with an optional bottom bar.
- Breakpoint
v1_4 - Describes a breakpoint for
WindoworDialog. - Breakpoint
Bin v1_4 - A widget that changes layout based on available size.
- Breakpoint
Condition v1_4 - Describes condition for an
Breakpoint. - Button
Content - A helper widget for creating buttons.
- Button
Row v1_6 - A
gtk::ListBoxRowthat looks like a button. - Callback
Animation Target - An
AnimationTargetthat calls a given callback during the animation. - Carousel
- A paginated scrolling widget.
- Carousel
Indicator Dots - A dots indicator for
Carousel. - Carousel
Indicator Lines - A lines indicator for
Carousel. - Clamp
- A widget constraining its child to a given size.
- Clamp
Layout - A layout manager constraining its children to a given size.
- Clamp
Scrollable - A scrollable
Clamp. - Combo
Row - A
gtk::ListBoxRowused to choose from a list of items. - Dialog
v1_5 - An adaptive dialog container.
- Entry
Row v1_2 - A
gtk::ListBoxRowwith an embedded text entry. - Enum
List Item EnumListItemis the type of items in aEnumListModel.- Enum
List Model - A
gio::ListModelrepresenting values of a given enum. - Expander
Row - A
gtk::ListBoxRowused to reveal widgets. - Flap
Deprecated - See the migration guide An adaptive container acting like a box or an overlay.
- Header
Bar - A title bar widget.
- Inline
View Switcher v1_7 - A view switcher that uses a toggle group.
- Layout
v1_6 - An individual layout in
MultiLayoutView. - Layout
Slot v1_6 - A child slot within
Layout. - Leaflet
Deprecated - See the migration guide An adaptive container acting like a box or a stack.
- Leaflet
Page Deprecated - See the migration guide
An auxiliary class used by
Leaflet. - Message
Dialog Deprecated v1_2 - Use
AlertDialog. A dialog presenting a message or a question. - Multi
Layout View v1_6 - A widget for switching between different layouts.
- Navigation
Page v1_4 - A page within
NavigationVieworNavigationSplitView. - Navigation
Split View v1_4 - A widget presenting sidebar and content side by side or as a navigation view.
- Navigation
View v1_4 - A page-based navigation container.
- None
Animation Target v1_9 - An
AnimationTargetthat doesn’t do anything. - Overlay
Split View v1_4 - A widget presenting sidebar and content side by side or as an overlay.
- Password
Entry Row v1_2 - A
EntryRowtailored for entering secrets. - Preferences
Dialog v1_5 - A dialog showing application’s preferences.
- Preferences
Group - A group of preference rows.
- Preferences
Page - A page from
PreferencesDialog. - Preferences
Row - A
gtk::ListBoxRowused to present preferences. - Preferences
Window Deprecated - Use
PreferencesDialog. A window to present an application’s preferences. - Property
Animation Target v1_2 - An
AnimationTargetchanging the value of a property of aglib::Objectinstance. - Shortcut
Label v1_8 - A widget that displays a keyboard shortcut.
- Shortcuts
Dialog v1_8 - A dialog that displays application’s keyboard shortcuts.
- 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 - Adaptive sidebar widget.
- Sidebar
Item v1_9 - An item within
SidebarSection. - Sidebar
Section v1_9 - A section within
Sidebar. - SpinRow
v1_4 - An
ActionRowwith an embedded spin button. - Spinner
v1_6 - A widget showing a loading spinner.
- Spinner
Paintable v1_6 - A paintable showing a loading spinner.
- Split
Button - A combined button and dropdown widget.
- Spring
Animation - A spring-based
Animation. - Spring
Params - Physical parameters of a spring for
SpringAnimation. - Squeezer
Deprecated - See the migration guide A best fit container.
- Squeezer
Page Deprecated - See the migration guide
An auxiliary class used by
Squeezer. - Status
Page - A page used for empty/error states and similar use-cases.
- 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 - A
gtk::ListBoxRowused to represent two states. - TabBar
- A tab bar for
TabView. - TabButton
v1_3 - A button that displays the number of
TabViewpages. - TabOverview
v1_3 - A tab overview for
TabView. - 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
- A helper object for
ToastOverlay. - Toast
Overlay - A widget showing toasts above its content.
- Toggle
v1_7 - A toggle within
ToggleGroup. - Toggle
Group v1_7 - A group of exclusive toggles.
- Toolbar
View v1_4 - A widget containing a page, as well as top and/or bottom bars.
- View
Stack - A view container for
ViewSwitcher. - View
Stack Page - An auxiliary class used by
ViewStack. - View
Stack Pages v1_4 - An auxiliary class used by
ViewStack. - View
Switcher - An adaptive view switcher.
- View
Switcher Bar - A view switcher action bar.
- View
Switcher Sidebar v1_9 - An adaptive sidebar that controls an
ViewStack. - View
Switcher Title Deprecated - See the migration guide A view switcher title.
- Window
- A freeform window.
- Window
Title - A helper widget for setting a window’s title and subtitle.
- WrapBox
v1_7 - A box-like widget that can wrap into multiple lines.
- Wrap
Layout v1_7 - A box-like layout that can wrap into multiple lines.
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 - Describes what
InlineViewSwitchertoggles display. - 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 - Describes the possible top or bottom bar styles in an
ToolbarViewwidget. - View
Switcher Policy - Describes the adaptive modes of
ViewSwitcher. - Wrap
Policy v1_7 - Describes line wrapping behavior in a
WrapLayoutorWrapBox.
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_ standalone v1_6 - Adjusts @rgba to be suitable as a standalone color.