448
|
1 /*
|
|
2 * Copyright (c) 2000, Red Hat, Inc.
|
|
3 *
|
|
4 * This program is free software; you can redistribute it and/or modify
|
|
5 * it under the terms of the GNU General Public License as published by
|
|
6 * the Free Software Foundation; either version 2 of the License, or
|
|
7 * (at your option) any later version.
|
|
8 *
|
|
9 * A copy of the GNU General Public License can be found at
|
|
10 * http://www.gnu.org/
|
|
11 *
|
|
12 * Written by DJ Delorie <dj@cygnus.com>
|
|
13 *
|
|
14 */
|
|
15
|
|
16 /* The purpose of this file is to manage the dialog box that lets the
|
|
17 user choose the source of the install - from the net, from the
|
|
18 current directory, or to just download files. */
|
|
19
|
|
20 #include "win32.h"
|
|
21 #include <stdio.h>
|
|
22 #include "dialog.h"
|
|
23 #include "resource.h"
|
|
24 #include "state.h"
|
|
25 #include "msg.h"
|
|
26 #include "log.h"
|
|
27
|
|
28 static int rb[] = { IDC_SOURCE_DOWNLOAD, IDC_SOURCE_NETINST, IDC_SOURCE_CWD, 0 };
|
|
29
|
|
30 static void
|
|
31 check_if_enable_next (HWND h)
|
|
32 {
|
|
33 EnableWindow (GetDlgItem (h, IDOK), source ? 1 : 0);
|
|
34 }
|
|
35
|
|
36 static void
|
|
37 load_dialog (HWND h)
|
|
38 {
|
|
39 rbset (h, rb, source);
|
|
40 check_if_enable_next (h);
|
|
41 }
|
|
42
|
|
43 static void
|
|
44 save_dialog (HWND h)
|
|
45 {
|
|
46 source = rbget (h, rb);
|
|
47 }
|
|
48
|
|
49 static BOOL
|
|
50 dialog_cmd (HWND h, int id, HWND hwndctl, UINT code)
|
|
51 {
|
|
52 switch (id)
|
|
53 {
|
|
54
|
|
55 case IDC_SOURCE_DOWNLOAD:
|
|
56 case IDC_SOURCE_NETINST:
|
|
57 case IDC_SOURCE_CWD:
|
|
58 save_dialog (h);
|
|
59 check_if_enable_next (h);
|
|
60 break;
|
|
61
|
|
62 case IDOK:
|
|
63 save_dialog (h);
|
|
64 NEXT (IDD_LOCAL_DIR);
|
|
65 break;
|
|
66
|
|
67 case IDC_BACK:
|
|
68 save_dialog (h);
|
|
69 NEXT (0);
|
|
70 break;
|
|
71
|
|
72 case IDCANCEL:
|
|
73 NEXT (0);
|
|
74 break;
|
|
75 }
|
|
76 return FALSE;
|
|
77 }
|
|
78
|
|
79 static BOOL CALLBACK
|
|
80 dialog_proc (HWND h, UINT message, WPARAM wParam, LPARAM lParam)
|
|
81 {
|
|
82 switch (message)
|
|
83 {
|
|
84 case WM_INITDIALOG:
|
|
85 load_dialog (h);
|
|
86 return FALSE;
|
|
87 case WM_COMMAND:
|
|
88 return HANDLE_WM_COMMAND (h, wParam, lParam, dialog_cmd);
|
|
89 }
|
|
90 return FALSE;
|
|
91 }
|
|
92
|
|
93 void
|
|
94 do_source (HINSTANCE h)
|
|
95 {
|
|
96 int rv = 0;
|
|
97 rv = DialogBox (h, MAKEINTRESOURCE (IDD_SOURCE), 0, dialog_proc);
|
|
98 if (rv == -1)
|
|
99 fatal (IDS_DIALOG_FAILED);
|
|
100
|
|
101 log (0, "source: %s",
|
|
102 (source == IDC_SOURCE_DOWNLOAD) ? "download" :
|
|
103 (source == IDC_SOURCE_NETINST) ? "network install" : "from cwd");
|
|
104 }
|
|
105
|