Author: mladen.turk(a)jboss.com
Date: 2008-04-07 07:55:16 -0400 (Mon, 07 Apr 2008)
New Revision: 1525
Modified:
trunk/build/install/xtool/xtool.c
Log:
Add Browse For Folder GUI Tool
Modified: trunk/build/install/xtool/xtool.c
===================================================================
--- trunk/build/install/xtool/xtool.c 2008-04-07 10:38:16 UTC (rev 1524)
+++ trunk/build/install/xtool/xtool.c 2008-04-07 11:55:16 UTC (rev 1525)
@@ -2923,7 +2923,8 @@
GuiBrowseForFolder(
HWND hWnd,
LPCSTR szTitle,
- LPSTR szPath)
+ LPSTR szPath,
+ int iFlags)
{
BOOL rv = FALSE;
@@ -2937,7 +2938,7 @@
bi.lpszTitle = szTitle;
bi.pszDisplayName = szPath;
bi.hwndOwner = hWnd;
- bi.ulFlags = BIF_USENEWUI;
+ bi.ulFlags = iFlags;
bi.pidlRoot = il;
if ((ir = SHBrowseForFolder(&bi)) != NULL) {
@@ -3578,6 +3579,16 @@
return retval;
}
+static int prog_browse_usage(int retval)
+{
+ fprintf(stderr, "Usage: %s [OPTION]... TITLE\n", progname);
+ fprintf(stderr, "Browse for Folders (or Files)\n\n");
+ fprintf(stderr, " -f Show Files as well.\n");
+ fprintf(stderr, " -r Read-only. Do not show New Folder
button.\n\n");
+ print_stdusage();
+ return retval;
+}
+
/*
* ---------------------------------------------------------------------
* end of programs usage
@@ -5054,6 +5065,9 @@
int modal = MB_TASKMODAL;
char *p, *msg = NULL;
+ if (!GuiInitialize()) {
+ return x_perror(0, "Windows GUI");
+ }
while ((ch = getopt(argc, argv, "i:st:hqvV", 0)) != EOF) {
switch (ch) {
case '.':
@@ -5161,7 +5175,7 @@
*(p++) = '\n';
}
}
- rv = MessageBoxA(NULL, msg, argv[0], type | icon | modal);
+ rv = MessageBoxA(HWND_DESKTOP, msg, argv[0], type | icon | modal);
x_free(msg);
if (rv == 0)
rv = -1;
@@ -5397,6 +5411,73 @@
return rv;
}
+static int prog_browse(int argc, const char **argv, const char **env)
+{
+ int ch, rv = 0;
+ int flags = BIF_USENEWUI;
+ char *p, *msg = NULL;
+ char path[MAX_PATH] = { 0 };
+
+ if (!GuiInitialize()) {
+ return x_perror(0, "Windows GUI");
+ }
+ while ((ch = getopt(argc, argv, "frhqvV", 0)) != EOF) {
+ switch (ch) {
+ case '.':
+ if (!stricmp(optarg, "verbose"))
+ xtrace = 1;
+ else if (!stricmp(optarg, "version"))
+ return print_banner(1);
+ else if (!stricmp(optarg, "help"))
+ return prog_browse_usage(0);
+ else
+ return prog_browse_usage(EINVAL);
+ break;
+ case 'v':
+ xtrace = 1;
+ break;
+ case 'V':
+ xtrace = 9;
+ break;
+ case 'q':
+ xquiet = 1;
+ break;
+ case 'h':
+ return prog_browse_usage(0);
+ break;
+ case 'r':
+ flags &= ~(BIF_USENEWUI);
+ break;
+ case 'f':
+ flags |= BIF_BROWSEINCLUDEFILES;
+ break;
+ case '?':
+ case ':':
+ return EINVAL;
+ break;
+ }
+ }
+ argc -= optind;
+ argv += optind;
+ if (argc < 1) {
+ return prog_browse_usage(EINVAL);
+ }
+ msg = x_strdup(argv[0]);
+ for (p = msg; *p; p++) {
+ if (*p == '\\' && *(p + 1) == 'n') {
+ *(p++) = '\r';
+ *(p++) = '\n';
+ }
+ }
+ if (GuiBrowseForFolder(HWND_DESKTOP, msg, path, flags)) {
+ fputs(path, stdout);
+ }
+ else
+ rv = 1;
+ x_free(msg);
+ return rv;
+}
+
/*
* ---------------------------------------------------------------------
* end of programs
@@ -5422,6 +5503,7 @@
{ "reg", prog_reg },
{ "msg", prog_msg },
{ "jdk", prog_jdk },
+ { "dir", prog_browse },
{ NULL, NULL }
};
@@ -5477,8 +5559,6 @@
xtools_pause = 1;
if ((e = getenv("XTOOLS_VERBOSE")) != NULL) {
xtrace = atoi(e);
- if (!xtrace)
- xtrace = 1;
}
}
@@ -5544,12 +5624,12 @@
x_free(modname);
setup_env(env);
rv = umain(argc, argv, env);
- if (xtools_pause) {
+ if (!xquiet && xtools_pause) {
fprintf(stdout, "\nPress any key to continue...");
getch();
fprintf(stdout, "\n");
}
- if (xtrace)
+ if (xtrace > 1)
warnx("exit(%d)", rv);
exit(rv);
/*