From: slava Date: Sat, 14 Oct 2006 02:49:14 +0000 (+0000) Subject: Interface builder menu bar not works X-Git-Url: https://gitweb.factorcode.org/gitweb.cgi?p=factor.git;a=commitdiff_plain;h=341caf245ca60d7181248e0eb8e0d6147e6d140f Interface builder menu bar not works --- diff --git a/Factor.app/Contents/Resources/English.lproj/Factor.nib/classes.nib b/Factor.app/Contents/Resources/English.lproj/Factor.nib/classes.nib index b9b4b09f6b..bf3d2a6560 100644 --- a/Factor.app/Contents/Resources/English.lproj/Factor.nib/classes.nib +++ b/Factor.app/Contents/Resources/English.lproj/Factor.nib/classes.nib @@ -1,4 +1,17 @@ { - IBClasses = ({CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }); + IBClasses = ( + { + ACTIONS = { + newFactorWorkspace = id; + runFactorFile = id; + saveFactorImage = id; + saveFactorImageAs = id; + showFactorHelp = id; + }; + CLASS = FirstResponder; + LANGUAGE = ObjC; + SUPERCLASS = NSObject; + } + ); IBVersion = 1; } \ No newline at end of file diff --git a/Factor.app/Contents/Resources/English.lproj/Factor.nib/info.nib b/Factor.app/Contents/Resources/English.lproj/Factor.nib/info.nib index bcc1ea3254..68d7cbf925 100644 --- a/Factor.app/Contents/Resources/English.lproj/Factor.nib/info.nib +++ b/Factor.app/Contents/Resources/English.lproj/Factor.nib/info.nib @@ -3,11 +3,11 @@ IBDocumentLocation - 1622 173 356 240 0 0 2560 1578 + 1207 49 525 491 0 0 2560 1578 IBEditorPositions 29 - 524 461 270 44 0 0 2560 1578 + 1771 315 420 44 0 0 2560 1578 IBFramework Version 439.0 diff --git a/Factor.app/Contents/Resources/English.lproj/Factor.nib/keyedobjects.nib b/Factor.app/Contents/Resources/English.lproj/Factor.nib/keyedobjects.nib index ea37efcd17..a51fdd8781 100644 Binary files a/Factor.app/Contents/Resources/English.lproj/Factor.nib/keyedobjects.nib and b/Factor.app/Contents/Resources/English.lproj/Factor.nib/keyedobjects.nib differ diff --git a/contrib/README.txt b/contrib/README.txt index 92dfa1dba1..c372d72f49 100644 --- a/contrib/README.txt +++ b/contrib/README.txt @@ -14,6 +14,7 @@ Available libraries: - boids -- Graphics demo for the UI (Eduardo Cavazos) - cairo -- cairo bindings (Sampo Vuori) - calendar -- timestamp/calendar with timezones (Doug Coleman) +- cocoa-callbacks -- Allows you to use Factor quotations as actions (Slava Pestov) - concurrency -- Erlang/Termite-style distibuted concurrency (Chris Double) - coroutines -- coroutines (Chris Double) - crypto -- Various cryptographic algorithms (Doug Coleman) diff --git a/contrib/cocoa-callbacks.factor b/contrib/cocoa-callbacks.factor new file mode 100644 index 0000000000..e4aa8c0018 --- /dev/null +++ b/contrib/cocoa-callbacks.factor @@ -0,0 +1,34 @@ +! Copyright (C) 2005, 2006 Kevin Reid. +! See http://factorcode.org/license.txt for BSD license. +IN: objc-classes +DEFER: FactorCallback + +IN: cocoa-callbacks +USING: gadgets hashtables kernel namespaces objc cocoa ; + +SYMBOL: callbacks + +: reset-callbacks ( -- ) + H{ } clone callbacks set-global ; + +reset-callbacks + +"NSObject" "FactorCallback" { + { "perform:" "void" { "id" "SEL" "id" } + [ 2drop callbacks get hash ui-try ] + } + + { "dealloc" "void" { "id" "SEL" } + [ + drop + dup callbacks get remove-hash + SUPER-> dealloc + ] + } +} define-objc-class + +: ( quot -- id ) + FactorCallback -> alloc -> init + [ callbacks get set-hash ] keep ; + +PROVIDE: callbacks ; diff --git a/library/modules.factor b/library/modules.factor index 99569de787..78361b9154 100644 --- a/library/modules.factor +++ b/library/modules.factor @@ -35,12 +35,6 @@ C: module ( name files tests -- module ) : require ( name -- ) dup module [ drop ] [ load-module ] if do-parse-hook ; -: run-files ( seq -- ) - [ - bootstrapping? get - [ parse-file % ] [ run-file ] ? each - ] no-parse-hook ; - : process-files ( seq -- newseq ) [ dup string? [ [ t ] 2array ] when ] map [ second call ] subset diff --git a/library/syntax/parse-stream.factor b/library/syntax/parse-stream.factor index 4ec43ef586..4cc00f9003 100644 --- a/library/syntax/parse-stream.factor +++ b/library/syntax/parse-stream.factor @@ -82,6 +82,12 @@ SYMBOL: parse-hook : run-file ( file -- ) parse-file call ; +: run-files ( seq -- ) + [ + bootstrapping? get + [ parse-file % ] [ run-file ] ? each + ] no-parse-hook ; + : no-parse-hook ( quot -- ) [ parse-hook off call ] with-scope ; inline diff --git a/library/ui/cocoa/callback.factor b/library/ui/cocoa/callback.factor deleted file mode 100644 index 0e1e12624c..0000000000 --- a/library/ui/cocoa/callback.factor +++ /dev/null @@ -1,32 +0,0 @@ -! Copyright (C) 2005, 2006 Kevin Reid. -! See http://factorcode.org/license.txt for BSD license. -IN: objc-classes -DEFER: FactorCallback - -IN: cocoa -USING: gadgets hashtables kernel namespaces objc ; - -SYMBOL: callbacks - -: reset-callbacks ( -- ) - H{ } clone callbacks set-global ; - -reset-callbacks - -"NSObject" "FactorCallback" { - { "perform:" "void" { "id" "SEL" "id" } - [ 2drop callbacks get hash ui-try ] - } - - { "dealloc" "void" { "id" "SEL" } - [ - drop - dup callbacks get remove-hash - SUPER-> dealloc - ] - } -} define-objc-class - -: ( quot -- id ) - FactorCallback -> alloc -> init - [ callbacks get set-hash ] keep ; \ No newline at end of file diff --git a/library/ui/cocoa/load.factor b/library/ui/cocoa/load.factor index 73c470f2f5..898e2331d7 100644 --- a/library/ui/cocoa/load.factor +++ b/library/ui/cocoa/load.factor @@ -6,7 +6,6 @@ PROVIDE: library/ui/cocoa { "core-foundation.factor" "types.factor" "init-cocoa.factor" - "callback.factor" "application-utils.factor" "pasteboard-utils.factor" "view-utils.factor" diff --git a/library/ui/cocoa/ui.factor b/library/ui/cocoa/ui.factor index 0b06024e6d..626006a419 100644 --- a/library/ui/cocoa/ui.factor +++ b/library/ui/cocoa/ui.factor @@ -4,8 +4,9 @@ IN: objc-classes DEFER: FactorApplicationDelegate IN: cocoa -USING: arrays gadgets gadgets-listener gadgets-workspace -hashtables kernel memory namespaces objc sequences errors freetype ; +USING: arrays gadgets gadgets-listener gadgets-help +gadgets-workspace hashtables kernel memory namespaces objc +sequences errors freetype help ; : finder-run-files ( alien -- ) #! We filter out the image name since that might be there on @@ -14,18 +15,38 @@ hashtables kernel memory namespaces objc sequences errors freetype ; NSApp NSApplicationDelegateReplySuccess -> replyToOpenOrPrint: ; +: menu-run-files ( -- ) + open-panel [ listener-run-files ] when* ; + ! Handle Open events from the Finder "NSObject" "FactorApplicationDelegate" { { "application:openFiles:" "void" { "id" "SEL" "id" "id" } [ >r 3drop r> finder-run-files ] } + + { "runFactorFile:" "id" { "id" "SEL" "id" } + [ 3drop menu-run-files f ] + } + + { "newFactorWorkspace:" "id" { "id" "SEL" "id" } + [ 3drop workspace-window f ] + } + + { "showFactorHelp:" "id" { "id" "SEL" "id" } + [ 3drop "handbook" help-gadget call-tool f ] + } } define-objc-class : install-app-delegate ( -- ) NSApp FactorApplicationDelegate install-delegate ; +: load-nib ( -- ) + NSBundle + "Factor.nib" NSApp -> loadNibNamed:owner: + drop ; + : init-cocoa ( -- ) - reset-callbacks + load-nib install-app-delegate register-services init-clipboard ; diff --git a/library/ui/tools/listener.factor b/library/ui/tools/listener.factor index ba6fbdc5e9..f35189d5d7 100644 --- a/library/ui/tools/listener.factor +++ b/library/ui/tools/listener.factor @@ -89,7 +89,7 @@ M: listener-gadget tool-help dup empty? [ drop ] [ - [ [ run-file ] each ] curry call-listener + [ run-files ] curry call-listener ] if ; : listener-eof ( listener -- ) diff --git a/vm/Config.macosx b/vm/Config.macosx index de71d178cf..8e35a3a06a 100644 --- a/vm/Config.macosx +++ b/vm/Config.macosx @@ -1,3 +1,3 @@ include vm/Config.unix PLAF_OBJS += vm/os-macosx.o vm/mach_signal.o -LIBS= -lm -framework Cocoa -framework OpenGL -L/usr/X11R6/lib -lfreetype +LIBS= -lm -framework Cocoa -framework OpenGL -framework AppKit -L/usr/X11R6/lib -lfreetype