Update Serbian translation from master branch
[wmaker-crm.git] / WINGs / Tests / wmquery.c
blobb2347e221104b10d18953983761f04da55a24bfd
2 /*
3 * Author: Len Trigg <trigg@cs.waikato.ac.nz>
4 */
6 #include <WINGs/WINGs.h>
8 #include <unistd.h>
9 #include <stdio.h>
10 #include <stdlib.h>
12 #include "logo.xpm"
14 _Noreturn void wAbort(void)
16 exit(1);
19 char *ProgName;
21 _Noreturn void usage(void)
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);
38 int main(int argc, char **argv)
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;
49 WMInitializeApplication("WMQuery", &argc, argv);
51 ProgName = argv[0];
53 if (!dpy) {
54 puts("could not open display");
55 exit(1);
58 while ((ch = getopt(argc, argv, "i:hp:t:")) != -1)
59 switch (ch) {
60 case 'i':
61 initial = optarg;
62 break;
63 case 'p':
64 prompt = optarg;
65 break;
66 case 't':
67 title = optarg;
68 break;
69 default:
70 usage();
73 for (; optind < argc; optind++)
74 usage();
76 scr = WMCreateSimpleApplicationScreen(dpy);
78 pixmap = WMCreatePixmapFromXPMData(scr, GNUSTEP_XPM);
80 WMSetApplicationIconPixmap(scr, pixmap);
81 WMReleasePixmap(pixmap);
83 if ((result = WMRunInputPanel(scr, NULL, title, prompt, initial, "OK", "Cancel")) != NULL)
84 printf("%s\n", result);
85 else
86 printf("\n");
87 return 0;