annotate plugins/docklet/trayicon-win32.c @ 6159:08606663df59

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