]> cygwin.com Git - cygwin-apps/setup.git/blob - source.cc
* localdir.cc: new, local package directory selection dialog; cd
[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 static char *cvsid = "\n%%% $Id$\n";
21
22 #include "win32.h"
23 #include <stdio.h>
24 #include "dialog.h"
25 #include "resource.h"
26 #include "state.h"
27 #include "msg.h"
28 #include "log.h"
29
30 static int rb[] = { IDC_SOURCE_DOWNLOAD, IDC_SOURCE_NETINST, IDC_SOURCE_CWD, 0 };
31
32 static void
33 check_if_enable_next (HWND h)
34 {
35 EnableWindow (GetDlgItem (h, IDOK), source ? 1 : 0);
36 }
37
38 static void
39 load_dialog (HWND h)
40 {
41 int i;
42 rbset (h, rb, source);
43 check_if_enable_next (h);
44 }
45
46 static void
47 save_dialog (HWND h)
48 {
49 int i;
50 source = rbget (h, rb);
51 }
52
53 static BOOL
54 dialog_cmd (HWND h, int id, HWND hwndctl, UINT code)
55 {
56 switch (id)
57 {
58
59 case IDC_SOURCE_DOWNLOAD:
60 case IDC_SOURCE_NETINST:
61 case IDC_SOURCE_CWD:
62 save_dialog (h);
63 check_if_enable_next (h);
64 break;
65
66 case IDOK:
67 save_dialog (h);
68 NEXT (IDD_LOCAL_DIR);
69 break;
70
71 case IDC_BACK:
72 save_dialog (h);
73 NEXT (0);
74 break;
75
76 case IDCANCEL:
77 NEXT (0);
78 break;
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);
89 return FALSE;
90 case WM_COMMAND:
91 return HANDLE_WM_COMMAND (h, wParam, lParam, dialog_cmd);
92 }
93 return FALSE;
94 }
95
96 void
97 do_source (HINSTANCE h)
98 {
99 int rv = 0;
100 rv = DialogBox (h, MAKEINTRESOURCE (IDD_SOURCE), 0, dialog_proc);
101 if (rv == -1)
102 fatal (IDS_DIALOG_FAILED);
103
104 log (0, "source: %s",
105 (source == IDC_SOURCE_DOWNLOAD) ? "download" :
106 (source == IDC_SOURCE_NETINST) ? "network install" : "from cwd");
107 }
108
This page took 0.112482 seconds and 5 git commands to generate.