]>
Commit | Line | Data |
---|---|---|
23c9e63c DD |
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 | ||
b24c88b3 RC |
20 | #if 0 |
21 | static const char *cvsid = | |
22 | "\n%%% $Id$\n"; | |
23 | #endif | |
8507f105 | 24 | |
23c9e63c DD |
25 | #include "win32.h" |
26 | #include <stdio.h> | |
27 | #include "dialog.h" | |
28 | #include "resource.h" | |
29 | #include "state.h" | |
30 | #include "msg.h" | |
89b1a15b | 31 | #include "log.h" |
cbfc4215 | 32 | #include "package_db.h" |
23c9e63c | 33 | |
ab57ceaa RC |
34 | #include "source.h" |
35 | ||
b24c88b3 RC |
36 | static int rb[] = |
37 | { IDC_SOURCE_NETINST, IDC_SOURCE_DOWNLOAD, IDC_SOURCE_CWD, 0 }; | |
23c9e63c DD |
38 | |
39 | static void | |
40 | load_dialog (HWND h) | |
41 | { | |
23c9e63c | 42 | rbset (h, rb, source); |
23c9e63c DD |
43 | } |
44 | ||
45 | static void | |
46 | save_dialog (HWND h) | |
47 | { | |
23c9e63c | 48 | source = rbget (h, rb); |
cbfc4215 | 49 | packagedb db; |
ab57ceaa RC |
50 | db.task = |
51 | source == IDC_SOURCE_DOWNLOAD ? PackageDB_Download : PackageDB_Install; | |
23c9e63c DD |
52 | } |
53 | ||
54 | static BOOL | |
55 | dialog_cmd (HWND h, int id, HWND hwndctl, UINT code) | |
56 | { | |
57 | switch (id) | |
58 | { | |
59 | ||
60 | case IDC_SOURCE_DOWNLOAD: | |
61 | case IDC_SOURCE_NETINST: | |
62 | case IDC_SOURCE_CWD: | |
63 | save_dialog (h); | |
23c9e63c DD |
64 | break; |
65 | ||
8a09aa99 CF |
66 | default: |
67 | break; | |
23c9e63c | 68 | } |
b24c88b3 | 69 | return 0; |
23c9e63c DD |
70 | } |
71 | ||
ab57ceaa RC |
72 | bool |
73 | SourcePage::Create () | |
23c9e63c | 74 | { |
ab57ceaa | 75 | return PropertyPage::Create (NULL, dialog_cmd, IDD_SOURCE); |
23c9e63c DD |
76 | } |
77 | ||
78 | void | |
ab57ceaa | 79 | SourcePage::OnActivate () |
23c9e63c | 80 | { |
2db33f10 RC |
81 | if (!source) |
82 | source = IDC_SOURCE_NETINST; | |
ab57ceaa RC |
83 | load_dialog (GetHWND ()); |
84 | // Check to see if any radio buttons are selected. If not, select a default. | |
85 | if ((!SendMessage | |
86 | (GetDlgItem (IDC_SOURCE_DOWNLOAD), BM_GETCHECK, 0, | |
87 | 0) == BST_CHECKED) | |
88 | && (!SendMessage (GetDlgItem (IDC_SOURCE_CWD), BM_GETCHECK, 0, 0) | |
89 | == BST_CHECKED)) | |
90 | { | |
91 | SendMessage (GetDlgItem (IDC_SOURCE_NETINST), BM_SETCHECK, | |
92 | BST_CHECKED, 0); | |
93 | } | |
94 | } | |
89b1a15b | 95 | |
ab57ceaa RC |
96 | long |
97 | SourcePage::OnNext () | |
98 | { | |
99 | HWND h = GetHWND (); | |
100 | ||
101 | save_dialog (h); | |
102 | if (source == IDC_SOURCE_DOWNLOAD) | |
103 | { | |
104 | // If all we're doing is downloading,skip the root directory page | |
105 | return IDD_LOCAL_DIR; | |
106 | } | |
107 | ||
108 | return 0; | |
109 | } | |
110 | ||
111 | long | |
112 | SourcePage::OnBack () | |
113 | { | |
114 | save_dialog (GetHWND ()); | |
115 | return 0; | |
116 | } | |
117 | ||
118 | void | |
119 | SourcePage::OnDeactivate () | |
120 | { | |
1ac649ed RC |
121 | log (LOG_PLAIN, String ("source: ") + |
122 | ((source == IDC_SOURCE_DOWNLOAD) ? "download" : | |
123 | (source == IDC_SOURCE_NETINST) ? "network install" : "from cwd")); | |
23c9e63c | 124 | } |