libadwaita/auto/
functions.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from
// from gir-files (https://github.com/gtk-rs/gir-files.git)
// DO NOT EDIT

use crate::ffi;
use glib::{prelude::*, translate::*};

/// Checks whether animations are enabled for @widget.
///
/// This should be used when implementing an animated widget to know whether to
/// animate it or not.
/// ## `widget`
/// a [`gtk::Widget`][crate::gtk::Widget]
///
/// # Returns
///
/// whether animations are enabled for @widget
#[doc(alias = "adw_get_enable_animations")]
#[doc(alias = "get_enable_animations")]
pub fn is_animations_enabled(widget: &impl IsA<gtk::Widget>) -> bool {
    assert_initialized_main_thread!();
    unsafe {
        from_glib(ffi::adw_get_enable_animations(
            widget.as_ref().to_glib_none().0,
        ))
    }
}

/// Returns the major version number of the Adwaita library.
///
/// For example, in libadwaita version 1.2.3 this is 1.
///
/// This function is in the library, so it represents the libadwaita library your
/// code is running against. Contrast with the `MAJOR_VERSION` constant,
/// which represents the major version of the libadwaita headers you have
/// included when compiling your code.
///
/// # Returns
///
/// the major version number of the Adwaita library
#[doc(alias = "adw_get_major_version")]
#[doc(alias = "get_major_version")]
pub fn major_version() -> u32 {
    assert_initialized_main_thread!();
    unsafe { ffi::adw_get_major_version() }
}

/// Returns the micro version number of the Adwaita library.
///
/// For example, in libadwaita version 1.2.3 this is 3.
///
/// This function is in the library, so it represents the libadwaita library your
/// code is running against. Contrast with the `MAJOR_VERSION` constant,
/// which represents the micro version of the libadwaita headers you have
/// included when compiling your code.
///
/// # Returns
///
/// the micro version number of the Adwaita library
#[doc(alias = "adw_get_micro_version")]
#[doc(alias = "get_micro_version")]
pub fn micro_version() -> u32 {
    assert_initialized_main_thread!();
    unsafe { ffi::adw_get_micro_version() }
}

/// Returns the minor version number of the Adwaita library.
///
/// For example, in libadwaita version 1.2.3 this is 2.
///
/// This function is in the library, so it represents the libadwaita library your
/// code is running against. Contrast with the `MAJOR_VERSION` constant,
/// which represents the minor version of the libadwaita headers you have
/// included when compiling your code.
///
/// # Returns
///
/// the minor version number of the Adwaita library
#[doc(alias = "adw_get_minor_version")]
#[doc(alias = "get_minor_version")]
pub fn minor_version() -> u32 {
    assert_initialized_main_thread!();
    unsafe { ffi::adw_get_minor_version() }
}

/// Use this function to check if libadwaita has been initialized with
/// [`init()`][crate::init()].
///
/// # Returns
///
/// the initialization status
#[doc(alias = "adw_is_initialized")]
pub fn is_initialized() -> bool {
    assert_initialized_main_thread!();
    unsafe { from_glib(ffi::adw_is_initialized()) }
}

/// Computes the linear interpolation between @a and @b for @t.
/// ## `a`
/// the start
/// ## `b`
/// the end
/// ## `t`
/// the interpolation rate
///
/// # Returns
///
/// the computed value
#[doc(alias = "adw_lerp")]
pub fn lerp(a: f64, b: f64, t: f64) -> f64 {
    assert_initialized_main_thread!();
    unsafe { ffi::adw_lerp(a, b, t) }
}

/// Adjusts @rgba to be suitable as a standalone color.
///
/// It will typically be darker for light background, and lighter for dark
/// background, ensuring contrast.
/// ## `rgba`
/// a background color
/// ## `dark`
/// Whether to calculate standalone color for light or dark background
///
/// # Returns
///
///
/// ## `standalone_rgba`
/// return location for the standalone color
#[cfg(feature = "v1_6")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
#[doc(alias = "adw_rgba_to_standalone")]
pub fn rgba_to_standalone(rgba: &gdk::RGBA, dark: bool) -> gdk::RGBA {
    assert_initialized_main_thread!();
    unsafe {
        let mut standalone_rgba = gdk::RGBA::uninitialized();
        ffi::adw_rgba_to_standalone(
            rgba.to_glib_none().0,
            dark.into_glib(),
            standalone_rgba.to_glib_none_mut().0,
        );
        standalone_rgba
    }
}