switchpanel default icon removed
[wmaker-crm.git] / WINGs / Tests / wmquery.c
blobdac70317613cab8c7b2ea559ceeedb27ee34ad81
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 void wAbort()
16 exit(1);
19 char *ProgName;
21 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;
48 extern char *optarg;
49 extern int optind;
51 WMInitializeApplication("WMQuery", &argc, argv);
53 ProgName = argv[0];
55 if (!dpy) {
56 puts("could not open display");
57 exit(1);
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();
75 for (; optind < argc; optind++)
76 usage();
78 scr = WMCreateSimpleApplicationScreen(dpy);
80 pixmap = WMCreatePixmapFromXPMData(scr, GNUSTEP_XPM);
82 WMSetApplicationIconPixmap(scr, pixmap);
83 WMReleasePixmap(pixmap);
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;