rofi_plugin_sys/icon_fetcher.rs
1//! Small helper to fetch icons. This makes use of the 'view' threadpool.
2//!
3//! This corresponds to `rofi-icon-fetcher.h`.
4
5use ::std::os::raw::{c_char, c_int};
6
7extern "C" {
8 /// Initialize the icon fetcher.
9 #[link_name = "rofi_icon_fetcher_init"]
10 pub fn init();
11
12 /// Destroy and free the memory used by the icon fetcher.
13 #[link_name = "rofi_icon_fetcher_destroy"]
14 pub fn destroy();
15
16 /// Query the icon-theme for icon with name and size.
17 ///
18 /// The returned icon will be the best match for the requested size,
19 /// it should still be resized to the actual size.
20 ///
21 /// `name` can also be a full path, if prefixed with `file://`.
22 ///
23 /// Returns the UID identifying the request.
24 #[link_name = "rofi_icon_fetcher_query"]
25 pub fn query(name: *const c_char, size: c_int) -> u32;
26
27 /// Query the icon-theme for icon with name and size.
28 ///
29 /// The returned icon will be the best match for the requested size,
30 /// it should still be resized to the actual size.
31 /// For icons it will take the min of wsize and hsize.
32 ///
33 /// `name` can also be a full path, if prefixed with `file://`.
34 ///
35 /// Returns the UID identifying the request.
36 #[link_name = "rofi_icon_fetcher_query_advanced"]
37 pub fn query_advanced(name: *const c_char, wsize: c_int, hsize: c_int) -> u32;
38
39 /// Retrieves the surface with the icon, or `NULL` if it wasn't found.
40 ///
41 /// Accepts a request UID.
42 #[link_name = "rofi_icon_fetcher_get"]
43 pub fn get(uid: u32) -> *mut cairo_sys::cairo_surface_t;
44
45 /// Retrieves the surface with the icon, writing the result into `surface`.
46 /// Returns whether the query succeeded.
47 ///
48 /// Accepts a request UID and an out pointer.
49 #[link_name = "rofi_icon_fetcher_get_ex"]
50 pub fn get_ex(uid: u32, surface: *mut *mut cairo_sys::cairo_surface_t) -> glib_sys::gboolean;
51
52 /// Checks if a file is a supported image (by looking at its extension).
53 ///
54 /// Returns true if it is an image, false otherwise.
55 #[link_name = "rofi_icon_fetcher_file_is_image"]
56 pub fn file_is_image(path: *const c_char) -> glib_sys::gboolean;
57}