annotate pidgin/win32/gtkdocklet-win32.c @ 16207:6ded371da50f

merge of '208954788ae2550f1dbc241cbca23eb02991dc5a' and 'a842e5eb826e08ac7e5b8a2e6c8f0ad46720afe0'
author Richard Laager <rlaager@wiktel.com>
date Mon, 16 Apr 2007 05:37:44 +0000
parents 495800004c0a
children 94ee22ed492b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /*
15515
75ffc646647f Win32 de-gaimification of pidgin
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15501
diff changeset
2 * System tray icon (aka docklet) plugin for Winpidgin
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
4 * Copyright (C) 2002-3 Robert McQueen <robot101@debian.org>
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
5 * Copyright (C) 2003 Herman Bloggs <hermanator12002@yahoo.com>
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
6 * Inspired by a similar plugin by:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
7 * John (J5) Palmieri <johnp@martianrock.com>
15515
75ffc646647f Win32 de-gaimification of pidgin
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15501
diff changeset
8 *
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 * This program is free software; you can redistribute it and/or
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 * modify it under the terms of the GNU General Public License as
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 * published by the Free Software Foundation; either version 2 of the
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 * License, or (at your option) any later version.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful, but
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 * General Public License for more details.
15515
75ffc646647f Win32 de-gaimification of pidgin
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15501
diff changeset
18 *
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20 * along with this program; if not, write to the Free Software
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
22 * 02111-1307, USA.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
23 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
24
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
25 #include <windows.h>
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
26 #include <gdk/gdkwin32.h>
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
27 #include <gdk/gdk.h>
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
28
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
29 #include "internal.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
30 #include "gtkblist.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
31 #include "debug.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33 #include "resource.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
34 #include "MinimizeToTray.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
35 #include "gtkwin32dep.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
36 #include "gtkdocklet.h"
15831
e04c98c1bce9 win32 fixes for s/gaim/purple/ stuff.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15823
diff changeset
37 #include "pidginstock.h"
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
38
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
39 /*
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
40 * DEFINES, MACROS & DATA TYPES
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
41 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
42 #define WM_TRAYMESSAGE WM_USER /* User defined WM Message */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
43
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
44 /*
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
45 * LOCALS
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
46 */
15701
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
47 static HWND systray_hwnd = NULL;
15709
b2b756b59d81 Cache the converted docklet HICONs. Sean noticed that there are actually .ico files in pixmaps/tray/16 (something that I missed). I'm not sure if I should just use those and eliminate the stock pixmap to HICON conversion hackery or if we can just get rid of those and avoid the duplication.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15701
diff changeset
48 static HICON cached_icons[DOCKLET_STATUS_CONNECTING + 1];
15701
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
49 static GtkWidget *image = NULL;
15515
75ffc646647f Win32 de-gaimification of pidgin
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15501
diff changeset
50 static NOTIFYICONDATA _nicon_data;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
51
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
52 static LRESULT CALLBACK systray_mainmsg_handler(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
53 static UINT taskbarRestartMsg; /* static here means value is kept across multiple calls to this func */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
54
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
55 switch(msg) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
56 case WM_CREATE:
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15773
diff changeset
57 purple_debug_info("docklet", "WM_CREATE\n");
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
58 taskbarRestartMsg = RegisterWindowMessage("TaskbarCreated");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
59 break;
15701
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
60
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
61 case WM_TIMER:
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15773
diff changeset
62 purple_debug_info("docklet", "WM_TIMER\n");
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
63 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
64
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
65 case WM_DESTROY:
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15773
diff changeset
66 purple_debug_info("docklet", "WM_DESTROY\n");
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
67 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
68
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
69 case WM_TRAYMESSAGE:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
70 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
71 int type = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
72
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
73 /* We'll use Double Click - Single click over on linux */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
74 if(lparam == WM_LBUTTONDBLCLK)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
75 type = 1;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
76 else if(lparam == WM_MBUTTONUP)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
77 type = 2;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
78 else if(lparam == WM_RBUTTONUP)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
79 type = 3;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
80 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
81 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
82
15501
d75099d2567e gaim_gtk to pidgin. I hope
Sean Egan <seanegan@gmail.com>
parents: 15461
diff changeset
83 pidgin_docklet_clicked(type);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
84 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
85 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
86 default:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
87 if (msg == taskbarRestartMsg) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
88 /* explorer crashed and left us hanging...
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
89 This will put the systray icon back in it's place, when it restarts */
15515
75ffc646647f Win32 de-gaimification of pidgin
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15501
diff changeset
90 Shell_NotifyIcon(NIM_ADD, &_nicon_data);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
91 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
92 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
93 }/* end switch */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
94
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
95 return DefWindowProc(hwnd, msg, wparam, lparam);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
96 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
97
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
98 /* Create hidden window to process systray messages */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
99 static HWND systray_create_hiddenwin() {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
100 WNDCLASSEX wcex;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
101 LPCTSTR wname;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
102
15515
75ffc646647f Win32 de-gaimification of pidgin
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15501
diff changeset
103 wname = TEXT("WinpidginSystrayWinCls");
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
104
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
105 wcex.cbSize = sizeof(wcex);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
106 wcex.style = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
107 wcex.lpfnWndProc = systray_mainmsg_handler;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
108 wcex.cbClsExtra = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
109 wcex.cbWndExtra = 0;
15997
495800004c0a 4bit icons for windows < XP. These are certainly not as pretty as the originals, but look a lot better than scaled down versions.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15831
diff changeset
110 wcex.hInstance = winpidgin_exe_hinstance();
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
111 wcex.hIcon = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
112 wcex.hCursor = NULL,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
113 wcex.hbrBackground = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
114 wcex.lpszMenuName = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
115 wcex.lpszClassName = wname;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
116 wcex.hIconSm = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
117
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
118 RegisterClassEx(&wcex);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
119
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
120 /* Create the window */
15997
495800004c0a 4bit icons for windows < XP. These are certainly not as pretty as the originals, but look a lot better than scaled down versions.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15831
diff changeset
121 return (CreateWindow(wname, "", 0, 0, 0, 0, 0, GetDesktopWindow(), NULL, winpidgin_exe_hinstance(), 0));
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
122 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
123
15701
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
124 static void systray_init_icon(HWND hWnd) {
15515
75ffc646647f Win32 de-gaimification of pidgin
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15501
diff changeset
125 ZeroMemory(&_nicon_data, sizeof(_nicon_data));
75ffc646647f Win32 de-gaimification of pidgin
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15501
diff changeset
126 _nicon_data.cbSize = sizeof(NOTIFYICONDATA);
75ffc646647f Win32 de-gaimification of pidgin
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15501
diff changeset
127 _nicon_data.hWnd = hWnd;
75ffc646647f Win32 de-gaimification of pidgin
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15501
diff changeset
128 _nicon_data.uID = 0;
75ffc646647f Win32 de-gaimification of pidgin
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15501
diff changeset
129 _nicon_data.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
75ffc646647f Win32 de-gaimification of pidgin
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15501
diff changeset
130 _nicon_data.uCallbackMessage = WM_TRAYMESSAGE;
15701
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
131 _nicon_data.hIcon = NULL;
15515
75ffc646647f Win32 de-gaimification of pidgin
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15501
diff changeset
132 lstrcpy(_nicon_data.szTip, PIDGIN_NAME);
75ffc646647f Win32 de-gaimification of pidgin
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15501
diff changeset
133 Shell_NotifyIcon(NIM_ADD, &_nicon_data);
15501
d75099d2567e gaim_gtk to pidgin. I hope
Sean Egan <seanegan@gmail.com>
parents: 15461
diff changeset
134 pidgin_docklet_embedded();
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
135 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
136
15701
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
137 /* This is ganked from GTK+.
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
138 * When we can use GTK+ 2.10 and the GtkStatusIcon stuff, this will no longer be necesary */
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
139 #define WIN32_GDI_FAILED(api) printf("GDI FAILED %s\n", api)
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
140
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
141 static gboolean
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
142 _gdk_win32_pixbuf_to_hicon_supports_alpha (void)
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
143 {
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
144 static gboolean is_win_xp=FALSE, is_win_xp_checked=FALSE;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
145
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
146 if (!is_win_xp_checked)
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
147 {
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
148 is_win_xp_checked = TRUE;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
149
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
150 if (!G_WIN32_IS_NT_BASED ())
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
151 is_win_xp = FALSE;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
152 else
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
153 {
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
154 OSVERSIONINFO version;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
155
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
156 memset (&version, 0, sizeof (version));
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
157 version.dwOSVersionInfoSize = sizeof (version);
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
158 is_win_xp = GetVersionEx (&version)
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
159 && version.dwPlatformId == VER_PLATFORM_WIN32_NT
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
160 && (version.dwMajorVersion > 5
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
161 || (version.dwMajorVersion == 5 && version.dwMinorVersion >= 1));
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
162 }
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
163 }
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
164 return is_win_xp;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
165 }
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
166
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
167 static HBITMAP
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
168 create_alpha_bitmap (gint size,
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
169 guchar **outdata)
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
170 {
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
171 BITMAPV5HEADER bi;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
172 HDC hdc;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
173 HBITMAP hBitmap;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
174
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
175 ZeroMemory (&bi, sizeof (BITMAPV5HEADER));
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
176 bi.bV5Size = sizeof (BITMAPV5HEADER);
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
177 bi.bV5Height = bi.bV5Width = size;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
178 bi.bV5Planes = 1;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
179 bi.bV5BitCount = 32;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
180 bi.bV5Compression = BI_BITFIELDS;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
181 /* The following mask specification specifies a supported 32 BPP
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
182 * alpha format for Windows XP (BGRA format).
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
183 */
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
184 bi.bV5RedMask = 0x00FF0000;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
185 bi.bV5GreenMask = 0x0000FF00;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
186 bi.bV5BlueMask = 0x000000FF;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
187 bi.bV5AlphaMask = 0xFF000000;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
188
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
189 /* Create the DIB section with an alpha channel. */
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
190 hdc = GetDC (NULL);
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
191 if (!hdc)
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
192 {
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
193 WIN32_GDI_FAILED ("GetDC");
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
194 return NULL;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
195 }
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
196 hBitmap = CreateDIBSection (hdc, (BITMAPINFO *)&bi, DIB_RGB_COLORS,
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
197 (PVOID *) outdata, NULL, (DWORD)0);
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
198 if (hBitmap == NULL)
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
199 WIN32_GDI_FAILED ("CreateDIBSection");
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
200 ReleaseDC (NULL, hdc);
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
201
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
202 return hBitmap;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
203 }
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
204
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
205 static HBITMAP
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
206 create_color_bitmap (gint size,
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
207 guchar **outdata,
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
208 gint bits)
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
209 {
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
210 struct {
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
211 BITMAPV4HEADER bmiHeader;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
212 RGBQUAD bmiColors[2];
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
213 } bmi;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
214 HDC hdc;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
215 HBITMAP hBitmap;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
216
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
217 ZeroMemory (&bmi, sizeof (bmi));
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
218 bmi.bmiHeader.bV4Size = sizeof (BITMAPV4HEADER);
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
219 bmi.bmiHeader.bV4Height = bmi.bmiHeader.bV4Width = size;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
220 bmi.bmiHeader.bV4Planes = 1;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
221 bmi.bmiHeader.bV4BitCount = bits;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
222 bmi.bmiHeader.bV4V4Compression = BI_RGB;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
223
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
224 /* when bits is 1, these will be used.
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
225 * bmiColors[0] already zeroed from ZeroMemory()
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
226 */
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
227 bmi.bmiColors[1].rgbBlue = 0xFF;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
228 bmi.bmiColors[1].rgbGreen = 0xFF;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
229 bmi.bmiColors[1].rgbRed = 0xFF;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
230
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
231 hdc = GetDC (NULL);
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
232 if (!hdc)
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
233 {
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
234 WIN32_GDI_FAILED ("GetDC");
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
235 return NULL;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
236 }
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
237 hBitmap = CreateDIBSection (hdc, (BITMAPINFO *)&bmi, DIB_RGB_COLORS,
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
238 (PVOID *) outdata, NULL, (DWORD)0);
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
239 if (hBitmap == NULL)
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
240 WIN32_GDI_FAILED ("CreateDIBSection");
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
241 ReleaseDC (NULL, hdc);
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
242
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
243 return hBitmap;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
244 }
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
245
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
246 static gboolean
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
247 pixbuf_to_hbitmaps_alpha_winxp (GdkPixbuf *pixbuf,
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
248 HBITMAP *color,
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
249 HBITMAP *mask)
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
250 {
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
251 /* Based on code from
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
252 * http://www.dotnet247.com/247reference/msgs/13/66301.aspx
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
253 */
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
254 HBITMAP hColorBitmap, hMaskBitmap;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
255 guchar *indata, *inrow;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
256 guchar *colordata, *colorrow, *maskdata, *maskbyte;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
257 gint width, height, size, i, i_offset, j, j_offset, rowstride;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
258 guint maskstride, mask_bit;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
259
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
260 width = gdk_pixbuf_get_width (pixbuf); /* width of icon */
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
261 height = gdk_pixbuf_get_height (pixbuf); /* height of icon */
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
262
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
263 /* The bitmaps are created square */
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
264 size = MAX (width, height);
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
265
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
266 hColorBitmap = create_alpha_bitmap (size, &colordata);
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
267 if (!hColorBitmap)
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
268 return FALSE;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
269 hMaskBitmap = create_color_bitmap (size, &maskdata, 1);
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
270 if (!hMaskBitmap)
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
271 {
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
272 DeleteObject (hColorBitmap);
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
273 return FALSE;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
274 }
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
275
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
276 /* MSDN says mask rows are aligned to "LONG" boundaries */
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
277 maskstride = (((size + 31) & ~31) >> 3);
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
278
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
279 indata = gdk_pixbuf_get_pixels (pixbuf);
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
280 rowstride = gdk_pixbuf_get_rowstride (pixbuf);
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
281
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
282 if (width > height)
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
283 {
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
284 i_offset = 0;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
285 j_offset = (width - height) / 2;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
286 }
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
287 else
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
288 {
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
289 i_offset = (height - width) / 2;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
290 j_offset = 0;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
291 }
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
292
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
293 for (j = 0; j < height; j++)
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
294 {
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
295 colorrow = colordata + 4*(j+j_offset)*size + 4*i_offset;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
296 maskbyte = maskdata + (j+j_offset)*maskstride + i_offset/8;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
297 mask_bit = (0x80 >> (i_offset % 8));
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
298 inrow = indata + (height-j-1)*rowstride;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
299 for (i = 0; i < width; i++)
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
300 {
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
301 colorrow[4*i+0] = inrow[4*i+2];
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
302 colorrow[4*i+1] = inrow[4*i+1];
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
303 colorrow[4*i+2] = inrow[4*i+0];
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
304 colorrow[4*i+3] = inrow[4*i+3];
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
305 if (inrow[4*i+3] == 0)
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
306 maskbyte[0] |= mask_bit; /* turn ON bit */
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
307 else
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
308 maskbyte[0] &= ~mask_bit; /* turn OFF bit */
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
309 mask_bit >>= 1;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
310 if (mask_bit == 0)
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
311 {
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
312 mask_bit = 0x80;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
313 maskbyte++;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
314 }
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
315 }
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
316 }
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
317
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
318 *color = hColorBitmap;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
319 *mask = hMaskBitmap;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
320
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
321 return TRUE;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
322 }
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
323
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
324 static gboolean
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
325 pixbuf_to_hbitmaps_normal (GdkPixbuf *pixbuf,
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
326 HBITMAP *color,
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
327 HBITMAP *mask)
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
328 {
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
329 /* Based on code from
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
330 * http://www.dotnet247.com/247reference/msgs/13/66301.aspx
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
331 */
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
332 HBITMAP hColorBitmap, hMaskBitmap;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
333 guchar *indata, *inrow;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
334 guchar *colordata, *colorrow, *maskdata, *maskbyte;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
335 gint width, height, size, i, i_offset, j, j_offset, rowstride, nc, bmstride;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
336 gboolean has_alpha;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
337 guint maskstride, mask_bit;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
338
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
339 width = gdk_pixbuf_get_width (pixbuf); /* width of icon */
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
340 height = gdk_pixbuf_get_height (pixbuf); /* height of icon */
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
341
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
342 /* The bitmaps are created square */
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
343 size = MAX (width, height);
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
344
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
345 hColorBitmap = create_color_bitmap (size, &colordata, 24);
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
346 if (!hColorBitmap)
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
347 return FALSE;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
348 hMaskBitmap = create_color_bitmap (size, &maskdata, 1);
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
349 if (!hMaskBitmap)
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
350 {
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
351 DeleteObject (hColorBitmap);
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
352 return FALSE;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
353 }
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
354
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
355 /* rows are always aligned on 4-byte boundarys */
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
356 bmstride = size * 3;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
357 if (bmstride % 4 != 0)
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
358 bmstride += 4 - (bmstride % 4);
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
359
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
360 /* MSDN says mask rows are aligned to "LONG" boundaries */
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
361 maskstride = (((size + 31) & ~31) >> 3);
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
362
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
363 indata = gdk_pixbuf_get_pixels (pixbuf);
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
364 rowstride = gdk_pixbuf_get_rowstride (pixbuf);
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
365 nc = gdk_pixbuf_get_n_channels (pixbuf);
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
366 has_alpha = gdk_pixbuf_get_has_alpha (pixbuf);
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
367
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
368 if (width > height)
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
369 {
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
370 i_offset = 0;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
371 j_offset = (width - height) / 2;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
372 }
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
373 else
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
374 {
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
375 i_offset = (height - width) / 2;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
376 j_offset = 0;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
377 }
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
378
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
379 for (j = 0; j < height; j++)
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
380 {
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
381 colorrow = colordata + (j+j_offset)*bmstride + 3*i_offset;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
382 maskbyte = maskdata + (j+j_offset)*maskstride + i_offset/8;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
383 mask_bit = (0x80 >> (i_offset % 8));
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
384 inrow = indata + (height-j-1)*rowstride;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
385 for (i = 0; i < width; i++)
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
386 {
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
387 if (has_alpha && inrow[nc*i+3] < 128)
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
388 {
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
389 colorrow[3*i+0] = colorrow[3*i+1] = colorrow[3*i+2] = 0;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
390 maskbyte[0] |= mask_bit; /* turn ON bit */
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
391 }
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
392 else
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
393 {
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
394 colorrow[3*i+0] = inrow[nc*i+2];
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
395 colorrow[3*i+1] = inrow[nc*i+1];
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
396 colorrow[3*i+2] = inrow[nc*i+0];
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
397 maskbyte[0] &= ~mask_bit; /* turn OFF bit */
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
398 }
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
399 mask_bit >>= 1;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
400 if (mask_bit == 0)
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
401 {
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
402 mask_bit = 0x80;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
403 maskbyte++;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
404 }
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
405 }
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
406 }
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
407
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
408 *color = hColorBitmap;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
409 *mask = hMaskBitmap;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
410
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
411 return TRUE;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
412 }
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
413
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
414 static HICON
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
415 pixbuf_to_hicon (GdkPixbuf *pixbuf)
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
416 {
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
417 gint x = 0, y = 0;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
418 gboolean is_icon = TRUE;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
419 ICONINFO ii;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
420 HICON icon;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
421 gboolean success;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
422
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
423 if (pixbuf == NULL)
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
424 return NULL;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
425
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
426 if (_gdk_win32_pixbuf_to_hicon_supports_alpha() && gdk_pixbuf_get_has_alpha (pixbuf))
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
427 success = pixbuf_to_hbitmaps_alpha_winxp (pixbuf, &ii.hbmColor, &ii.hbmMask);
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
428 else
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
429 success = pixbuf_to_hbitmaps_normal (pixbuf, &ii.hbmColor, &ii.hbmMask);
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
430
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
431 if (!success)
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
432 return NULL;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
433
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
434 ii.fIcon = is_icon;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
435 ii.xHotspot = x;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
436 ii.yHotspot = y;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
437 icon = CreateIconIndirect (&ii);
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
438 DeleteObject (ii.hbmColor);
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
439 DeleteObject (ii.hbmMask);
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
440 return icon;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
441 }
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
442
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
443 static HICON load_hicon_from_stock(const char *stock) {
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
444 HICON hicon = NULL;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
445 GdkPixbuf *pixbuf = gtk_widget_render_icon(image, stock,
15773
79144a15ea78 16px tray icons. These are used if the tray is shorter than 22px, and in Windows where all tray icons are 16x16. I still need to attach to a resizing signal to make them automatically update when the tray resizes.
Sean Egan <seanegan@gmail.com>
parents: 15715
diff changeset
446 gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL), NULL);
15701
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
447
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
448 if (pixbuf) {
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
449 hicon = pixbuf_to_hicon(pixbuf);
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
450 g_object_unref(pixbuf);
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
451 } else
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15773
diff changeset
452 purple_debug_error("Unable to load pixbuf for %s.\n", stock);
15701
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
453
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
454 return hicon;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
455 }
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
456
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
457
15709
b2b756b59d81 Cache the converted docklet HICONs. Sean noticed that there are actually .ico files in pixmaps/tray/16 (something that I missed). I'm not sure if I should just use those and eliminate the stock pixmap to HICON conversion hackery or if we can just get rid of those and avoid the duplication.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15701
diff changeset
458 static void systray_change_icon(HICON hicon) {
15701
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
459 g_return_if_fail(hicon != NULL);
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
460
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
461 _nicon_data.hIcon = hicon;
15515
75ffc646647f Win32 de-gaimification of pidgin
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15501
diff changeset
462 Shell_NotifyIcon(NIM_MODIFY, &_nicon_data);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
463 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
464
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
465 static void systray_remove_nid(void) {
15515
75ffc646647f Win32 de-gaimification of pidgin
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15501
diff changeset
466 Shell_NotifyIcon(NIM_DELETE, &_nicon_data);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
467 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
468
15515
75ffc646647f Win32 de-gaimification of pidgin
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15501
diff changeset
469 static void winpidgin_tray_update_icon(DockletStatus icon) {
15701
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
470
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
471 g_return_if_fail(image != NULL);
15709
b2b756b59d81 Cache the converted docklet HICONs. Sean noticed that there are actually .ico files in pixmaps/tray/16 (something that I missed). I'm not sure if I should just use those and eliminate the stock pixmap to HICON conversion hackery or if we can just get rid of those and avoid the duplication.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15701
diff changeset
472 g_return_if_fail(icon < (sizeof(cached_icons) / sizeof(HICON)));
15701
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
473
15709
b2b756b59d81 Cache the converted docklet HICONs. Sean noticed that there are actually .ico files in pixmaps/tray/16 (something that I missed). I'm not sure if I should just use those and eliminate the stock pixmap to HICON conversion hackery or if we can just get rid of those and avoid the duplication.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15701
diff changeset
474 /* Look up and cache the HICON if we don't already have it */
b2b756b59d81 Cache the converted docklet HICONs. Sean noticed that there are actually .ico files in pixmaps/tray/16 (something that I missed). I'm not sure if I should just use those and eliminate the stock pixmap to HICON conversion hackery or if we can just get rid of those and avoid the duplication.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15701
diff changeset
475 if (cached_icons[icon] == NULL) {
b2b756b59d81 Cache the converted docklet HICONs. Sean noticed that there are actually .ico files in pixmaps/tray/16 (something that I missed). I'm not sure if I should just use those and eliminate the stock pixmap to HICON conversion hackery or if we can just get rid of those and avoid the duplication.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15701
diff changeset
476 const gchar *icon_name = NULL;
b2b756b59d81 Cache the converted docklet HICONs. Sean noticed that there are actually .ico files in pixmaps/tray/16 (something that I missed). I'm not sure if I should just use those and eliminate the stock pixmap to HICON conversion hackery or if we can just get rid of those and avoid the duplication.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15701
diff changeset
477 switch (icon) {
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
478 case DOCKLET_STATUS_OFFLINE:
15701
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
479 icon_name = PIDGIN_STOCK_TRAY_OFFLINE;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
480 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
481 case DOCKLET_STATUS_CONNECTING:
15701
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
482 icon_name = PIDGIN_STOCK_TRAY_CONNECT;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
483 break;
15701
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
484 case DOCKLET_STATUS_AVAILABLE:
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
485 icon_name = PIDGIN_STOCK_TRAY_AVAILABLE;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
486 break;
15701
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
487 case DOCKLET_STATUS_PENDING:
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
488 icon_name = PIDGIN_STOCK_TRAY_PENDING;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
489 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
490 case DOCKLET_STATUS_AWAY:
15701
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
491 icon_name = PIDGIN_STOCK_TRAY_AWAY;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
492 break;
15701
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
493 case DOCKLET_STATUS_BUSY:
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
494 icon_name = PIDGIN_STOCK_TRAY_BUSY;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
495 break;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
496 case DOCKLET_STATUS_XA:
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
497 icon_name = PIDGIN_STOCK_TRAY_XA;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
498 break;
15709
b2b756b59d81 Cache the converted docklet HICONs. Sean noticed that there are actually .ico files in pixmaps/tray/16 (something that I missed). I'm not sure if I should just use those and eliminate the stock pixmap to HICON conversion hackery or if we can just get rid of those and avoid the duplication.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15701
diff changeset
499 }
b2b756b59d81 Cache the converted docklet HICONs. Sean noticed that there are actually .ico files in pixmaps/tray/16 (something that I missed). I'm not sure if I should just use those and eliminate the stock pixmap to HICON conversion hackery or if we can just get rid of those and avoid the duplication.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15701
diff changeset
500
b2b756b59d81 Cache the converted docklet HICONs. Sean noticed that there are actually .ico files in pixmaps/tray/16 (something that I missed). I'm not sure if I should just use those and eliminate the stock pixmap to HICON conversion hackery or if we can just get rid of those and avoid the duplication.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15701
diff changeset
501 g_return_if_fail(icon_name != NULL);
b2b756b59d81 Cache the converted docklet HICONs. Sean noticed that there are actually .ico files in pixmaps/tray/16 (something that I missed). I'm not sure if I should just use those and eliminate the stock pixmap to HICON conversion hackery or if we can just get rid of those and avoid the duplication.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15701
diff changeset
502
b2b756b59d81 Cache the converted docklet HICONs. Sean noticed that there are actually .ico files in pixmaps/tray/16 (something that I missed). I'm not sure if I should just use those and eliminate the stock pixmap to HICON conversion hackery or if we can just get rid of those and avoid the duplication.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15701
diff changeset
503 cached_icons[icon] = load_hicon_from_stock(icon_name);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
504 }
15701
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
505
15709
b2b756b59d81 Cache the converted docklet HICONs. Sean noticed that there are actually .ico files in pixmaps/tray/16 (something that I missed). I'm not sure if I should just use those and eliminate the stock pixmap to HICON conversion hackery or if we can just get rid of those and avoid the duplication.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15701
diff changeset
506 systray_change_icon(cached_icons[icon]);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
507 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
508
15515
75ffc646647f Win32 de-gaimification of pidgin
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15501
diff changeset
509 static void winpidgin_tray_blank_icon() {
15701
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
510 _nicon_data.hIcon = NULL;
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
511 Shell_NotifyIcon(NIM_MODIFY, &_nicon_data);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
512 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
513
15515
75ffc646647f Win32 de-gaimification of pidgin
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15501
diff changeset
514 static void winpidgin_tray_set_tooltip(gchar *tooltip) {
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
515 if (tooltip) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
516 char *locenc = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
517 locenc = g_locale_from_utf8(tooltip, -1, NULL, NULL, NULL);
15515
75ffc646647f Win32 de-gaimification of pidgin
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15501
diff changeset
518 lstrcpyn(_nicon_data.szTip, locenc, sizeof(_nicon_data.szTip) / sizeof(TCHAR));
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
519 g_free(locenc);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
520 } else {
15515
75ffc646647f Win32 de-gaimification of pidgin
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15501
diff changeset
521 lstrcpy(_nicon_data.szTip, PIDGIN_NAME);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
522 }
15515
75ffc646647f Win32 de-gaimification of pidgin
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15501
diff changeset
523 Shell_NotifyIcon(NIM_MODIFY, &_nicon_data);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
524 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
525
15515
75ffc646647f Win32 de-gaimification of pidgin
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15501
diff changeset
526 static void winpidgin_tray_minimize(PidginBuddyList *gtkblist) {
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
527 MinimizeWndToTray(GDK_WINDOW_HWND(gtkblist->window->window));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
528 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
529
15515
75ffc646647f Win32 de-gaimification of pidgin
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15501
diff changeset
530 static void winpidgin_tray_maximize(PidginBuddyList *gtkblist) {
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
531 RestoreWndFromTray(GDK_WINDOW_HWND(gtkblist->window->window));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
532 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
533
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
534
15515
75ffc646647f Win32 de-gaimification of pidgin
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15501
diff changeset
535 static void winpidgin_tray_create() {
15997
495800004c0a 4bit icons for windows < XP. These are certainly not as pretty as the originals, but look a lot better than scaled down versions.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15831
diff changeset
536 OSVERSIONINFO osinfo;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
537 /* dummy window to process systray messages */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
538 systray_hwnd = systray_create_hiddenwin();
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
539
15701
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
540 image = gtk_image_new();
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
541 #if GLIB_CHECK_VERSION(2,10,0)
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
542 g_object_ref_sink(image);
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
543 #else
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
544 g_object_ref(image);
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
545 gtk_object_sink(GTK_OBJECT(image));
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
546 #endif
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
547
15997
495800004c0a 4bit icons for windows < XP. These are certainly not as pretty as the originals, but look a lot better than scaled down versions.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15831
diff changeset
548 osinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
495800004c0a 4bit icons for windows < XP. These are certainly not as pretty as the originals, but look a lot better than scaled down versions.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15831
diff changeset
549 GetVersionEx(&osinfo);
495800004c0a 4bit icons for windows < XP. These are certainly not as pretty as the originals, but look a lot better than scaled down versions.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15831
diff changeset
550
495800004c0a 4bit icons for windows < XP. These are certainly not as pretty as the originals, but look a lot better than scaled down versions.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15831
diff changeset
551 /* Load icons, and init systray notify icon
495800004c0a 4bit icons for windows < XP. These are certainly not as pretty as the originals, but look a lot better than scaled down versions.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15831
diff changeset
552 * NOTE: Windows < XP only supports displaying 4-bit images in the Systray,
495800004c0a 4bit icons for windows < XP. These are certainly not as pretty as the originals, but look a lot better than scaled down versions.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15831
diff changeset
553 * 2K and ME will use the highest color depth that the desktop will support,
495800004c0a 4bit icons for windows < XP. These are certainly not as pretty as the originals, but look a lot better than scaled down versions.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15831
diff changeset
554 * but will scale it back to 4-bits for display.
495800004c0a 4bit icons for windows < XP. These are certainly not as pretty as the originals, but look a lot better than scaled down versions.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15831
diff changeset
555 * That is why we use custom 4-bit icons for pre XP Windowses */
495800004c0a 4bit icons for windows < XP. These are certainly not as pretty as the originals, but look a lot better than scaled down versions.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15831
diff changeset
556 if (osinfo.dwMajorVersion < 5 || (osinfo.dwMajorVersion == 5 && osinfo.dwMinorVersion == 0))
495800004c0a 4bit icons for windows < XP. These are certainly not as pretty as the originals, but look a lot better than scaled down versions.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15831
diff changeset
557 {
495800004c0a 4bit icons for windows < XP. These are certainly not as pretty as the originals, but look a lot better than scaled down versions.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15831
diff changeset
558 cached_icons[DOCKLET_STATUS_OFFLINE] = (HICON) LoadImage(winpidgin_dll_hinstance(),
495800004c0a 4bit icons for windows < XP. These are certainly not as pretty as the originals, but look a lot better than scaled down versions.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15831
diff changeset
559 MAKEINTRESOURCE(PIDGIN_TRAY_OFFLINE_4BIT), IMAGE_ICON, 16, 16, LR_CREATEDIBSECTION);
495800004c0a 4bit icons for windows < XP. These are certainly not as pretty as the originals, but look a lot better than scaled down versions.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15831
diff changeset
560 cached_icons[DOCKLET_STATUS_AVAILABLE] = (HICON) LoadImage(winpidgin_dll_hinstance(),
495800004c0a 4bit icons for windows < XP. These are certainly not as pretty as the originals, but look a lot better than scaled down versions.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15831
diff changeset
561 MAKEINTRESOURCE(PIDGIN_TRAY_AVAILABLE_4BIT), IMAGE_ICON, 16, 16, LR_CREATEDIBSECTION);
495800004c0a 4bit icons for windows < XP. These are certainly not as pretty as the originals, but look a lot better than scaled down versions.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15831
diff changeset
562 cached_icons[DOCKLET_STATUS_AWAY] = (HICON) LoadImage(winpidgin_dll_hinstance(),
495800004c0a 4bit icons for windows < XP. These are certainly not as pretty as the originals, but look a lot better than scaled down versions.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15831
diff changeset
563 MAKEINTRESOURCE(PIDGIN_TRAY_AWAY_4BIT), IMAGE_ICON, 16, 16, LR_CREATEDIBSECTION);
495800004c0a 4bit icons for windows < XP. These are certainly not as pretty as the originals, but look a lot better than scaled down versions.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15831
diff changeset
564 cached_icons[DOCKLET_STATUS_XA] = (HICON) LoadImage(winpidgin_dll_hinstance(),
495800004c0a 4bit icons for windows < XP. These are certainly not as pretty as the originals, but look a lot better than scaled down versions.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15831
diff changeset
565 MAKEINTRESOURCE(PIDGIN_TRAY_XA_4BIT), IMAGE_ICON, 16, 16, LR_CREATEDIBSECTION);
495800004c0a 4bit icons for windows < XP. These are certainly not as pretty as the originals, but look a lot better than scaled down versions.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15831
diff changeset
566 cached_icons[DOCKLET_STATUS_BUSY] = (HICON) LoadImage(winpidgin_dll_hinstance(),
495800004c0a 4bit icons for windows < XP. These are certainly not as pretty as the originals, but look a lot better than scaled down versions.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15831
diff changeset
567 MAKEINTRESOURCE(PIDGIN_TRAY_BUSY_4BIT), IMAGE_ICON, 16, 16, LR_CREATEDIBSECTION);
495800004c0a 4bit icons for windows < XP. These are certainly not as pretty as the originals, but look a lot better than scaled down versions.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15831
diff changeset
568 cached_icons[DOCKLET_STATUS_CONNECTING] = (HICON) LoadImage(winpidgin_dll_hinstance(),
495800004c0a 4bit icons for windows < XP. These are certainly not as pretty as the originals, but look a lot better than scaled down versions.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15831
diff changeset
569 MAKEINTRESOURCE(PIDGIN_TRAY_CONNECTING_4BIT), IMAGE_ICON, 16, 16, LR_CREATEDIBSECTION);
495800004c0a 4bit icons for windows < XP. These are certainly not as pretty as the originals, but look a lot better than scaled down versions.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15831
diff changeset
570 cached_icons[DOCKLET_STATUS_PENDING] = (HICON) LoadImage(winpidgin_dll_hinstance(),
495800004c0a 4bit icons for windows < XP. These are certainly not as pretty as the originals, but look a lot better than scaled down versions.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15831
diff changeset
571 MAKEINTRESOURCE(PIDGIN_TRAY_PENDING_4BIT), IMAGE_ICON, 16, 16, LR_CREATEDIBSECTION);
495800004c0a 4bit icons for windows < XP. These are certainly not as pretty as the originals, but look a lot better than scaled down versions.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15831
diff changeset
572 }
495800004c0a 4bit icons for windows < XP. These are certainly not as pretty as the originals, but look a lot better than scaled down versions.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15831
diff changeset
573
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
574 /* Create icon in systray */
15701
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
575 systray_init_icon(systray_hwnd);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
576
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15773
diff changeset
577 purple_signal_connect(pidgin_blist_get_handle(), "gtkblist-hiding",
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15773
diff changeset
578 pidgin_docklet_get_handle(), PURPLE_CALLBACK(winpidgin_tray_minimize), NULL);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15773
diff changeset
579 purple_signal_connect(pidgin_blist_get_handle(), "gtkblist-unhiding",
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15773
diff changeset
580 pidgin_docklet_get_handle(), PURPLE_CALLBACK(winpidgin_tray_maximize), NULL);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
581
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15773
diff changeset
582 purple_debug_info("docklet", "created\n");
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
583 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
584
15515
75ffc646647f Win32 de-gaimification of pidgin
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15501
diff changeset
585 static void winpidgin_tray_destroy() {
15709
b2b756b59d81 Cache the converted docklet HICONs. Sean noticed that there are actually .ico files in pixmaps/tray/16 (something that I missed). I'm not sure if I should just use those and eliminate the stock pixmap to HICON conversion hackery or if we can just get rid of those and avoid the duplication.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15701
diff changeset
586 int cached_cnt = sizeof(cached_icons) / sizeof(HICON);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
587 systray_remove_nid();
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
588 DestroyWindow(systray_hwnd);
15501
d75099d2567e gaim_gtk to pidgin. I hope
Sean Egan <seanegan@gmail.com>
parents: 15461
diff changeset
589 pidgin_docklet_remove();
15701
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
590
15709
b2b756b59d81 Cache the converted docklet HICONs. Sean noticed that there are actually .ico files in pixmaps/tray/16 (something that I missed). I'm not sure if I should just use those and eliminate the stock pixmap to HICON conversion hackery or if we can just get rid of those and avoid the duplication.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15701
diff changeset
591 while (--cached_cnt >= 0) {
b2b756b59d81 Cache the converted docklet HICONs. Sean noticed that there are actually .ico files in pixmaps/tray/16 (something that I missed). I'm not sure if I should just use those and eliminate the stock pixmap to HICON conversion hackery or if we can just get rid of those and avoid the duplication.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15701
diff changeset
592 if (cached_icons[cached_cnt] != NULL)
b2b756b59d81 Cache the converted docklet HICONs. Sean noticed that there are actually .ico files in pixmaps/tray/16 (something that I missed). I'm not sure if I should just use those and eliminate the stock pixmap to HICON conversion hackery or if we can just get rid of those and avoid the duplication.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15701
diff changeset
593 DestroyIcon(cached_icons[cached_cnt]);
b2b756b59d81 Cache the converted docklet HICONs. Sean noticed that there are actually .ico files in pixmaps/tray/16 (something that I missed). I'm not sure if I should just use those and eliminate the stock pixmap to HICON conversion hackery or if we can just get rid of those and avoid the duplication.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15701
diff changeset
594 cached_icons[cached_cnt] = NULL;
b2b756b59d81 Cache the converted docklet HICONs. Sean noticed that there are actually .ico files in pixmaps/tray/16 (something that I missed). I'm not sure if I should just use those and eliminate the stock pixmap to HICON conversion hackery or if we can just get rid of those and avoid the duplication.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15701
diff changeset
595 }
b2b756b59d81 Cache the converted docklet HICONs. Sean noticed that there are actually .ico files in pixmaps/tray/16 (something that I missed). I'm not sure if I should just use those and eliminate the stock pixmap to HICON conversion hackery or if we can just get rid of those and avoid the duplication.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15701
diff changeset
596
15701
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
597 g_object_unref(image);
4a331e8d01df Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15515
diff changeset
598 image = NULL;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
599 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
600
15515
75ffc646647f Win32 de-gaimification of pidgin
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15501
diff changeset
601 static struct docklet_ui_ops winpidgin_tray_ops =
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
602 {
15515
75ffc646647f Win32 de-gaimification of pidgin
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15501
diff changeset
603 winpidgin_tray_create,
75ffc646647f Win32 de-gaimification of pidgin
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15501
diff changeset
604 winpidgin_tray_destroy,
75ffc646647f Win32 de-gaimification of pidgin
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15501
diff changeset
605 winpidgin_tray_update_icon,
75ffc646647f Win32 de-gaimification of pidgin
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15501
diff changeset
606 winpidgin_tray_blank_icon,
75ffc646647f Win32 de-gaimification of pidgin
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15501
diff changeset
607 winpidgin_tray_set_tooltip,
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
608 NULL
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
609 };
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
610
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
611 /* Used by docklet's plugin load func */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
612 void docklet_ui_init() {
15709
b2b756b59d81 Cache the converted docklet HICONs. Sean noticed that there are actually .ico files in pixmaps/tray/16 (something that I missed). I'm not sure if I should just use those and eliminate the stock pixmap to HICON conversion hackery or if we can just get rid of those and avoid the duplication.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15701
diff changeset
613 /* Initialize the cached icons to NULL */
b2b756b59d81 Cache the converted docklet HICONs. Sean noticed that there are actually .ico files in pixmaps/tray/16 (something that I missed). I'm not sure if I should just use those and eliminate the stock pixmap to HICON conversion hackery or if we can just get rid of those and avoid the duplication.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15701
diff changeset
614 ZeroMemory(cached_icons, sizeof(cached_icons));
b2b756b59d81 Cache the converted docklet HICONs. Sean noticed that there are actually .ico files in pixmaps/tray/16 (something that I missed). I'm not sure if I should just use those and eliminate the stock pixmap to HICON conversion hackery or if we can just get rid of those and avoid the duplication.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15701
diff changeset
615
15515
75ffc646647f Win32 de-gaimification of pidgin
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15501
diff changeset
616 pidgin_docklet_set_ui_ops(&winpidgin_tray_ops);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
617 }