public
Description: A popular sample Cocoa application rewritten in Nu. Original code by Aaron Hillegass, ported to Nu by Tim Burks.
Homepage: http://programming.nu/posts/2007/12/12/nupagepacker
Clone URL: git://github.com/timburks/nupagepacker.git
nupagepacker / nu / main.nu
100644 37 lines (28 sloc) 1.355 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
;; @file main.nu
;; @discussion Entry point for a Nu program.
;;
;; @copyright Copyright (c) 2007 Tim Burks, Neon Design Technology, Inc.
 
(load "Nu:nu") ;; essentials
(load "Nu:cocoa")  ;; wrapped frameworks
(load "Nu:console")  ;; interactive console
(load "bridged") ;; more bridged declarations
(load "helpers")  ;; some helper functions
(load "packer")    ;; the main application code
 
;; Initialize methods for Nu classes aren't (yet) called automatically, so we call them here.
(PackerView initialize)
(PreferenceController initialize)
(DraggingSourcePDFView initialize)
 
;; The console is too much fun to omit.
(set SHOW_CONSOLE_AT_STARTUP nil)
 
;; The main application controller.
(class AppController is NSObject
     (imethod (void) applicationDidFinishLaunching: (id) sender is
          (set $console ((NuConsoleWindowController alloc) init))
          (if SHOW_CONSOLE_AT_STARTUP ($console toggleConsole:self))
          ((CatalogController sharedCatalogController) showWindow:nil)))
 
(load "scripting") ;; scripting support must be loaded after AppControler is defined
 
(set NSApp (NSApplication sharedApplication))
 
;; this makes the application window take focus when we've started it from the terminal (like when we type "nuke run")
(NSApp activateIgnoringOtherApps:YES)
 
;; run the main Cocoa event loop
(NSApplicationMain 0 nil)