X-Git-Url: https://repo.or.cz/w/wmaker-crm.git/blobdiff_plain/59fc927dc9f183802621138534fa6eaafe5593ba..688a56e8ab67b56550e2874d9d7423f0d435bfd9:/WINGs/Tests/wmfile.c diff --git a/WINGs/Tests/wmfile.c b/WINGs/Tests/wmfile.c dissimilarity index 79% index 1482ed56..f12362e9 100644 --- a/WINGs/Tests/wmfile.c +++ b/WINGs/Tests/wmfile.c @@ -1,126 +1,112 @@ -/* - * Author: Len Trigg - */ - -/* - Update: Franck Wolff - ----------------------------------------------------------------------- - List of updated functions : - - main : - add -s option for a save panel... - ----------------------------------------------------------------------- - */ - - - -#include - -#include -#include -#include - -#include "logo.xpm" - - - - -void -wAbort() -{ - exit(1); -} - -char *ProgName; - -void usage(void) -{ - fprintf(stderr, - "usage:\n" - "\t%s [-options]\n" - "\n" - "options:\n" - " -s\t\tSave panel (default open panel)\n" - " -i \tInitial directory (default /)\n" - " -t \tQuery window title (default none)\n" - "\n" - "information:\n" - "\t%s pops up a WindowMaker style file selection panel.\n" - "\n" - "version:\n" - "\t%s\n" - ,ProgName,ProgName,__DATE__ - ); - exit(0); -} - -#define OPEN_PANEL_TYPE 0 -#define SAVE_PANEL_TYPE 1 - -int main(int argc, char **argv) -{ - Display *dpy = XOpenDisplay(""); - WMScreen *scr; - WMPixmap *pixmap; - WMOpenPanel *oPanel; - WMSavePanel *sPanel; - /* RImage *image;*/ - char *title = NULL; - char *initial = "/"; - int ch; - int panelType = OPEN_PANEL_TYPE; - extern char *optarg; - extern int optind; - - if (!dpy) { - puts("could not open display"); - exit(1); - } - - WMInitializeApplication("WMFile", &argc, argv); - - ProgName = argv[0]; - - while((ch = getopt(argc, argv, "si:ht:")) != -1) - switch(ch) - { - case 's': - panelType = SAVE_PANEL_TYPE; - break; - case 'i': - initial = optarg; - break; - case 't': - title = optarg; - break; - default: - usage(); - } - - for(; optind + */ + +/* + Update: Franck Wolff + ----------------------------------------------------------------------- + List of updated functions : + - main : + add -s option for a save panel... + ----------------------------------------------------------------------- + */ + +#include + +#include +#include +#include + +#include "logo.xpm" + +void wAbort() +{ + exit(1); +} + +char *ProgName; + +void usage(void) +{ + fprintf(stderr, + "usage:\n" + "\t%s [-options]\n" + "\n" + "options:\n" + " -s\t\tSave panel (default open panel)\n" + " -i \tInitial directory (default /)\n" + " -t \tQuery window title (default none)\n" + "\n" + "information:\n" + "\t%s pops up a WindowMaker style file selection panel.\n" + "\n" "version:\n" "\t%s\n", ProgName, ProgName, __DATE__); + exit(0); +} + +#define OPEN_PANEL_TYPE 0 +#define SAVE_PANEL_TYPE 1 + +int main(int argc, char **argv) +{ + Display *dpy = XOpenDisplay(""); + WMScreen *scr; + WMPixmap *pixmap; + WMOpenPanel *oPanel; + WMSavePanel *sPanel; + /* RImage *image; */ + char *title = NULL; + char *initial = "/"; + int ch; + int panelType = OPEN_PANEL_TYPE; + extern char *optarg; + extern int optind; + + if (!dpy) { + puts("could not open display"); + exit(1); + } + + WMInitializeApplication("WMFile", &argc, argv); + + ProgName = argv[0]; + + while ((ch = getopt(argc, argv, "si:ht:")) != -1) + switch (ch) { + case 's': + panelType = SAVE_PANEL_TYPE; + break; + case 'i': + initial = optarg; + break; + case 't': + title = optarg; + break; + default: + usage(); + } + + for (; optind < argc; optind++) + usage(); + + scr = WMCreateSimpleApplicationScreen(dpy); + + pixmap = WMCreatePixmapFromXPMData(scr, GNUSTEP_XPM); + WMSetApplicationIconPixmap(scr, pixmap); + WMReleasePixmap(pixmap); + if (panelType == SAVE_PANEL_TYPE) { + sPanel = WMGetSavePanel(scr); + if (WMRunModalFilePanelForDirectory(sPanel, NULL, initial, + /*title */ NULL, NULL) == True) + printf("%s\n", WMGetFilePanelFileName(sPanel)); + else + printf("\n"); + } else { + oPanel = WMGetOpenPanel(scr); + if (WMRunModalFilePanelForDirectory(oPanel, NULL, initial, + /*title */ NULL, NULL) == True) + printf("%s\n", WMGetFilePanelFileName(oPanel)); + else + printf("\n"); + } + return 0; +}