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 *
|
673
|
14 * Sync'ed with cinstall 2001-10-16
|
448
|
15 */
|
|
16
|
|
17 /* The purpose of this file is to manage the dialog box that lets the
|
|
18 user choose the source of the install - from the net, from the
|
|
19 current directory, or to just download files. */
|
|
20
|
|
21 #include "win32.h"
|
|
22 #include <stdio.h>
|
|
23 #include "dialog.h"
|
|
24 #include "resource.h"
|
|
25 #include "state.h"
|
|
26 #include "msg.h"
|
|
27 #include "log.h"
|
|
28
|
673
|
29 static int rb[] = { IDC_SOURCE_NETINST, IDC_SOURCE_DOWNLOAD, IDC_SOURCE_CWD, 0 };
|
448
|
30
|
|
31 static void
|
|
32 check_if_enable_next (HWND h)
|
|
33 {
|
|
34 EnableWindow (GetDlgItem (h, IDOK), source ? 1 : 0);
|
|
35 }
|
|
36
|
|
37 static void
|
|
38 load_dialog (HWND h)
|
|
39 {
|
673
|
40 int i;
|
448
|
41 rbset (h, rb, source);
|
|
42 }
|
|
43
|
|
44 static void
|
|
45 save_dialog (HWND h)
|
|
46 {
|
673
|
47 int i;
|
448
|
48 source = rbget (h, rb);
|
|
49 }
|
|
50
|
|
51 static BOOL
|
|
52 dialog_cmd (HWND h, int id, HWND hwndctl, UINT code)
|
|
53 {
|
|
54 switch (id)
|
|
55 {
|
|
56
|
|
57 case IDC_SOURCE_DOWNLOAD:
|
|
58 case IDC_SOURCE_NETINST:
|
|
59 case IDC_SOURCE_CWD:
|
|
60 save_dialog (h);
|
|
61 break;
|
|
62
|
|
63 case IDOK:
|
|
64 save_dialog (h);
|
|
65 NEXT (IDD_LOCAL_DIR);
|
|
66 break;
|
|
67
|
|
68 case IDC_BACK:
|
|
69 save_dialog (h);
|
|
70 NEXT (0);
|
|
71 break;
|
|
72
|
|
73 case IDCANCEL:
|
|
74 NEXT (0);
|
|
75 break;
|
673
|
76
|
|
77 default:
|
|
78 break;
|
448
|
79 }
|
|
80 }
|
|
81
|
|
82 static BOOL CALLBACK
|
|
83 dialog_proc (HWND h, UINT message, WPARAM wParam, LPARAM lParam)
|
|
84 {
|
|
85 switch (message)
|
|
86 {
|
|
87 case WM_INITDIALOG:
|
|
88 load_dialog (h);
|
673
|
89 // Check to see if any radio buttons are selected. If not, select a default.
|
|
90 if ((!SendMessage(GetDlgItem (h, IDC_SOURCE_DOWNLOAD), BM_GETCHECK, 0, 0) == BST_CHECKED)
|
|
91 && (!SendMessage(GetDlgItem (h, IDC_SOURCE_CWD), BM_GETCHECK, 0, 0) == BST_CHECKED))
|
|
92 {
|
|
93 SendMessage(GetDlgItem (h, IDC_SOURCE_NETINST), BM_SETCHECK, BST_CHECKED, 0);
|
|
94 }
|
448
|
95 return FALSE;
|
|
96 case WM_COMMAND:
|
|
97 return HANDLE_WM_COMMAND (h, wParam, lParam, dialog_cmd);
|
|
98 }
|
|
99 return FALSE;
|
|
100 }
|
|
101
|
|
102 void
|
|
103 do_source (HINSTANCE h)
|
|
104 {
|
|
105 int rv = 0;
|
673
|
106 /* source = IDC_SOURCE_CWD;*/
|
|
107 source = IDC_SOURCE_NETINST;
|
448
|
108 rv = DialogBox (h, MAKEINTRESOURCE (IDD_SOURCE), 0, dialog_proc);
|
|
109 if (rv == -1)
|
|
110 fatal (IDS_DIALOG_FAILED);
|
|
111
|
|
112 log (0, "source: %s",
|
|
113 (source == IDC_SOURCE_DOWNLOAD) ? "download" :
|
|
114 (source == IDC_SOURCE_NETINST) ? "network install" : "from cwd");
|
|
115 }
|
|
116
|