Add support for a tooltip (Windows only currently)
This commit is contained in:
committed by
Dmitry Mikushin
parent
95b83171b7
commit
5cc49f2f32
13
example.c
13
example.c
@@ -56,29 +56,32 @@ static void submenu_cb(struct tray_menu *item) {
|
|||||||
// Test tray init
|
// Test tray init
|
||||||
static struct tray tray = {
|
static struct tray tray = {
|
||||||
.icon = TRAY_ICON1,
|
.icon = TRAY_ICON1,
|
||||||
|
#if TRAY_WINAPI
|
||||||
|
.tooltip = "Tray",
|
||||||
|
#endif
|
||||||
.menu =
|
.menu =
|
||||||
(struct tray_menu[]){
|
(struct tray_menu[]) {
|
||||||
{.text = "Hello", .cb = hello_cb},
|
{.text = "Hello", .cb = hello_cb},
|
||||||
{.text = "Checked", .checked = 1, .cb = toggle_cb},
|
{.text = "Checked", .checked = 1, .cb = toggle_cb},
|
||||||
{.text = "Disabled", .disabled = 1},
|
{.text = "Disabled", .disabled = 1},
|
||||||
{.text = "-"},
|
{.text = "-"},
|
||||||
{.text = "SubMenu",
|
{.text = "SubMenu",
|
||||||
.submenu =
|
.submenu =
|
||||||
(struct tray_menu[]){
|
(struct tray_menu[]) {
|
||||||
{.text = "FIRST", .checked = 1, .cb = submenu_cb},
|
{.text = "FIRST", .checked = 1, .cb = submenu_cb},
|
||||||
{.text = "SECOND",
|
{.text = "SECOND",
|
||||||
.submenu =
|
.submenu =
|
||||||
(struct tray_menu[]){
|
(struct tray_menu[]) {
|
||||||
{.text = "THIRD",
|
{.text = "THIRD",
|
||||||
.submenu =
|
.submenu =
|
||||||
(struct tray_menu[]){
|
(struct tray_menu[]) {
|
||||||
{.text = "7", .cb = submenu_cb},
|
{.text = "7", .cb = submenu_cb},
|
||||||
{.text = "-"},
|
{.text = "-"},
|
||||||
{.text = "8", .cb = submenu_cb},
|
{.text = "8", .cb = submenu_cb},
|
||||||
{.text = NULL}}},
|
{.text = NULL}}},
|
||||||
{.text = "FOUR",
|
{.text = "FOUR",
|
||||||
.submenu =
|
.submenu =
|
||||||
(struct tray_menu[]){
|
(struct tray_menu[]) {
|
||||||
{.text = "5", .cb = submenu_cb},
|
{.text = "5", .cb = submenu_cb},
|
||||||
{.text = "6", .cb = submenu_cb},
|
{.text = "6", .cb = submenu_cb},
|
||||||
{.text = NULL}}},
|
{.text = NULL}}},
|
||||||
|
|||||||
4
tray.h
4
tray.h
@@ -5,6 +5,7 @@ struct tray_menu;
|
|||||||
|
|
||||||
struct tray {
|
struct tray {
|
||||||
const char *icon;
|
const char *icon;
|
||||||
|
char *tooltip;
|
||||||
struct tray_menu *menu;
|
struct tray_menu *menu;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -308,8 +309,9 @@ static int tray_init(struct tray *tray) {
|
|||||||
nid.cbSize = sizeof(NOTIFYICONDATA);
|
nid.cbSize = sizeof(NOTIFYICONDATA);
|
||||||
nid.hWnd = hwnd;
|
nid.hWnd = hwnd;
|
||||||
nid.uID = 0;
|
nid.uID = 0;
|
||||||
nid.uFlags = NIF_ICON | NIF_MESSAGE;
|
nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
|
||||||
nid.uCallbackMessage = WM_TRAY_CALLBACK_MESSAGE;
|
nid.uCallbackMessage = WM_TRAY_CALLBACK_MESSAGE;
|
||||||
|
strncpy(nid.szTip, tray->tooltip, sizeof(nid.szTip));
|
||||||
Shell_NotifyIcon(NIM_ADD, &nid);
|
Shell_NotifyIcon(NIM_ADD, &nid);
|
||||||
|
|
||||||
tray_update(tray);
|
tray_update(tray);
|
||||||
|
|||||||
Reference in New Issue
Block a user