changed indentation to use spaces only
[wmaker-crm.git] / WINGs / Tests / wmfile.c
blob1482ed561d8384240cc7280b81a714cd53c1d9da
1 /*
2 * Author: Len Trigg <trigg@cs.waikato.ac.nz>
3 */
5 /*
6 Update: Franck Wolff <frawolff@club-internet.fr>
7 -----------------------------------------------------------------------
8 List of updated functions :
9 - main :
10 add -s option for a save panel...
11 -----------------------------------------------------------------------
16 #include <WINGs/WINGs.h>
18 #include <unistd.h>
19 #include <stdio.h>
20 #include <stdlib.h>
22 #include "logo.xpm"
27 void
28 wAbort()
30 exit(1);
33 char *ProgName;
35 void usage(void)
37 fprintf(stderr,
38 "usage:\n"
39 "\t%s [-options]\n"
40 "\n"
41 "options:\n"
42 " -s\t\tSave panel (default open panel)\n"
43 " -i <str>\tInitial directory (default /)\n"
44 " -t <str>\tQuery window title (default none)\n"
45 "\n"
46 "information:\n"
47 "\t%s pops up a WindowMaker style file selection panel.\n"
48 "\n"
49 "version:\n"
50 "\t%s\n"
51 ,ProgName,ProgName,__DATE__
53 exit(0);
56 #define OPEN_PANEL_TYPE 0
57 #define SAVE_PANEL_TYPE 1
59 int main(int argc, char **argv)
61 Display *dpy = XOpenDisplay("");
62 WMScreen *scr;
63 WMPixmap *pixmap;
64 WMOpenPanel *oPanel;
65 WMSavePanel *sPanel;
66 /* RImage *image;*/
67 char *title = NULL;
68 char *initial = "/";
69 int ch;
70 int panelType = OPEN_PANEL_TYPE;
71 extern char *optarg;
72 extern int optind;
74 if (!dpy) {
75 puts("could not open display");
76 exit(1);
79 WMInitializeApplication("WMFile", &argc, argv);
81 ProgName = argv[0];
83 while((ch = getopt(argc, argv, "si:ht:")) != -1)
84 switch(ch)
86 case 's':
87 panelType = SAVE_PANEL_TYPE;
88 break;
89 case 'i':
90 initial = optarg;
91 break;
92 case 't':
93 title = optarg;
94 break;
95 default:
96 usage();
99 for(; optind <argc; optind++)
100 usage();
102 scr = WMCreateSimpleApplicationScreen(dpy);
106 pixmap = WMCreatePixmapFromXPMData(scr, GNUSTEP_XPM);
107 WMSetApplicationIconPixmap(scr, pixmap);
108 WMReleasePixmap(pixmap);
109 if (panelType == SAVE_PANEL_TYPE) {
110 sPanel = WMGetSavePanel(scr);
111 if (WMRunModalFilePanelForDirectory(sPanel, NULL, initial,
112 /*title*/ NULL, NULL) == True)
113 printf("%s\n", WMGetFilePanelFileName(sPanel));
114 else
115 printf("\n");
116 } else {
117 oPanel = WMGetOpenPanel(scr);
118 if (WMRunModalFilePanelForDirectory(oPanel, NULL, initial,
119 /*title*/ NULL, NULL) == True)
120 printf("%s\n", WMGetFilePanelFileName(oPanel));
121 else
122 printf("\n");
124 return 0;