Skip to content

Commit

Permalink
win32 tray now shows "self.name : self.statusmsg"
Browse files Browse the repository at this point in the history
added void redraw_tray(void) that currently just updates the tray tooltip
  • Loading branch information
Gregory Mullen (grayhatter) committed Dec 20, 2014
1 parent 19ac581 commit cf23b7d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions ui_edits.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ static void edit_status_onenter(void)
self.statusmsg = p;
memcpy(self.statusmsg, data, length);
self.statusmsg_length = length;
redraw_tray();

tox_postmessage(TOX_SETSTATUSMSG, length, 0, self.statusmsg);//!
}
Expand Down
20 changes: 17 additions & 3 deletions win32/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -805,16 +805,29 @@ void redraw(void)
{
panel_draw(&panel_main, 0, 0, utox_window_width, utox_window_height);
}
/**
* redraw_tray(void)
* creates a win32 NOTIFYICONDATAW struct, sets the tiptab flag, gives *hwnd,
* sets struct .cbSize, and resets the tibtab to native self.name;
*/

void redraw_tray(void)
{
char *tip;
tip = malloc(128 * sizeof(char)); //128 is the max length of nid.szTip
snprintf(tip, 127*sizeof(char), "%s : %s", self.name, self.statusmsg);

NOTIFYICONDATAW nid = {
.uFlags = NIF_TIP,
.hWnd = hwnd,
.cbSize = sizeof(nid),
};

utf8tonative(self.name, nid.szTip, self.name_length > sizeof(nid.szTip) / sizeof(*nid.szTip) -1 ? sizeof(nid.szTip) / sizeof(*nid.szTip) -1 : self.name_length);
utf8tonative(tip, nid.szTip, strlen(tip));

Shell_NotifyIconW(NIM_MODIFY, &nid);

free(tip);
}

static int grabx, graby, grabpx, grabpy;
Expand Down Expand Up @@ -1063,7 +1076,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR cmd, int n
.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP,
.uCallbackMessage = WM_NOTIFYICON,
.hIcon = my_icon,
.szTip = "Tox - tooltip",
.szTip = "uTox default tooltip",
.cbSize = sizeof(nid),
};

Expand Down Expand Up @@ -1092,9 +1105,9 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR cmd, int n
tme.hwndTrack = hwnd;

nid.hWnd = hwnd;
strcpy(nid.szTip, self.name);
Shell_NotifyIcon(NIM_ADD, &nid);


SetBkMode(hdc, TRANSPARENT);

dnd_init(hwnd);
Expand All @@ -1114,6 +1127,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR cmd, int n

draw = 1;
redraw();
redraw_tray();

while(GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
Expand Down

0 comments on commit cf23b7d

Please sign in to comment.