! Copyright (C) 2006, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: alien.syntax cocoa cocoa.application cocoa.classes cocoa.dialogs cocoa.nibs cocoa.pasteboard cocoa.runtime cocoa.subclassing core-foundation.strings eval kernel listener locals memory namespaces system ui.backend.cocoa ui.theme.switching ui.tools.browser ui.tools.listener vocabs.refresh ; FROM: alien.c-types => int void ; IN: ui.backend.cocoa.tools : finder-run-files ( alien -- ) CF>string-array listener-run-files NSApp NSApplicationDelegateReplySuccess -> replyToOpenOrPrint: ; : menu-run-files ( -- ) open-panel [ listener-run-files ] when* ; : menu-save-image ( -- ) image-path save-panel [ save-image ] when* ; ! Handle Open events from the Finder : install-workspace-delegate ( -- ) NSApp FactorWorkspaceApplicationDelegate install-delegate ; ! Service support; evaluate Factor code from other apps :: do-service ( pboard error quot -- ) pboard error ?pasteboard-string dup [ quot call( string -- result/f ) ] when [ pboard set-pasteboard-string ] when* ; string) ] with-interactive-vocabs ] do-service ] ; ;CLASS> : register-services ( -- ) NSApp FactorServiceProvider -> alloc -> init -> setServicesProvider: ; FUNCTION: void NSUpdateDynamicServices ( ) [ install-workspace-delegate "Factor.nib" load-nib register-services ] cocoa-startup-hook set-global