1/*
2 * small test-driver for new dialog functionality
3 *
4 * Copyright (c) 1995, Jordan Hubbard
5 *
6 * All rights reserved.
7 *
8 * This source code may be used, modified, copied, distributed, and
9 * sold, in both source and binary form provided that the above
10 * copyright and these terms are retained, verbatim, as the first
11 * lines of this file.  Under no circumstances is the author
12 * responsible for the proper functioning of the software nor does
13 * the author assume any responsibility for damages incurred with
14 * its use.
15 */
16
17#include <sys/cdefs.h>
18__FBSDID("$FreeBSD$");
19
20#include <stdio.h>
21#include <stdlib.h>
22#include <string.h>
23#include <unistd.h>
24#include <sys/wait.h>
25#include <dialog.h>
26
27/* Hook functions */
28
29static char bachelor[10], bachelette[10];
30
31static int
32getBachelor(dialogMenuItem *self)
33{
34    return !strcmp(bachelor, self->prompt);
35}
36
37static int
38setBachelor(dialogMenuItem *self)
39{
40    strcpy(bachelor, self->prompt);
41    return DITEM_SUCCESS | DITEM_REDRAW;
42}
43
44static int
45getBachelette(dialogMenuItem *self)
46{
47    return !strcmp(bachelette, self->prompt);
48}
49
50static int
51setBachelette(dialogMenuItem *self)
52{
53    strcpy(bachelette, self->prompt);
54    return DITEM_SUCCESS | DITEM_REDRAW;
55}
56
57/* menu6- More complex radiolist menu that creates two groups in a single menu */
58/* prompt	title								checked		fire */
59static dialogMenuItem menu6[] = {
60    { "Tom",	"Tom's a dynamic shoe salesman from Tulsa, OK!",		getBachelor,	setBachelor },
61    { "Dick",	"Dick's a retired engine inspector from McDonnell-Douglas!",	getBachelor,	setBachelor },
62    { "Harry",	"Harry's a professional female impersonator from Las Vegas!",	getBachelor,	setBachelor },
63    { "-----",	"----------------------------------",		NULL, NULL, NULL, NULL, ' ', ' ', ' ' },
64    { "Jane",	"Jane's a twice-divorced housewife from Moose, Oregon!",	getBachelette,	setBachelette },
65    { "Sally",	"Sally's a shy Human Resources Manager for IBM!",		getBachelette,	setBachelette },
66    { "Mary",	"Mary's an energetic serial killer on the lam!",		getBachelette,	setBachelette },
67};
68
69/* End of hook functions */
70
71/* Kick it off, James! */
72int
73main(int argc, char **argv)
74{
75    int retval;
76
77    init_dialog();
78
79    retval = dialog_radiolist("this is dialog_radiolist() in action, test #2",
80			      "Welcome to \"The Love Blender!\" - America's favorite game show\n"
81			      "where YOU, the contestant, get to choose which of these two\n"
82			      "fine specimens of humanity will go home together, whether they\n"
83			      "like it or not!", -1, -1, 7, -7, menu6, NULL);
84    dialog_clear();
85    fprintf(stderr, "I'm sure that %s and %s will be very happy together!\n", bachelor, bachelette);
86
87    end_dialog();
88    return 0;
89}
90