-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Added more context menu tools and and setup for the future
- Loading branch information
Showing
9 changed files
with
292 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import SwiftUI | ||
|
||
protocol AstrixSection { | ||
var sectionName: String { get } | ||
|
||
func getSectionItems() -> [NSMenuItem] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// | ||
// SuggestionsSection.swift | ||
// FinderTools | ||
// | ||
// Created by Thom van den Broek on 19/11/2024. | ||
// | ||
|
||
import SwiftUI | ||
import FinderSync | ||
|
||
class ItemSection: AstrixSection { | ||
var sectionName: String { NSLocalizedString("Item", comment: "Item section") } | ||
|
||
func getSectionItems() -> [NSMenuItem] { | ||
var result: [NSMenuItem] = [] | ||
|
||
if let workspacePath = FIFinderSyncController.default().targetedURL(), | ||
let itemPaths = FIFinderSyncController.default().selectedItemURLs() { | ||
// Only allow it on single items | ||
if itemPaths.count > 1 || workspacePath.relativePath == itemPaths.first?.relativePath { return [] } | ||
|
||
let userDefaults = UserDefaults(suiteName: Constants.Id.DefaultsDomain) | ||
let editorKey = userDefaults?.string(forKey: Constants.Id.DefaultEditorKey) ?? SupportedApps.none.rawValue | ||
|
||
// Open the editor in this workspace | ||
if editorKey != SupportedApps.none.rawValue { | ||
let openInEditorItem = NSMenuItem(title: NSLocalizedString("Open in Editor", comment: ""), action: #selector(FinderSync.openItemInEditor(_:)), keyEquivalent: "") | ||
result.append(openInEditorItem) | ||
} | ||
} | ||
return result | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// | ||
// SuggestionsSection.swift | ||
// FinderTools | ||
// | ||
// Created by Thom van den Broek on 19/11/2024. | ||
// | ||
|
||
import SwiftUI | ||
import FinderSync | ||
|
||
class SuggestionsSection: AstrixSection { | ||
var sectionName: String { NSLocalizedString("Suggestions", comment: "Suggestions section") } | ||
|
||
func getSectionItems() -> [NSMenuItem] { | ||
var result: [NSMenuItem] = [] | ||
|
||
if let workspacePath = FIFinderSyncController.default().targetedURL() { | ||
// check if the folder contains a .vscode folder | ||
if FileManager.default.fileExists(atPath: (workspacePath.appendingPathComponent(".vscode")).path) { | ||
if Scripting.shared.isAppInstalled(bundleIdentifier: SupportedApps.vsCode.rawValue) { | ||
let item = NSMenuItem( | ||
title: NSLocalizedString("Open in \(Utilities.getBundleApplicationName(bundleId: .vsCode))", comment: ""), | ||
action: #selector(FinderSync.openInVSCode(_:)), | ||
keyEquivalent: "" | ||
) | ||
result.append(item) | ||
} | ||
if Scripting.shared.isAppInstalled(bundleIdentifier: SupportedApps.vsCodeInsiders.rawValue) { | ||
let item = NSMenuItem( | ||
title: NSLocalizedString("Open in \(Utilities.getBundleApplicationName(bundleId: .vsCodeInsiders))", comment: ""), | ||
action: #selector(FinderSync.openInVSCodeInsiders(_:)), | ||
keyEquivalent: "" | ||
) | ||
result.append(item) | ||
} | ||
if Scripting.shared.isAppInstalled(bundleIdentifier: SupportedApps.cursor.rawValue) { | ||
let item = NSMenuItem( | ||
title: NSLocalizedString("Open in \(Utilities.getBundleApplicationName(bundleId: .cursor))", comment: ""), | ||
action: #selector(FinderSync.openInCursor(_:)), | ||
keyEquivalent: "" | ||
) | ||
result.append(item) | ||
} | ||
} | ||
|
||
// check if there is any file ending with .xcodeproj | ||
let (success, response) = Utilities.runCommand("cd '\(workspacePath.relativePath)' && find *.xcodeproj -d 0") | ||
NSLog("success: \(success), res: \(response)") | ||
NSLog("installed: \(Scripting.shared.isAppInstalled(bundleIdentifier: SupportedApps.xcode.rawValue))") | ||
if success && Scripting.shared.isAppInstalled(bundleIdentifier: SupportedApps.xcode.rawValue) { | ||
let item = NSMenuItem( | ||
title: NSLocalizedString("Open in \(Utilities.getBundleApplicationName(bundleId: .xcode))", comment: ""), | ||
action: #selector(FinderSync.openInXCode(_:)), | ||
keyEquivalent: "" | ||
) | ||
result.append(item) | ||
} | ||
} | ||
|
||
return result | ||
} | ||
} |
Oops, something went wrong.