Mercurial > pidgin.yaz
annotate plugins/docklet/docklet-win32.c @ 11613:d15a1d755417
[gaim-migrate @ 13887]
if we just sent an im, from the callback on the entry,
we've probably seen the tab
committer: Tailor Script <tailor@pidgin.im>
author | Tim Ringenbach <marv@pidgin.im> |
---|---|
date | Wed, 05 Oct 2005 01:52:20 +0000 |
parents | 976c7b186789 |
children | cae2fb7e8594 |
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 | 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 |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
117 wcex.style = 0; |
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 | 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; |
6894
c2fb9192377b
[gaim-migrate @ 7441]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
155 if(text) { |
c2fb9192377b
[gaim-migrate @ 7441]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
156 locenc = g_locale_from_utf8(text, -1, NULL, NULL, NULL); |
c2fb9192377b
[gaim-migrate @ 7441]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
157 lstrcpy(wgaim_nid.szTip, locenc); |
c2fb9192377b
[gaim-migrate @ 7441]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
158 g_free(locenc); |
c2fb9192377b
[gaim-migrate @ 7441]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
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 |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
167 static void wgaim_tray_update_icon(enum docklet_status icon) { |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
168 switch (icon) { |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
169 case offline: |
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; |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
172 case offline_connecting: |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
173 case online_connecting: |
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: |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
176 systray_change_icon(sysicon_conn, 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 online_pending: |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
179 systray_change_icon(sysicon_pend, GAIM_SYSTRAY_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: |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
182 systray_change_icon(sysicon_away, 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 case away_pending: |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
185 systray_change_icon(sysicon_awypend, GAIM_SYSTRAY_AWAY_HINT); |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
186 break; |
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 } |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
189 |
6894
c2fb9192377b
[gaim-migrate @ 7441]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
190 static void wgaim_tray_blank_icon() { |
c2fb9192377b
[gaim-migrate @ 7441]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
191 systray_change_icon(sysicon_blank, NULL); |
c2fb9192377b
[gaim-migrate @ 7441]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
192 } |
c2fb9192377b
[gaim-migrate @ 7441]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
193 |
6209
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
194 static void wgaim_tray_create() { |
10520
976c7b186789
[gaim-migrate @ 11835]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10268
diff
changeset
|
195 OSVERSIONINFO osinfo; |
6209
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
196 /* dummy window to process systray messages */ |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
197 systray_hwnd = systray_create_hiddenwin(); |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
198 |
10520
976c7b186789
[gaim-migrate @ 11835]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10268
diff
changeset
|
199 osinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); |
976c7b186789
[gaim-migrate @ 11835]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10268
diff
changeset
|
200 GetVersionEx(&osinfo); |
976c7b186789
[gaim-migrate @ 11835]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10268
diff
changeset
|
201 |
976c7b186789
[gaim-migrate @ 11835]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10268
diff
changeset
|
202 /* Load icons, and init systray notify icon |
976c7b186789
[gaim-migrate @ 11835]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10268
diff
changeset
|
203 * 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
|
204 * 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
|
205 * but will scale it back to 4-bits for display. |
976c7b186789
[gaim-migrate @ 11835]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10268
diff
changeset
|
206 * 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
|
207 if (osinfo.dwMajorVersion == 5 && osinfo.dwMinorVersion > 0) { |
976c7b186789
[gaim-migrate @ 11835]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10268
diff
changeset
|
208 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
|
209 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
|
210 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
|
211 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
|
212 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
|
213 } else { |
976c7b186789
[gaim-migrate @ 11835]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10268
diff
changeset
|
214 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
|
215 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
|
216 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
|
217 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
|
218 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
|
219 } |
6894
c2fb9192377b
[gaim-migrate @ 7441]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
220 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
|
221 |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
222 /* Create icon in systray */ |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
223 systray_init_icon(systray_hwnd, sysicon_disconn); |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
224 gaim_debug(GAIM_DEBUG_INFO, "tray icon", "created\n"); |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
225 } |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
226 |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
227 static void wgaim_tray_destroy() { |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
228 systray_remove_nid(); |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
229 DestroyWindow(systray_hwnd); |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
230 docklet_remove(TRUE); |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
231 } |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
232 |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
233 static struct docklet_ui_ops wgaim_tray_ops = |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
234 { |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
235 wgaim_tray_create, |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
236 wgaim_tray_destroy, |
6894
c2fb9192377b
[gaim-migrate @ 7441]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
237 wgaim_tray_update_icon, |
10268
d082b2a71ee7
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9863
diff
changeset
|
238 wgaim_tray_blank_icon, |
d082b2a71ee7
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9863
diff
changeset
|
239 NULL |
6209
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 |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
242 /* Used by docklet's plugin load func */ |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
243 void docklet_ui_init() { |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
244 docklet_set_ui_ops(&wgaim_tray_ops); |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
245 } |