2018-06-09 13:13:57 -04:00
|
|
|
#ifndef ROFI_ICON_FETCHER_H
|
|
|
|
#define ROFI_ICON_FETCHER_H
|
|
|
|
|
2021-08-19 07:34:01 -04:00
|
|
|
#include <cairo.h>
|
2018-06-09 13:13:57 -04:00
|
|
|
#include <glib.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
2018-06-12 05:10:46 -04:00
|
|
|
/**
|
|
|
|
* @defgroup ICONFETCHER IconFetcher
|
|
|
|
* @ingroup HELPERS
|
|
|
|
*
|
|
|
|
* Small helper of to fetch icons. This makes use of the 'view' threadpool.
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize the icon fetcher.
|
|
|
|
*/
|
2021-08-19 07:34:01 -04:00
|
|
|
void rofi_icon_fetcher_init(void);
|
2018-06-09 13:13:57 -04:00
|
|
|
|
2018-06-12 05:10:46 -04:00
|
|
|
/**
|
|
|
|
* Destroy and free the memory used by the icon fetcher.
|
|
|
|
*/
|
2021-08-19 07:34:01 -04:00
|
|
|
void rofi_icon_fetcher_destroy(void);
|
2018-06-09 13:13:57 -04:00
|
|
|
|
2018-06-12 05:10:46 -04:00
|
|
|
/**
|
|
|
|
* @param name The name of the icon to fetch.
|
|
|
|
* @param size The size of the icon to fetch.
|
|
|
|
*
|
|
|
|
* Query the icon-theme for icon with name and size.
|
2021-08-19 07:34:01 -04:00
|
|
|
* The returned icon will be the best match for the requested size, it should
|
|
|
|
* still be resized to the actual size.
|
2018-06-12 05:10:46 -04:00
|
|
|
*
|
|
|
|
* name can also be a full path, if prefixed with file://.
|
|
|
|
*
|
|
|
|
* @returns the uid identifying the request.
|
|
|
|
*/
|
2021-08-19 07:34:01 -04:00
|
|
|
uint32_t rofi_icon_fetcher_query(const char *name, const int size);
|
2021-06-15 11:22:39 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param name The name of the icon to fetch.
|
|
|
|
* @param wsize The width of the icon to fetch.
|
|
|
|
* @param hsize The height of the icon to fetch.
|
|
|
|
*
|
|
|
|
* Query the icon-theme for icon with name and size.
|
2021-08-19 07:34:01 -04:00
|
|
|
* The returned icon will be the best match for the requested size, it should
|
|
|
|
* still be resized to the actual size. For icons it will take the min of wsize
|
|
|
|
* and hsize.
|
2021-06-15 11:22:39 -04:00
|
|
|
*
|
|
|
|
* name can also be a full path, if prefixed with file://.
|
|
|
|
*
|
|
|
|
* @returns the uid identifying the request.
|
|
|
|
*/
|
2021-08-19 07:34:01 -04:00
|
|
|
uint32_t rofi_icon_fetcher_query_advanced(const char *name, const int wsize,
|
|
|
|
const int hsize);
|
2018-06-09 13:13:57 -04:00
|
|
|
|
2018-06-12 05:10:46 -04:00
|
|
|
/**
|
|
|
|
* @param uid The unique id representing the matching request.
|
|
|
|
*
|
|
|
|
* If the surface is used, the user should reference the surface.
|
|
|
|
*
|
|
|
|
* @returns the surface with the icon, NULL when not found.
|
|
|
|
*/
|
2021-08-19 07:34:01 -04:00
|
|
|
cairo_surface_t *rofi_icon_fetcher_get(const uint32_t uid);
|
2018-06-09 13:13:57 -04:00
|
|
|
|
2022-10-22 05:03:11 -04:00
|
|
|
/**
|
|
|
|
* @param uid The unique id representing the matching request.
|
|
|
|
* @param surface [out] The surface found.
|
|
|
|
*
|
|
|
|
* If the surface is used, the user should reference the surface.
|
|
|
|
*
|
|
|
|
* @returns false if a query was done and failed.
|
|
|
|
*/
|
|
|
|
gboolean rofi_icon_fetcher_get_ex(const uint32_t uid,
|
|
|
|
cairo_surface_t **surface);
|
2021-05-05 15:53:29 -04:00
|
|
|
/**
|
|
|
|
* @param path the image path to check.
|
|
|
|
*
|
|
|
|
* Checks if a file is a supported image. (by looking at extension).
|
|
|
|
*
|
|
|
|
* @returns true if image, false otherwise.
|
|
|
|
*/
|
2021-08-19 07:34:01 -04:00
|
|
|
gboolean rofi_icon_fetcher_file_is_image(const char *const path);
|
2020-10-12 15:39:36 -04:00
|
|
|
/** @} */
|
2018-06-09 13:13:57 -04:00
|
|
|
#endif // ROFI_ICON_FETCHER_H
|