Change to the linux kernel coding style
[wmaker-crm.git] / WINGs / Tests / wmquery.c
Commit [+]AuthorDateLineData
9d2e6ef9 scottc1998-09-29 22:36:29 +00001
2/*
6830b057 dan2004-10-12 21:28:27 +00003 * Author: Len Trigg <trigg@cs.waikato.ac.nz>
9d2e6ef9 scottc1998-09-29 22:36:29 +00004 */
5
a20aebde dan2001-01-18 19:21:56 +00006#include <WINGs/WINGs.h>
9d2e6ef9 scottc1998-09-29 22:36:29 +00007
8#include <unistd.h>
9#include <stdio.h>
c2ec1cfe dan2002-11-13 15:13:48 +000010#include <stdlib.h>
9d2e6ef9 scottc1998-09-29 22:36:29 +000011
12#include "logo.xpm"
13
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +020014void wAbort()
9d2e6ef9 scottc1998-09-29 22:36:29 +000015{
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +020016 exit(1);
9d2e6ef9 scottc1998-09-29 22:36:29 +000017}
18
19char *ProgName;
20
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +020021void usage(void)
9d2e6ef9 scottc1998-09-29 22:36:29 +000022{
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +020023 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);
9d2e6ef9 scottc1998-09-29 22:36:29 +000036}
37
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +020038int main(int argc, char **argv)
9d2e6ef9 scottc1998-09-29 22:36:29 +000039{
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +020040 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;
9d2e6ef9 scottc1998-09-29 22:36:29 +000090}