Deleted Added
sdiff udiff text old ( 15091 ) new ( 15242 )
full compact
1/*
2 * The new sysinstall program.
3 *
4 * This is probably the last attempt in the `sysinstall' line, the next
5 * generation being slated for what's essentially a complete rewrite.
6 *
7 * $Id: dmenu.c,v 1.14 1996/03/02 07:31:51 jkh Exp $
8 *
9 * Copyright (c) 1995
10 * Jordan Hubbard. All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer,
17 * verbatim and that no modifications are made prior to this
18 * point in the file.
19 * 2. Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the distribution.
22 * 3. All advertising materials mentioning features or use of this software
23 * must display the following acknowledgement:
24 * This product includes software developed by Jordan Hubbard
25 * for the FreeBSD Project.
26 * 4. The name of Jordan Hubbard or the FreeBSD project may not be used to
27 * endorse or promote products derived from this software without specific
28 * prior written permission.
29 *
30 * THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND
31 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
32 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
33 * ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE
34 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
35 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
36 * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION)

--- 10 unchanged lines hidden (view full) ---

47#define MAX_MENU 15
48
49static Boolean cancelled;
50
51int
52dmenuDisplayFile(dialogMenuItem *tmp)
53{
54 systemDisplayHelp((char *)tmp->data);
55 return RET_SUCCESS;
56}
57
58int
59dmenuSubmenu(dialogMenuItem *tmp)
60{
61 dialog_clear();
62 return dmenuOpenSimple((DMenu *)tmp->data);
63}
64
65int
66dmenuSystemCommand(dialogMenuItem *tmp)
67{
68 int i;
69
70 i = systemExecute((char *)tmp->data) ? RET_FAIL : RET_SUCCESS;
71 dialog_clear();
72 return i;
73}
74
75int
76dmenuSystemCommandBox(dialogMenuItem *tmp)
77{
78 use_helpfile(NULL);
79 use_helpline("Select OK to dismiss this dialog");
80 dialog_prgbox(tmp->title, (char *)tmp->data, 22, 76, 1, 1);
81 dialog_clear();
82 return RET_SUCCESS;
83}
84
85int
86dmenuCancel(dialogMenuItem *tmp)
87{
88 cancelled = TRUE;
89 return RET_SUCCESS;
90}
91
92int
93dmenuSetVariable(dialogMenuItem *tmp)
94{
95 variable_set((char *)tmp->data);
96 msgInfo("Set %s", tmp->data);
97 return RET_SUCCESS;
98}
99
100int
101dmenuSetFlag(dialogMenuItem *tmp)
102{
103 *((unsigned int *)tmp->data) |= tmp->aux;
104 return RET_SUCCESS;
105}
106
107int
108dmenuSetValue(dialogMenuItem *tmp)
109{
110 *((unsigned int *)tmp->data) = tmp->aux;
111 return RET_SUCCESS;
112}
113
114/* Traverse menu but give user no control over positioning */
115Boolean
116dmenuOpenSimple(DMenu *menu)
117{
118 int choice, scroll, curr, max;
119

--- 63 unchanged lines hidden (view full) ---

183 while (1) {
184 char buf[FILENAME_MAX];
185
186 /* Any helpful hints, put 'em up! */
187 use_helpline(menu->helpline);
188 use_helpfile(systemHelpFile(menu->helpfile, buf));
189
190 /* Pop up that dialog! */
191 if (menu->type == DMENU_NORMAL_TYPE)
192 rval = dialog_menu((u_char *)menu->title, (u_char *)menu->prompt, -1, -1,
193 menu_height(menu, n), -n, menu->items, NULL, choice, scroll);
194
195 else if (menu->type == DMENU_RADIO_TYPE)
196 rval = dialog_radiolist((u_char *)menu->title, (u_char *)menu->prompt, -1, -1,
197 menu_height(menu, n), -n, menu->items, NULL);
198
199 else if (menu->type == DMENU_CHECKLIST_TYPE)
200 rval = dialog_checklist((u_char *)menu->title, (u_char *)menu->prompt, -1, -1,
201 menu_height(menu, n), -n, menu->items, NULL);
202
203 /* This seems to be the only technique that works for getting the display to look right */
204 dialog_clear();
205 if (rval)
206 return FALSE;
207 else if (cancelled) {
208 cancelled = FALSE;
209 return TRUE;
210 }
211 }
212}