2023-10-16 20:13:51 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/// Waybar ABI version. 1 is the latest version
|
|
|
|
extern const size_t wbcffi_version;
|
|
|
|
|
2023-10-19 20:10:32 +00:00
|
|
|
/// Private Waybar CFFI module
|
|
|
|
typedef struct wbcffi_module wbcffi_module;
|
|
|
|
|
|
|
|
/// Waybar module information
|
|
|
|
typedef struct {
|
|
|
|
/// Waybar CFFI object pointer
|
|
|
|
wbcffi_module* obj;
|
|
|
|
|
|
|
|
/// Waybar version string
|
|
|
|
const char* waybar_version;
|
|
|
|
|
|
|
|
/// Returns the waybar widget allocated for this module
|
|
|
|
/// @param obj Waybar CFFI object pointer
|
|
|
|
GtkContainer* (*get_root_widget)(wbcffi_module* obj);
|
|
|
|
|
|
|
|
/// Queues a request for calling wbcffi_update() on the next GTK main event
|
|
|
|
/// loop iteration
|
|
|
|
/// @param obj Waybar CFFI object pointer
|
|
|
|
void (*queue_update)(wbcffi_module*);
|
|
|
|
} wbcffi_init_info;
|
|
|
|
|
2023-10-16 20:13:51 +00:00
|
|
|
/// Config key-value pair
|
2023-10-19 20:10:32 +00:00
|
|
|
typedef struct {
|
2023-10-16 20:13:51 +00:00
|
|
|
/// Entry key
|
|
|
|
const char* key;
|
|
|
|
/// Entry value as string. JSON object and arrays are serialized.
|
|
|
|
const char* value;
|
2023-10-19 20:10:32 +00:00
|
|
|
} wbcffi_config_entry;
|
2023-10-16 20:13:51 +00:00
|
|
|
|
|
|
|
/// Module init/new function, called on module instantiation
|
|
|
|
///
|
|
|
|
/// MANDATORY CFFI function
|
|
|
|
///
|
2023-10-19 20:10:32 +00:00
|
|
|
/// @param init_info Waybar module information
|
2023-10-16 20:13:51 +00:00
|
|
|
/// @param config_entries Flat representation of the module JSON config. The data only available
|
|
|
|
/// during wbcffi_init call.
|
|
|
|
/// @param config_entries_len Number of entries in `config_entries`
|
|
|
|
///
|
|
|
|
/// @return A untyped pointer to module data, NULL if the module failed to load.
|
2023-10-19 20:10:32 +00:00
|
|
|
void* wbcffi_init(const wbcffi_init_info* init_info, const wbcffi_config_entry* config_entries,
|
2023-10-16 20:13:51 +00:00
|
|
|
size_t config_entries_len);
|
|
|
|
|
|
|
|
/// Module deinit/delete function, called when Waybar is closed or when the module is removed
|
|
|
|
///
|
|
|
|
/// MANDATORY CFFI function
|
|
|
|
///
|
|
|
|
/// @param instance Module instance data (as returned by `wbcffi_init`)
|
|
|
|
void wbcffi_deinit(void* instance);
|
|
|
|
|
2023-10-17 16:11:48 +00:00
|
|
|
/// Called from the GTK main event loop, to update the UI
|
|
|
|
///
|
|
|
|
/// Optional CFFI function
|
|
|
|
///
|
|
|
|
/// @param instance Module instance data (as returned by `wbcffi_init`)
|
|
|
|
/// @param action_name Action name
|
|
|
|
void wbcffi_update(void* instance);
|
|
|
|
|
|
|
|
/// Called when Waybar receives a POSIX signal and forwards it to each module
|
2023-10-16 20:13:51 +00:00
|
|
|
///
|
|
|
|
/// Optional CFFI function
|
|
|
|
///
|
|
|
|
/// @param instance Module instance data (as returned by `wbcffi_init`)
|
|
|
|
/// @param signal Signal ID
|
|
|
|
void wbcffi_refresh(void* instance, int signal);
|
|
|
|
|
2023-10-17 16:11:48 +00:00
|
|
|
/// Called on module action (see
|
|
|
|
/// https://github.com/Alexays/Waybar/wiki/Configuration#module-actions-config)
|
2023-10-16 20:13:51 +00:00
|
|
|
///
|
|
|
|
/// Optional CFFI function
|
|
|
|
///
|
|
|
|
/// @param instance Module instance data (as returned by `wbcffi_init`)
|
2023-10-17 16:11:48 +00:00
|
|
|
/// @param action_name Action name
|
|
|
|
void wbcffi_doaction(void* instance, const char* action_name);
|
2023-10-16 20:13:51 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|