]> cygwin.com Git - cygwin-apps/setup.git/blob - source.cc
2002-09-21 Robert Collins <rbtcollins@hotmail.com>
[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
36 #include "getopt++/BoolOption.h"
37
38 static BoolOption DownloadOption (false, 'D', "download", "Download from internet");
39 static BoolOption LocalOption (false, 'L', "local-install", "Install from local directory");
40
41 static int rb[] =
42 { IDC_SOURCE_NETINST, IDC_SOURCE_DOWNLOAD, IDC_SOURCE_CWD, 0 };
43
44 static void
45 load_dialog (HWND h)
46 {
47 rbset (h, rb, source);
48 }
49
50 static void
51 save_dialog (HWND h)
52 {
53 source = rbget (h, rb);
54 packagedb db;
55 db.task =
56 source == IDC_SOURCE_DOWNLOAD ? PackageDB_Download : PackageDB_Install;
57 }
58
59 static BOOL
60 dialog_cmd (HWND h, int id, HWND hwndctl, UINT code)
61 {
62 switch (id)
63 {
64
65 case IDC_SOURCE_DOWNLOAD:
66 case IDC_SOURCE_NETINST:
67 case IDC_SOURCE_CWD:
68 save_dialog (h);
69 break;
70
71 default:
72 break;
73 }
74 return 0;
75 }
76
77 bool
78 SourcePage::Create ()
79 {
80 return PropertyPage::Create (NULL, dialog_cmd, IDD_SOURCE);
81 }
82
83 void
84 SourcePage::OnActivate ()
85 {
86 if (!source)
87 {
88 if (DownloadOption)
89 source = IDC_SOURCE_DOWNLOAD;
90 else if (LocalOption)
91 source = IDC_SOURCE_CWD;
92 else
93 source = IDC_SOURCE_NETINST;
94 }
95
96 load_dialog (GetHWND ());
97 // Check to see if any radio buttons are selected. If not, select a default.
98 if ((!SendMessage
99 (GetDlgItem (IDC_SOURCE_DOWNLOAD), BM_GETCHECK, 0,
100 0) == BST_CHECKED)
101 && (!SendMessage (GetDlgItem (IDC_SOURCE_CWD), BM_GETCHECK, 0, 0)
102 == BST_CHECKED))
103 {
104 SendMessage (GetDlgItem (IDC_SOURCE_NETINST), BM_SETCHECK,
105 BST_CHECKED, 0);
106 }
107 }
108
109 long
110 SourcePage::OnNext ()
111 {
112 HWND h = GetHWND ();
113
114 save_dialog (h);
115 if (source == IDC_SOURCE_DOWNLOAD)
116 {
117 // If all we're doing is downloading,skip the root directory page
118 return IDD_LOCAL_DIR;
119 }
120
121 return 0;
122 }
123
124 long
125 SourcePage::OnBack ()
126 {
127 save_dialog (GetHWND ());
128 return 0;
129 }
130
131 void
132 SourcePage::OnDeactivate ()
133 {
134 log (LOG_PLAIN, String ("source: ") +
135 ((source == IDC_SOURCE_DOWNLOAD) ? "download" :
136 (source == IDC_SOURCE_NETINST) ? "network install" : "from cwd"));
137 }
138
139 long
140 SourcePage::OnUnattended ()
141 {
142 return OnNext();
143 }
This page took 0.180515 seconds and 5 git commands to generate.