pidgin/win32/gtkdocklet-win32.c

Sat, 03 Nov 2007 16:32:28 +0000

author
Will Thompson <resiak@pidgin.im>
date
Sat, 03 Nov 2007 16:32:28 +0000
branch
cpw.resiak.disconnectreason
changeset 21321
92eba625e29a
parent 20961
f69b1356bb55
child 20962
bca687215ee8
permissions
-rw-r--r--

Fix iterating over accounts_signed_on_elsewhere while doing things that will
cause it to change.

6278
d0cd8645bf90 [gaim-migrate @ 6777]
Herman Bloggs <herman@bluedigits.com>
parents: 6261
diff changeset
1 /*
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15562
diff changeset
2 * System tray icon (aka docklet) plugin for Winpidgin
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
3 *
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
4 * Copyright (C) 2002-3 Robert McQueen <robot101@debian.org>
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
5 * Copyright (C) 2003 Herman Bloggs <hermanator12002@yahoo.com>
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
6 * Inspired by a similar plugin by:
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
7 * John (J5) Palmieri <johnp@martianrock.com>
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15562
diff changeset
8 *
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
9 * This program is free software; you can redistribute it and/or
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
10 * modify it under the terms of the GNU General Public License as
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
11 * published by the Free Software Foundation; either version 2 of the
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
12 * License, or (at your option) any later version.
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
13 *
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful, but
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
17 * General Public License for more details.
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15562
diff changeset
18 *
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
20 * along with this program; if not, write to the Free Software
19859
71d37b57eff2 The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 19832
diff changeset
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
71d37b57eff2 The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 19832
diff changeset
22 * 02111-1301, USA.
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
23 */
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
24
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
25 #include <windows.h>
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
26 #include <gdk/gdkwin32.h>
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
27 #include <gdk/gdk.h>
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
28
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
29 #include "internal.h"
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
30 #include "gtkblist.h"
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
31 #include "debug.h"
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
32
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
33 #include "resource.h"
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
34 #include "MinimizeToTray.h"
14286
9ff15ceacd34 [gaim-migrate @ 16905]
Daniel Atallah <datallah@pidgin.im>
parents: 14253
diff changeset
35 #include "gtkwin32dep.h"
14745
d43256e1e6fd [gaim-migrate @ 17435]
Daniel Atallah <datallah@pidgin.im>
parents: 14743
diff changeset
36 #include "gtkdocklet.h"
15891
8703019e56de win32 fixes for s/gaim/purple/ stuff.
Daniel Atallah <datallah@pidgin.im>
parents: 15884
diff changeset
37 #include "pidginstock.h"
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
38
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
39 /*
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
40 * DEFINES, MACROS & DATA TYPES
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
41 */
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
42 #define WM_TRAYMESSAGE WM_USER /* User defined WM Message */
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
43
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
44 /*
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
45 * LOCALS
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
46 */
15765
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
47 static HWND systray_hwnd = NULL;
16996
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
48 /* additional two cached_icons entries for pending and connecting icons */
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
49 static HICON cached_icons[PURPLE_STATUS_NUM_PRIMITIVES + 2];
15765
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
50 static GtkWidget *image = NULL;
20142
af8e3a8b68df applied changes from 0a36aea71847198e73c07cbef0be7e7a7db12c57
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
51 /* This is used to trigger click events on so they appear to GTK+ as if they are triggered by input */
af8e3a8b68df applied changes from 0a36aea71847198e73c07cbef0be7e7a7db12c57
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
52 static GtkWidget *dummy_button = NULL;
af8e3a8b68df applied changes from 0a36aea71847198e73c07cbef0be7e7a7db12c57
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
53 static GtkWidget *dummy_window = NULL;
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15562
diff changeset
54 static NOTIFYICONDATA _nicon_data;
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
55
20142
af8e3a8b68df applied changes from 0a36aea71847198e73c07cbef0be7e7a7db12c57
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
56 static gboolean dummy_button_cb(GtkWidget *widget, GdkEventButton *event, gpointer user_data) {
af8e3a8b68df applied changes from 0a36aea71847198e73c07cbef0be7e7a7db12c57
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
57 pidgin_docklet_clicked(event->button);
af8e3a8b68df applied changes from 0a36aea71847198e73c07cbef0be7e7a7db12c57
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
58 return TRUE;
af8e3a8b68df applied changes from 0a36aea71847198e73c07cbef0be7e7a7db12c57
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
59 }
af8e3a8b68df applied changes from 0a36aea71847198e73c07cbef0be7e7a7db12c57
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
60
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
61 static LRESULT CALLBACK systray_mainmsg_handler(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
62 static UINT taskbarRestartMsg; /* static here means value is kept across multiple calls to this func */
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
63
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
64 switch(msg) {
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
65 case WM_CREATE:
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15834
diff changeset
66 purple_debug_info("docklet", "WM_CREATE\n");
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
67 taskbarRestartMsg = RegisterWindowMessage("TaskbarCreated");
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
68 break;
15765
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
69
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
70 case WM_TIMER:
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15834
diff changeset
71 purple_debug_info("docklet", "WM_TIMER\n");
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
72 break;
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
73
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
74 case WM_DESTROY:
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15834
diff changeset
75 purple_debug_info("docklet", "WM_DESTROY\n");
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
76 break;
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
77
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
78 case WM_TRAYMESSAGE:
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
79 {
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
80 int type = 0;
20142
af8e3a8b68df applied changes from 0a36aea71847198e73c07cbef0be7e7a7db12c57
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
81 GdkEvent *event;
af8e3a8b68df applied changes from 0a36aea71847198e73c07cbef0be7e7a7db12c57
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
82 GdkEventButton *event_btn;
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
83
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
84 /* We'll use Double Click - Single click over on linux */
14745
d43256e1e6fd [gaim-migrate @ 17435]
Daniel Atallah <datallah@pidgin.im>
parents: 14743
diff changeset
85 if(lparam == WM_LBUTTONDBLCLK)
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
86 type = 1;
14745
d43256e1e6fd [gaim-migrate @ 17435]
Daniel Atallah <datallah@pidgin.im>
parents: 14743
diff changeset
87 else if(lparam == WM_MBUTTONUP)
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
88 type = 2;
14745
d43256e1e6fd [gaim-migrate @ 17435]
Daniel Atallah <datallah@pidgin.im>
parents: 14743
diff changeset
89 else if(lparam == WM_RBUTTONUP)
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
90 type = 3;
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
91 else
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
92 break;
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
93
20142
af8e3a8b68df applied changes from 0a36aea71847198e73c07cbef0be7e7a7db12c57
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
94 gtk_widget_show_all(dummy_window);
af8e3a8b68df applied changes from 0a36aea71847198e73c07cbef0be7e7a7db12c57
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
95 event = gdk_event_new(GDK_BUTTON_PRESS);
af8e3a8b68df applied changes from 0a36aea71847198e73c07cbef0be7e7a7db12c57
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
96 event_btn = (GdkEventButton *) event;
af8e3a8b68df applied changes from 0a36aea71847198e73c07cbef0be7e7a7db12c57
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
97 event_btn->window = g_object_ref (gdk_get_default_root_window());
af8e3a8b68df applied changes from 0a36aea71847198e73c07cbef0be7e7a7db12c57
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
98 event_btn->send_event = TRUE;
af8e3a8b68df applied changes from 0a36aea71847198e73c07cbef0be7e7a7db12c57
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
99 event_btn->time = GetTickCount();
af8e3a8b68df applied changes from 0a36aea71847198e73c07cbef0be7e7a7db12c57
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
100 event_btn->axes = NULL;
af8e3a8b68df applied changes from 0a36aea71847198e73c07cbef0be7e7a7db12c57
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
101 event_btn->state = 0;
af8e3a8b68df applied changes from 0a36aea71847198e73c07cbef0be7e7a7db12c57
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
102 event_btn->button = type;
af8e3a8b68df applied changes from 0a36aea71847198e73c07cbef0be7e7a7db12c57
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
103 event_btn->device = gdk_display_get_default ()->core_pointer;
af8e3a8b68df applied changes from 0a36aea71847198e73c07cbef0be7e7a7db12c57
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
104 event->any.window = g_object_ref(dummy_window->window);
af8e3a8b68df applied changes from 0a36aea71847198e73c07cbef0be7e7a7db12c57
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
105 gdk_window_set_user_data(event->any.window, dummy_button);
af8e3a8b68df applied changes from 0a36aea71847198e73c07cbef0be7e7a7db12c57
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
106
af8e3a8b68df applied changes from 0a36aea71847198e73c07cbef0be7e7a7db12c57
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
107 gtk_main_do_event((GdkEvent *)event);
af8e3a8b68df applied changes from 0a36aea71847198e73c07cbef0be7e7a7db12c57
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
108 gtk_widget_hide(dummy_window);
af8e3a8b68df applied changes from 0a36aea71847198e73c07cbef0be7e7a7db12c57
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
109 gdk_event_free((GdkEvent *)event);
af8e3a8b68df applied changes from 0a36aea71847198e73c07cbef0be7e7a7db12c57
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
110
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
111 break;
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
112 }
14745
d43256e1e6fd [gaim-migrate @ 17435]
Daniel Atallah <datallah@pidgin.im>
parents: 14743
diff changeset
113 default:
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
114 if (msg == taskbarRestartMsg) {
14745
d43256e1e6fd [gaim-migrate @ 17435]
Daniel Atallah <datallah@pidgin.im>
parents: 14743
diff changeset
115 /* explorer crashed and left us hanging...
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
116 This will put the systray icon back in it's place, when it restarts */
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15562
diff changeset
117 Shell_NotifyIcon(NIM_ADD, &_nicon_data);
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
118 }
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
119 break;
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
120 }/* end switch */
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
121
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
122 return DefWindowProc(hwnd, msg, wparam, lparam);
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
123 }
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
124
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
125 /* Create hidden window to process systray messages */
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
126 static HWND systray_create_hiddenwin() {
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
127 WNDCLASSEX wcex;
14745
d43256e1e6fd [gaim-migrate @ 17435]
Daniel Atallah <datallah@pidgin.im>
parents: 14743
diff changeset
128 LPCTSTR wname;
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
129
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15562
diff changeset
130 wname = TEXT("WinpidginSystrayWinCls");
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
131
14745
d43256e1e6fd [gaim-migrate @ 17435]
Daniel Atallah <datallah@pidgin.im>
parents: 14743
diff changeset
132 wcex.cbSize = sizeof(wcex);
11709
da6e9cd5f6d9 [gaim-migrate @ 14000]
Casey Harkins <charkins@pidgin.im>
parents: 10520
diff changeset
133 wcex.style = 0;
14745
d43256e1e6fd [gaim-migrate @ 17435]
Daniel Atallah <datallah@pidgin.im>
parents: 14743
diff changeset
134 wcex.lpfnWndProc = systray_mainmsg_handler;
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
135 wcex.cbClsExtra = 0;
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
136 wcex.cbWndExtra = 0;
16058
dc1c7b09a058 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 <datallah@pidgin.im>
parents: 15891
diff changeset
137 wcex.hInstance = winpidgin_exe_hinstance();
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
138 wcex.hIcon = NULL;
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
139 wcex.hCursor = NULL,
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
140 wcex.hbrBackground = NULL;
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
141 wcex.lpszMenuName = NULL;
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
142 wcex.lpszClassName = wname;
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
143 wcex.hIconSm = NULL;
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
144
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
145 RegisterClassEx(&wcex);
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
146
9863
323e4fe28791 [gaim-migrate @ 10742]
Mark Doliner <markdoliner@pidgin.im>
parents: 9709
diff changeset
147 /* Create the window */
16058
dc1c7b09a058 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 <datallah@pidgin.im>
parents: 15891
diff changeset
148 return (CreateWindow(wname, "", 0, 0, 0, 0, 0, GetDesktopWindow(), NULL, winpidgin_exe_hinstance(), 0));
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
149 }
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
150
15765
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
151 static void systray_init_icon(HWND hWnd) {
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15562
diff changeset
152 ZeroMemory(&_nicon_data, sizeof(_nicon_data));
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15562
diff changeset
153 _nicon_data.cbSize = sizeof(NOTIFYICONDATA);
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15562
diff changeset
154 _nicon_data.hWnd = hWnd;
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15562
diff changeset
155 _nicon_data.uID = 0;
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15562
diff changeset
156 _nicon_data.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15562
diff changeset
157 _nicon_data.uCallbackMessage = WM_TRAYMESSAGE;
15765
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
158 _nicon_data.hIcon = NULL;
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15562
diff changeset
159 lstrcpy(_nicon_data.szTip, PIDGIN_NAME);
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15562
diff changeset
160 Shell_NotifyIcon(NIM_ADD, &_nicon_data);
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15522
diff changeset
161 pidgin_docklet_embedded();
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
162 }
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
163
15765
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
164 /* This is ganked from GTK+.
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
165 * When we can use GTK+ 2.10 and the GtkStatusIcon stuff, this will no longer be necesary */
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
166 #define WIN32_GDI_FAILED(api) printf("GDI FAILED %s\n", api)
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
167
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
168 static gboolean
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
169 _gdk_win32_pixbuf_to_hicon_supports_alpha (void)
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
170 {
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
171 static gboolean is_win_xp=FALSE, is_win_xp_checked=FALSE;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
172
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
173 if (!is_win_xp_checked)
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
174 {
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
175 is_win_xp_checked = TRUE;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
176
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
177 if (!G_WIN32_IS_NT_BASED ())
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
178 is_win_xp = FALSE;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
179 else
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
180 {
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
181 OSVERSIONINFO version;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
182
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
183 memset (&version, 0, sizeof (version));
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
184 version.dwOSVersionInfoSize = sizeof (version);
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
185 is_win_xp = GetVersionEx (&version)
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
186 && version.dwPlatformId == VER_PLATFORM_WIN32_NT
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
187 && (version.dwMajorVersion > 5
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
188 || (version.dwMajorVersion == 5 && version.dwMinorVersion >= 1));
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
189 }
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
190 }
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
191 return is_win_xp;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
192 }
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
193
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
194 static HBITMAP
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
195 create_alpha_bitmap (gint size,
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
196 guchar **outdata)
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
197 {
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
198 BITMAPV5HEADER bi;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
199 HDC hdc;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
200 HBITMAP hBitmap;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
201
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
202 ZeroMemory (&bi, sizeof (BITMAPV5HEADER));
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
203 bi.bV5Size = sizeof (BITMAPV5HEADER);
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
204 bi.bV5Height = bi.bV5Width = size;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
205 bi.bV5Planes = 1;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
206 bi.bV5BitCount = 32;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
207 bi.bV5Compression = BI_BITFIELDS;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
208 /* The following mask specification specifies a supported 32 BPP
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
209 * alpha format for Windows XP (BGRA format).
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
210 */
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
211 bi.bV5RedMask = 0x00FF0000;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
212 bi.bV5GreenMask = 0x0000FF00;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
213 bi.bV5BlueMask = 0x000000FF;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
214 bi.bV5AlphaMask = 0xFF000000;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
215
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
216 /* Create the DIB section with an alpha channel. */
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
217 hdc = GetDC (NULL);
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
218 if (!hdc)
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
219 {
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
220 WIN32_GDI_FAILED ("GetDC");
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
221 return NULL;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
222 }
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
223 hBitmap = CreateDIBSection (hdc, (BITMAPINFO *)&bi, DIB_RGB_COLORS,
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
224 (PVOID *) outdata, NULL, (DWORD)0);
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
225 if (hBitmap == NULL)
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
226 WIN32_GDI_FAILED ("CreateDIBSection");
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
227 ReleaseDC (NULL, hdc);
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
228
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
229 return hBitmap;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
230 }
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
231
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
232 static HBITMAP
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
233 create_color_bitmap (gint size,
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
234 guchar **outdata,
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
235 gint bits)
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
236 {
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
237 struct {
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
238 BITMAPV4HEADER bmiHeader;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
239 RGBQUAD bmiColors[2];
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
240 } bmi;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
241 HDC hdc;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
242 HBITMAP hBitmap;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
243
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
244 ZeroMemory (&bmi, sizeof (bmi));
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
245 bmi.bmiHeader.bV4Size = sizeof (BITMAPV4HEADER);
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
246 bmi.bmiHeader.bV4Height = bmi.bmiHeader.bV4Width = size;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
247 bmi.bmiHeader.bV4Planes = 1;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
248 bmi.bmiHeader.bV4BitCount = bits;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
249 bmi.bmiHeader.bV4V4Compression = BI_RGB;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
250
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
251 /* when bits is 1, these will be used.
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
252 * bmiColors[0] already zeroed from ZeroMemory()
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
253 */
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
254 bmi.bmiColors[1].rgbBlue = 0xFF;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
255 bmi.bmiColors[1].rgbGreen = 0xFF;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
256 bmi.bmiColors[1].rgbRed = 0xFF;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
257
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
258 hdc = GetDC (NULL);
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
259 if (!hdc)
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
260 {
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
261 WIN32_GDI_FAILED ("GetDC");
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
262 return NULL;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
263 }
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
264 hBitmap = CreateDIBSection (hdc, (BITMAPINFO *)&bmi, DIB_RGB_COLORS,
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
265 (PVOID *) outdata, NULL, (DWORD)0);
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
266 if (hBitmap == NULL)
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
267 WIN32_GDI_FAILED ("CreateDIBSection");
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
268 ReleaseDC (NULL, hdc);
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
269
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
270 return hBitmap;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
271 }
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
272
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
273 static gboolean
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
274 pixbuf_to_hbitmaps_alpha_winxp (GdkPixbuf *pixbuf,
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
275 HBITMAP *color,
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
276 HBITMAP *mask)
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
277 {
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
278 /* Based on code from
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
279 * http://www.dotnet247.com/247reference/msgs/13/66301.aspx
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
280 */
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
281 HBITMAP hColorBitmap, hMaskBitmap;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
282 guchar *indata, *inrow;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
283 guchar *colordata, *colorrow, *maskdata, *maskbyte;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
284 gint width, height, size, i, i_offset, j, j_offset, rowstride;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
285 guint maskstride, mask_bit;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
286
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
287 width = gdk_pixbuf_get_width (pixbuf); /* width of icon */
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
288 height = gdk_pixbuf_get_height (pixbuf); /* height of icon */
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
289
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
290 /* The bitmaps are created square */
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
291 size = MAX (width, height);
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
292
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
293 hColorBitmap = create_alpha_bitmap (size, &colordata);
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
294 if (!hColorBitmap)
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
295 return FALSE;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
296 hMaskBitmap = create_color_bitmap (size, &maskdata, 1);
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
297 if (!hMaskBitmap)
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
298 {
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
299 DeleteObject (hColorBitmap);
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
300 return FALSE;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
301 }
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
302
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
303 /* MSDN says mask rows are aligned to "LONG" boundaries */
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
304 maskstride = (((size + 31) & ~31) >> 3);
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
305
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
306 indata = gdk_pixbuf_get_pixels (pixbuf);
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
307 rowstride = gdk_pixbuf_get_rowstride (pixbuf);
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
308
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
309 if (width > height)
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
310 {
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
311 i_offset = 0;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
312 j_offset = (width - height) / 2;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
313 }
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
314 else
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
315 {
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
316 i_offset = (height - width) / 2;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
317 j_offset = 0;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
318 }
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
319
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
320 for (j = 0; j < height; j++)
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
321 {
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
322 colorrow = colordata + 4*(j+j_offset)*size + 4*i_offset;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
323 maskbyte = maskdata + (j+j_offset)*maskstride + i_offset/8;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
324 mask_bit = (0x80 >> (i_offset % 8));
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
325 inrow = indata + (height-j-1)*rowstride;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
326 for (i = 0; i < width; i++)
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
327 {
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
328 colorrow[4*i+0] = inrow[4*i+2];
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
329 colorrow[4*i+1] = inrow[4*i+1];
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
330 colorrow[4*i+2] = inrow[4*i+0];
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
331 colorrow[4*i+3] = inrow[4*i+3];
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
332 if (inrow[4*i+3] == 0)
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
333 maskbyte[0] |= mask_bit; /* turn ON bit */
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
334 else
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
335 maskbyte[0] &= ~mask_bit; /* turn OFF bit */
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
336 mask_bit >>= 1;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
337 if (mask_bit == 0)
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
338 {
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
339 mask_bit = 0x80;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
340 maskbyte++;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
341 }
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
342 }
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
343 }
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
344
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
345 *color = hColorBitmap;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
346 *mask = hMaskBitmap;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
347
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
348 return TRUE;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
349 }
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
350
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
351 static gboolean
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
352 pixbuf_to_hbitmaps_normal (GdkPixbuf *pixbuf,
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
353 HBITMAP *color,
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
354 HBITMAP *mask)
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
355 {
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
356 /* Based on code from
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
357 * http://www.dotnet247.com/247reference/msgs/13/66301.aspx
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
358 */
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
359 HBITMAP hColorBitmap, hMaskBitmap;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
360 guchar *indata, *inrow;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
361 guchar *colordata, *colorrow, *maskdata, *maskbyte;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
362 gint width, height, size, i, i_offset, j, j_offset, rowstride, nc, bmstride;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
363 gboolean has_alpha;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
364 guint maskstride, mask_bit;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
365
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
366 width = gdk_pixbuf_get_width (pixbuf); /* width of icon */
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
367 height = gdk_pixbuf_get_height (pixbuf); /* height of icon */
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
368
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
369 /* The bitmaps are created square */
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
370 size = MAX (width, height);
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
371
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
372 hColorBitmap = create_color_bitmap (size, &colordata, 24);
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
373 if (!hColorBitmap)
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
374 return FALSE;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
375 hMaskBitmap = create_color_bitmap (size, &maskdata, 1);
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
376 if (!hMaskBitmap)
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
377 {
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
378 DeleteObject (hColorBitmap);
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
379 return FALSE;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
380 }
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
381
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
382 /* rows are always aligned on 4-byte boundarys */
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
383 bmstride = size * 3;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
384 if (bmstride % 4 != 0)
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
385 bmstride += 4 - (bmstride % 4);
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
386
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
387 /* MSDN says mask rows are aligned to "LONG" boundaries */
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
388 maskstride = (((size + 31) & ~31) >> 3);
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
389
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
390 indata = gdk_pixbuf_get_pixels (pixbuf);
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
391 rowstride = gdk_pixbuf_get_rowstride (pixbuf);
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
392 nc = gdk_pixbuf_get_n_channels (pixbuf);
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
393 has_alpha = gdk_pixbuf_get_has_alpha (pixbuf);
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
394
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
395 if (width > height)
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
396 {
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
397 i_offset = 0;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
398 j_offset = (width - height) / 2;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
399 }
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
400 else
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
401 {
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
402 i_offset = (height - width) / 2;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
403 j_offset = 0;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
404 }
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
405
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
406 for (j = 0; j < height; j++)
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
407 {
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
408 colorrow = colordata + (j+j_offset)*bmstride + 3*i_offset;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
409 maskbyte = maskdata + (j+j_offset)*maskstride + i_offset/8;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
410 mask_bit = (0x80 >> (i_offset % 8));
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
411 inrow = indata + (height-j-1)*rowstride;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
412 for (i = 0; i < width; i++)
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
413 {
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
414 if (has_alpha && inrow[nc*i+3] < 128)
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
415 {
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
416 colorrow[3*i+0] = colorrow[3*i+1] = colorrow[3*i+2] = 0;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
417 maskbyte[0] |= mask_bit; /* turn ON bit */
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
418 }
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
419 else
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
420 {
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
421 colorrow[3*i+0] = inrow[nc*i+2];
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
422 colorrow[3*i+1] = inrow[nc*i+1];
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
423 colorrow[3*i+2] = inrow[nc*i+0];
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
424 maskbyte[0] &= ~mask_bit; /* turn OFF bit */
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
425 }
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
426 mask_bit >>= 1;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
427 if (mask_bit == 0)
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
428 {
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
429 mask_bit = 0x80;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
430 maskbyte++;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
431 }
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
432 }
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
433 }
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
434
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
435 *color = hColorBitmap;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
436 *mask = hMaskBitmap;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
437
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
438 return TRUE;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
439 }
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
440
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
441 static HICON
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
442 pixbuf_to_hicon (GdkPixbuf *pixbuf)
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
443 {
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
444 gint x = 0, y = 0;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
445 gboolean is_icon = TRUE;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
446 ICONINFO ii;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
447 HICON icon;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
448 gboolean success;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
449
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
450 if (pixbuf == NULL)
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
451 return NULL;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
452
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
453 if (_gdk_win32_pixbuf_to_hicon_supports_alpha() && gdk_pixbuf_get_has_alpha (pixbuf))
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
454 success = pixbuf_to_hbitmaps_alpha_winxp (pixbuf, &ii.hbmColor, &ii.hbmMask);
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
455 else
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
456 success = pixbuf_to_hbitmaps_normal (pixbuf, &ii.hbmColor, &ii.hbmMask);
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
457
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
458 if (!success)
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
459 return NULL;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
460
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
461 ii.fIcon = is_icon;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
462 ii.xHotspot = x;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
463 ii.yHotspot = y;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
464 icon = CreateIconIndirect (&ii);
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
465 DeleteObject (ii.hbmColor);
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
466 DeleteObject (ii.hbmMask);
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
467 return icon;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
468 }
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
469
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
470 static HICON load_hicon_from_stock(const char *stock) {
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
471 HICON hicon = NULL;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
472 GdkPixbuf *pixbuf = gtk_widget_render_icon(image, stock,
15834
ba09306a7b0a 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@pidgin.im>
parents: 15774
diff changeset
473 gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL), NULL);
15765
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
474
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
475 if (pixbuf) {
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
476 hicon = pixbuf_to_hicon(pixbuf);
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
477 g_object_unref(pixbuf);
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
478 } else
19832
84b69b21672b Patch from QuLogic. Fixes #2903 ('Missing newlines in debug messages.')
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16996
diff changeset
479 purple_debug_error("docklet", "Unable to load pixbuf for %s.\n", stock);
15765
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
480
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
481 return hicon;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
482 }
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
483
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
484
15770
e0454c66f042 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 <datallah@pidgin.im>
parents: 15765
diff changeset
485 static void systray_change_icon(HICON hicon) {
15765
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
486 g_return_if_fail(hicon != NULL);
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
487
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
488 _nicon_data.hIcon = hicon;
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15562
diff changeset
489 Shell_NotifyIcon(NIM_MODIFY, &_nicon_data);
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
490 }
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
491
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
492 static void systray_remove_nid(void) {
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15562
diff changeset
493 Shell_NotifyIcon(NIM_DELETE, &_nicon_data);
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
494 }
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
495
16996
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
496 static void winpidgin_tray_update_icon(PurpleStatusPrimitive status,
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
497 gboolean connecting, gboolean pending) {
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
498
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
499 int icon_index;
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
500 g_return_if_fail(image != NULL);
15765
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
501
16996
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
502 if(connecting)
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
503 icon_index = PURPLE_STATUS_NUM_PRIMITIVES;
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
504 else if(pending)
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
505 icon_index = PURPLE_STATUS_NUM_PRIMITIVES+1;
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
506 else
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
507 icon_index = status;
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
508
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
509 g_return_if_fail(icon_index < (sizeof(cached_icons) / sizeof(HICON)));
15765
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
510
15770
e0454c66f042 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 <datallah@pidgin.im>
parents: 15765
diff changeset
511 /* Look up and cache the HICON if we don't already have it */
16996
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
512 if (cached_icons[icon_index] == NULL) {
15770
e0454c66f042 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 <datallah@pidgin.im>
parents: 15765
diff changeset
513 const gchar *icon_name = NULL;
16996
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
514 switch (status) {
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
515 case PURPLE_STATUS_OFFLINE:
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
516 icon_name = PIDGIN_STOCK_TRAY_OFFLINE;
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
517 break;
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
518 case PURPLE_STATUS_AWAY:
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
519 icon_name = PIDGIN_STOCK_TRAY_AWAY;
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
520 break;
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
521 case PURPLE_STATUS_UNAVAILABLE:
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
522 icon_name = PIDGIN_STOCK_TRAY_BUSY;
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
523 break;
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
524 case PURPLE_STATUS_EXTENDED_AWAY:
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
525 icon_name = PIDGIN_STOCK_TRAY_XA;
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
526 break;
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
527 case PURPLE_STATUS_INVISIBLE:
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
528 icon_name = PIDGIN_STOCK_TRAY_INVISIBLE;
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
529 break;
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
530 default:
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
531 icon_name = PIDGIN_STOCK_TRAY_AVAILABLE;
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
532 break;
15770
e0454c66f042 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 <datallah@pidgin.im>
parents: 15765
diff changeset
533 }
e0454c66f042 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 <datallah@pidgin.im>
parents: 15765
diff changeset
534
16996
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
535 if (pending)
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
536 icon_name = PIDGIN_STOCK_TRAY_PENDING;
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
537 if (connecting)
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
538 icon_name = PIDGIN_STOCK_TRAY_CONNECT;
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
539
15770
e0454c66f042 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 <datallah@pidgin.im>
parents: 15765
diff changeset
540 g_return_if_fail(icon_name != NULL);
e0454c66f042 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 <datallah@pidgin.im>
parents: 15765
diff changeset
541
16996
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
542 cached_icons[icon_index] = load_hicon_from_stock(icon_name);
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
543 }
15765
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
544
16996
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
545 systray_change_icon(cached_icons[icon_index]);
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
546 }
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
547
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15562
diff changeset
548 static void winpidgin_tray_blank_icon() {
15765
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
549 _nicon_data.hIcon = NULL;
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
550 Shell_NotifyIcon(NIM_MODIFY, &_nicon_data);
12471
5d7c12d525ed [gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents: 12016
diff changeset
551 }
5d7c12d525ed [gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents: 12016
diff changeset
552
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15562
diff changeset
553 static void winpidgin_tray_set_tooltip(gchar *tooltip) {
12471
5d7c12d525ed [gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents: 12016
diff changeset
554 if (tooltip) {
5d7c12d525ed [gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents: 12016
diff changeset
555 char *locenc = NULL;
5d7c12d525ed [gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents: 12016
diff changeset
556 locenc = g_locale_from_utf8(tooltip, -1, NULL, NULL, NULL);
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15562
diff changeset
557 lstrcpyn(_nicon_data.szTip, locenc, sizeof(_nicon_data.szTip) / sizeof(TCHAR));
12471
5d7c12d525ed [gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents: 12016
diff changeset
558 g_free(locenc);
5d7c12d525ed [gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents: 12016
diff changeset
559 } else {
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15562
diff changeset
560 lstrcpy(_nicon_data.szTip, PIDGIN_NAME);
12471
5d7c12d525ed [gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents: 12016
diff changeset
561 }
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15562
diff changeset
562 Shell_NotifyIcon(NIM_MODIFY, &_nicon_data);
6894
8c6e286b079d [gaim-migrate @ 7441]
Herman Bloggs <herman@bluedigits.com>
parents: 6425
diff changeset
563 }
8c6e286b079d [gaim-migrate @ 7441]
Herman Bloggs <herman@bluedigits.com>
parents: 6425
diff changeset
564
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15562
diff changeset
565 static void winpidgin_tray_minimize(PidginBuddyList *gtkblist) {
12016
0517ad5d0196 [gaim-migrate @ 14309]
Casey Harkins <charkins@pidgin.im>
parents: 11709
diff changeset
566 MinimizeWndToTray(GDK_WINDOW_HWND(gtkblist->window->window));
0517ad5d0196 [gaim-migrate @ 14309]
Casey Harkins <charkins@pidgin.im>
parents: 11709
diff changeset
567 }
0517ad5d0196 [gaim-migrate @ 14309]
Casey Harkins <charkins@pidgin.im>
parents: 11709
diff changeset
568
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15562
diff changeset
569 static void winpidgin_tray_maximize(PidginBuddyList *gtkblist) {
12016
0517ad5d0196 [gaim-migrate @ 14309]
Casey Harkins <charkins@pidgin.im>
parents: 11709
diff changeset
570 RestoreWndFromTray(GDK_WINDOW_HWND(gtkblist->window->window));
0517ad5d0196 [gaim-migrate @ 14309]
Casey Harkins <charkins@pidgin.im>
parents: 11709
diff changeset
571 }
0517ad5d0196 [gaim-migrate @ 14309]
Casey Harkins <charkins@pidgin.im>
parents: 11709
diff changeset
572
20961
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
573 /* Checks to see if a window matches a specified name. If it matches,
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
574 * the matched_hwnd pointer is set to the checked window.
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
575 *
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
576 * hwnd is the window to check
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
577 * matched_hwnd points to hwnd on a match
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
578 * name is the expected class name
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
579 *
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
580 * returns TRUE if there was a match, otherwise FALSE
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
581 */
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
582 static BOOL
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
583 check_hwnd_class_name(HWND hwnd, HWND *matched_hwnd, char *name)
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
584 {
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
585 TCHAR class_name[256];
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
586
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
587 /* get class name of window */
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
588 GetClassName(hwnd, class_name, 255);
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
589
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
590 /* compare class name with specified name */
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
591 if(strncmp(class_name, name, 255)!=0) return FALSE;
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
592
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
593 /* set matched_hwnd to hwnd */
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
594 *matched_hwnd = hwnd;
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
595 return TRUE;
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
596 }
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
597
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
598 /* callback for EnumChildWindows looking for TrayNotifyWnd */
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
599 static BOOL CALLBACK
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
600 find_tray_notify_hwnd_cb(HWND hwnd, LPARAM lparam)
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
601 {
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
602 return !check_hwnd_class_name(hwnd, (HWND*)lparam, "TrayNotifyWnd");
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
603 }
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
604
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
605 /* callback for EnumChildWindows looking for ToolbarWindow32 */
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
606 static BOOL CALLBACK
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
607 find_tray_toolbar_hwnd_cb(HWND hwnd, LPARAM lparam)
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
608 {
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
609 return !check_hwnd_class_name(hwnd, (HWND*)lparam, "ToolbarWindow32");
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
610 }
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
611
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
612 static HWND
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
613 get_tray_toolbar_hwnd()
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
614 {
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
615 HWND shell_tray_hwnd = NULL;
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
616 HWND tray_notify_hwnd = NULL;
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
617 HWND tray_toolbar_hwnd = NULL;
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
618
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
619 /* find the top-level window of the system tray area */
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
620 shell_tray_hwnd = FindWindow("Shell_TrayWnd", NULL);
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
621 if(!shell_tray_hwnd) return NULL;
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
622
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
623 /* enumerate over the shell_tray_hwnd children windows looking for the tray_notify_hwnd */
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
624 EnumChildWindows(shell_tray_hwnd, find_tray_notify_hwnd_cb, (LPARAM)&tray_notify_hwnd);
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
625 if(!tray_notify_hwnd || !IsWindow(tray_notify_hwnd)) return NULL;
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
626
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
627 /* enumerate over the tray_notify_hwnd children windows looking for tray_toolbar_hwnd */
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
628 EnumChildWindows(tray_notify_hwnd, find_tray_toolbar_hwnd_cb, (LPARAM)&tray_toolbar_hwnd);
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
629 if(!tray_toolbar_hwnd || !IsWindow(tray_toolbar_hwnd)) return NULL;
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
630
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
631 return tray_toolbar_hwnd;
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
632 }
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
633
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
634
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
635 /* Get the geometry of the tray icon. This might break if the user is running a
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
636 * non-standard shell, in which case this function will return FALSE. If the
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
637 * tray icon is hidden (possible >= winxp), then the geometry of the tray itself
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
638 * is returned. If FALSE is returned, x, y, w and h are left unchanged.
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
639 * Any of the parameters (x, y, w, h) may be NULL if that value is not
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
640 * desired.
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
641 *
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
642 * This code is based on the method and code described here by Irek Zielinski:
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
643 * http://www.codeproject.com/shell/ctrayiconposition.asp?msg=999295
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
644 */
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
645 static gboolean
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
646 winpidgin_tray_get_geometry(gint *x, gint *y, gint *w, gint *h)
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
647 {
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
648 /* systray_hwnd is the parent window of our systray icon */
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
649 HWND tray_toolbar_hwnd = NULL;
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
650 DWORD tray_toolbar_pid = -1;
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
651 HANDLE tray_toolbar_proc = NULL;
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
652 int tray_toolbar_bcount = 0;
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
653 LPVOID tray_toolbar_mem = NULL;
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
654
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
655 TBBUTTON button;
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
656 DWORD nbytes = -1;
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
657 DWORD hwnd_id_pair[2] = { -1, -1};
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
658 RECT rect;
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
659 POINT top_left;
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
660 POINT bot_right;
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
661 gboolean found_docklet = FALSE;
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
662 int i;
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
663
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
664 /* get the tray_toolbar_hwnd */
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
665 tray_toolbar_hwnd = get_tray_toolbar_hwnd();
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
666 if(!tray_toolbar_hwnd) {
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
667 return FALSE;
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
668 }
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
669
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
670 /* count buttons in the tray_toolbar_hwnd */
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
671 tray_toolbar_bcount = SendMessage(tray_toolbar_hwnd, TB_BUTTONCOUNT, 0, 0);
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
672 if(tray_toolbar_bcount < 1) {
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
673 return FALSE;
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
674 }
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
675
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
676 /* get pid of the tray_toolbar_hwnd parent process */
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
677 GetWindowThreadProcessId(tray_toolbar_hwnd, &tray_toolbar_pid);
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
678 if(tray_toolbar_pid <= 0) {
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
679 return FALSE;
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
680 }
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
681
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
682 /* open the tray_toolbar_hwnd parent process */
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
683 tray_toolbar_proc = OpenProcess(PROCESS_ALL_ACCESS, 0, tray_toolbar_pid);
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
684 if(!tray_toolbar_proc) {
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
685 return FALSE;
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
686 }
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
687
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
688 /* allocate some memory in the tray_toolbar_hwnd process space */
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
689 tray_toolbar_mem = VirtualAllocEx(tray_toolbar_proc, NULL, sizeof(TBBUTTON), MEM_COMMIT, PAGE_READWRITE);
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
690 if(!tray_toolbar_mem) {
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
691 CloseHandle(tray_toolbar_proc);
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
692 return FALSE;
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
693 }
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
694
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
695 /* loop through buttons, looking for the docklet */
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
696 for(i=0; i<tray_toolbar_bcount; i++) {
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
697
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
698 /* get the button */
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
699 SendMessage(tray_toolbar_hwnd, TB_GETBUTTON, i, (LPARAM)tray_toolbar_mem);
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
700 ReadProcessMemory(tray_toolbar_proc, tray_toolbar_mem, &button, sizeof(TBBUTTON), &nbytes);
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
701 if(nbytes < sizeof(TBBUTTON)) {
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
702 continue;
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
703 }
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
704
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
705 /* get the dwData from the button */
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
706 ReadProcessMemory(tray_toolbar_proc, (LPVOID)button.dwData, &hwnd_id_pair, sizeof(hwnd_id_pair), &nbytes);
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
707 if(nbytes < sizeof(hwnd_id_pair)) {
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
708 continue;
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
709 }
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
710
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
711 /* compare hwnd of button against systray_hwnd */
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
712 if((HWND)hwnd_id_pair[0] != systray_hwnd) {
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
713 continue;
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
714 }
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
715
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
716 /* check if button is hidden */
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
717 if(button.fsState & TBSTATE_HIDDEN) {
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
718 break;
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
719 }
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
720
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
721 /* get RECT of docklet icon */
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
722 SendMessage(tray_toolbar_hwnd, TB_GETITEMRECT, i, (LPARAM)tray_toolbar_mem);
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
723 ReadProcessMemory(tray_toolbar_proc, tray_toolbar_mem, &rect, sizeof(RECT), &nbytes);
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
724 if(nbytes < sizeof(RECT)) {
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
725 break;
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
726 }
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
727
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
728 /* translate to screen coordinates */
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
729 top_left.x = rect.left;
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
730 top_left.y = rect.top;
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
731 bot_right.x = rect.right;
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
732 bot_right.y = rect.bottom;
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
733
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
734 MapWindowPoints(tray_toolbar_hwnd, NULL, (LPPOINT)&top_left, 1);
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
735 MapWindowPoints(tray_toolbar_hwnd, NULL, (LPPOINT)&bot_right, 1);
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
736
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
737 found_docklet = TRUE;
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
738 break;
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
739 }
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
740
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
741 if(!found_docklet) {
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
742 /* fallback on geometry of tray itself */
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
743 GetWindowRect(tray_toolbar_hwnd, &rect);
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
744 if(x!=NULL) *x = rect.left;
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
745 if(y!=NULL) *y = rect.top;
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
746 if(w!=NULL) *w = rect.right - rect.left;
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
747 if(h!=NULL) *h = rect.bottom - rect.top;
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
748 } else {
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
749 if(x!=NULL) *x = top_left.x;
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
750 if(y!=NULL) *y = top_left.y;
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
751 if(w!=NULL) *w = bot_right.x - top_left.x;
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
752 if(h!=NULL) *h = bot_right.y - top_left.y;
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
753 }
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
754
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
755 /* clean up */
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
756 VirtualFreeEx(tray_toolbar_proc, tray_toolbar_mem, 0, MEM_RELEASE);
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
757 CloseHandle(tray_toolbar_proc);
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
758 return TRUE;
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
759 }
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
760
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
761 static GObject *
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
762 winpidgin_tray_get_gdk_screen()
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
763 {
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
764 return (GObject *)gdk_screen_get_default();
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
765 }
12016
0517ad5d0196 [gaim-migrate @ 14309]
Casey Harkins <charkins@pidgin.im>
parents: 11709
diff changeset
766
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15562
diff changeset
767 static void winpidgin_tray_create() {
16058
dc1c7b09a058 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 <datallah@pidgin.im>
parents: 15891
diff changeset
768 OSVERSIONINFO osinfo;
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
769 /* dummy window to process systray messages */
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
770 systray_hwnd = systray_create_hiddenwin();
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
771
20142
af8e3a8b68df applied changes from 0a36aea71847198e73c07cbef0be7e7a7db12c57
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
772 dummy_window = gtk_window_new(GTK_WINDOW_POPUP);
af8e3a8b68df applied changes from 0a36aea71847198e73c07cbef0be7e7a7db12c57
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
773 dummy_button = gtk_button_new();
af8e3a8b68df applied changes from 0a36aea71847198e73c07cbef0be7e7a7db12c57
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
774 gtk_container_add(GTK_CONTAINER(dummy_window), dummy_button);
af8e3a8b68df applied changes from 0a36aea71847198e73c07cbef0be7e7a7db12c57
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
775
af8e3a8b68df applied changes from 0a36aea71847198e73c07cbef0be7e7a7db12c57
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
776 /* We trigger the click event indirectly so that gtk_get_current_event_state() is TRUE when the event is handled */
af8e3a8b68df applied changes from 0a36aea71847198e73c07cbef0be7e7a7db12c57
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
777 g_signal_connect(G_OBJECT(dummy_button), "button-press-event",
af8e3a8b68df applied changes from 0a36aea71847198e73c07cbef0be7e7a7db12c57
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
778 G_CALLBACK(dummy_button_cb), NULL);
af8e3a8b68df applied changes from 0a36aea71847198e73c07cbef0be7e7a7db12c57
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
779
15765
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
780 image = gtk_image_new();
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
781 #if GLIB_CHECK_VERSION(2,10,0)
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
782 g_object_ref_sink(image);
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
783 #else
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
784 g_object_ref(image);
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
785 gtk_object_sink(GTK_OBJECT(image));
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
786 #endif
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
787
16058
dc1c7b09a058 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 <datallah@pidgin.im>
parents: 15891
diff changeset
788 osinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
dc1c7b09a058 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 <datallah@pidgin.im>
parents: 15891
diff changeset
789 GetVersionEx(&osinfo);
dc1c7b09a058 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 <datallah@pidgin.im>
parents: 15891
diff changeset
790
dc1c7b09a058 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 <datallah@pidgin.im>
parents: 15891
diff changeset
791 /* Load icons, and init systray notify icon
dc1c7b09a058 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 <datallah@pidgin.im>
parents: 15891
diff changeset
792 * NOTE: Windows < XP only supports displaying 4-bit images in the Systray,
dc1c7b09a058 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 <datallah@pidgin.im>
parents: 15891
diff changeset
793 * 2K and ME will use the highest color depth that the desktop will support,
dc1c7b09a058 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 <datallah@pidgin.im>
parents: 15891
diff changeset
794 * but will scale it back to 4-bits for display.
dc1c7b09a058 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 <datallah@pidgin.im>
parents: 15891
diff changeset
795 * That is why we use custom 4-bit icons for pre XP Windowses */
dc1c7b09a058 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 <datallah@pidgin.im>
parents: 15891
diff changeset
796 if (osinfo.dwMajorVersion < 5 || (osinfo.dwMajorVersion == 5 && osinfo.dwMinorVersion == 0))
dc1c7b09a058 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 <datallah@pidgin.im>
parents: 15891
diff changeset
797 {
16996
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
798 cached_icons[PURPLE_STATUS_OFFLINE] = (HICON) LoadImage(winpidgin_dll_hinstance(),
16058
dc1c7b09a058 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 <datallah@pidgin.im>
parents: 15891
diff changeset
799 MAKEINTRESOURCE(PIDGIN_TRAY_OFFLINE_4BIT), IMAGE_ICON, 16, 16, LR_CREATEDIBSECTION);
16996
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
800 cached_icons[PURPLE_STATUS_AVAILABLE] = (HICON) LoadImage(winpidgin_dll_hinstance(),
16058
dc1c7b09a058 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 <datallah@pidgin.im>
parents: 15891
diff changeset
801 MAKEINTRESOURCE(PIDGIN_TRAY_AVAILABLE_4BIT), IMAGE_ICON, 16, 16, LR_CREATEDIBSECTION);
16996
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
802 cached_icons[PURPLE_STATUS_AWAY] = (HICON) LoadImage(winpidgin_dll_hinstance(),
16058
dc1c7b09a058 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 <datallah@pidgin.im>
parents: 15891
diff changeset
803 MAKEINTRESOURCE(PIDGIN_TRAY_AWAY_4BIT), IMAGE_ICON, 16, 16, LR_CREATEDIBSECTION);
16996
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
804 cached_icons[PURPLE_STATUS_EXTENDED_AWAY] = (HICON) LoadImage(winpidgin_dll_hinstance(),
16058
dc1c7b09a058 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 <datallah@pidgin.im>
parents: 15891
diff changeset
805 MAKEINTRESOURCE(PIDGIN_TRAY_XA_4BIT), IMAGE_ICON, 16, 16, LR_CREATEDIBSECTION);
16996
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
806 cached_icons[PURPLE_STATUS_UNAVAILABLE] = (HICON) LoadImage(winpidgin_dll_hinstance(),
16058
dc1c7b09a058 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 <datallah@pidgin.im>
parents: 15891
diff changeset
807 MAKEINTRESOURCE(PIDGIN_TRAY_BUSY_4BIT), IMAGE_ICON, 16, 16, LR_CREATEDIBSECTION);
16996
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
808 cached_icons[PURPLE_STATUS_NUM_PRIMITIVES] = (HICON) LoadImage(winpidgin_dll_hinstance(),
16058
dc1c7b09a058 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 <datallah@pidgin.im>
parents: 15891
diff changeset
809 MAKEINTRESOURCE(PIDGIN_TRAY_CONNECTING_4BIT), IMAGE_ICON, 16, 16, LR_CREATEDIBSECTION);
16996
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
810 cached_icons[PURPLE_STATUS_NUM_PRIMITIVES+1] = (HICON) LoadImage(winpidgin_dll_hinstance(),
16058
dc1c7b09a058 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 <datallah@pidgin.im>
parents: 15891
diff changeset
811 MAKEINTRESOURCE(PIDGIN_TRAY_PENDING_4BIT), IMAGE_ICON, 16, 16, LR_CREATEDIBSECTION);
16996
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
812 cached_icons[PURPLE_STATUS_INVISIBLE] = (HICON) LoadImage(winpidgin_dll_hinstance(),
16808
c0736ad72fd6 And make them used
Sean Egan <seanegan@pidgin.im>
parents: 16058
diff changeset
813 MAKEINTRESOURCE(PIDGIN_TRAY_INVISIBLE_4BIT), IMAGE_ICON, 16, 16, LR_CREATEDIBSECTION);
16058
dc1c7b09a058 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 <datallah@pidgin.im>
parents: 15891
diff changeset
814 }
dc1c7b09a058 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 <datallah@pidgin.im>
parents: 15891
diff changeset
815
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
816 /* Create icon in systray */
15765
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
817 systray_init_icon(systray_hwnd);
12016
0517ad5d0196 [gaim-migrate @ 14309]
Casey Harkins <charkins@pidgin.im>
parents: 11709
diff changeset
818
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15834
diff changeset
819 purple_signal_connect(pidgin_blist_get_handle(), "gtkblist-hiding",
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15834
diff changeset
820 pidgin_docklet_get_handle(), PURPLE_CALLBACK(winpidgin_tray_minimize), NULL);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15834
diff changeset
821 purple_signal_connect(pidgin_blist_get_handle(), "gtkblist-unhiding",
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15834
diff changeset
822 pidgin_docklet_get_handle(), PURPLE_CALLBACK(winpidgin_tray_maximize), NULL);
12016
0517ad5d0196 [gaim-migrate @ 14309]
Casey Harkins <charkins@pidgin.im>
parents: 11709
diff changeset
823
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15834
diff changeset
824 purple_debug_info("docklet", "created\n");
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
825 }
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
826
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15562
diff changeset
827 static void winpidgin_tray_destroy() {
15770
e0454c66f042 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 <datallah@pidgin.im>
parents: 15765
diff changeset
828 int cached_cnt = sizeof(cached_icons) / sizeof(HICON);
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
829 systray_remove_nid();
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
830 DestroyWindow(systray_hwnd);
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15522
diff changeset
831 pidgin_docklet_remove();
15765
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
832
15770
e0454c66f042 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 <datallah@pidgin.im>
parents: 15765
diff changeset
833 while (--cached_cnt >= 0) {
e0454c66f042 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 <datallah@pidgin.im>
parents: 15765
diff changeset
834 if (cached_icons[cached_cnt] != NULL)
e0454c66f042 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 <datallah@pidgin.im>
parents: 15765
diff changeset
835 DestroyIcon(cached_icons[cached_cnt]);
e0454c66f042 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 <datallah@pidgin.im>
parents: 15765
diff changeset
836 cached_icons[cached_cnt] = NULL;
e0454c66f042 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 <datallah@pidgin.im>
parents: 15765
diff changeset
837 }
e0454c66f042 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 <datallah@pidgin.im>
parents: 15765
diff changeset
838
15765
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
839 g_object_unref(image);
f281403e98cf Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
840 image = NULL;
20142
af8e3a8b68df applied changes from 0a36aea71847198e73c07cbef0be7e7a7db12c57
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
841
af8e3a8b68df applied changes from 0a36aea71847198e73c07cbef0be7e7a7db12c57
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
842 gtk_widget_destroy(dummy_window);
af8e3a8b68df applied changes from 0a36aea71847198e73c07cbef0be7e7a7db12c57
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
843 dummy_button = NULL;
af8e3a8b68df applied changes from 0a36aea71847198e73c07cbef0be7e7a7db12c57
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
844 dummy_window = NULL;
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
845 }
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
846
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15562
diff changeset
847 static struct docklet_ui_ops winpidgin_tray_ops =
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
848 {
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15562
diff changeset
849 winpidgin_tray_create,
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15562
diff changeset
850 winpidgin_tray_destroy,
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15562
diff changeset
851 winpidgin_tray_update_icon,
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15562
diff changeset
852 winpidgin_tray_blank_icon,
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15562
diff changeset
853 winpidgin_tray_set_tooltip,
20961
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
854 NULL,
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
855 winpidgin_tray_get_geometry,
f69b1356bb55 Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents: 20142
diff changeset
856 winpidgin_tray_get_gdk_screen
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
857 };
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
858
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
859 /* Used by docklet's plugin load func */
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
860 void docklet_ui_init() {
15770
e0454c66f042 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 <datallah@pidgin.im>
parents: 15765
diff changeset
861 /* Initialize the cached icons to NULL */
e0454c66f042 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 <datallah@pidgin.im>
parents: 15765
diff changeset
862 ZeroMemory(cached_icons, sizeof(cached_icons));
e0454c66f042 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 <datallah@pidgin.im>
parents: 15765
diff changeset
863
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15562
diff changeset
864 pidgin_docklet_set_ui_ops(&winpidgin_tray_ops);
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
865 }

mercurial