Mercurial > pidgin
annotate src/win32/win32dep.c @ 3856:50ac7e205045
[gaim-migrate @ 4008]
Gtkspell/aspell update
committer: Tailor Script <tailor@pidgin.im>
author | Herman Bloggs <hermanator12002@yahoo.com> |
---|---|
date | Sat, 02 Nov 2002 01:38:51 +0000 |
parents | 9682c0e022c6 |
children | 3e508dd31b76 |
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> | |
11 #include <glib.h> | |
12 #include "gaim.h" | |
13 | |
14 #include "stdafx.h" | |
15 #include "resource.h" | |
16 | |
17 /* | |
18 * DEFINES & MACROS | |
19 */ | |
20 #define WM_TRAYMESSAGE WM_USER | |
21 #define GAIM_SYSTRAY_HINT "Gaim Instant Messenger" | |
22 | |
23 /* | |
24 * LOCALS | |
25 */ | |
26 static char install_dir[MAXPATHLEN]; | |
27 static char lib_dir[MAXPATHLEN]; | |
28 static char locale_dir[MAXPATHLEN]; | |
29 static int bhide_icon; | |
30 | |
31 /* | |
32 * GLOBALS | |
33 */ | |
3856
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
34 HINSTANCE gaimexe_hInstance = 0; |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
35 HINSTANCE gaimdll_hInstance = 0; |
3630 | 36 |
37 /* | |
38 * STATIC CODE | |
39 */ | |
40 | |
41 static void ShowNotifyIcon(HWND hWnd,BOOL bAdd) | |
42 { | |
43 NOTIFYICONDATA nid; | |
44 ZeroMemory(&nid,sizeof(nid)); | |
45 nid.cbSize=sizeof(NOTIFYICONDATA); | |
46 nid.hWnd=hWnd; | |
47 nid.uID=0; | |
48 nid.uFlags=NIF_ICON | NIF_MESSAGE | NIF_TIP; | |
49 nid.uCallbackMessage=WM_TRAYMESSAGE; | |
3856
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
50 nid.hIcon=LoadIcon(gaimexe_hInstance,MAKEINTRESOURCE(IDI_ICON2)); |
3630 | 51 lstrcpy(nid.szTip,TEXT(GAIM_SYSTRAY_HINT)); |
52 | |
53 if(bAdd) | |
54 Shell_NotifyIcon(NIM_ADD,&nid); | |
55 else | |
56 Shell_NotifyIcon(NIM_DELETE,&nid); | |
57 } | |
58 | |
59 static GdkFilterReturn traymsg_filter_func( GdkXEvent *xevent, GdkEvent *event, gpointer data) | |
60 { | |
61 MSG *msg = (MSG*)xevent; | |
62 | |
63 if( msg->lParam == WM_LBUTTONDBLCLK ) { | |
64 RestoreWndFromTray(msg->hwnd); | |
65 bhide_icon = TRUE; | |
66 return GDK_FILTER_REMOVE; | |
67 } | |
68 | |
69 if( msg->lParam == WM_LBUTTONUP ) { | |
70 if(bhide_icon) { | |
71 ShowNotifyIcon(msg->hwnd,FALSE); | |
72 bhide_icon = FALSE; | |
73 } | |
74 } | |
75 return GDK_FILTER_REMOVE; | |
76 } | |
77 | |
78 /* | |
79 * PUBLIC CODE | |
80 */ | |
81 | |
3856
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
82 /* Determine Gaim Paths during Runtime */ |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
83 |
3630 | 84 char* wgaim_install_dir(void) { |
85 HMODULE hmod; | |
86 char* buf; | |
87 | |
88 hmod = GetModuleHandle(NULL); | |
89 if( hmod == 0 ) { | |
90 buf = g_win32_error_message( GetLastError() ); | |
91 debug_printf("GetModuleHandle error: %s\n", buf); | |
92 free(buf); | |
93 return NULL; | |
94 } | |
95 if(GetModuleFileName( hmod, (char*)&install_dir, MAXPATHLEN ) == 0) { | |
96 buf = g_win32_error_message( GetLastError() ); | |
97 debug_printf("GetModuleFileName error: %s\n", buf); | |
98 free(buf); | |
99 return NULL; | |
100 } | |
101 buf = g_path_get_dirname( install_dir ); | |
102 strcpy( (char*)&install_dir, buf ); | |
103 free( buf ); | |
104 | |
105 return (char*)&install_dir; | |
106 } | |
107 | |
108 char* wgaim_lib_dir(void) { | |
109 strcpy(lib_dir, wgaim_install_dir()); | |
110 strcat(lib_dir, G_DIR_SEPARATOR_S "plugins"); | |
111 return (char*)&lib_dir; | |
112 } | |
113 | |
114 char* wgaim_locale_dir(void) { | |
115 strcpy(locale_dir, wgaim_install_dir()); | |
116 strcat(locale_dir, G_DIR_SEPARATOR_S "locale"); | |
117 return (char*)&locale_dir; | |
118 } | |
119 | |
3856
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
120 /* Systray related routines */ |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
121 |
3630 | 122 GdkFilterReturn wgaim_window_filter( GdkXEvent *xevent, GdkEvent *event, gpointer data) |
123 { | |
124 MSG *msg = (MSG*)xevent; | |
125 | |
126 switch( msg->message ) { | |
127 case WM_SYSCOMMAND: | |
128 if( msg->wParam == SC_MINIMIZE ) { | |
129 MinimizeWndToTray(msg->hwnd); | |
130 ShowNotifyIcon(msg->hwnd,TRUE); | |
131 | |
132 SetWindowLong(msg->hwnd,DWL_MSGRESULT,0); | |
133 return GDK_FILTER_REMOVE; | |
134 } | |
135 break; | |
136 case WM_CLOSE: | |
137 MinimizeWndToTray(msg->hwnd); | |
138 ShowNotifyIcon(msg->hwnd,TRUE); | |
139 return GDK_FILTER_REMOVE; | |
140 } | |
141 | |
142 return GDK_FILTER_CONTINUE; | |
143 } | |
144 | |
3856
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
145 /* Windows Initializations */ |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
146 |
3630 | 147 void wgaim_init(void) { |
3856
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
148 char* locale=0; |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
149 char newenv[128]; |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
150 |
3630 | 151 /* Filter to catch systray events */ |
152 gdk_add_client_message_filter (GDK_POINTER_TO_ATOM (WM_TRAYMESSAGE), | |
153 traymsg_filter_func, | |
154 NULL); | |
3856
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
155 /* get default locale */ |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
156 locale = g_win32_getlocale(); |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
157 debug_printf("Language profile used: %s\n", locale); |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
158 |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
159 /* |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
160 * Aspell config |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
161 */ |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
162 /* Set LANG env var */ |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
163 sprintf(newenv, "LANG=%s", locale); |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
164 if(putenv(newenv)<0) |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
165 debug_printf("putenv failed\n"); |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
166 g_free(locale); |
3630 | 167 } |
3856
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
168 |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
169 BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved ) { |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
170 gaimdll_hInstance = hinstDLL; |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
171 return TRUE; |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
172 } |