Change to the linux kernel coding style
[wmaker-crm.git] / WINGs / Tests / wmquery.c
1
2 /*
3 * Author: Len Trigg <trigg@cs.waikato.ac.nz>
4 */
5
6 #include <WINGs/WINGs.h>
7
8 #include <unistd.h>
9 #include <stdio.h>
10 #include <stdlib.h>
11
12 #include "logo.xpm"
13
14 void wAbort()
15 {
16 exit(1);
17 }
18
19 char *ProgName;
20
21 void usage(void)
22 {
23 fprintf(stderr,
24 "usage:\n"
25 "\t%s [-options]\n"
26 "\n"
27 "options:\n"
28 " -i <str>\tInitial entry contents (default none)\n"
29 " -p <str>\tPrompt message (default none)\n"
30 " -t <str>\tQuery window title (default none)\n"
31 "\n"
32 "information:\n"
33 "\t%s pops up a WindowMaker style input panel.\n"
34 "\n" "version:\n" "\t%s\n", ProgName, ProgName, __DATE__);
35 exit(0);
36 }
37
38 int main(int argc, char **argv)
39 {
40 Display *dpy = XOpenDisplay("");
41 WMScreen *scr;
42 WMPixmap *pixmap;
43 char *title = NULL;
44 char *prompt = NULL;
45 char *initial = NULL;
46 char *result = NULL;
47 int ch;
48 extern char *optarg;
49 extern int optind;
50
51 WMInitializeApplication("WMQuery", &argc, argv);
52
53 ProgName = argv[0];
54
55 if (!dpy) {
56 puts("could not open display");
57 exit(1);
58 }
59
60 while ((ch = getopt(argc, argv, "i:hp:t:")) != -1)
61 switch (ch) {
62 case 'i':
63 initial = optarg;
64 break;
65 case 'p':
66 prompt = optarg;
67 break;
68 case 't':
69 title = optarg;
70 break;
71 default:
72 usage();
73 }
74
75 for (; optind < argc; optind++)
76 usage();
77
78 scr = WMCreateSimpleApplicationScreen(dpy);
79
80 pixmap = WMCreatePixmapFromXPMData(scr, GNUSTEP_XPM);
81
82 WMSetApplicationIconPixmap(scr, pixmap);
83 WMReleasePixmap(pixmap);
84
85 if ((result = WMRunInputPanel(scr, NULL, title, prompt, initial, "OK", "Cancel")) != NULL)
86 printf("%s\n", result);
87 else
88 printf("\n");
89 return 0;
90 }