Skip to content

Commit 189ec58

Browse files
committedJan 9, 2019
Drag into Dock-Icon kind-of works now
1 parent d62c00c commit 189ec58

File tree

4 files changed

+32
-12
lines changed

4 files changed

+32
-12
lines changed
 

‎Skewbacca Native/AppDelegate.swift

+7-11
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,27 @@
1-
//
2-
// AppDelegate.swift
3-
// Skewbacca Native
4-
//
5-
// Created by Antonio Radovcic on 01.01.19.
6-
// Copyright © 2019 niorad. All rights reserved.
7-
//
8-
91
import Cocoa
102

113
@NSApplicationMain
124
class AppDelegate: NSObject, NSApplicationDelegate {
135

146
@IBOutlet weak var openMenuItem: NSMenuItem!
157
@IBOutlet weak var exportMenuItem: NSMenuItem!
8+
var rootVC: ViewController!
9+
10+
func application(_ sender: NSApplication, openFile filename: String) -> Bool {
11+
rootVC.onFileDraggedOnDock(filename)
12+
return true
13+
}
1614

1715
func applicationDidFinishLaunching(_ aNotification: Notification) {
18-
// Insert code here to initialize your application
16+
rootVC = (NSApplication.shared.mainWindow?.windowController?.contentViewController as! ViewController)
1917
}
2018

2119
func applicationWillTerminate(_ aNotification: Notification) {
22-
// Insert code here to tear down your application
2320
}
2421

2522
func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
2623
return true
2724
}
2825

29-
3026
}
3127

‎Skewbacca Native/Info.plist

+21
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,27 @@
44
<dict>
55
<key>CFBundleDevelopmentRegion</key>
66
<string>$(DEVELOPMENT_LANGUAGE)</string>
7+
<key>CFBundleDocumentTypes</key>
8+
<array>
9+
<dict>
10+
<key>CFBundleTypeExtensions</key>
11+
<array>
12+
<string>*</string>
13+
</array>
14+
<key>CFBundleTypeMIMETypes</key>
15+
<array>
16+
<string>image/jpeg</string>
17+
</array>
18+
<key>CFBundleTypeName</key>
19+
<string>Image Files</string>
20+
<key>CFBundleTypeRole</key>
21+
<string>Viewer</string>
22+
<key>LSTypeIsPackage</key>
23+
<integer>0</integer>
24+
<key>NSDocumentClass</key>
25+
<string>NSDocument</string>
26+
</dict>
27+
</array>
728
<key>CFBundleExecutable</key>
829
<string>$(EXECUTABLE_NAME)</string>
930
<key>CFBundleIconFile</key>

‎Skewbacca Native/StageController.swift

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import Cocoa
22

3-
43
class StageController: NSViewController {
54

65
@IBOutlet var topLeft: NSImageView!

‎Skewbacca Native/ViewController.swift

+4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ class ViewController: NSViewController {
2323
}
2424
}
2525

26+
func onFileDraggedOnDock(_ path: String) {
27+
stageViewController!.setImage(URL(fileURLWithPath: path))
28+
}
29+
2630
@IBAction func onOpenMenuItemSelected(_ sender: Any) {
2731
let openDialog = NSOpenPanel()
2832
openDialog.title = "Open Image"

0 commit comments

Comments
 (0)
Please sign in to comment.