Skip to content

Commit 429931c

Browse files
committed
Add dock drag/drop ability
1 parent cdccef8 commit 429931c

File tree

6 files changed

+53
-5
lines changed

6 files changed

+53
-5
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ Sentinel/.DS_Store
33
Sentinel Resources/.DS_Store
44
.DS_Store
55
*.xcuserstate
6-
Builds/
6+
Builds/
7+
.claude

Sentinel.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.

Sentinel/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<key>CFBundleTypeName</key>
99
<string>Application Bundle</string>
1010
<key>CFBundleTypeRole</key>
11-
<string>Viewer</string>
11+
<string>Editor</string>
1212
<key>LSHandlerRank</key>
1313
<string>Default</string>
1414
<key>LSItemContentTypes</key>

Sentinel/SentinelApp.swift

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,33 @@ class AppDelegate: NSObject, NSApplicationDelegate {
6262
updateGatekeeperUI(appState: AppState.shared)
6363
}
6464
}
65+
66+
// MARK: - File Opening
67+
68+
func application(_ sender: NSApplication, openFiles filenames: [String]) {
69+
// Set multiDrop flag if more than one file
70+
if filenames.count > 1 {
71+
updateOnMain {
72+
AppState.shared.multiDrop = true
73+
}
74+
}
75+
76+
// Process each dropped file
77+
for filename in filenames {
78+
guard FileManager.default.fileExists(atPath: filename) else {
79+
printOS("File dropped on Dock icon doesn't exist: \(filename)")
80+
continue
81+
}
82+
83+
let fileURL = URL(fileURLWithPath: filename)
84+
85+
guard fileURL.pathExtension == "app" else {
86+
printOS("Dropped file is not an application bundle: \(filename)")
87+
continue
88+
}
89+
90+
// Process the file using existing logic
91+
handleDeepLinkedApps(url: fileURL, appState: AppState.shared)
92+
}
93+
}
6594
}

Sentinel/Utilities/DeepLink.swift

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,24 @@ import Foundation
99
import AlinFoundation
1010

1111
func handleDeepLinkedApps(url: URL, appState: AppState) {
12+
// Case 1: Direct file URL (from Dock drop)
13+
if url.isFileURL {
14+
guard FileManager.default.fileExists(atPath: url.path) else {
15+
printOS("DLM: Direct file URL doesn't exist: \(url.path)")
16+
return
17+
}
18+
19+
updateOnMain {
20+
appState.status = "Attempting to remove app from quarantine"
21+
appState.isLoading = true
22+
}
23+
Task {
24+
_ = await CmdRunDrop(cmd: "xattr -rd com.apple.quarantine", path: url.path, type: .quarantine, appState: appState)
25+
}
26+
return
27+
}
28+
29+
// Case 2: URL scheme with query parameters (from deep link)
1230
if let components = URLComponents(url: url, resolvingAgainstBaseURL: true),
1331
let queryItems = components.queryItems {
1432

@@ -28,11 +46,11 @@ func handleDeepLinkedApps(url: URL, appState: AppState) {
2846
{
2947
_ = await CmdRunDrop(cmd: "xattr -rd com.apple.quarantine", path: pathURL.path, type: .quarantine, appState: appState)
3048
}
31-
49+
3250
} else {
3351
printOS("DLM: No valid query items for 'path' found in the URL.")
3452
}
3553
} else {
36-
printOS("DLM: URL does not match the expected scheme pear://")
54+
printOS("DLM: URL does not match expected format")
3755
}
3856
}

0 commit comments

Comments
 (0)