diff --git a/Makefile b/Makefile index ab9915cad8..1a5fad4abf 100644 --- a/Makefile +++ b/Makefile @@ -92,22 +92,6 @@ windows: macosx.app: cp $(BINARY) $(BUNDLE)/Contents/MacOS/Factor - rm -rf $(BUNDLE)/Contents/Resources/ - mkdir -p $(BUNDLE)/Contents/Resources/fonts/ - - chmod +x cp_dir - find doc library contrib examples fonts \( -name '*.factor' \ - -o -name '*.facts' \ - -o -name '*.txt' \ - -o -name '*.html' \ - -o -name '*.ttf' \ - -o -name '*.js' \) \ - -exec ./cp_dir {} $(BUNDLE)/Contents/Resources/{} \; - - cp version.factor $(BUNDLE)/Contents/Resources/ - - cp $(IMAGE) $(BUNDLE)/Contents/Resources/factor.image - install_name_tool \ -id @executable_path/../Frameworks/libfreetype.6.dylib \ Factor.app/Contents/Frameworks/libfreetype.6.dylib diff --git a/TODO.FACTOR.txt b/TODO.FACTOR.txt index c3dc9a94d0..de498ed38f 100644 --- a/TODO.FACTOR.txt +++ b/TODO.FACTOR.txt @@ -46,7 +46,7 @@ - slider needs to be modelized - continuation handling in walker is screwy - graphical module manager tool -- figure out what goes in the .app and what doesn't +- fonts/ should go inside the .app -- we need multi-tier resource-path - should be possible to drop an image file on the .app to run it - add-gadget, model-changed, set-model should compile - shortcuts: diff --git a/library/ui/cocoa/core-foundation.factor b/library/ui/cocoa/core-foundation.factor index 4cfa1f7315..08ca9bbdba 100644 --- a/library/ui/cocoa/core-foundation.factor +++ b/library/ui/cocoa/core-foundation.factor @@ -75,7 +75,3 @@ FUNCTION: void CFRelease ( void* cf ) ; ] [ "Cannot load bundled named " swap append throw ] ?if ; - -: running.app? ( -- ? ) - #! Test if we're running Factor.app. - "Contents/Resources" image subseq? ; diff --git a/library/ui/cocoa/init-cocoa.factor b/library/ui/cocoa/init-cocoa.factor index 7033092c9a..1484ea0121 100644 --- a/library/ui/cocoa/init-cocoa.factor +++ b/library/ui/cocoa/init-cocoa.factor @@ -10,6 +10,7 @@ USING: cocoa compiler io kernel objc sequences words ; { "NSApplication" "NSAutoreleasePool" + "NSBundle" "NSError" "NSEvent" "NSException" diff --git a/library/ui/cocoa/ui.factor b/library/ui/cocoa/ui.factor index 465bc863c6..57d4b6623e 100644 --- a/library/ui/cocoa/ui.factor +++ b/library/ui/cocoa/ui.factor @@ -62,6 +62,12 @@ IN: gadgets : flush-gl-context ( handle -- ) first -> openGLContext -> flushBuffer ; +: running.app? ( -- ? ) + #! Test if we're running Factor.app. + "Factor.app" + NSBundle -> mainBundle -> bundlePath CF>string + subseq? ; + IN: shells : ui diff --git a/vm/os-macosx.m b/vm/os-macosx.m index fd0a892a60..7ba439f06a 100644 --- a/vm/os-macosx.m +++ b/vm/os-macosx.m @@ -43,7 +43,12 @@ void early_init(void) const char *default_image_path(void) { NSBundle *bundle = [NSBundle mainBundle]; - NSString *image = [[bundle resourcePath] stringByAppendingString:@"/factor.image"]; + NSString *path = [bundle bundlePath]; + NSString *image; + if([path hasSuffix:@".app"] || [path hasSuffix:@".app/"]) + image = [[path stringByDeletingLastPathComponent] stringByAppendingString:@"/factor.image"]; + else + image = [path stringByAppendingString:@"/factor.image"]; return [image cString]; }