Initial revision
[wmaker-crm.git] / WINGs / wmfile.c
blob6dae5831e9438f08372799eded26316e35adc78b
2 /*
3 * Author: Len Trigg <trigg@cs.waikato.ac.nz>
4 */
7 #include "WINGs.h"
9 #include <unistd.h>
10 #include <stdio.h>
12 #include "logo.xpm"
17 void
18 wAbort()
20 exit(1);
23 char *ProgName;
25 void usage(void)
27 fprintf(stderr,
28 "usage:\n"
29 "\t%s [-options]\n"
30 "\n"
31 "options:\n"
32 " -i <str>\tInitial directory (default /)\n"
33 " -t <str>\tQuery window title (default none)\n"
34 "\n"
35 "information:\n"
36 "\t%s pops up a WindowMaker style file selection panel.\n"
37 "\n"
38 "version:\n"
39 "\t%s\n"
40 ,ProgName,ProgName,__DATE__
42 exit(0);
45 int main(int argc, char **argv)
47 Display *dpy = XOpenDisplay("");
48 WMScreen *scr;
49 WMPixmap *pixmap;
50 WMOpenPanel *panel;
51 /* RImage *image;*/
52 char *title = NULL;
53 char *initial = "/";
54 int ch;
55 extern char *optarg;
56 extern int optind;
58 WMInitializeApplication("WMFile", &argc, argv);
60 ProgName = argv[0];
62 if (!dpy) {
63 puts("could not open display");
64 exit(1);
66 while((ch = getopt(argc, argv, "i:ht:")) != -1)
67 switch(ch)
69 case 'i':
70 initial = optarg;
71 break;
72 case 't':
73 title = optarg;
74 break;
75 default:
76 usage();
79 for(; optind <argc; optind++)
80 usage();
82 scr = WMCreateSimpleApplicationScreen(dpy);
86 pixmap = WMCreatePixmapFromXPMData(scr, GNUSTEP_XPM);
87 WMSetApplicationIconImage(scr, pixmap); WMReleasePixmap(pixmap);
88 panel = WMGetOpenPanel(scr);
90 /* The 3rd argument for this function is the initial name of the file,
91 * not the name of the window, although it's not implemented yet */
92 if (WMRunModalOpenPanelForDirectory(panel, NULL, initial, /*title*/ NULL, NULL) == True)
93 printf("%s\n", WMGetFilePanelFileName(panel));
94 else
95 printf("\n");
96 return 0;