]> cygwin.com Git - cygwin-apps/setup.git/blob - source.cc
2002-07-15 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 static int rb[] =
37 { IDC_SOURCE_NETINST, IDC_SOURCE_DOWNLOAD, IDC_SOURCE_CWD, 0 };
38
39 static void
40 load_dialog (HWND h)
41 {
42 rbset (h, rb, source);
43 }
44
45 static void
46 save_dialog (HWND h)
47 {
48 source = rbget (h, rb);
49 packagedb db;
50 db.task =
51 source == IDC_SOURCE_DOWNLOAD ? PackageDB_Download : PackageDB_Install;
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);
64 break;
65
66 default:
67 break;
68 }
69 return 0;
70 }
71
72 bool
73 SourcePage::Create ()
74 {
75 return PropertyPage::Create (NULL, dialog_cmd, IDD_SOURCE);
76 }
77
78 void
79 SourcePage::OnActivate ()
80 {
81 if (!source)
82 source = IDC_SOURCE_NETINST;
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 }
95
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 {
121 log (LOG_PLAIN, String ("source: ") +
122 ((source == IDC_SOURCE_DOWNLOAD) ? "download" :
123 (source == IDC_SOURCE_NETINST) ? "network install" : "from cwd"));
124 }
This page took 0.039776 seconds and 5 git commands to generate.