annotate plugins/docklet/docklet-win32.c @ 12280:45aa1d86428e

[gaim-migrate @ 14584] This pref has been renamed to other things committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Thu, 01 Dec 2005 05:03:45 +0000
parents 24c7fb94d3a3
children 011efeb86b8d
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 */
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;
6894
c2fb9192377b [gaim-migrate @ 7441]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
58 static HICON sysicon_blank=0;
6209
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
59 static NOTIFYICONDATA wgaim_nid;
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
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
62 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
63 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
64
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
65 switch(msg) {
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
66 case WM_CREATE:
6425
26b739bc9f1a [gaim-migrate @ 6933]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6278
diff changeset
67 gaim_debug(GAIM_DEBUG_INFO, "tray icon", "WM_CREATE\n");
6209
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
68 taskbarRestartMsg = RegisterWindowMessage("TaskbarCreated");
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
69 break;
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
70
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
71 case WM_TIMER:
6425
26b739bc9f1a [gaim-migrate @ 6933]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6278
diff changeset
72 gaim_debug(GAIM_DEBUG_INFO, "tray icon", "WM_TIMER\n");
6209
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
73 break;
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
74
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
75 case WM_DESTROY:
6425
26b739bc9f1a [gaim-migrate @ 6933]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6278
diff changeset
76 gaim_debug(GAIM_DEBUG_INFO, "tray icon", "WM_DESTROY\n");
6209
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
77 break;
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
78
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
79 case WM_TRAYMESSAGE:
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
80 {
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
81 int type = 0;
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
82
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
83 /* We'll use Double Click - Single click over on linux */
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
84 if( lparam == WM_LBUTTONDBLCLK )
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
85 type = 1;
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
86 else if( lparam == WM_MBUTTONUP )
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
87 type = 2;
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
88 else if( lparam == WM_RBUTTONUP )
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
89 type = 3;
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
90 else
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 docklet_clicked(type);
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
94 break;
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
95 }
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
96 default:
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
97 if (msg == taskbarRestartMsg) {
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
98 /* explorer crashed and left us hanging...
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
99 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
100 Shell_NotifyIcon(NIM_ADD,&wgaim_nid);
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 break;
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
103 }/* end switch */
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 return DefWindowProc(hwnd, msg, wparam, lparam);
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
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
108 /* Create hidden window to process systray messages */
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
109 static HWND systray_create_hiddenwin() {
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
110 WNDCLASSEX wcex;
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
111 TCHAR wname[32];
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
112
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
113 strcpy(wname, "GaimWin");
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
114
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
115 wcex.cbSize = sizeof(WNDCLASSEX);
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
116
11709
cae2fb7e8594 [gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10520
diff changeset
117 wcex.style = 0;
6209
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
118 wcex.lpfnWndProc = (WNDPROC)systray_mainmsg_handler;
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
119 wcex.cbClsExtra = 0;
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
120 wcex.cbWndExtra = 0;
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
121 wcex.hInstance = wgaim_hinstance();
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
122 wcex.hIcon = NULL;
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
123 wcex.hCursor = NULL,
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
124 wcex.hbrBackground = NULL;
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
125 wcex.lpszMenuName = NULL;
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
126 wcex.lpszClassName = wname;
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
127 wcex.hIconSm = NULL;
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
128
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
129 RegisterClassEx(&wcex);
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
130
9863
0e3a84f18467 [gaim-migrate @ 10742]
Mark Doliner <mark@kingant.net>
parents: 9709
diff changeset
131 /* Create the window */
6209
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
132 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
133 }
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
134
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
135 static void systray_init_icon(HWND hWnd, HICON icon) {
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
136 char* locenc=NULL;
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
137
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
138 ZeroMemory(&wgaim_nid,sizeof(wgaim_nid));
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
139 wgaim_nid.cbSize=sizeof(NOTIFYICONDATA);
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
140 wgaim_nid.hWnd=hWnd;
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
141 wgaim_nid.uID=0;
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
142 wgaim_nid.uFlags=NIF_ICON | NIF_MESSAGE | NIF_TIP;
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
143 wgaim_nid.uCallbackMessage=WM_TRAYMESSAGE;
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
144 wgaim_nid.hIcon=icon;
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
145 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
146 strcpy(wgaim_nid.szTip, locenc);
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
147 g_free(locenc);
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
148 Shell_NotifyIcon(NIM_ADD,&wgaim_nid);
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
149 docklet_embedded();
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
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
152 static void systray_change_icon(HICON icon, char* text) {
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
153 char *locenc=NULL;
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
154 wgaim_nid.hIcon = icon;
11709
cae2fb7e8594 [gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10520
diff changeset
155 if (text) {
cae2fb7e8594 [gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10520
diff changeset
156 locenc = g_locale_from_utf8(text, -1, NULL, NULL, NULL);
cae2fb7e8594 [gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10520
diff changeset
157 lstrcpy(wgaim_nid.szTip, locenc);
cae2fb7e8594 [gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10520
diff changeset
158 g_free(locenc);
cae2fb7e8594 [gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10520
diff changeset
159 }
6209
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
160 Shell_NotifyIcon(NIM_MODIFY,&wgaim_nid);
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
161 }
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 static void systray_remove_nid(void) {
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
164 Shell_NotifyIcon(NIM_DELETE,&wgaim_nid);
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
165 }
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
166
11709
cae2fb7e8594 [gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10520
diff changeset
167 static void wgaim_tray_update_icon(DockletStatus icon) {
6209
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
168 switch (icon) {
11709
cae2fb7e8594 [gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10520
diff changeset
169 case DOCKLET_STATUS_OFFLINE:
6209
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
170 systray_change_icon(sysicon_disconn, GAIM_SYSTRAY_DISCONN_HINT);
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
171 break;
11709
cae2fb7e8594 [gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10520
diff changeset
172 case DOCKLET_STATUS_CONNECTING:
6209
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
173 break;
11709
cae2fb7e8594 [gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10520
diff changeset
174 case DOCKLET_STATUS_ONLINE:
6209
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
175 systray_change_icon(sysicon_conn, GAIM_SYSTRAY_HINT);
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
176 break;
11709
cae2fb7e8594 [gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10520
diff changeset
177 case DOCKLET_STATUS_ONLINE_PENDING:
6209
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
178 systray_change_icon(sysicon_pend, GAIM_SYSTRAY_HINT);
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
179 break;
11709
cae2fb7e8594 [gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10520
diff changeset
180 case DOCKLET_STATUS_AWAY:
6209
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
181 systray_change_icon(sysicon_away, GAIM_SYSTRAY_AWAY_HINT);
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
182 break;
11709
cae2fb7e8594 [gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10520
diff changeset
183 case DOCKLET_STATUS_AWAY_PENDING:
6209
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
184 systray_change_icon(sysicon_awypend, GAIM_SYSTRAY_AWAY_HINT);
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
185 break;
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 }
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
188
6894
c2fb9192377b [gaim-migrate @ 7441]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
189 static void wgaim_tray_blank_icon() {
11709
cae2fb7e8594 [gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10520
diff changeset
190 systray_change_icon(sysicon_blank, NULL);
6894
c2fb9192377b [gaim-migrate @ 7441]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
191 }
c2fb9192377b [gaim-migrate @ 7441]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
192
12016
24c7fb94d3a3 [gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11709
diff changeset
193 void wgaim_tray_minimize(GaimGtkBuddyList *gtkblist) {
24c7fb94d3a3 [gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11709
diff changeset
194 MinimizeWndToTray(GDK_WINDOW_HWND(gtkblist->window->window));
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
24c7fb94d3a3 [gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11709
diff changeset
197 void wgaim_tray_maximize(GaimGtkBuddyList *gtkblist) {
24c7fb94d3a3 [gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11709
diff changeset
198 RestoreWndFromTray(GDK_WINDOW_HWND(gtkblist->window->window));
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
24c7fb94d3a3 [gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11709
diff changeset
201
6209
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
202 static void wgaim_tray_create() {
10520
976c7b186789 [gaim-migrate @ 11835]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10268
diff changeset
203 OSVERSIONINFO osinfo;
6209
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
204 /* dummy window to process systray messages */
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
205 systray_hwnd = systray_create_hiddenwin();
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
206
10520
976c7b186789 [gaim-migrate @ 11835]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10268
diff changeset
207 osinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
976c7b186789 [gaim-migrate @ 11835]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10268
diff changeset
208 GetVersionEx(&osinfo);
976c7b186789 [gaim-migrate @ 11835]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10268
diff changeset
209
976c7b186789 [gaim-migrate @ 11835]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10268
diff changeset
210 /* Load icons, and init systray notify icon
976c7b186789 [gaim-migrate @ 11835]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10268
diff changeset
211 * NOTE: Windows > XP only supports displaying 4-bit images in the Systray,
976c7b186789 [gaim-migrate @ 11835]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10268
diff changeset
212 * 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
213 * but will scale it back to 4-bits for display.
976c7b186789 [gaim-migrate @ 11835]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10268
diff changeset
214 * 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
215 if (osinfo.dwMajorVersion == 5 && osinfo.dwMinorVersion > 0) {
976c7b186789 [gaim-migrate @ 11835]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10268
diff changeset
216 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
217 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
218 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
219 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
220 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
221 } else {
976c7b186789 [gaim-migrate @ 11835]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10268
diff changeset
222 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
223 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
224 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
225 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
226 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
227 }
6894
c2fb9192377b [gaim-migrate @ 7441]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
228 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
229
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
230 /* Create icon in systray */
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
231 systray_init_icon(systray_hwnd, sysicon_disconn);
12016
24c7fb94d3a3 [gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11709
diff changeset
232
24c7fb94d3a3 [gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11709
diff changeset
233 gaim_signal_connect(gaim_gtk_blist_get_handle(), "gtkblist-hiding",
24c7fb94d3a3 [gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11709
diff changeset
234 &handle, GAIM_CALLBACK(wgaim_tray_minimize), NULL);
24c7fb94d3a3 [gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11709
diff changeset
235 gaim_signal_connect(gaim_gtk_blist_get_handle(), "gtkblist-unhiding",
24c7fb94d3a3 [gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11709
diff changeset
236 &handle, GAIM_CALLBACK(wgaim_tray_maximize), NULL);
24c7fb94d3a3 [gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11709
diff changeset
237
6209
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
238 gaim_debug(GAIM_DEBUG_INFO, "tray icon", "created\n");
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
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
241 static void wgaim_tray_destroy() {
12016
24c7fb94d3a3 [gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11709
diff changeset
242 gaim_signals_disconnect_by_handle(&handle);
6209
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
243 systray_remove_nid();
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
244 DestroyWindow(systray_hwnd);
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
245 docklet_remove(TRUE);
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
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
248 static struct docklet_ui_ops wgaim_tray_ops =
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
249 {
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
250 wgaim_tray_create,
dd715b02df41 [gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
251 wgaim_tray_destroy,
6894
c2fb9192377b [gaim-migrate @ 7441]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
252 wgaim_tray_update_icon,
10268
d082b2a71ee7 [gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents: 9863
diff changeset
253 wgaim_tray_blank_icon,
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 }