Skip to content

Commit 27cc54a

Browse files
committed
Open/Save
1 parent 7bd8dab commit 27cc54a

File tree

5 files changed

+62
-3
lines changed

5 files changed

+62
-3
lines changed

ColorSet.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
05D11EC720E13B9400A621B5 /* Icon.icns in Resources */ = {isa = PBXBuildFile; fileRef = 05D11EC620E13B9400A621B5 /* Icon.icns */; };
2222
05D11ECA20E13DFF00A621B5 /* ColorSet.AboutWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 05D11EC820E13DFF00A621B5 /* ColorSet.AboutWindowController.xib */; };
2323
05D11ECC20E13E0900A621B5 /* AboutWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 05D11ECB20E13E0800A621B5 /* AboutWindowController.swift */; };
24+
05D11ECE20E165FB00A621B5 /* File.icns in Resources */ = {isa = PBXBuildFile; fileRef = 05D11ECD20E165FB00A621B5 /* File.icns */; };
2425
/* End PBXBuildFile section */
2526

2627
/* Begin PBXFileReference section */
@@ -43,6 +44,7 @@
4344
05D11EC620E13B9400A621B5 /* Icon.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = Icon.icns; sourceTree = "<group>"; };
4445
05D11EC920E13DFF00A621B5 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/ColorSet.AboutWindowController.xib; sourceTree = "<group>"; };
4546
05D11ECB20E13E0800A621B5 /* AboutWindowController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AboutWindowController.swift; sourceTree = "<group>"; };
47+
05D11ECD20E165FB00A621B5 /* File.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = File.icns; sourceTree = "<group>"; };
4648
/* End PBXFileReference section */
4749

4850
/* Begin PBXFrameworksBuildPhase section */
@@ -106,6 +108,7 @@
106108
isa = PBXGroup;
107109
children = (
108110
05D11EC620E13B9400A621B5 /* Icon.icns */,
111+
05D11ECD20E165FB00A621B5 /* File.icns */,
109112
0543AE7720DC33DF00284E99 /* MainMenu.xib */,
110113
0543AE7E20DC35CC00284E99 /* ColorSet.MainWindowController.xib */,
111114
05D11EC820E13DFF00A621B5 /* ColorSet.AboutWindowController.xib */,
@@ -179,6 +182,7 @@
179182
files = (
180183
05D11EC720E13B9400A621B5 /* Icon.icns in Resources */,
181184
0543AE8020DC35CC00284E99 /* ColorSet.MainWindowController.xib in Resources */,
185+
05D11ECE20E165FB00A621B5 /* File.icns in Resources */,
182186
0543AE7B20DC33DF00284E99 /* MainMenu.xib in Resources */,
183187
05D11ECA20E13DFF00A621B5 /* ColorSet.AboutWindowController.xib in Resources */,
184188
);

ColorSet/Classes/ApplicationDelegate.swift

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ class ApplicationDelegate: NSResponder, NSApplicationDelegate
5959
self.aboutWindowController?.window?.makeKeyAndOrderFront( sender )
6060
}
6161

62+
func application( _ sender: NSApplication, openFile filename: String ) -> Bool
63+
{
64+
return self.open( url: URL( fileURLWithPath: filename ) )
65+
}
66+
6267
@IBAction public func openDocument( _ sender: Any? )
6368
{
6469
let panel = NSOpenPanel()
@@ -81,6 +86,11 @@ class ApplicationDelegate: NSResponder, NSApplicationDelegate
8186
return
8287
}
8388

89+
let _ = self.open( url: url )
90+
}
91+
92+
private func open( url: URL ) -> Bool
93+
{
8494
do
8595
{
8696
let data = try Data( contentsOf: url )
@@ -93,20 +103,22 @@ class ApplicationDelegate: NSResponder, NSApplicationDelegate
93103

94104
alert.runModal()
95105

96-
return
106+
return false
97107
}
98108

99109
let controller = MainWindowController( colors: colors )
100110
controller.url = url
101111

102112
controller.window?.center()
103-
controller.window?.makeKeyAndOrderFront( sender )
113+
controller.window?.makeKeyAndOrderFront( nil )
104114

105115
self.controllers.append( controller )
106116
}
107117
catch let error as NSError
108118
{
109119
NSAlert( error: error ).runModal()
110120
}
121+
122+
return true
111123
}
112124
}

ColorSet/Info.plist

Lines changed: 43 additions & 0 deletions
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>colorset</string>
13+
</array>
14+
<key>CFBundleTypeIconFile</key>
15+
<string>File</string>
16+
<key>CFBundleTypeName</key>
17+
<string>Color Set File</string>
18+
<key>CFBundleTypeRole</key>
19+
<string>Editor</string>
20+
<key>LSItemContentTypes</key>
21+
<array>
22+
<string>com.DigiDNA.ColorSet</string>
23+
</array>
24+
<key>LSTypeIsPackage</key>
25+
<integer>0</integer>
26+
</dict>
27+
</array>
728
<key>CFBundleExecutable</key>
829
<string>$(EXECUTABLE_NAME)</string>
930
<key>CFBundleIconFile</key>
@@ -28,5 +49,27 @@
2849
<string>MainMenu</string>
2950
<key>NSPrincipalClass</key>
3051
<string>NSApplication</string>
52+
<key>UTExportedTypeDeclarations</key>
53+
<array>
54+
<dict>
55+
<key>UTTypeConformsTo</key>
56+
<array>
57+
<string>public.data</string>
58+
</array>
59+
<key>UTTypeDescription</key>
60+
<string>Color Set File</string>
61+
<key>UTTypeIconFile</key>
62+
<string>File</string>
63+
<key>UTTypeIdentifier</key>
64+
<string>com.DigiDNA.ColorSet</string>
65+
<key>UTTypeTagSpecification</key>
66+
<dict>
67+
<key>public.filename-extension</key>
68+
<array>
69+
<string>colorset</string>
70+
</array>
71+
</dict>
72+
</dict>
73+
</array>
3174
</dict>
3275
</plist>

ColorSet/Interface/Base.lproj/ColorSet.MainWindowController.xib

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,7 @@
819819
</view>
820820
<point key="canvasLocation" x="244" y="314"/>
821821
</window>
822-
<arrayController id="awq-PE-ook"/>
822+
<arrayController selectsInsertedObjects="NO" avoidsEmptySelection="NO" id="awq-PE-ook"/>
823823
</objects>
824824
<resources>
825825
<image name="NSApplicationIcon" width="128" height="128"/>

ColorSet/Interface/File.icns

439 KB
Binary file not shown.

0 commit comments

Comments
 (0)