Sync README with current public API
This commit is contained in:
34
README.md
34
README.md
@@ -53,21 +53,23 @@ Execute the `tray_example` application:
|
|||||||
|
|
||||||
## API
|
## API
|
||||||
|
|
||||||
Tray structure defines an icon and a menu.
|
A tray is defined by an icon, an optional tooltip and a menu.
|
||||||
Menu is a NULL-terminated array of items.
|
The menu is a NULL-terminated array of items.
|
||||||
Menu item defines menu text, menu checked and disabled (grayed) flags and a
|
Each menu item can be disabled, checked, represented as a checkbox and invoke a
|
||||||
callback with some optional context pointer.
|
callback with an optional context pointer.
|
||||||
|
|
||||||
```c
|
```c
|
||||||
struct tray {
|
struct tray {
|
||||||
char *icon;
|
const char *icon;
|
||||||
|
char *tooltip;
|
||||||
struct tray_menu *menu;
|
struct tray_menu *menu;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct tray_menu {
|
struct tray_menu {
|
||||||
char *text;
|
const char *text;
|
||||||
int disabled;
|
int disabled;
|
||||||
int checked;
|
int checked;
|
||||||
|
int checkbox;
|
||||||
|
|
||||||
void (*cb)(struct tray_menu *);
|
void (*cb)(struct tray_menu *);
|
||||||
void *context;
|
void *context;
|
||||||
@@ -76,15 +78,23 @@ struct tray_menu {
|
|||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
* `int tray_init(struct tray *)` - creates tray icon. Returns -1 if tray icon/menu can't be created.
|
* `int tray_init(struct tray *)` - creates the tray icon and its menu. Returns `-1` if the tray icon or menu cannot be created.
|
||||||
* `void tray_update(struct tray *)` - updates tray icon and menu.
|
* `void tray_update(struct tray *)` - updates the tray icon, tooltip and menu state.
|
||||||
* `int tray_loop(int blocking)` - runs one iteration of the UI loop. Returns -1 if `tray_exit()` has been called.
|
* `int tray_loop(int blocking)` - runs one iteration of the UI loop. Returns `-1` after `tray_exit()` has been called.
|
||||||
* `void tray_exit()` - terminates UI loop.
|
* `void tray_exit(void)` - terminates the UI loop and cleans up tray resources.
|
||||||
|
|
||||||
All functions are meant to be called from the UI thread only.
|
All functions are meant to be called from the UI thread only.
|
||||||
|
|
||||||
Menu arrays must be terminated with a NULL item, e.g. the last item in the
|
Menu arrays must be terminated with a NULL item, i.e. the last item in the
|
||||||
array must have text field set to NULL.
|
array must have `text == NULL`.
|
||||||
|
|
||||||
|
### Notes
|
||||||
|
|
||||||
|
* `tooltip` is optional.
|
||||||
|
* A separator is created by using `text = "-"`.
|
||||||
|
* Some behavior may depend on the underlying backend or desktop environment.
|
||||||
|
Keep the public API generic and treat platform-specific interaction details as
|
||||||
|
backend-specific implementation behavior.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user