switchpanel default icon removed
[wmaker-crm.git] / WINGs / Tests / wmfile.c
blobf12362e9ffcab082824d59b30f1cfb64566f7513
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 -----------------------------------------------------------------------
14 #include <WINGs/WINGs.h>
16 #include <unistd.h>
17 #include <stdio.h>
18 #include <stdlib.h>
20 #include "logo.xpm"
22 void wAbort()
24 exit(1);
27 char *ProgName;
29 void usage(void)
31 fprintf(stderr,
32 "usage:\n"
33 "\t%s [-options]\n"
34 "\n"
35 "options:\n"
36 " -s\t\tSave panel (default open panel)\n"
37 " -i <str>\tInitial directory (default /)\n"
38 " -t <str>\tQuery window title (default none)\n"
39 "\n"
40 "information:\n"
41 "\t%s pops up a WindowMaker style file selection panel.\n"
42 "\n" "version:\n" "\t%s\n", ProgName, ProgName, __DATE__);
43 exit(0);
46 #define OPEN_PANEL_TYPE 0
47 #define SAVE_PANEL_TYPE 1
49 int main(int argc, char **argv)
51 Display *dpy = XOpenDisplay("");
52 WMScreen *scr;
53 WMPixmap *pixmap;
54 WMOpenPanel *oPanel;
55 WMSavePanel *sPanel;
56 /* RImage *image; */
57 char *title = NULL;
58 char *initial = "/";
59 int ch;
60 int panelType = OPEN_PANEL_TYPE;
61 extern char *optarg;
62 extern int optind;
64 if (!dpy) {
65 puts("could not open display");
66 exit(1);
69 WMInitializeApplication("WMFile", &argc, argv);
71 ProgName = argv[0];
73 while ((ch = getopt(argc, argv, "si:ht:")) != -1)
74 switch (ch) {
75 case 's':
76 panelType = SAVE_PANEL_TYPE;
77 break;
78 case 'i':
79 initial = optarg;
80 break;
81 case 't':
82 title = optarg;
83 break;
84 default:
85 usage();
88 for (; optind < argc; optind++)
89 usage();
91 scr = WMCreateSimpleApplicationScreen(dpy);
93 pixmap = WMCreatePixmapFromXPMData(scr, GNUSTEP_XPM);
94 WMSetApplicationIconPixmap(scr, pixmap);
95 WMReleasePixmap(pixmap);
96 if (panelType == SAVE_PANEL_TYPE) {
97 sPanel = WMGetSavePanel(scr);
98 if (WMRunModalFilePanelForDirectory(sPanel, NULL, initial,
99 /*title */ NULL, NULL) == True)
100 printf("%s\n", WMGetFilePanelFileName(sPanel));
101 else
102 printf("\n");
103 } else {
104 oPanel = WMGetOpenPanel(scr);
105 if (WMRunModalFilePanelForDirectory(oPanel, NULL, initial,
106 /*title */ NULL, NULL) == True)
107 printf("%s\n", WMGetFilePanelFileName(oPanel));
108 else
109 printf("\n");
111 return 0;