annotate plugins/docklet/docklet-win32.c @ 6569:4dbd1efc6a47

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