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
UseAboutDialog
. A window showing information about the application. - A
gtk::ListBoxRow
used to present actions. - Alert
Dialog v1_5
A dialog presenting a message or a question. - A base class for animations.
- Represents a value
Animation
can animate. - A base class for Adwaita applications.
- A freeform application window.
- A widget displaying an image, with a generated fallback.
- Banner
v1_3
A bar with contextual information. - A widget with one child.
- Bottom
Sheet v1_6
A bottom sheet with an optional bottom bar. - Breakpoint
v1_4
- Breakpoint
Bin v1_4
A widget that changes layout based on available size. - Describes condition for an
Breakpoint
. - A helper widget for creating buttons.
- Button
Row v1_6
Agtk::ListBoxRow
that looks like a button. - An
AnimationTarget
that calls a given callback during the animation. - A paginated scrolling widget.
- A dots indicator for
Carousel
. - A lines indicator for
Carousel
. - A widget constraining its child to a given size.
- A layout manager constraining its children to a given size.
- A scrollable
Clamp
. - A
gtk::ListBoxRow
used to choose from a list of items. - Dialog
v1_5
An adaptive dialog container. - Entry
Row v1_2
Agtk::ListBoxRow
with an embedded text entry. EnumListItem
is the type of items in aEnumListModel
.- A
gio::ListModel
representing values of a given enum. - A
gtk::ListBoxRow
used to reveal widgets. - Flap
Deprecated See the migration guide An adaptive container acting like a box or an overlay. - A title bar widget.
- A view switcher that uses a toggle group.
- Layout
v1_6
An individual layout inMultiLayoutView
. - Layout
Slot v1_6
A child slot withinLayout
. - 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 byLeaflet
. - Message
Dialog Deprecated v1_2
UseAlertDialog
. 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 withinNavigationView
orNavigationSplitView
. - 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
AEntryRow
tailored for entering secrets. - A dialog showing application’s preferences.
- A group of preference rows.
- A page from
PreferencesDialog
. - A
gtk::ListBoxRow
used to present preferences. - Preferences
Window Deprecated UsePreferencesDialog
. A window to present an application’s preferences. - An
AnimationTarget
changing the value of a property of aglib::Object
instance. - SpinRow
v1_4
AnActionRow
with an embedded spin button. - Spinner
v1_6
A widget showing a loading spinner. - Spinner
Paintable v1_6
A paintable showing a loading spinner. - A combined button and dropdown widget.
- A spring-based
Animation
. - 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 bySqueezer
. - A page used for empty/error states and similar use-cases.
- A class for managing application-wide styling.
- An interface for swipeable widgets.
- Switch
Row v1_4
Agtk::ListBoxRow
used to represent two states. - A tab bar for
TabView
. - TabButton
v1_3
A button that displays the number ofTabView
pages. - TabOverview
v1_3
A tab overview forTabView
. - An auxiliary class used by
TabView
. - A dynamic tabbed container.
- TabView
Shortcuts v1_2
Describes available shortcuts in anTabView
. - A time-based
Animation
. - A helper object for
ToastOverlay
. - A widget showing toasts above its content.
- Toggle
v1_7
A toggle withinToggleGroup
. - 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. - A view container for
ViewSwitcher
. - An auxiliary class used by
ViewStack
. - View
Stack Pages v1_4
An auxiliary class used byViewStack
. - An adaptive view switcher.
- A view switcher action bar.
- View
Switcher Title Deprecated See the migration guide A view switcher title. - A freeform window.
- 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. - Describes the possible states of an
Animation
. - Describes length types for
BreakpointCondition
. - Describes ratio types for
BreakpointCondition
. - Describes title centering behavior of a
HeaderBar
widget. - Application color schemes for
color-scheme
. - Describes the available presentation modes for
Dialog
. - Describes the available easing functions for use with
TimedAnimation
. - Flap
Fold Policy Deprecated Describes the possible folding behavior of aFlap
widget. - Flap
Transition Type Deprecated Describes transitions types of aFlap
widget. - Fold
Threshold Policy Deprecated - Describes what
InlineViewSwitcher
toggles display. - Justify
Mode v1_7
Describes line justify behaviors in aWrapLayout
orWrapBox
. - Leaflet
Transition Type Deprecated Describes the possible transitions in aLeaflet
widget. - Length
Unit v1_4
Describes length units. - Describes the direction of a swipe navigation gesture.
- Pack
Direction v1_7
Describes child packing behavior in aWrapLayout
orWrapBox
. - Describes the possible styles of
AlertDialog
response buttons. - Squeezer
Transition Type Deprecated Describes the possible transitions in aSqueezer
widget. Toast
behavior when another toast is already displayed.- Toolbar
Style v1_4
Describes the possible top or bottom bar styles in anToolbarView
widget. - Describes the adaptive modes of
ViewSwitcher
. - Wrap
Policy v1_7
Describes line wrapping behavior in aWrapLayout
orWrapBox
.
Functions§
- Initializes Libadwaita.
- Checks whether animations are enabled for @widget.
- Use this function to check if libadwaita has been initialized with
init()
. - Computes the linear interpolation between @a and @b for @t.
- Returns the major version number of the Adwaita library.
- Returns the micro version number of the Adwaita library.
- Returns the minor version number of the Adwaita library.
- Adjusts @rgba to be suitable as a standalone color.