Update Serbian translation from master branch
[wmaker-crm.git] / WINGs / Tests / wmfile.c
blob276e89906ed3e58eb45042874b25471f94c6eb43
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 _Noreturn void wAbort(void)
24 exit(1);
27 char *ProgName;
29 _Noreturn 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 char *title = NULL;
57 char *initial = "/";
58 int ch;
59 int panelType = OPEN_PANEL_TYPE;
61 if (!dpy) {
62 puts("could not open display");
63 exit(1);
66 WMInitializeApplication("WMFile", &argc, argv);
68 ProgName = argv[0];
70 while ((ch = getopt(argc, argv, "si:ht:")) != -1)
71 switch (ch) {
72 case 's':
73 panelType = SAVE_PANEL_TYPE;
74 break;
75 case 'i':
76 initial = optarg;
77 break;
78 case 't':
79 title = optarg;
80 break;
81 default:
82 usage();
85 for (; optind < argc; optind++)
86 usage();
88 scr = WMCreateSimpleApplicationScreen(dpy);
90 pixmap = WMCreatePixmapFromXPMData(scr, GNUSTEP_XPM);
91 WMSetApplicationIconPixmap(scr, pixmap);
92 WMReleasePixmap(pixmap);
93 if (panelType == SAVE_PANEL_TYPE) {
94 sPanel = WMGetSavePanel(scr);
95 if (WMRunModalFilePanelForDirectory(sPanel, NULL, initial,
96 title, NULL) == True)
97 printf("%s\n", WMGetFilePanelFileName(sPanel));
98 else
99 printf("\n");
100 } else {
101 oPanel = WMGetOpenPanel(scr);
102 if (WMRunModalFilePanelForDirectory(oPanel, NULL, initial,
103 title, NULL) == True)
104 printf("%s\n", WMGetFilePanelFileName(oPanel));
105 else
106 printf("\n");
108 return 0;