annotate plugins/docklet/docklet-win32.c @ 13086:6c772241a6f8

[gaim-migrate @ 15448] Apparently, if you don't have tooltip text specified for a System Tray icon, the customizations for always showing and etc. aren't stored. This seems to work if the tooltip text change, but there needs to be one at startup. committer: Tailor Script <tailor@pidgin.im>
author Daniel Atallah <daniel.atallah@gmail.com>
date Tue, 31 Jan 2006 21:45:10 +0000
parents a2de852981c1
children
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"
9709
4d05b6e9e9cd [gaim-migrate @ 10570]
Mark Doliner <mark@kingant.net>
parents: 6894
diff changeset
35 #include "gtkdialogs.h"
6209
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 */
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
44 #define WM_TRAYMESSAGE WM_USER /* User defined WM Message */
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
45
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
46 /*
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
47 * LOCALS
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 static HWND systray_hwnd=0;
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
50 static HICON sysicon_disconn=0;
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
51 static HICON sysicon_conn=0;
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
52 static HICON sysicon_away=0;
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
53 static HICON sysicon_pend=0;
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
54 static HICON sysicon_awypend=0;
6894
c2fb9192377b [gaim-migrate @ 7441]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
55 static HICON sysicon_blank=0;
6209
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
56 static NOTIFYICONDATA wgaim_nid;
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
57
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
58
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
59 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
60 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
61
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
62 switch(msg) {
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
63 case WM_CREATE:
6425
26b739bc9f1a [gaim-migrate @ 6933]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6278
diff changeset
64 gaim_debug(GAIM_DEBUG_INFO, "tray icon", "WM_CREATE\n");
6209
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
65 taskbarRestartMsg = RegisterWindowMessage("TaskbarCreated");
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
66 break;
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
67
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
68 case WM_TIMER:
6425
26b739bc9f1a [gaim-migrate @ 6933]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6278
diff changeset
69 gaim_debug(GAIM_DEBUG_INFO, "tray icon", "WM_TIMER\n");
6209
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
70 break;
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
71
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
72 case WM_DESTROY:
6425
26b739bc9f1a [gaim-migrate @ 6933]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6278
diff changeset
73 gaim_debug(GAIM_DEBUG_INFO, "tray icon", "WM_DESTROY\n");
6209
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
74 break;
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
75
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
76 case WM_TRAYMESSAGE:
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 int type = 0;
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 /* We'll use Double Click - Single click over on linux */
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
81 if( lparam == WM_LBUTTONDBLCLK )
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
82 type = 1;
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
83 else if( lparam == WM_MBUTTONUP )
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
84 type = 2;
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
85 else if( lparam == WM_RBUTTONUP )
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
86 type = 3;
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
87 else
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
88 break;
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
89
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
90 docklet_clicked(type);
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
91 break;
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
92 }
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
93 default:
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
94 if (msg == taskbarRestartMsg) {
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
95 /* explorer crashed and left us hanging...
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
96 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
97 Shell_NotifyIcon(NIM_ADD,&wgaim_nid);
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
98 }
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
99 break;
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
100 }/* end switch */
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
101
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
102 return DefWindowProc(hwnd, msg, wparam, lparam);
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
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
105 /* Create hidden window to process systray messages */
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
106 static HWND systray_create_hiddenwin() {
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
107 WNDCLASSEX wcex;
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
108 TCHAR wname[32];
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
109
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
110 strcpy(wname, "GaimWin");
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 wcex.cbSize = sizeof(WNDCLASSEX);
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
113
11709
cae2fb7e8594 [gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10520
diff changeset
114 wcex.style = 0;
6209
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
115 wcex.lpfnWndProc = (WNDPROC)systray_mainmsg_handler;
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
116 wcex.cbClsExtra = 0;
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
117 wcex.cbWndExtra = 0;
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
118 wcex.hInstance = wgaim_hinstance();
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
119 wcex.hIcon = NULL;
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
120 wcex.hCursor = NULL,
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
121 wcex.hbrBackground = NULL;
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
122 wcex.lpszMenuName = NULL;
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
123 wcex.lpszClassName = wname;
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
124 wcex.hIconSm = NULL;
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
125
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
126 RegisterClassEx(&wcex);
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
127
9863
0e3a84f18467 [gaim-migrate @ 10742]
Mark Doliner <mark@kingant.net>
parents: 9709
diff changeset
128 /* Create the window */
6209
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
129 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
130 }
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
131
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
132 static void systray_init_icon(HWND hWnd, HICON icon) {
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
133 ZeroMemory(&wgaim_nid,sizeof(wgaim_nid));
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
134 wgaim_nid.cbSize=sizeof(NOTIFYICONDATA);
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
135 wgaim_nid.hWnd=hWnd;
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
136 wgaim_nid.uID=0;
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
137 wgaim_nid.uFlags=NIF_ICON | NIF_MESSAGE | NIF_TIP;
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
138 wgaim_nid.uCallbackMessage=WM_TRAYMESSAGE;
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
139 wgaim_nid.hIcon=icon;
13086
6c772241a6f8 [gaim-migrate @ 15448]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12498
diff changeset
140 lstrcpy(wgaim_nid.szTip, "Gaim");
6209
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
141 Shell_NotifyIcon(NIM_ADD,&wgaim_nid);
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
142 docklet_embedded();
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
143 }
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
144
12471
011efeb86b8d [gaim-migrate @ 14781]
Richard Laager <rlaager@wiktel.com>
parents: 12016
diff changeset
145 static void systray_change_icon(HICON icon) {
6209
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
146 wgaim_nid.hIcon = icon;
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
147 Shell_NotifyIcon(NIM_MODIFY,&wgaim_nid);
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
148 }
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 static void systray_remove_nid(void) {
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
151 Shell_NotifyIcon(NIM_DELETE,&wgaim_nid);
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
152 }
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
153
11709
cae2fb7e8594 [gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10520
diff changeset
154 static void wgaim_tray_update_icon(DockletStatus icon) {
6209
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
155 switch (icon) {
11709
cae2fb7e8594 [gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10520
diff changeset
156 case DOCKLET_STATUS_OFFLINE:
12471
011efeb86b8d [gaim-migrate @ 14781]
Richard Laager <rlaager@wiktel.com>
parents: 12016
diff changeset
157 systray_change_icon(sysicon_disconn);
6209
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
158 break;
11709
cae2fb7e8594 [gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10520
diff changeset
159 case DOCKLET_STATUS_CONNECTING:
6209
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
160 break;
11709
cae2fb7e8594 [gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10520
diff changeset
161 case DOCKLET_STATUS_ONLINE:
12471
011efeb86b8d [gaim-migrate @ 14781]
Richard Laager <rlaager@wiktel.com>
parents: 12016
diff changeset
162 systray_change_icon(sysicon_conn);
6209
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
163 break;
11709
cae2fb7e8594 [gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10520
diff changeset
164 case DOCKLET_STATUS_ONLINE_PENDING:
12471
011efeb86b8d [gaim-migrate @ 14781]
Richard Laager <rlaager@wiktel.com>
parents: 12016
diff changeset
165 systray_change_icon(sysicon_pend);
6209
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
166 break;
11709
cae2fb7e8594 [gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10520
diff changeset
167 case DOCKLET_STATUS_AWAY:
12471
011efeb86b8d [gaim-migrate @ 14781]
Richard Laager <rlaager@wiktel.com>
parents: 12016
diff changeset
168 systray_change_icon(sysicon_away);
6209
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
169 break;
11709
cae2fb7e8594 [gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10520
diff changeset
170 case DOCKLET_STATUS_AWAY_PENDING:
12471
011efeb86b8d [gaim-migrate @ 14781]
Richard Laager <rlaager@wiktel.com>
parents: 12016
diff changeset
171 systray_change_icon(sysicon_awypend);
6209
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
172 break;
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
173 }
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
174 }
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
175
6894
c2fb9192377b [gaim-migrate @ 7441]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
176 static void wgaim_tray_blank_icon() {
12471
011efeb86b8d [gaim-migrate @ 14781]
Richard Laager <rlaager@wiktel.com>
parents: 12016
diff changeset
177 systray_change_icon(sysicon_blank);
011efeb86b8d [gaim-migrate @ 14781]
Richard Laager <rlaager@wiktel.com>
parents: 12016
diff changeset
178 }
011efeb86b8d [gaim-migrate @ 14781]
Richard Laager <rlaager@wiktel.com>
parents: 12016
diff changeset
179
011efeb86b8d [gaim-migrate @ 14781]
Richard Laager <rlaager@wiktel.com>
parents: 12016
diff changeset
180 static void wgaim_tray_set_tooltip(gchar *tooltip) {
011efeb86b8d [gaim-migrate @ 14781]
Richard Laager <rlaager@wiktel.com>
parents: 12016
diff changeset
181 if (tooltip) {
011efeb86b8d [gaim-migrate @ 14781]
Richard Laager <rlaager@wiktel.com>
parents: 12016
diff changeset
182 char *locenc = NULL;
011efeb86b8d [gaim-migrate @ 14781]
Richard Laager <rlaager@wiktel.com>
parents: 12016
diff changeset
183 locenc = g_locale_from_utf8(tooltip, -1, NULL, NULL, NULL);
011efeb86b8d [gaim-migrate @ 14781]
Richard Laager <rlaager@wiktel.com>
parents: 12016
diff changeset
184 lstrcpyn(wgaim_nid.szTip, locenc, sizeof(wgaim_nid.szTip)/sizeof(TCHAR));
011efeb86b8d [gaim-migrate @ 14781]
Richard Laager <rlaager@wiktel.com>
parents: 12016
diff changeset
185 g_free(locenc);
011efeb86b8d [gaim-migrate @ 14781]
Richard Laager <rlaager@wiktel.com>
parents: 12016
diff changeset
186 } else {
13086
6c772241a6f8 [gaim-migrate @ 15448]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12498
diff changeset
187 lstrcpy(wgaim_nid.szTip, "Gaim");
12471
011efeb86b8d [gaim-migrate @ 14781]
Richard Laager <rlaager@wiktel.com>
parents: 12016
diff changeset
188 }
011efeb86b8d [gaim-migrate @ 14781]
Richard Laager <rlaager@wiktel.com>
parents: 12016
diff changeset
189 Shell_NotifyIcon(NIM_MODIFY, &wgaim_nid);
6894
c2fb9192377b [gaim-migrate @ 7441]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
190 }
c2fb9192377b [gaim-migrate @ 7441]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
191
12016
24c7fb94d3a3 [gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11709
diff changeset
192 void wgaim_tray_minimize(GaimGtkBuddyList *gtkblist) {
24c7fb94d3a3 [gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11709
diff changeset
193 MinimizeWndToTray(GDK_WINDOW_HWND(gtkblist->window->window));
24c7fb94d3a3 [gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11709
diff changeset
194 }
24c7fb94d3a3 [gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11709
diff changeset
195
24c7fb94d3a3 [gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11709
diff changeset
196 void wgaim_tray_maximize(GaimGtkBuddyList *gtkblist) {
24c7fb94d3a3 [gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11709
diff changeset
197 RestoreWndFromTray(GDK_WINDOW_HWND(gtkblist->window->window));
24c7fb94d3a3 [gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11709
diff changeset
198 }
24c7fb94d3a3 [gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11709
diff changeset
199
24c7fb94d3a3 [gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11709
diff changeset
200
6209
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
201 static void wgaim_tray_create() {
10520
976c7b186789 [gaim-migrate @ 11835]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10268
diff changeset
202 OSVERSIONINFO osinfo;
6209
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
203 /* dummy window to process systray messages */
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
204 systray_hwnd = systray_create_hiddenwin();
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
205
10520
976c7b186789 [gaim-migrate @ 11835]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10268
diff changeset
206 osinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
976c7b186789 [gaim-migrate @ 11835]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10268
diff changeset
207 GetVersionEx(&osinfo);
976c7b186789 [gaim-migrate @ 11835]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10268
diff changeset
208
976c7b186789 [gaim-migrate @ 11835]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10268
diff changeset
209 /* Load icons, and init systray notify icon
13086
6c772241a6f8 [gaim-migrate @ 15448]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12498
diff changeset
210 * NOTE: Windows < XP only supports displaying 4-bit images in the Systray,
10520
976c7b186789 [gaim-migrate @ 11835]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10268
diff changeset
211 * 2K and ME will use the highest color depth that the desktop will support,
976c7b186789 [gaim-migrate @ 11835]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10268
diff changeset
212 * but will scale it back to 4-bits for display.
976c7b186789 [gaim-migrate @ 11835]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10268
diff changeset
213 * That is why we use custom 4-bit icons for pre XP Windowses */
976c7b186789 [gaim-migrate @ 11835]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10268
diff changeset
214 if (osinfo.dwMajorVersion == 5 && osinfo.dwMinorVersion > 0) {
976c7b186789 [gaim-migrate @ 11835]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10268
diff changeset
215 sysicon_disconn = (HICON)LoadImage(wgaim_hinstance(), MAKEINTRESOURCE(GAIM_OFFLINE_TRAY_ICON), IMAGE_ICON, 16, 16, 0);
976c7b186789 [gaim-migrate @ 11835]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10268
diff changeset
216 sysicon_conn = (HICON)LoadImage(wgaim_hinstance(), MAKEINTRESOURCE(GAIM_TRAY_ICON), IMAGE_ICON, 16, 16, 0);
976c7b186789 [gaim-migrate @ 11835]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10268
diff changeset
217 sysicon_away = (HICON)LoadImage(wgaim_hinstance(), MAKEINTRESOURCE(GAIM_AWAY_TRAY_ICON), IMAGE_ICON, 16, 16, 0);
976c7b186789 [gaim-migrate @ 11835]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10268
diff changeset
218 sysicon_pend = (HICON)LoadImage(wgaim_hinstance(), MAKEINTRESOURCE(GAIM_PEND_TRAY_ICON), IMAGE_ICON, 16, 16, 0);
976c7b186789 [gaim-migrate @ 11835]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10268
diff changeset
219 sysicon_awypend = (HICON)LoadImage(wgaim_hinstance(), MAKEINTRESOURCE(GAIM_AWAYPEND_TRAY_ICON), IMAGE_ICON, 16, 16, 0);
976c7b186789 [gaim-migrate @ 11835]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10268
diff changeset
220 } else {
976c7b186789 [gaim-migrate @ 11835]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10268
diff changeset
221 sysicon_disconn = (HICON)LoadImage(wgaim_hinstance(), MAKEINTRESOURCE(GAIM_OFFLINE_TRAY_ICON_4BIT), IMAGE_ICON, 16, 16, 0);
976c7b186789 [gaim-migrate @ 11835]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10268
diff changeset
222 sysicon_conn = (HICON)LoadImage(wgaim_hinstance(), MAKEINTRESOURCE(GAIM_TRAY_ICON_4BIT), IMAGE_ICON, 16, 16, 0);
976c7b186789 [gaim-migrate @ 11835]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10268
diff changeset
223 sysicon_away = (HICON)LoadImage(wgaim_hinstance(), MAKEINTRESOURCE(GAIM_AWAY_TRAY_ICON_4BIT), IMAGE_ICON, 16, 16, 0);
976c7b186789 [gaim-migrate @ 11835]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10268
diff changeset
224 sysicon_pend = (HICON)LoadImage(wgaim_hinstance(), MAKEINTRESOURCE(GAIM_PEND_TRAY_ICON_4BIT), IMAGE_ICON, 16, 16, 0);
976c7b186789 [gaim-migrate @ 11835]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10268
diff changeset
225 sysicon_awypend = (HICON)LoadImage(wgaim_hinstance(), MAKEINTRESOURCE(GAIM_AWAYPEND_TRAY_ICON_4BIT), IMAGE_ICON, 16, 16, 0);
976c7b186789 [gaim-migrate @ 11835]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10268
diff changeset
226 }
6894
c2fb9192377b [gaim-migrate @ 7441]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
227 sysicon_blank = (HICON)LoadImage(wgaim_hinstance(), MAKEINTRESOURCE(GAIM_BLANK_TRAY_ICON), IMAGE_ICON, 16, 16, 0);
6209
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
228
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
229 /* Create icon in systray */
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
230 systray_init_icon(systray_hwnd, sysicon_disconn);
12016
24c7fb94d3a3 [gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11709
diff changeset
231
24c7fb94d3a3 [gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11709
diff changeset
232 gaim_signal_connect(gaim_gtk_blist_get_handle(), "gtkblist-hiding",
24c7fb94d3a3 [gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11709
diff changeset
233 &handle, GAIM_CALLBACK(wgaim_tray_minimize), NULL);
24c7fb94d3a3 [gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11709
diff changeset
234 gaim_signal_connect(gaim_gtk_blist_get_handle(), "gtkblist-unhiding",
24c7fb94d3a3 [gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11709
diff changeset
235 &handle, GAIM_CALLBACK(wgaim_tray_maximize), NULL);
24c7fb94d3a3 [gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11709
diff changeset
236
6209
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
237 gaim_debug(GAIM_DEBUG_INFO, "tray icon", "created\n");
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
238 }
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
239
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
240 static void wgaim_tray_destroy() {
12016
24c7fb94d3a3 [gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11709
diff changeset
241 gaim_signals_disconnect_by_handle(&handle);
6209
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
242 systray_remove_nid();
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
243 DestroyWindow(systray_hwnd);
12498
a2de852981c1 [gaim-migrate @ 14810]
Richard Laager <rlaager@wiktel.com>
parents: 12471
diff changeset
244 docklet_remove();
6209
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
245 }
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
246
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
247 static struct docklet_ui_ops wgaim_tray_ops =
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
248 {
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
249 wgaim_tray_create,
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
250 wgaim_tray_destroy,
6894
c2fb9192377b [gaim-migrate @ 7441]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
251 wgaim_tray_update_icon,
10268
d082b2a71ee7 [gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents: 9863
diff changeset
252 wgaim_tray_blank_icon,
12471
011efeb86b8d [gaim-migrate @ 14781]
Richard Laager <rlaager@wiktel.com>
parents: 12016
diff changeset
253 wgaim_tray_set_tooltip,
10268
d082b2a71ee7 [gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents: 9863
diff changeset
254 NULL
6209
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
255 };
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
256
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
257 /* Used by docklet's plugin load func */
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
258 void docklet_ui_init() {
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
259 docklet_set_ui_ops(&wgaim_tray_ops);
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
260 }