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
/// This function fetches the version of the GEGL library being used by
/// the running process.
///
/// # Returns
///
///
/// ## `major`
/// a pointer to a int where the major version number will be stored
///
/// ## `minor`
/// ditto for the minor version number
///
/// ## `micro`
/// ditto for the micro version number
#[doc(alias = "get_version")]
#[doc(alias = "babl_get_version")]
pub fn version() -> (i32, i32, i32) {
unsafe {
let mut major: i32 = 0;
let mut minor: i32 = 0;
let mut micro: i32 = 0;
ffi::babl_get_version(&mut major, &mut minor, &mut micro);
(major, minor, micro)
}
}
/// Call this function before using any other GEGL functions. It will
/// initialize everything needed to operate GEGL and parses some
/// standard command line options. `argc` and `argv` are adjusted
/// accordingly so your own code will never see those standard
/// arguments.
///
/// Note that there is an alternative way to initialize GEGL: if you
/// are calling `g_option_context_parse()` with the option group returned
/// by `gegl_get_option_group()`, you don't have to call `gegl_init()`.
/// ## `argv`
/// a pointer to the array of command line arguments.
#[doc(alias = "babl_init")]
pub fn init() {
static INIT: std::sync::Once = std::sync::Once::new();
INIT.call_once(|| unsafe {
ffi::babl_init();
});
}
/// Call this function when you're done using GEGL. It will clean up
/// caches and write/dump debug information if the correct debug flags
/// are set.
#[doc(alias = "babl_exit")]
#[deprecated(note = "init() is once, so calling exit is unwanted")]
pub fn exit() {
// We disable calling babl_exit.
// unsafe {
// ffi::babl_exit();
// }
}
#[cfg(test)]
mod tests {
use super::version;
#[test]
fn test_version() {
let config = system_deps::Config::new().probe().unwrap();
let dep = config
.get_by_name("babl")
.or_else(|| config.get_by_name("babl-0.1"))
.unwrap();
let v = version();
assert!(matches!(
version_compare::compare(&dep.version, &format!("{}.{}.{}", v.0, v.1, v.2)),
Ok(version_compare::Cmp::Eq)
));
}
}