]> cygwin.com Git - cygwin-apps/setup.git/blob - source.cc
Backport some changes from trunk.
[cygwin-apps/setup.git] / source.cc
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 #if 0
21 static const char *cvsid =
22 "\n%%% $Id$\n";
23 #endif
24
25 #include "win32.h"
26 #include <stdio.h>
27 #include "dialog.h"
28 #include "resource.h"
29 #include "state.h"
30 #include "msg.h"
31 #include "log.h"
32 #include "package_db.h"
33
34 #include "source.h"
35 #include "SourceSetting.h"
36 static SourceSetting theSetting;
37
38 #include "getopt++/BoolOption.h"
39
40 static BoolOption DownloadOption (false, 'D', "download", "Download from internet");
41 static BoolOption LocalOption (false, 'L', "local-install", "Install from local directory");
42
43 static int rb[] =
44 { IDC_SOURCE_NETINST, IDC_SOURCE_DOWNLOAD, IDC_SOURCE_CWD, 0 };
45
46 static void
47 load_dialog (HWND h)
48 {
49 rbset (h, rb, source);
50 }
51
52 static void
53 save_dialog (HWND h)
54 {
55 source = rbget (h, rb);
56 packagedb db;
57 db.task =
58 source == IDC_SOURCE_DOWNLOAD ? PackageDB_Download : PackageDB_Install;
59 }
60
61 static BOOL
62 dialog_cmd (HWND h, int id, HWND hwndctl, UINT code)
63 {
64 switch (id)
65 {
66
67 case IDC_SOURCE_DOWNLOAD:
68 case IDC_SOURCE_NETINST:
69 case IDC_SOURCE_CWD:
70 save_dialog (h);
71 break;
72
73 default:
74 break;
75 }
76 return 0;
77 }
78
79 bool
80 SourcePage::Create ()
81 {
82 return PropertyPage::Create (NULL, dialog_cmd, IDD_SOURCE);
83 }
84
85 void
86 SourcePage::OnActivate ()
87 {
88 if (!source)
89 {
90 if (DownloadOption)
91 source = IDC_SOURCE_DOWNLOAD;
92 else if (LocalOption)
93 source = IDC_SOURCE_CWD;
94 else
95 source = IDC_SOURCE_NETINST;
96 }
97
98 load_dialog (GetHWND ());
99 // Check to see if any radio buttons are selected. If not, select a default.
100 if ((!SendMessage
101 (GetDlgItem (IDC_SOURCE_DOWNLOAD), BM_GETCHECK, 0,
102 0) == BST_CHECKED)
103 && (!SendMessage (GetDlgItem (IDC_SOURCE_CWD), BM_GETCHECK, 0, 0)
104 == BST_CHECKED))
105 {
106 SendMessage (GetDlgItem (IDC_SOURCE_NETINST), BM_SETCHECK,
107 BST_CHECKED, 0);
108 }
109 }
110
111 long
112 SourcePage::OnNext ()
113 {
114 HWND h = GetHWND ();
115
116 save_dialog (h);
117 return 0;
118 }
119
120 long
121 SourcePage::OnBack ()
122 {
123 save_dialog (GetHWND ());
124 return 0;
125 }
126
127 void
128 SourcePage::OnDeactivate ()
129 {
130 log (LOG_PLAIN, String ("source: ") +
131 ((source == IDC_SOURCE_DOWNLOAD) ? "download" :
132 (source == IDC_SOURCE_NETINST) ? "network install" : "from cwd"));
133 }
134
135 long
136 SourcePage::OnUnattended ()
137 {
138 return OnNext();
139 }
This page took 0.040665 seconds and 5 git commands to generate.