tray latest
Cross-platform, super tiny C99 implementation of a system tray icon with a popup menu and notifications.
tray.h
Go to the documentation of this file.
1
5#ifndef TRAY_H
6#define TRAY_H
7
8#if defined(TRAY_WINAPI)
9 #include <Windows.h>
10#endif
11
12#ifdef __cplusplus
13extern "C" {
14#endif
15
19 struct tray_menu;
20
24 struct tray {
25 const char *icon;
26 const char *tooltip;
27 const char *notification_icon;
28 const char *notification_text;
29 const char *notification_title;
30 void (*notification_cb)();
31 struct tray_menu *menu;
32 const int iconPathCount;
33 const char *allIconPaths[];
34 };
35
39 struct tray_menu {
40 const char *text;
42 int checked;
44
45 void (*cb)(struct tray_menu *);
46 void *context;
47
49 };
50
56 int tray_init(struct tray *tray);
57
63 int tray_loop(int blocking);
64
69 void tray_update(struct tray *tray);
70
74 void tray_show_menu(void);
75
79 void tray_exit(void);
80
81#if defined(TRAY_WINAPI)
86 HWND tray_get_hwnd(void);
87#endif
88
89#ifdef __cplusplus
90} // extern "C"
91#endif
92
93#endif /* TRAY_H */
Tray menu item.
Definition tray.h:39
void * context
Context to pass to the callback.
Definition tray.h:46
struct tray_menu * submenu
Submenu items.
Definition tray.h:48
int checkbox
Whether the item is a checkbox.
Definition tray.h:43
void(* cb)(struct tray_menu *)
Callback to invoke when the item is clicked.
Definition tray.h:45
int disabled
Whether the item is disabled.
Definition tray.h:41
const char * text
Text to display.
Definition tray.h:40
int checked
Whether the item is checked.
Definition tray.h:42
Tray icon.
Definition tray.h:24
const char * notification_title
Title to display in the notification.
Definition tray.h:29
void(* notification_cb)()
Callback to invoke when the notification is clicked.
Definition tray.h:30
const char * allIconPaths[]
Array of icon paths.
Definition tray.h:33
const char * tooltip
Tooltip to display.
Definition tray.h:26
const char * notification_icon
Icon to display in the notification.
Definition tray.h:27
const int iconPathCount
Number of icon paths.
Definition tray.h:32
struct tray_menu * menu
Menu items.
Definition tray.h:31
const char * icon
Icon to display.
Definition tray.h:25
const char * notification_text
Text to display in the notification.
Definition tray.h:28
int tray_init(struct tray *tray)
Create tray icon.
Definition tray_darwin.m:86
HWND tray_get_hwnd(void)
Get the tray window handle.
Definition tray_windows.c:344
void tray_show_menu(void)
Force show the tray menu (for testing purposes).
Definition tray_darwin.m:129
void tray_exit(void)
Terminate UI loop.
Definition tray_darwin.m:133
int tray_loop(int blocking)
Run one iteration of the UI loop.
Definition tray_darwin.m:99
void tray_update(struct tray *tray)
Update the tray icon and menu.
Definition tray_darwin.m:116