Mercurial > pidgin.yaz
annotate src/win32/win32dep.c @ 4026:a997156437b6
[gaim-migrate @ 4230]
Win prefs page w/ transparency option added
committer: Tailor Script <tailor@pidgin.im>
author | Herman Bloggs <hermanator12002@yahoo.com> |
---|---|
date | Sun, 01 Dec 2002 03:08:27 +0000 |
parents | a1245dcf7b31 |
children | a3ec0146c73e |
rev | line source |
---|---|
3630 | 1 /* |
2 * win32dep.c | |
3 * | |
4 * Author: Herman Bloggs <hermanator12002@yahoo.com> | |
5 * Date: June, 2002 | |
6 * Description: Windows dependant code for Gaim | |
7 */ | |
8 #include <windows.h> | |
9 #include <stdlib.h> | |
10 #include <stdio.h> | |
3983
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
11 #include <winuser.h> |
3630 | 12 #include <glib.h> |
3973
d9287e87ba56
[gaim-migrate @ 4157]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3950
diff
changeset
|
13 #include <gdk/gdkwin32.h> |
3630 | 14 #include "gaim.h" |
15 | |
16 #include "stdafx.h" | |
17 #include "resource.h" | |
3950
c25cf0495533
[gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3907
diff
changeset
|
18 #include "MinimizeToTray.h" |
c25cf0495533
[gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3907
diff
changeset
|
19 #include "systray.h" |
3973
d9287e87ba56
[gaim-migrate @ 4157]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3950
diff
changeset
|
20 #include "winuser_extra.h" |
d9287e87ba56
[gaim-migrate @ 4157]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3950
diff
changeset
|
21 #include "IdleTracker.h" |
3630 | 22 |
23 /* | |
24 * DEFINES & MACROS | |
25 */ | |
3950
c25cf0495533
[gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3907
diff
changeset
|
26 |
3630 | 27 /* |
3983
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
28 * DATA STRUCTS |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
29 */ |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
30 struct _WGAIM_FLASH_INFO { |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
31 guint t_handle; |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
32 guint sig_handler; |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
33 }; |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
34 typedef struct _WGAIM_FLASH_INFO WGAIM_FLASH_INFO; |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
35 |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
36 /* |
3630 | 37 * LOCALS |
38 */ | |
39 static char install_dir[MAXPATHLEN]; | |
40 static char lib_dir[MAXPATHLEN]; | |
41 static char locale_dir[MAXPATHLEN]; | |
42 static int bhide_icon; | |
4026
a997156437b6
[gaim-migrate @ 4230]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3983
diff
changeset
|
43 static int imalpha = 255; |
3950
c25cf0495533
[gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3907
diff
changeset
|
44 |
3630 | 45 /* |
46 * GLOBALS | |
47 */ | |
3856
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
48 HINSTANCE gaimexe_hInstance = 0; |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
49 HINSTANCE gaimdll_hInstance = 0; |
3630 | 50 |
51 /* | |
3983
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
52 * PROTOS |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
53 */ |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
54 BOOL (*MyFlashWindowEx)(PFLASHWINFO pfwi)=NULL; |
4026
a997156437b6
[gaim-migrate @ 4230]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3983
diff
changeset
|
55 BOOL (*MySetLayeredWindowAttributes)(HWND hwnd, COLORREF crKey, BYTE bAlpha, DWORD dwFlags)=NULL; |
a997156437b6
[gaim-migrate @ 4230]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3983
diff
changeset
|
56 void wgaim_set_wintrans(GtkWidget *window, int trans); |
3983
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
57 |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
58 /* |
3630 | 59 * STATIC CODE |
60 */ | |
61 | |
3983
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
62 /* Window flasher */ |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
63 static gboolean flash_window_cb(gpointer data) { |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
64 FlashWindow((HWND)data, TRUE); |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
65 return TRUE; |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
66 } |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
67 |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
68 static void halt_flash_filter(GtkWidget *widget, GdkEventFocus *event, WGAIM_FLASH_INFO *finfo) { |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
69 /* Stop flashing and remove filter */ |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
70 debug_printf("Removing timeout\n"); |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
71 gtk_timeout_remove(finfo->t_handle); |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
72 debug_printf("Disconnecting signal handler\n"); |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
73 g_signal_handler_disconnect(G_OBJECT(widget),finfo->sig_handler); |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
74 debug_printf("done\n"); |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
75 } |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
76 |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
77 /* Determine whether the specified dll contains the specified procedure. |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
78 If so, load it (if not already loaded). */ |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
79 static FARPROC find_and_loadproc( char* dllname, char* procedure ) { |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
80 HMODULE hmod; |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
81 int did_load=0; |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
82 FARPROC proc = 0; |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
83 |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
84 if(!(hmod=GetModuleHandle(dllname))) { |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
85 debug_printf("%s not found. Loading it..\n", dllname); |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
86 if(!(hmod = LoadLibrary(dllname))) { |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
87 debug_printf("Could not load: %s\n", dllname); |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
88 return NULL; |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
89 } |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
90 else |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
91 did_load = 1; |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
92 } |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
93 |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
94 if((proc=GetProcAddress(hmod, procedure))) { |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
95 debug_printf("This version of %s contains %s\n", dllname, procedure); |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
96 return proc; |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
97 } |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
98 else { |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
99 debug_printf("Function: %s not found in dll: %s\n", procedure, dllname); |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
100 if(did_load) { |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
101 /* unload dll */ |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
102 FreeLibrary(hmod); |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
103 } |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
104 return NULL; |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
105 } |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
106 } |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
107 |
4026
a997156437b6
[gaim-migrate @ 4230]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3983
diff
changeset
|
108 static void load_winver_specific_procs(void) { |
3983
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
109 /* Used for Win98+ and WinNT5+ */ |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
110 MyFlashWindowEx = (void*)find_and_loadproc("user32.dll", "FlashWindowEx" ); |
4026
a997156437b6
[gaim-migrate @ 4230]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3983
diff
changeset
|
111 /* Used for Win2k+ */ |
a997156437b6
[gaim-migrate @ 4230]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3983
diff
changeset
|
112 MySetLayeredWindowAttributes = (void*)find_and_loadproc("user32.dll", "SetLayeredWindowAttributes" ); |
3983
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
113 } |
3630 | 114 |
4026
a997156437b6
[gaim-migrate @ 4230]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3983
diff
changeset
|
115 /* Transparency slider callbacks */ |
a997156437b6
[gaim-migrate @ 4230]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3983
diff
changeset
|
116 static void change_im_alpha(GtkWidget *w, gpointer data) { |
a997156437b6
[gaim-migrate @ 4230]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3983
diff
changeset
|
117 wgaim_set_wintrans(GTK_WIDGET(data), gtk_range_get_value(GTK_RANGE(w))); |
a997156437b6
[gaim-migrate @ 4230]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3983
diff
changeset
|
118 } |
3630 | 119 |
120 /* | |
121 * PUBLIC CODE | |
122 */ | |
123 | |
3950
c25cf0495533
[gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3907
diff
changeset
|
124 /* Misc Wingaim functions */ |
c25cf0495533
[gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3907
diff
changeset
|
125 HINSTANCE wgaim_hinstance(void) { |
c25cf0495533
[gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3907
diff
changeset
|
126 return gaimexe_hInstance; |
c25cf0495533
[gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3907
diff
changeset
|
127 } |
c25cf0495533
[gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3907
diff
changeset
|
128 |
3856
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
129 /* Determine Gaim Paths during Runtime */ |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
130 |
3630 | 131 char* wgaim_install_dir(void) { |
132 HMODULE hmod; | |
133 char* buf; | |
134 | |
135 hmod = GetModuleHandle(NULL); | |
136 if( hmod == 0 ) { | |
137 buf = g_win32_error_message( GetLastError() ); | |
138 debug_printf("GetModuleHandle error: %s\n", buf); | |
139 free(buf); | |
140 return NULL; | |
141 } | |
142 if(GetModuleFileName( hmod, (char*)&install_dir, MAXPATHLEN ) == 0) { | |
143 buf = g_win32_error_message( GetLastError() ); | |
144 debug_printf("GetModuleFileName error: %s\n", buf); | |
145 free(buf); | |
146 return NULL; | |
147 } | |
148 buf = g_path_get_dirname( install_dir ); | |
149 strcpy( (char*)&install_dir, buf ); | |
150 free( buf ); | |
151 | |
152 return (char*)&install_dir; | |
153 } | |
154 | |
155 char* wgaim_lib_dir(void) { | |
156 strcpy(lib_dir, wgaim_install_dir()); | |
157 strcat(lib_dir, G_DIR_SEPARATOR_S "plugins"); | |
158 return (char*)&lib_dir; | |
159 } | |
160 | |
161 char* wgaim_locale_dir(void) { | |
162 strcpy(locale_dir, wgaim_install_dir()); | |
163 strcat(locale_dir, G_DIR_SEPARATOR_S "locale"); | |
164 return (char*)&locale_dir; | |
165 } | |
166 | |
3973
d9287e87ba56
[gaim-migrate @ 4157]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3950
diff
changeset
|
167 /* Miscellaneous */ |
d9287e87ba56
[gaim-migrate @ 4157]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3950
diff
changeset
|
168 |
3983
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
169 /* FlashWindowEx is only supported by Win98+ and WinNT5+. If its |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
170 not supported we do it our own way */ |
3973
d9287e87ba56
[gaim-migrate @ 4157]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3950
diff
changeset
|
171 void wgaim_im_blink(GtkWidget *window) { |
3983
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
172 if(MyFlashWindowEx) { |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
173 FLASHWINFO info; |
3973
d9287e87ba56
[gaim-migrate @ 4157]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3950
diff
changeset
|
174 |
3983
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
175 info.cbSize = sizeof(FLASHWINFO); |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
176 info.hwnd = GDK_WINDOW_HWND(window->window); |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
177 info.dwFlags = FLASHW_ALL | FLASHW_TIMERNOFG; |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
178 info.dwTimeout = 0; |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
179 MyFlashWindowEx(&info); |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
180 } |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
181 else { |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
182 WGAIM_FLASH_INFO *finfo = g_new0(WGAIM_FLASH_INFO, 1); |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
183 |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
184 /* Start Flashing window */ |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
185 finfo->t_handle = gtk_timeout_add(1000, flash_window_cb, GDK_WINDOW_HWND(window->window)); |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
186 finfo->sig_handler = g_signal_connect(G_OBJECT(window), "focus-in-event", G_CALLBACK(halt_flash_filter), finfo); |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
187 } |
3973
d9287e87ba56
[gaim-migrate @ 4157]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3950
diff
changeset
|
188 } |
d9287e87ba56
[gaim-migrate @ 4157]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3950
diff
changeset
|
189 |
4026
a997156437b6
[gaim-migrate @ 4230]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3983
diff
changeset
|
190 /* Set window transparency level */ |
a997156437b6
[gaim-migrate @ 4230]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3983
diff
changeset
|
191 void wgaim_set_wintrans(GtkWidget *window, int trans) { |
a997156437b6
[gaim-migrate @ 4230]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3983
diff
changeset
|
192 if(MySetLayeredWindowAttributes) { |
a997156437b6
[gaim-migrate @ 4230]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3983
diff
changeset
|
193 HWND hWnd = GDK_WINDOW_HWND(window->window); |
a997156437b6
[gaim-migrate @ 4230]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3983
diff
changeset
|
194 SetWindowLong(hWnd,GWL_EXSTYLE,GetWindowLong(hWnd,GWL_EXSTYLE) | WS_EX_LAYERED); |
a997156437b6
[gaim-migrate @ 4230]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3983
diff
changeset
|
195 MySetLayeredWindowAttributes(hWnd,0,trans,LWA_ALPHA); |
a997156437b6
[gaim-migrate @ 4230]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3983
diff
changeset
|
196 } |
a997156437b6
[gaim-migrate @ 4230]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3983
diff
changeset
|
197 } |
a997156437b6
[gaim-migrate @ 4230]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3983
diff
changeset
|
198 |
a997156437b6
[gaim-migrate @ 4230]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3983
diff
changeset
|
199 void wgaim_set_imalpha(int val) { |
a997156437b6
[gaim-migrate @ 4230]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3983
diff
changeset
|
200 imalpha = val; |
a997156437b6
[gaim-migrate @ 4230]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3983
diff
changeset
|
201 } |
a997156437b6
[gaim-migrate @ 4230]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3983
diff
changeset
|
202 |
a997156437b6
[gaim-migrate @ 4230]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3983
diff
changeset
|
203 int wgaim_get_imalpha(int val) { |
a997156437b6
[gaim-migrate @ 4230]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3983
diff
changeset
|
204 return imalpha; |
a997156437b6
[gaim-migrate @ 4230]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3983
diff
changeset
|
205 } |
a997156437b6
[gaim-migrate @ 4230]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3983
diff
changeset
|
206 |
a997156437b6
[gaim-migrate @ 4230]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3983
diff
changeset
|
207 int wgaim_has_transparency() { |
a997156437b6
[gaim-migrate @ 4230]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3983
diff
changeset
|
208 return MySetLayeredWindowAttributes ? TRUE : FALSE; |
a997156437b6
[gaim-migrate @ 4230]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3983
diff
changeset
|
209 } |
a997156437b6
[gaim-migrate @ 4230]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3983
diff
changeset
|
210 |
a997156437b6
[gaim-migrate @ 4230]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3983
diff
changeset
|
211 GtkWidget *wgaim_wintrans_slider(GtkWidget *win) { |
a997156437b6
[gaim-migrate @ 4230]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3983
diff
changeset
|
212 GtkWidget *hbox; |
a997156437b6
[gaim-migrate @ 4230]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3983
diff
changeset
|
213 GtkWidget *label, *slider; |
a997156437b6
[gaim-migrate @ 4230]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3983
diff
changeset
|
214 |
a997156437b6
[gaim-migrate @ 4230]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3983
diff
changeset
|
215 hbox = gtk_hbox_new(FALSE, 5); |
a997156437b6
[gaim-migrate @ 4230]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3983
diff
changeset
|
216 |
a997156437b6
[gaim-migrate @ 4230]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3983
diff
changeset
|
217 label = gtk_label_new(_("Opacity:")); |
a997156437b6
[gaim-migrate @ 4230]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3983
diff
changeset
|
218 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5); |
a997156437b6
[gaim-migrate @ 4230]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3983
diff
changeset
|
219 |
a997156437b6
[gaim-migrate @ 4230]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3983
diff
changeset
|
220 slider = gtk_hscale_new_with_range(50,255,1); |
a997156437b6
[gaim-migrate @ 4230]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3983
diff
changeset
|
221 gtk_range_set_value(GTK_RANGE(slider), imalpha); |
a997156437b6
[gaim-migrate @ 4230]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3983
diff
changeset
|
222 gtk_widget_set_usize(GTK_WIDGET(slider), 200, -1); |
a997156437b6
[gaim-migrate @ 4230]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3983
diff
changeset
|
223 |
a997156437b6
[gaim-migrate @ 4230]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3983
diff
changeset
|
224 /* On slider val change, update window's transparency level */ |
a997156437b6
[gaim-migrate @ 4230]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3983
diff
changeset
|
225 gtk_signal_connect(GTK_OBJECT(slider), "value-changed", GTK_SIGNAL_FUNC(change_im_alpha), win); |
a997156437b6
[gaim-migrate @ 4230]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3983
diff
changeset
|
226 gtk_box_pack_start(GTK_BOX(hbox), slider, FALSE, TRUE, 5); |
a997156437b6
[gaim-migrate @ 4230]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3983
diff
changeset
|
227 |
a997156437b6
[gaim-migrate @ 4230]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3983
diff
changeset
|
228 /* Set the initial transparency level */ |
a997156437b6
[gaim-migrate @ 4230]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3983
diff
changeset
|
229 wgaim_set_wintrans(win, imalpha); |
a997156437b6
[gaim-migrate @ 4230]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3983
diff
changeset
|
230 |
a997156437b6
[gaim-migrate @ 4230]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3983
diff
changeset
|
231 gtk_widget_show_all(hbox); |
a997156437b6
[gaim-migrate @ 4230]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3983
diff
changeset
|
232 |
a997156437b6
[gaim-migrate @ 4230]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3983
diff
changeset
|
233 return hbox; |
a997156437b6
[gaim-migrate @ 4230]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3983
diff
changeset
|
234 } |
a997156437b6
[gaim-migrate @ 4230]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3983
diff
changeset
|
235 |
3856
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
236 /* Windows Initializations */ |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
237 |
3630 | 238 void wgaim_init(void) { |
3907
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
239 WORD wVersionRequested; |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
240 WSADATA wsaData; |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
241 int err; |
3856
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
242 char* locale=0; |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
243 char newenv[128]; |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
244 |
3907
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
245 debug_printf("wgaim_init\n"); |
3950
c25cf0495533
[gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3907
diff
changeset
|
246 |
3983
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
247 load_winver_specific_procs(); |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
248 |
3950
c25cf0495533
[gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3907
diff
changeset
|
249 /* Initialize Wingaim systray icon */ |
c25cf0495533
[gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3907
diff
changeset
|
250 wgaim_systray_init(); |
c25cf0495533
[gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3907
diff
changeset
|
251 |
3907
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
252 /* |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
253 * Winsock init |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
254 */ |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
255 wVersionRequested = MAKEWORD( 2, 2 ); |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
256 |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
257 err = WSAStartup( wVersionRequested, &wsaData ); |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
258 if ( err != 0 ) { |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
259 return 1; |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
260 } |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
261 |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
262 /* Confirm that the winsock DLL supports 2.2 */ |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
263 /* Note that if the DLL supports versions greater than |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
264 2.2 in addition to 2.2, it will still return 2.2 in |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
265 wVersion since that is the version we requested. */ |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
266 |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
267 if ( LOBYTE( wsaData.wVersion ) != 2 || |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
268 HIBYTE( wsaData.wVersion ) != 2 ) { |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
269 debug_printf("Could not find a usable WinSock DLL. Oh well.\n"); |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
270 WSACleanup( ); |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
271 return 1; |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
272 } |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
273 |
3856
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
274 /* get default locale */ |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
275 locale = g_win32_getlocale(); |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
276 debug_printf("Language profile used: %s\n", locale); |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
277 |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
278 /* |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
279 * Aspell config |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
280 */ |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
281 /* Set LANG env var */ |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
282 sprintf(newenv, "LANG=%s", locale); |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
283 if(putenv(newenv)<0) |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
284 debug_printf("putenv failed\n"); |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
285 g_free(locale); |
3905
3e508dd31b76
[gaim-migrate @ 4058]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3856
diff
changeset
|
286 |
3907
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
287 /* |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
288 * IdleTracker Initialization |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
289 */ |
3905
3e508dd31b76
[gaim-migrate @ 4058]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3856
diff
changeset
|
290 if(!IdleTrackerInit()) |
3e508dd31b76
[gaim-migrate @ 4058]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3856
diff
changeset
|
291 debug_printf("IdleTracker failed to initialize\n"); |
3630 | 292 } |
3856
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
293 |
3907
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
294 /* Windows Cleanup */ |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
295 |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
296 void wgaim_cleanup(void) { |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
297 debug_printf("wgaim_cleanup\n"); |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
298 |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
299 /* winsock cleanup */ |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
300 WSACleanup( ); |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
301 |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
302 /* IdleTracker cleanup */ |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
303 IdleTrackerTerm(); |
3950
c25cf0495533
[gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3907
diff
changeset
|
304 |
c25cf0495533
[gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3907
diff
changeset
|
305 /* Remove systray icon */ |
c25cf0495533
[gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3907
diff
changeset
|
306 wgaim_systray_cleanup(); |
3907
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
307 } |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
308 |
3950
c25cf0495533
[gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3907
diff
changeset
|
309 /* DLL initializer */ |
3856
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
310 BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved ) { |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
311 gaimdll_hInstance = hinstDLL; |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
312 return TRUE; |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
313 } |