French localization.
[wine] / programs / winecfg / main.c
1 /*
2  * WineCfg main entry point
3  *
4  * Copyright 2002 Jaco Greeff
5  * Copyright 2003 Dimitrie O. Paun
6  * Copyright 2003 Mike Hearn
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  *
22  */
23
24 #include "config.h"
25
26 #include <stdlib.h>
27 #include <stdio.h>
28 #include <stdarg.h>
29 #ifdef HAVE_UNISTD_H
30 #include <unistd.h>
31 #endif
32
33 #define NONAMELESSUNION
34 #define NONAMELESSSTRUCT
35
36 #include <windef.h>
37 #include <winbase.h>
38 #include <winuser.h>
39 #include <commctrl.h>
40 #include <wine/debug.h>
41
42 #include "properties.h"
43 #include "resource.h"
44 #include "winecfg.h"
45
46 WINE_DEFAULT_DEBUG_CHANNEL(winecfg);
47
48 void CALLBACK
49 PropSheetCallback (HWND hWnd, UINT uMsg, LPARAM lParam)
50 {
51     switch (uMsg)
52     {
53         /*
54          * hWnd = NULL, lParam == dialog resource
55          */
56     case PSCB_PRECREATE:
57         break;
58
59     case PSCB_INITIALIZED:
60         break;
61
62     default:
63         break;
64     }
65 }
66
67 INT_PTR CALLBACK
68 AboutDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
69 {
70     switch (uMsg) {
71
72         case WM_NOTIFY:
73             if (((LPNMHDR)lParam)->code != PSN_SETACTIVE) break;
74             /* otherwise fall through, we want to refresh the page as well */
75         case WM_INITDIALOG:
76             break;
77
78         case WM_COMMAND:
79             break;
80             
81         default:
82             break;
83             
84     }
85     return FALSE;
86 }
87
88 #define NUM_PROPERTY_PAGES 6
89
90 INT_PTR
91 doPropertySheet (HINSTANCE hInstance, HWND hOwner)
92 {
93     PROPSHEETPAGE psp[NUM_PROPERTY_PAGES];
94     PROPSHEETHEADER psh;
95     int pg = 0; /* start with page 0 */
96
97     /*
98      * Fill out the (Applications) PROPSHEETPAGE data structure 
99      * for the property sheet
100      */
101     psp[pg].dwSize = sizeof (PROPSHEETPAGE);
102     psp[pg].dwFlags = PSP_USETITLE;
103     psp[pg].hInstance = hInstance;
104     psp[pg].u.pszTemplate = MAKEINTRESOURCE (IDD_APPCFG);
105     psp[pg].u2.pszIcon = NULL;
106     psp[pg].pfnDlgProc = AppDlgProc;
107     psp[pg].pszTitle = "Applications";
108     psp[pg].lParam = 0;
109     pg++;
110
111     /*
112      * Fill out the (Libraries) PROPSHEETPAGE data structure 
113      * for the property sheet
114      */
115     psp[pg].dwSize = sizeof (PROPSHEETPAGE);
116     psp[pg].dwFlags = PSP_USETITLE;
117     psp[pg].hInstance = hInstance;
118     psp[pg].u.pszTemplate = MAKEINTRESOURCE (IDD_DLLCFG);
119     psp[pg].u2.pszIcon = NULL;
120     psp[pg].pfnDlgProc = LibrariesDlgProc;
121     psp[pg].pszTitle = "Libraries";
122     psp[pg].lParam = 0;
123     pg++;
124     
125     /*
126      * Fill out the (X11Drv) PROPSHEETPAGE data structure 
127      * for the property sheet
128      */
129     psp[pg].dwSize = sizeof (PROPSHEETPAGE);
130     psp[pg].dwFlags = PSP_USETITLE;
131     psp[pg].hInstance = hInstance;
132     psp[pg].u.pszTemplate = MAKEINTRESOURCE (IDD_GRAPHCFG);
133     psp[pg].u2.pszIcon = NULL;
134     psp[pg].pfnDlgProc = GraphDlgProc;
135     psp[pg].pszTitle = "Graphics";
136     psp[pg].lParam = 0;
137     pg++;
138
139     psp[pg].dwSize = sizeof (PROPSHEETPAGE);
140     psp[pg].dwFlags = PSP_USETITLE;
141     psp[pg].hInstance = hInstance;
142     psp[pg].u.pszTemplate = MAKEINTRESOURCE (IDD_DRIVECFG);
143     psp[pg].u2.pszIcon = NULL;
144     psp[pg].pfnDlgProc = DriveDlgProc;
145     psp[pg].pszTitle = "Drives";
146     psp[pg].lParam = 0;
147     pg++;
148
149     psp[pg].dwSize = sizeof (PROPSHEETPAGE);
150     psp[pg].dwFlags = PSP_USETITLE;
151     psp[pg].hInstance = hInstance;
152     psp[pg].u.pszTemplate = MAKEINTRESOURCE (IDD_AUDIOCFG);
153     psp[pg].u2.pszIcon = NULL;
154     psp[pg].pfnDlgProc = AudioDlgProc;
155     psp[pg].pszTitle = "Audio";
156     psp[pg].lParam = 0;
157     pg++;
158
159     /*
160      * Fill out the (General) PROPSHEETPAGE data structure 
161      * for the property sheet
162      */
163     psp[pg].dwSize = sizeof (PROPSHEETPAGE);
164     psp[pg].dwFlags = PSP_USETITLE;
165     psp[pg].hInstance = hInstance;
166     psp[pg].u.pszTemplate = MAKEINTRESOURCE (IDD_ABOUTCFG);
167     psp[pg].u2.pszIcon = NULL;
168     psp[pg].pfnDlgProc = AboutDlgProc;
169     psp[pg].pszTitle = "About";
170     psp[pg].lParam = 0;
171     pg++;
172
173     /*
174      * Fill out the PROPSHEETHEADER
175      */
176     psh.dwSize = sizeof (PROPSHEETHEADER);
177     psh.dwFlags = PSH_PROPSHEETPAGE | PSH_USEICONID | PSH_USECALLBACK;
178     psh.hwndParent = hOwner;
179     psh.hInstance = hInstance;
180     psh.u.pszIcon = NULL;
181     psh.pszCaption = "Wine Configuration";
182     psh.nPages = NUM_PROPERTY_PAGES;
183     psh.u3.ppsp = (LPCPROPSHEETPAGE) & psp;
184     psh.pfnCallback = (PFNPROPSHEETCALLBACK) PropSheetCallback;
185     psh.u2.nStartPage = 0;
186
187     /*
188      * Display the modal property sheet
189      */
190     return PropertySheet (&psh);
191 }
192
193 /******************************************************************************
194  * Name       : ProcessCmdLine
195  * Description: Checks command line parameters for 'autodetect drives' option
196  * Parameters : lpCmdLine - the command line
197  * Returns    : TRUE - if '/D' was found. Drive autodetection was carried out.
198  *              FALSE - no '/D' option found in command line
199  * Notes      : This is a very simple implementation, which only works 
200  *              correctly if the one and only cmd line option is '/D' or
201  *              no option at all. Has to be reworked, if more options are to
202  *              be supported.
203  */
204 BOOL
205 ProcessCmdLine(LPSTR lpCmdLine)
206 {
207     if ((lpCmdLine[0] == '/' || lpCmdLine[0] == '-') && 
208         (lpCmdLine[1] == 'D' || lpCmdLine[1] == 'd')) 
209     {
210         gui_mode = FALSE;
211         if (autodetect_drives()) {
212             apply_drive_changes();
213         }
214         return TRUE;
215     }
216
217     return FALSE;
218 }
219
220 /*****************************************************************************
221  * Name       : WinMain
222  * Description: Main windows entry point
223  * Parameters : hInstance
224  *              hPrev
225  *              szCmdLine
226  *              nShow
227  * Returns    : Program exit code
228  */
229 int WINAPI
230 WinMain (HINSTANCE hInstance, HINSTANCE hPrev, LPSTR szCmdLine, int nShow)
231 {
232     if (ProcessCmdLine(szCmdLine)) {
233         return 0;
234     }
235         
236     /* Until winecfg is fully functional, warn users that it is incomplete and doesn't do anything */
237     if (!getenv("WINECFG_NOWARN")) {
238         WINE_FIXME("The winecfg tool is not yet complete, and does not actually alter your configuration.\n");
239         WINE_FIXME("If you want to alter the way Wine works, look in the ~/.wine/config file for more information.\n");
240         MessageBoxA(NULL, "The winecfg tool is not yet complete, and does not actually alter your configuration\n\n"
241                     "If you want to alter the way Wine works, look in the ~/.wine/config file for more information.",
242                     "", MB_OK | MB_ICONEXCLAMATION);
243     }
244
245     if (initialize() != 0) {
246         WINE_ERR("initialization failed, aborting\n");
247         ExitProcess(1);
248     }
249     
250     /*
251      * The next 3 lines should be all that is needed
252      * for the Wine Configuration property sheet
253      */
254     InitCommonControls ();
255     if (doPropertySheet (hInstance, NULL) > 0) {
256         WINE_TRACE("OK\n");
257     } else {
258         WINE_TRACE("Cancel\n");
259     }
260     
261     ExitProcess (0);
262
263     return 0;
264 }