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
// Take a look at the license at the top of the repository in the LICENSE file.
use crate::IconTheme;
use glib::translate::*;
impl IconTheme {
/// Returns an array of integers describing the sizes at which
/// the icon is available without scaling.
///
/// A size of -1 means that the icon is available in a scalable
/// format. The array is zero-terminated.
/// ## `icon_name`
/// the name of an icon
///
/// # Returns
///
/// A newly
/// allocated array describing the sizes at which the icon is
/// available. The array should be freed with g_free() when it is no
/// longer needed.
#[doc(alias = "gtk_icon_theme_get_icon_sizes")]
#[doc(alias = "get_icon_sizes")]
pub fn icon_sizes(&self, icon_name: &str) -> Vec<i32> {
unsafe {
let sizes_ptr = ffi::gtk_icon_theme_get_icon_sizes(
self.to_glib_none().0,
icon_name.to_glib_none().0,
);
let mut sizes = Vec::new();
let mut i = 0;
loop {
// zero-terminated array
let ret = std::ptr::read(sizes_ptr.add(i));
if ret == 0 {
break;
}
sizes.push(ret);
i += 1;
}
glib::ffi::g_free(sizes_ptr as *mut _);
sizes
}
}
}