]> cygwin.com Git - cygwin-apps/setup.git/blob - other.cc
2001-12-04 Robert Collins <rbtcollins@hotmail.com>
[cygwin-apps/setup.git] / other.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 /* This handles the "other URL" option from the mirror site
17 selection. */
18
19 #if 0
20 static const char *cvsid =
21 "\n%%% $Id$\n";
22 #endif
23
24 #include "win32.h"
25 #include <shlobj.h>
26 #include <stdio.h>
27 #include <stdlib.h>
28 #include "dialog.h"
29 #include "resource.h"
30 #include "state.h"
31 #include "msg.h"
32 #include "log.h"
33 #include "site.h"
34
35 static char * other_url = 0;
36
37 static void
38 check_if_enable_next (HWND h)
39 {
40 EnableWindow (GetDlgItem (h, IDOK), other_url ? 1 : 0);
41 }
42
43 static void
44 load_dialog (HWND h)
45 {
46 eset (h, IDC_OTHER_URL, other_url);
47 check_if_enable_next (h);
48 }
49
50 static void
51 save_dialog (HWND h)
52 {
53 other_url = eget (h, IDC_OTHER_URL, other_url);
54 site_list_type *newsite = new site_list_type (other_url);
55 site_list_type &listobj = all_site_list.registerbyobject (*newsite);
56 if (&listobj != newsite)
57 /* That site was already registered */
58 delete newsite;
59 site_list.registerbyobject (listobj);
60 }
61
62 static BOOL
63 dialog_cmd (HWND h, int id, HWND hwndctl, UINT code)
64 {
65 switch (id)
66 {
67
68 case IDC_OTHER_URL:
69 other_url = eget (h, IDC_OTHER_URL, other_url);
70 check_if_enable_next (h);
71 break;
72
73 case IDOK:
74 save_dialog (h);
75 save_site_url ();
76 NEXT (IDD_S_LOAD_INI);
77 break;
78
79 case IDC_BACK:
80 save_dialog (h);
81 NEXT (IDD_SITE);
82 break;
83
84 case IDCANCEL:
85 NEXT (0);
86 break;
87 }
88 return 0;
89 }
90
91 static BOOL CALLBACK
92 dialog_proc (HWND h, UINT message, WPARAM wParam, LPARAM lParam)
93 {
94 switch (message)
95 {
96 case WM_INITDIALOG:
97 load_dialog (h);
98 return FALSE;
99 case WM_COMMAND:
100 return HANDLE_WM_COMMAND (h, wParam, lParam, dialog_cmd);
101 }
102 return FALSE;
103 }
104
105 void
106 do_other (HINSTANCE h)
107 {
108 int rv = 0;
109 rv = DialogBox (h, MAKEINTRESOURCE (IDD_OTHER_URL), 0, dialog_proc);
110 if (rv == -1)
111 fatal (IDS_DIALOG_FAILED);
112
113 log (0, "site: %s", other_url);
114 }
This page took 0.039824 seconds and 5 git commands to generate.