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::Application
instead ofgtk::Application
, or by - calling
init
onstartup
.
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::ListBoxRow
used 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
Animation
can 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
Window
orDialog
. - 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::ListBoxRow
that looks like a button. - Callback
Animation Target - An
AnimationTarget
that 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::ListBoxRow
used to choose from a list of items. - Dialog
v1_5
- An adaptive dialog container.
- Entry
Row v1_2
- A
gtk::ListBoxRow
with an embedded text entry. - Enum
List Item EnumListItem
is the type of items in aEnumListModel
.- Enum
List Model - A
gio::ListModel
representing values of a given enum. - Expander
Row - A
gtk::ListBoxRow
used 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
NavigationView
orNavigationSplitView
. - 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.
- Overlay
Split View v1_4
- A widget presenting sidebar and content side by side or as an overlay.
- Password
Entry Row v1_2
- A
EntryRow
tailored 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::ListBoxRow
used to present preferences. - Preferences
Window Deprecated - Use
PreferencesDialog
. A window to present an application’s preferences. - Property
Animation Target v1_2
- An
AnimationTarget
changing the value of a property of aglib::Object
instance. - 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
. - SpinRow
v1_4
- An
ActionRow
with 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
,NavigationView
andOverlaySplitView
. - Swipeable
- An interface for swipeable widgets.
- Switch
Row v1_4
- A
gtk::ListBoxRow
used to represent two states. - TabBar
- A tab bar for
TabView
. - TabButton
v1_3
- A button that displays the number of
TabView
pages. - 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 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
HeaderBar
widget. - 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
Flap
widget. - Flap
Transition Type Deprecated - Describes transitions types of a
Flap
widget. - Fold
Threshold Policy Deprecated - Determines when
Flap
andLeaflet
will fold. - Inline
View Switcher Display Mode v1_7
- Describes what
InlineViewSwitcher
toggles display. - Justify
Mode v1_7
- Describes line justify behaviors in a
WrapLayout
orWrapBox
. - Leaflet
Transition Type Deprecated - Describes the possible transitions in a
Leaflet
widget. - 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
WrapLayout
orWrapBox
. - Response
Appearance v1_2
- Describes the possible styles of
AlertDialog
response buttons. - Squeezer
Transition Type Deprecated - Describes the possible transitions in a
Squeezer
widget. - Toast
Priority Toast
behavior when another toast is already displayed.- Toolbar
Style v1_4
- Describes the possible top or bottom bar styles in an
ToolbarView
widget. - View
Switcher Policy - Describes the adaptive modes of
ViewSwitcher
. - Wrap
Policy v1_7
- Describes line wrapping behavior in a
WrapLayout
orWrapBox
.
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.