mirror of
https://github.com/exituser/Pearcleaner.git
synced 2026-09-17 03:48:55 +00:00
v3.5.0
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.security.app-sandbox</key>
|
||||
<true/>
|
||||
<key>com.apple.security.files.user-selected.read-write</key>
|
||||
<true/>
|
||||
<key>com.apple.security.temporary-exception.files.home-relative-path.read-write</key>
|
||||
<array>
|
||||
<string>/</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,131 @@
|
||||
//
|
||||
// FinderSync.swift
|
||||
// FinderOpen
|
||||
//
|
||||
// Created by Alin Lupascu on 4/11/24.
|
||||
//
|
||||
|
||||
import Cocoa
|
||||
import FinderSync
|
||||
|
||||
class FinderOpen: FIFinderSync {
|
||||
|
||||
override init() {
|
||||
super.init()
|
||||
NSLog("FinderSync() launched from %@", Bundle.main.bundlePath as NSString)
|
||||
// Set the directory URLs that the Finder Sync extension observes
|
||||
FIFinderSyncController.default().directoryURLs = Set([URL(fileURLWithPath: "/")])
|
||||
}
|
||||
|
||||
override func menu(for menuKind: FIMenuKind) -> NSMenu {
|
||||
let menu = NSMenu(title: "")
|
||||
|
||||
// Ensure we are dealing with the contextual menu for items
|
||||
if menuKind == .contextualMenuForItems {
|
||||
// Get the selected items
|
||||
if let selectedItemURLs = FIFinderSyncController.default().selectedItemURLs(),
|
||||
selectedItemURLs.count == 1, selectedItemURLs.first?.pathExtension == "app" {
|
||||
// Add menu item if the selected item is a .app file
|
||||
let menuItem = NSMenuItem(title: "Pearcleaner Uninstall", action: #selector(openInMyApp), keyEquivalent: "")
|
||||
// menuItem.image = NSImage(named: NSImage.trashEmptyName)
|
||||
// menu.addItem(withTitle: "Pearcleaner Uninstall", action: #selector(openInMyApp), keyEquivalent: "")
|
||||
menu.addItem(menuItem)
|
||||
}
|
||||
}
|
||||
|
||||
// Return the menu (which may be empty if the conditions are not met)
|
||||
return menu
|
||||
|
||||
}
|
||||
|
||||
@objc func openInMyApp(_ sender: AnyObject?) {
|
||||
// Get the selected items (files/folders) in Finder
|
||||
guard let selectedItems = FIFinderSyncController.default().selectedItemURLs(), !selectedItems.isEmpty else {
|
||||
return
|
||||
}
|
||||
|
||||
// Consider only the first selected item
|
||||
let firstSelectedItem = selectedItems[0]
|
||||
let path = firstSelectedItem.path
|
||||
NSWorkspace.shared.open(URL(string: "pear://com.alienator88.Pearcleaner?path=\(path)")!)
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
//class FinderSync: FIFinderSync {
|
||||
//
|
||||
// var myFolderURL = URL(fileURLWithPath: "/Users/Shared/MySyncExtension Documents")
|
||||
//
|
||||
// override init() {
|
||||
// super.init()
|
||||
//
|
||||
// NSLog("FinderSync() launched from %@", Bundle.main.bundlePath as NSString)
|
||||
//
|
||||
// // Set up the directory we are syncing.
|
||||
// FIFinderSyncController.default().directoryURLs = [self.myFolderURL]
|
||||
//
|
||||
// // Set up images for our badge identifiers. For demonstration purposes, this uses off-the-shelf images.
|
||||
// FIFinderSyncController.default().setBadgeImage(NSImage(named: NSImage.colorPanelName)!, label: "Status One" , forBadgeIdentifier: "One")
|
||||
// FIFinderSyncController.default().setBadgeImage(NSImage(named: NSImage.cautionName)!, label: "Status Two", forBadgeIdentifier: "Two")
|
||||
// }
|
||||
//
|
||||
// // MARK: - Primary Finder Sync protocol methods
|
||||
//
|
||||
// override func beginObservingDirectory(at url: URL) {
|
||||
// // The user is now seeing the container's contents.
|
||||
// // If they see it in more than one view at a time, we're only told once.
|
||||
// NSLog("beginObservingDirectoryAtURL: %@", url.path as NSString)
|
||||
// }
|
||||
//
|
||||
//
|
||||
// override func endObservingDirectory(at url: URL) {
|
||||
// // The user is no longer seeing the container's contents.
|
||||
// NSLog("endObservingDirectoryAtURL: %@", url.path as NSString)
|
||||
// }
|
||||
//
|
||||
// override func requestBadgeIdentifier(for url: URL) {
|
||||
// NSLog("requestBadgeIdentifierForURL: %@", url.path as NSString)
|
||||
//
|
||||
// // For demonstration purposes, this picks one of our two badges, or no badge at all, based on the filename.
|
||||
// let whichBadge = abs(url.path.hash) % 3
|
||||
// let badgeIdentifier = ["", "One", "Two"][whichBadge]
|
||||
// FIFinderSyncController.default().setBadgeIdentifier(badgeIdentifier, for: url)
|
||||
// }
|
||||
//
|
||||
// // MARK: - Menu and toolbar item support
|
||||
//
|
||||
// override var toolbarItemName: String {
|
||||
// return "FinderSy"
|
||||
// }
|
||||
//
|
||||
// override var toolbarItemToolTip: String {
|
||||
// return "FinderSy: Click the toolbar item for a menu."
|
||||
// }
|
||||
//
|
||||
// override var toolbarItemImage: NSImage {
|
||||
// return NSImage(named: NSImage.cautionName)!
|
||||
// }
|
||||
//
|
||||
// override func menu(for menuKind: FIMenuKind) -> NSMenu {
|
||||
// // Produce a menu for the extension.
|
||||
// let menu = NSMenu(title: "")
|
||||
// menu.addItem(withTitle: "Example Menu Item", action: #selector(sampleAction(_:)), keyEquivalent: "")
|
||||
// return menu
|
||||
// }
|
||||
//
|
||||
// @IBAction func sampleAction(_ sender: AnyObject?) {
|
||||
// let target = FIFinderSyncController.default().targetedURL()
|
||||
// let items = FIFinderSyncController.default().selectedItemURLs()
|
||||
//
|
||||
// let item = sender as! NSMenuItem
|
||||
// NSLog("sampleAction: menu item: %@, target = %@, items = ", item.title as NSString, target!.path as NSString)
|
||||
// for obj in items! {
|
||||
// NSLog(" %@", obj.path as NSString)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>$(APP_VERSION)</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>$(APP_BUILD)</string>
|
||||
<key>NSExtension</key>
|
||||
<dict>
|
||||
<key>NSExtensionAttributes</key>
|
||||
<dict/>
|
||||
<key>NSExtensionPointIdentifier</key>
|
||||
<string>com.apple.FinderSync</string>
|
||||
<key>NSExtensionPrincipalClass</key>
|
||||
<string>$(PRODUCT_MODULE_NAME).FinderOpen</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
||||
Reference in New Issue
Block a user