diff options
| author | Matthias Melcher <fltk@matthiasm.com> | 2010-02-21 22:46:13 +0000 |
|---|---|---|
| committer | Matthias Melcher <fltk@matthiasm.com> | 2010-02-21 22:46:13 +0000 |
| commit | 3b65dcead9c531a5a9d533945f5ba0e27be98161 (patch) | |
| tree | f722da5b7876d7552bb85f20721dc8aab82266a2 /test | |
| parent | 47ed5a1dddcb084f3fdfa871d39de0df09c30a97 (diff) | |
Fixed Demo for OS X to use the correct command to launch other applications from the right current directory.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7133 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'test')
| -rw-r--r-- | test/demo.cxx | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/test/demo.cxx b/test/demo.cxx index 7900df413..4df676a5f 100644 --- a/test/demo.cxx +++ b/test/demo.cxx @@ -38,7 +38,7 @@ const char *default_menu[] = { "#\n", "\n", "@main:Widget\\nTests:@x\n", - "@x:Fl_Browser:browser\n", + "@x:Fl_Browser:browser browser.cxx\n", "@x:Fl_Input:input\n", "@x:Fl_Output:output\n", "@x:Fl_Button:radio\n", @@ -377,18 +377,33 @@ void dobut(Fl_Widget *, long arg) char *cmd = strdup(menus[men].icommand[bn]); char *arg = strchr(cmd, ' '); - char command[2048]; + char command[2048], path[2048], app_path[2048]; + + // this neat litle block of cose ensures that the current directory is set + // to the location of the Demo application. + CFBundleRef app = CFBundleGetMainBundle(); + CFURLRef url = CFBundleCopyBundleURL(app); + CFStringRef cc_app_path = CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle); + CFStringGetCString(cc_app_path, app_path, 2048, kCFStringEncodingUTF8); + if (*app_path) { + char *n = strrchr(app_path, '/'); + if (n) { + *n = 0; + chdir(app_path); + } + } + if (arg) { *arg = 0; - if (strcmp(cmd, "../fluid/fluid")==0) -// sprintf(command, "open ../../../Fluid.app --args %s", arg+1); - sprintf(command, "../../../Fluid.app/Contents/MacOS/Fluid ../../../../../../../test/%s", arg+1); - else -// sprintf(command, "open ../../../%s.app --args %s", cmd, arg+1); - sprintf(command, "../../../%s.app/Contents/MacOS/%s ../../../../../../../test/%s", cmd, cmd, arg+1); + if (strcmp(cmd, "../fluid/fluid")==0) { + fl_filename_absolute(path, 2048, "../../../../test/"); + sprintf(command, "open Fluid.app --args %s%s", path, arg+1); + } else { + fl_filename_absolute(path, 2048, "../../../../test/"); + sprintf(command, "open %s.app --args %s%s", cmd, path, arg+1); + } } else { -// sprintf(command, "open ../../../%s.app", cmd); - sprintf(command, "../../../%s.app/Contents/MacOS/%s", cmd, cmd); + sprintf(command, "open %s.app", cmd); } // puts(command); system(command); |
