forked from IngmarStein/Monolingual
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AppDelegate.swift
62 lines (48 loc) · 2.18 KB
/
AppDelegate.swift
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//
// AppDelegate.swift
// Monolingual
//
// Created by Ingmar Stein on 14.07.14.
//
//
import Cocoa
let ProcessApplicationNotification = "ProcessApplicationNotification"
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
var preferencesWindowController : NSWindowController?
func applicationDidFinishLaunching(NSNotification) {
let applications = [ "Path" : "/Applications", "Languages" : true, "Architectures" : true ]
let developer = [ "Path" : "/Developer", "Languages" : true, "Architectures" : true ]
let library = [ "Path" : "/Library", "Languages" : true, "Architectures" : true ]
let systemPath = [ "Path" : "/System", "Languages" : true, "Architectures" : false ]
let defaultRoots = [ applications, developer, library, systemPath ]
let defaultDict = [ "Roots" : defaultRoots, "Trash" : false, "Strip" : false ]
NSUserDefaults.standardUserDefaults().registerDefaults(defaultDict)
}
func applicationShouldTerminateAfterLastWindowClosed(NSApplication!) -> Bool {
return true
}
func application(sender: NSApplication!, openFile filename: String!) -> Bool {
let dict = [ "Path" : filename, "Language" : true, "Architectures" : true ]
NSNotificationCenter.defaultCenter().postNotificationName(ProcessApplicationNotification, object: self, userInfo: dict)
return true
}
// #pragma mark - Actions
@IBAction func documentationBundler(sender : NSMenuItem) {
let docURL = NSBundle.mainBundle().URLForResource(sender.title, withExtension:nil)
NSWorkspace.sharedWorkspace().openURL(docURL!)
}
@IBAction func openWebsite(AnyObject) {
NSWorkspace.sharedWorkspace().openURL(NSURL(string:"https://ingmarstein.github.io/Monolingual")!)
}
@IBAction func donate(AnyObject) {
NSWorkspace.sharedWorkspace().openURL(NSURL(string:"https://ingmarstein.github.io/Monolingual/donate.html")!)
}
@IBAction func showPreferences(sender: AnyObject) {
if preferencesWindowController == nil {
let storyboard = NSStoryboard(name:"Main", bundle:nil)
preferencesWindowController = storyboard!.instantiateControllerWithIdentifier("PreferencesWindow") as? NSWindowController
}
preferencesWindowController?.showWindow(sender)
}
}