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:
- 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.show();
});
application.run();
}
Re-exports
Modules
Structs
- AboutWindow
v1_2
A window showing information about the application. - A
gtk::ListBoxRow
used to present actions. - 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.
- A helper widget for creating buttons.
- 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. - EntryRow
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. - An adaptive container acting like a box or an overlay.
- A title bar widget.
- An adaptive container acting like a box or a stack.
- An auxiliary class used by
Leaflet
. - MessageDialog
v1_2
A dialog presenting a message or a question. - PasswordEntryRow
v1_2
AEntryRow
tailored for entering secrets. - A group of preference rows.
- A page from
PreferencesWindow
. - A
gtk::ListBoxRow
used to present preferences. - 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. - A combined button and dropdown widget.
- A spring-based
Animation
. - Physical parameters of a spring for
SpringAnimation
. - A best fit container.
- An auxiliary class used by
Squeezer
. - A page used for empty/error states and similar use-cases.
- A class for managing application-wide styling.
- An interface for swipeable widgets.
- SwitchRow
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.
- TabViewShortcuts
v1_2
Describes available shortcuts in anTabView
. - A time-based
Animation
. - A helper object for
ToastOverlay
. - A widget showing toasts above its content.
- ToolbarView
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
. - An adaptive view switcher.
- A view switcher action bar.
- A view switcher title.
- A freeform window.
- A helper widget for setting a window’s title and subtitle.
Enums
- Describes the possible states of an
Animation
. - Describes title centering behavior of a
HeaderBar
widget. - Application color schemes for
color-scheme
. - Describes the available easing functions for use with
TimedAnimation
. - Describes the possible folding behavior of a
Flap
widget. - Describes transitions types of a
Flap
widget. - Describes the possible transitions in a
Leaflet
widget. - Describes the direction of a swipe navigation gesture.
- Describes the possible styles of
MessageDialog
response buttons. - Describes the possible transitions in a
Squeezer
widget. Toast
behavior when another toast is already displayed.- ToolbarStyle
v1_4
Describes the possible top or bottom bar styles in anToolbarView
widget. - Describes the adaptive modes of
ViewSwitcher
.
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.