annotate plugins/docklet/trayicon-win32.c @ 6092:35560e017fa1

[gaim-migrate @ 6551] This fixes the buddy icon deletion issue, mad props go to Herman for finding the cause of this. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Fri, 11 Jul 2003 22:00:01 +0000
parents b2c8e08508af
children 29ddc42ff402
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6077
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
1 /* System tray icon (aka docklet) plugin for Gaim
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
2 * Copyright (C) 2002 Robert McQueen <robot101@debian.org>
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
3 * Copyright (C) 2003 Herman Bloggs <hermanator12002@yahoo.com>
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
4 * Inspired by a similar plugin by:
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
5 * John (J5) Palmieri <johnp@martianrock.com>
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
6 *
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
7 * This program is free software; you can redistribute it and/or
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
8 * modify it under the terms of the GNU General Public License as
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
9 * published by the Free Software Foundation; either version 2 of the
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
10 * License, or (at your option) any later version.
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
11 *
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
15 * General Public License for more details.
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
16 *
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
18 * along with this program; if not, write to the Free Software
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
20 * 02111-1307, USA.
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
21 */
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
22 #include <windows.h>
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
23 #include <gdk/gdkwin32.h>
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
24 #include <gdk/gdk.h>
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
25
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
26 #include "internal.h"
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
27 #include "gtkblist.h"
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
28 #include "gtkprefs.h"
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
29 #include "debug.h"
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
30
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
31 #include "gaim.h"
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
32 #include "ui.h"
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
33
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
34 #include "resource.h"
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
35 #include "MinimizeToTray.h"
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
36 #include "docklet.h"
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
37
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
38 /*
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
39 * DEFINES, MACROS & DATA TYPES
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
40 */
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
41 #define GAIM_SYSTRAY_HINT _("Gaim Instant Messenger")
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
42 #define GAIM_SYSTRAY_DISCONN_HINT _("Gaim Instant Messenger - Signed off")
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
43 #define GAIM_SYSTRAY_AWAY_HINT _("Gaim Instant Messenger - Away")
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
44 #define WM_TRAYMESSAGE WM_USER /* User defined WM Message */
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
45
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
46 /*
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
47 * LOCALS
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
48 */
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
49 static HWND systray_hwnd=0;
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
50 static HICON sysicon_disconn=0;
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
51 static HICON sysicon_conn=0;
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
52 static HICON sysicon_away=0;
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
53 static HICON sysicon_pend=0;
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
54 static HICON sysicon_awypend=0;
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
55 static NOTIFYICONDATA wgaim_nid;
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
56
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
57
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
58 static LRESULT CALLBACK systray_mainmsg_handler(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
59 static UINT taskbarRestartMsg; /* static here means value is kept across multiple calls to this func */
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
60
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
61 switch(msg) {
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
62 case WM_CREATE:
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
63 gaim_debug(GAIM_DEBUG_INFO, "wgaim_systray", "WM_CREATE\n");
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
64 taskbarRestartMsg = RegisterWindowMessage("TaskbarCreated");
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
65 break;
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
66
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
67 case WM_TIMER:
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
68 gaim_debug(GAIM_DEBUG_INFO, "wgaim_systray", "WM_TIMER\n");
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
69 break;
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
70
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
71 case WM_DESTROY:
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
72 gaim_debug(GAIM_DEBUG_INFO, "wgaim_systray", "WM_DESTROY\n");
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
73 break;
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
74
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
75 case WM_TRAYMESSAGE:
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
76 {
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
77 int type = 0;
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
78
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
79 /* We'll use Double Click - Single click over on linux */
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
80 if( lparam == WM_LBUTTONDBLCLK )
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
81 type = 1;
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
82 else if( lparam == WM_MBUTTONUP )
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
83 type = 2;
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
84 else if( lparam == WM_RBUTTONUP )
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
85 type = 3;
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
86 else
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
87 break;
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
88
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
89 docklet_clicked(type);
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
90 break;
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
91 }
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
92 default:
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
93 if (msg == taskbarRestartMsg) {
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
94 /* explorer crashed and left us hanging...
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
95 This will put the systray icon back in it's place, when it restarts */
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
96 Shell_NotifyIcon(NIM_ADD,&wgaim_nid);
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
97 }
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
98 break;
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
99 }/* end switch */
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
100
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
101 return DefWindowProc(hwnd, msg, wparam, lparam);
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
102 }
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
103
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
104 /* Create hidden window to process systray messages */
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
105 static HWND systray_create_hiddenwin() {
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
106 WNDCLASSEX wcex;
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
107 TCHAR wname[32];
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
108
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
109 strcpy(wname, "GaimWin");
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
110
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
111 wcex.cbSize = sizeof(WNDCLASSEX);
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
112
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
113 wcex.style = 0;
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
114 wcex.lpfnWndProc = (WNDPROC)systray_mainmsg_handler;
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
115 wcex.cbClsExtra = 0;
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
116 wcex.cbWndExtra = 0;
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
117 wcex.hInstance = wgaim_hinstance();
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
118 wcex.hIcon = NULL;
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
119 wcex.hCursor = NULL,
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
120 wcex.hbrBackground = NULL;
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
121 wcex.lpszMenuName = NULL;
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
122 wcex.lpszClassName = wname;
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
123 wcex.hIconSm = NULL;
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
124
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
125 RegisterClassEx(&wcex);
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
126
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
127 // Create the window
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
128 return (CreateWindow(wname, "", 0, 0, 0, 0, 0, GetDesktopWindow(), NULL, wgaim_hinstance(), 0));
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
129 }
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
130
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
131 static void systray_init_icon(HWND hWnd, HICON icon) {
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
132 char* locenc=NULL;
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
133
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
134 ZeroMemory(&wgaim_nid,sizeof(wgaim_nid));
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
135 wgaim_nid.cbSize=sizeof(NOTIFYICONDATA);
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
136 wgaim_nid.hWnd=hWnd;
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
137 wgaim_nid.uID=0;
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
138 wgaim_nid.uFlags=NIF_ICON | NIF_MESSAGE | NIF_TIP;
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
139 wgaim_nid.uCallbackMessage=WM_TRAYMESSAGE;
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
140 wgaim_nid.hIcon=icon;
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
141 locenc=g_locale_from_utf8(GAIM_SYSTRAY_DISCONN_HINT, -1, NULL, NULL, NULL);
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
142 strcpy(wgaim_nid.szTip, locenc);
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
143 g_free(locenc);
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
144 Shell_NotifyIcon(NIM_ADD,&wgaim_nid);
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
145 docklet_embedded();
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
146 }
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
147
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
148 static void systray_change_icon(HICON icon, char* text) {
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
149 char *locenc=NULL;
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
150 wgaim_nid.hIcon = icon;
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
151 locenc = g_locale_from_utf8(text, -1, NULL, NULL, NULL);
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
152 lstrcpy(wgaim_nid.szTip, locenc);
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
153 g_free(locenc);
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
154 Shell_NotifyIcon(NIM_MODIFY,&wgaim_nid);
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
155 }
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
156
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
157 static void systray_remove_nid(void) {
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
158 Shell_NotifyIcon(NIM_DELETE,&wgaim_nid);
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
159 }
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
160
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
161 static void wgaim_tray_update_icon(enum docklet_status icon) {
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
162 switch (icon) {
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
163 case offline:
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
164 systray_change_icon(sysicon_disconn, GAIM_SYSTRAY_DISCONN_HINT);
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
165 break;
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
166 case offline_connecting:
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
167 case online_connecting:
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
168 break;
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
169 case online:
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
170 systray_change_icon(sysicon_conn, GAIM_SYSTRAY_HINT);
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
171 break;
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
172 case online_pending:
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
173 systray_change_icon(sysicon_pend, GAIM_SYSTRAY_HINT);
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
174 break;
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
175 case away:
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
176 systray_change_icon(sysicon_away, GAIM_SYSTRAY_AWAY_HINT);
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
177 break;
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
178 case away_pending:
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
179 systray_change_icon(sysicon_awypend, GAIM_SYSTRAY_AWAY_HINT);
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
180 break;
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
181 }
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
182 }
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
183
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
184 static void wgaim_tray_create() {
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
185 /* dummy window to process systray messages */
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
186 systray_hwnd = systray_create_hiddenwin();
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
187
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
188 /* Load icons, and init systray notify icon */
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
189 sysicon_disconn = (HICON)LoadImage(wgaim_hinstance(), MAKEINTRESOURCE(GAIM_OFFLINE_TRAY_ICON), IMAGE_ICON, 16, 16, 0);
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
190 sysicon_conn = (HICON)LoadImage(wgaim_hinstance(), MAKEINTRESOURCE(GAIM_TRAY_ICON), IMAGE_ICON, 16, 16, 0);
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
191 sysicon_away = (HICON)LoadImage(wgaim_hinstance(), MAKEINTRESOURCE(GAIM_AWAY_TRAY_ICON), IMAGE_ICON, 16, 16, 0);
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
192 sysicon_pend = (HICON)LoadImage(wgaim_hinstance(), MAKEINTRESOURCE(GAIM_PEND_TRAY_ICON), IMAGE_ICON, 16, 16, 0);
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
193 sysicon_awypend = (HICON)LoadImage(wgaim_hinstance(), MAKEINTRESOURCE(GAIM_AWAYPEND_TRAY_ICON), IMAGE_ICON, 16, 16, 0);
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
194
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
195 /* Create icon in systray */
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
196 systray_init_icon(systray_hwnd, sysicon_disconn);
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
197 gaim_debug(GAIM_DEBUG_INFO, "docklet", "Tray Icon: created\n");
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
198 }
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
199
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
200 static void wgaim_tray_destroy() {
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
201 systray_remove_nid();
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
202 DestroyWindow(systray_hwnd);
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
203 }
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
204
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
205 static struct gaim_tray_ops wgaim_tray_ops =
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
206 {
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
207 wgaim_tray_create,
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
208 wgaim_tray_destroy,
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
209 wgaim_tray_update_icon
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
210 };
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
211
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
212 /* Used by docklet's plugin load func */
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
213 void trayicon_init() {
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
214 docklet_set_tray_ops(&wgaim_tray_ops);
b2c8e08508af [gaim-migrate @ 6536]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
215 }