findersync

package
v0.6.18 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 22, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package findersync provides Go bindings for the FinderSync framework.

Modify the Finder’s user interface to express file synchronization and control.

Use Finder Sync to cleanly and safely modify the Finder’s user interface to express file synchronization status and control. Unlike most extension points, Finder Sync doesn’t add features to a host app. Instead, it lets you modify the behavior of the Finder itself.

Classes

  • FIFinderSync: A type to subclass to add badges, custom shortcut menus, and toolbar buttons to the Finder.
  • FIFinderSyncController: A controller that acts as a bridge between your Finder Sync extension and the Finder itself.

Protocols

  • FIFinderSync: The group of methods to implement for modifying the Finder user interface to express file synchronization status and control. (FIMenuKind)

Key Types

  • FIFinderSync - A type to subclass to add badges, custom shortcut menus, and toolbar buttons to the Finder.
  • FIFinderSyncController - A controller that acts as a bridge between your Finder Sync extension and the Finder itself.

Code generated from Apple documentation. DO NOT EDIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewErrorBlock

func NewErrorBlock(handler ErrorHandler) (objc.ID, func())

NewErrorBlock wraps a Go ErrorHandler as an Objective-C block. The caller must defer the returned cleanup function.

Used by:

Types

type ErrorHandler

type ErrorHandler = func(error)

ErrorHandler is the signature for a completion handler block.

Used by:

type FIFinderSync

type FIFinderSync struct {
	objectivec.Object
}

A type to subclass to add badges, custom shortcut menus, and toolbar buttons to the Finder.

Overview

Subclass the FIFinderSync class when you want to customize the appearance of the Finder. Although the FIFinderSync class doesn’t provide any developer accessible API, it does adopt the FIFinderSyncProtocol protocol. This protocol declares methods you can implement to modify the appearance of the Finder. For more information on these methods, see FIFinderSyncProtocol. To learn more about creating a Finder Sync extension, see Finder Sync in App Extension Programming Guide.

See: https://developer.apple.com/documentation/FinderSync/FIFinderSync-swift.class

func FIFinderSyncFromID

func FIFinderSyncFromID(id objc.ID) FIFinderSync

FIFinderSyncFromID constructs a FIFinderSync from an objc.ID.

A type to subclass to add badges, custom shortcut menus, and toolbar buttons to the Finder.

func NewFIFinderSync

func NewFIFinderSync() FIFinderSync

NewFIFinderSync creates a new FIFinderSync instance.

func (FIFinderSync) Autorelease

func (f FIFinderSync) Autorelease() FIFinderSync

Autorelease adds the receiver to the current autorelease pool.

func (FIFinderSync) BeginObservingDirectoryAtURL

func (f FIFinderSync) BeginObservingDirectoryAtURL(url foundation.NSURL)

Tells the extension that the user is looking at a monitored directory or at one of its subdirectories.

url: The URL of the directory.

Discussion

Override this method to receive notifications when the user opens the contents of a monitored directory or one of its subdirectories in the Finder. The system calls “ only once for each unique URL. As long as the content remains visible in at least one Finder window, any additional Finder windows that open to the same URL are ignored.

See: https://developer.apple.com/documentation/FinderSync/FIFinderSyncProtocol/beginObservingDirectory(at:)

func (FIFinderSync) EndObservingDirectoryAtURL

func (f FIFinderSync) EndObservingDirectoryAtURL(url foundation.NSURL)

Tells the extension that the user has stopped looking at a monitored directory or at one of its subdirectories.

url: The URL of the directory.

Discussion

Override this method to receive notifications when the user is no longer looking at the contents of the given URL. As with [BeginObservingDirectoryAtURL], the Open and Save dialogs are tracked separately from the Finder.

See: https://developer.apple.com/documentation/FinderSync/FIFinderSyncProtocol/endObservingDirectory(at:)

func (FIFinderSync) Init

func (f FIFinderSync) Init() FIFinderSync

Init initializes the instance.

func (FIFinderSync) MenuForMenuKind

func (f FIFinderSync) MenuForMenuKind(menu FIMenuKind) appkit.NSMenu

Requests a custom menu from the extension.

menu: The type of menu being displayed. For a list of possible values, see FIMenuKind.

Return Value

A custom menu.

Discussion

Override this method to provide custom menus in the Finder. You can customize this menu based both on the menu’s kind and on the selected and targeted items (if any). You can get the selected and targeted items from the extension’s FIFinderSyncController.

If `kind` is FIMenuKindToolbarItemMenu, the system always calls this method even if the target and selection are not related to the extension.

The extension’s principal object provides a method for each menu item’s assigned action.

See: https://developer.apple.com/documentation/FinderSync/FIFinderSyncProtocol/menu(for:)

func (FIFinderSync) RequestBadgeIdentifierForURL

func (f FIFinderSync) RequestBadgeIdentifierForURL(url foundation.NSURL)

Requests a badge for the given file or directory.

url: The URL of a file or directory inside the extension’s monitored directories.

Discussion

Override this method to receive notifications whenever a new item becomes visible in the Finder. Check the item’s state, and call FIFinderSyncController.SetBadgeIdentifierForURL to set an appropriate badge.

See: https://developer.apple.com/documentation/FinderSync/FIFinderSyncProtocol/requestBadgeIdentifier(for:)

func (FIFinderSync) ToolbarItemImage

func (f FIFinderSync) ToolbarItemImage() appkit.NSImage

The image for the extension’s toolbar button.

See: https://developer.apple.com/documentation/FinderSync/FIFinderSyncProtocol/toolbarItemImage

func (FIFinderSync) ToolbarItemName

func (f FIFinderSync) ToolbarItemName() string

The name of the extension’s toolbar button.

See: https://developer.apple.com/documentation/FinderSync/FIFinderSyncProtocol/toolbarItemName

func (FIFinderSync) ToolbarItemToolTip

func (f FIFinderSync) ToolbarItemToolTip() string

The tooltip text for the extension’s toolbar button.

See: https://developer.apple.com/documentation/FinderSync/FIFinderSyncProtocol/toolbarItemToolTip

type FIFinderSyncClass

type FIFinderSyncClass struct {
	// contains filtered or unexported fields
}

func GetFIFinderSyncClass

func GetFIFinderSyncClass() FIFinderSyncClass

GetFIFinderSyncClass returns the class object for FIFinderSync.

func (FIFinderSyncClass) Alloc

func (fc FIFinderSyncClass) Alloc() FIFinderSync

Alloc allocates memory for a new instance of the class.

func (FIFinderSyncClass) Class

func (fc FIFinderSyncClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

type FIFinderSyncController

type FIFinderSyncController struct {
	foundation.NSExtensionContext
}

A controller that acts as a bridge between your Finder Sync extension and the Finder itself.

Overview

Use the Finder Sync controller to configure your extension, to set badges on items in the Finder’s window, and to get a list of selected and targeted items.

Managing the Finder Sync Controller

Instance Methods

See: https://developer.apple.com/documentation/FinderSync/FIFinderSyncController

func FIFinderSyncControllerFromID

func FIFinderSyncControllerFromID(id objc.ID) FIFinderSyncController

FIFinderSyncControllerFromID constructs a FIFinderSyncController from an objc.ID.

A controller that acts as a bridge between your Finder Sync extension and the Finder itself.

func NewFIFinderSyncController

func NewFIFinderSyncController() FIFinderSyncController

NewFIFinderSyncController creates a new FIFinderSyncController instance.

func (FIFinderSyncController) Autorelease

Autorelease adds the receiver to the current autorelease pool.

func (FIFinderSyncController) DirectoryURLs

func (f FIFinderSyncController) DirectoryURLs() foundation.INSSet

The directories managed by this extension.

Discussion

The extension receives [BeginObservingDirectoryAtURL] and [EndObservingDirectoryAtURL] messages for every directory in this set and for all of their subdirectories.

Always set `directoryURLs` when the extension starts. If there are no directories to watch, set `directoryURLs` to an empty set.

See: https://developer.apple.com/documentation/FinderSync/FIFinderSyncController/directoryURLs

func (FIFinderSyncController) Init

Init initializes the instance.

func (FIFinderSyncController) SelectedItemURLs

func (f FIFinderSyncController) SelectedItemURLs() []foundation.NSURL

Returns an array of selected items.

Return Value

An array of items currently selected in the Finder window.

Discussion

Use this method when creating a shortcut menu or a menu for the extension’s toolbar button. You can then modify the menu’s content based on the items currently selected.

This method returns valid values only from the Finder Sync extension’s [MenuForMenuKind] method or from one of the menu actions created in this method. If the selected items are outside the extension’s managed directories (for example, when the user clicks on the toolbar button), this method returns `nil`.

See: https://developer.apple.com/documentation/FinderSync/FIFinderSyncController/selectedItemURLs()

func (FIFinderSyncController) SetBadgeIdentifierForURL

func (f FIFinderSyncController) SetBadgeIdentifierForURL(badgeID string, url foundation.NSURL)

Sets the badge for a file or directory.

badgeID: A unique ID, identifying the badge.

url: The URL of the file or directory.

Discussion

Adds the specified badge to the given file or directory. Setting the identifier to an empty string (`@""`) removes the badge.

Avoid adding badges to items that the Finder hasn’t displayed yet. When setting the initial badge, call this method from your Finder Sync extension’s [RequestBadgeIdentifierForURL] method. When updating badges, call this method only for items that have already received a badge.

See: https://developer.apple.com/documentation/FinderSync/FIFinderSyncController/setBadgeIdentifier(_:for:)

func (FIFinderSyncController) SetBadgeImageLabelForBadgeIdentifier

func (f FIFinderSyncController) SetBadgeImageLabelForBadgeIdentifier(image appkit.NSImage, label string, badgeID string)

Sets the badge image and label for the given ID.

image: An NSImage object. The system may or may not draw this image on top of the item’s icon; when it does, the system determines the overlay position. Don’t add any padding to the image to adjust this positioning. The image draws at up to 320 x 320 points.

label: A label describing the sync state represented by this badge. Each label should be a short localized string, such as “Waiting.”

badgeID: A unique ID, identifying this badge.

Discussion

Use this method to configure your badges. Finder may display the image, the label or both. Your Finder Sync extension typically sets up a fixed number of badges during its `init` method.

See: https://developer.apple.com/documentation/FinderSync/FIFinderSyncController/setBadgeImage(_:label:forBadgeIdentifier:)

func (FIFinderSyncController) SetDirectoryURLs

func (f FIFinderSyncController) SetDirectoryURLs(value foundation.INSSet)

func (FIFinderSyncController) SetLastUsedDateForItemWithURLCompletionSync

func (f FIFinderSyncController) SetLastUsedDateForItemWithURLCompletionSync(ctx context.Context, lastUsedDate foundation.NSDate, itemURL foundation.NSURL) error

SetLastUsedDateForItemWithURLCompletionSync is a synchronous wrapper around FIFinderSyncController.SetLastUsedDateForItemWithURLCompletion. It blocks until the completion handler fires or the context is cancelled.

func (FIFinderSyncController) SetTagDataForItemWithURLCompletionSync

func (f FIFinderSyncController) SetTagDataForItemWithURLCompletionSync(ctx context.Context, tagData foundation.NSData, itemURL foundation.NSURL) error

SetTagDataForItemWithURLCompletionSync is a synchronous wrapper around FIFinderSyncController.SetTagDataForItemWithURLCompletion. It blocks until the completion handler fires or the context is cancelled.

func (FIFinderSyncController) TargetedURL

func (f FIFinderSyncController) TargetedURL() foundation.NSURL

Returns the URL of the Finder’s current target.

Return Value

The URL of the Finder’s current target.

Discussion

Use this method when creating a custom shortcut menu for the Finder. This returns the URL of the item that the user Control-clicked, letting you customize the menu for that item.

This method returns valid values only from the Finder Sync extension’s [MenuForMenuKind] method or from one of the menu actions created in this method. If the selected items are outside the extension’s managed directories (for example, when the user clicks on the toolbar button), this method returns `nil`.

See: https://developer.apple.com/documentation/FinderSync/FIFinderSyncController/targetedURL()

type FIFinderSyncControllerClass

type FIFinderSyncControllerClass struct {
	// contains filtered or unexported fields
}

func GetFIFinderSyncControllerClass

func GetFIFinderSyncControllerClass() FIFinderSyncControllerClass

GetFIFinderSyncControllerClass returns the class object for FIFinderSyncController.

func (FIFinderSyncControllerClass) Alloc

Alloc allocates memory for a new instance of the class.

func (FIFinderSyncControllerClass) Class

Class returns the underlying Objective-C class pointer.

func (FIFinderSyncControllerClass) DefaultController

func (_FIFinderSyncControllerClass FIFinderSyncControllerClass) DefaultController() FIFinderSyncController

Returns the shared Finder Sync controller object.

Return Value

The default Finder Sync controller object for this extension.

See: https://developer.apple.com/documentation/FinderSync/FIFinderSyncController/default()

func (FIFinderSyncControllerClass) IsExtensionEnabled

func (_FIFinderSyncControllerClass FIFinderSyncControllerClass) IsExtensionEnabled() bool

See: https://developer.apple.com/documentation/FinderSync/FIFinderSyncController/isExtensionEnabled

func (FIFinderSyncControllerClass) ShowExtensionManagementInterface

func (_FIFinderSyncControllerClass FIFinderSyncControllerClass) ShowExtensionManagementInterface()

See: https://developer.apple.com/documentation/FinderSync/FIFinderSyncController/showExtensionManagementInterface()

type FIFinderSyncProtocol

type FIFinderSyncProtocol interface {
	objectivec.IObject

	// The image for the extension’s toolbar button.
	//
	// See: https://developer.apple.com/documentation/FinderSync/FIFinderSyncProtocol/toolbarItemImage
	ToolbarItemImage() appkit.NSImage

	// The name of the extension’s toolbar button.
	//
	// See: https://developer.apple.com/documentation/FinderSync/FIFinderSyncProtocol/toolbarItemName
	ToolbarItemName() string

	// The tooltip text for the extension’s toolbar button.
	//
	// See: https://developer.apple.com/documentation/FinderSync/FIFinderSyncProtocol/toolbarItemToolTip
	ToolbarItemToolTip() string
}

The group of methods to implement for modifying the Finder user interface to express file synchronization status and control.

See: https://developer.apple.com/documentation/FinderSync/FIFinderSyncProtocol

type FIFinderSyncProtocolObject

type FIFinderSyncProtocolObject struct {
	objectivec.Object
}

FIFinderSyncProtocolObject wraps an existing Objective-C object that conforms to the FIFinderSyncProtocol protocol.

func FIFinderSyncProtocolObjectFromID

func FIFinderSyncProtocolObjectFromID(id objc.ID) FIFinderSyncProtocolObject

FIFinderSyncProtocolObjectFromID constructs a FIFinderSyncProtocolObject from an objc.ID. The object is determined to conform to the protocol at runtime.

func (FIFinderSyncProtocolObject) BaseObject

func (FIFinderSyncProtocolObject) BeginObservingDirectoryAtURL

func (o FIFinderSyncProtocolObject) BeginObservingDirectoryAtURL(url foundation.NSURL)

Tells the extension that the user is looking at a monitored directory or at one of its subdirectories.

url: The URL of the directory.

Discussion

Override this method to receive notifications when the user opens the contents of a monitored directory or one of its subdirectories in the Finder. The system calls “ only once for each unique URL. As long as the content remains visible in at least one Finder window, any additional Finder windows that open to the same URL are ignored.

See: https://developer.apple.com/documentation/FinderSync/FIFinderSyncProtocol/beginObservingDirectory(at:)

func (FIFinderSyncProtocolObject) EndObservingDirectoryAtURL

func (o FIFinderSyncProtocolObject) EndObservingDirectoryAtURL(url foundation.NSURL)

Tells the extension that the user has stopped looking at a monitored directory or at one of its subdirectories.

url: The URL of the directory.

Discussion

Override this method to receive notifications when the user is no longer looking at the contents of the given URL. As with [BeginObservingDirectoryAtURL], the Open and Save dialogs are tracked separately from the Finder.

See: https://developer.apple.com/documentation/FinderSync/FIFinderSyncProtocol/endObservingDirectory(at:)

func (FIFinderSyncProtocolObject) MenuForMenuKind

func (o FIFinderSyncProtocolObject) MenuForMenuKind(menu FIMenuKind) appkit.NSMenu

Requests a custom menu from the extension.

menu: The type of menu being displayed. For a list of possible values, see FIMenuKind.

Return Value

A custom menu.

Discussion

Override this method to provide custom menus in the Finder. You can customize this menu based both on the menu’s kind and on the selected and targeted items (if any). You can get the selected and targeted items from the extension’s FIFinderSyncController.

If `kind` is FIMenuKindToolbarItemMenu, the system always calls this method even if the target and selection are not related to the extension.

The extension’s principal object provides a method for each menu item’s assigned action.

See: https://developer.apple.com/documentation/FinderSync/FIFinderSyncProtocol/menu(for:)

func (FIFinderSyncProtocolObject) RequestBadgeIdentifierForURL

func (o FIFinderSyncProtocolObject) RequestBadgeIdentifierForURL(url foundation.NSURL)

Requests a badge for the given file or directory.

url: The URL of a file or directory inside the extension’s monitored directories.

Discussion

Override this method to receive notifications whenever a new item becomes visible in the Finder. Check the item’s state, and call FIFinderSyncController.SetBadgeIdentifierForURL to set an appropriate badge.

See: https://developer.apple.com/documentation/FinderSync/FIFinderSyncProtocol/requestBadgeIdentifier(for:)

func (FIFinderSyncProtocolObject) ToolbarItemImage

func (o FIFinderSyncProtocolObject) ToolbarItemImage() appkit.NSImage

The image for the extension’s toolbar button.

Discussion

To add a toolbar item to the Finder, override the getter method for the toolbar image, name, and tooltip properties.

See: https://developer.apple.com/documentation/FinderSync/FIFinderSyncProtocol/toolbarItemImage

func (FIFinderSyncProtocolObject) ToolbarItemName

func (o FIFinderSyncProtocolObject) ToolbarItemName() string

The name of the extension’s toolbar button.

Discussion

To add a toolbar item to the Finder, override the getter method for the toolbar image, name, and tooltip properties.

See: https://developer.apple.com/documentation/FinderSync/FIFinderSyncProtocol/toolbarItemName

func (FIFinderSyncProtocolObject) ToolbarItemToolTip

func (o FIFinderSyncProtocolObject) ToolbarItemToolTip() string

The tooltip text for the extension’s toolbar button.

Discussion

To add a toolbar item to the Finder, override the getter method for the toolbar image, name, and tooltip properties.

See: https://developer.apple.com/documentation/FinderSync/FIFinderSyncProtocol/toolbarItemToolTip

type FIMenuKind

type FIMenuKind uint

See: https://developer.apple.com/documentation/FinderSync/FIMenuKind

const (
	// FIMenuKindContextualMenuForContainer: A shortcut menu created when the user control-clicks on the Finder window’s background.
	FIMenuKindContextualMenuForContainer FIMenuKind = 1
	// FIMenuKindContextualMenuForItems: A shortcut menu created when the user control-clicks on an item or a group of selected items inside the Finder window.
	FIMenuKindContextualMenuForItems FIMenuKind = 0
	// FIMenuKindContextualMenuForSidebar: A shortcut menu created when the user control-clicks on an item in the sidebar.
	FIMenuKindContextualMenuForSidebar FIMenuKind = 2
	// FIMenuKindToolbarItemMenu: A menu created when the user clicks on the extension’s toolbar button.
	FIMenuKindToolbarItemMenu FIMenuKind = 3
)

func (FIMenuKind) String

func (e FIMenuKind) String() string

type IFIFinderSync

type IFIFinderSync interface {
	objectivec.IObject

	// Tells the extension that the user is looking at a monitored directory or at one of its subdirectories.
	BeginObservingDirectoryAtURL(url foundation.NSURL)
	// Tells the extension that the user has stopped looking at a monitored directory or at one of its subdirectories.
	EndObservingDirectoryAtURL(url foundation.NSURL)
	MakeListenerEndpointForServiceNameItemURLAndReturnError(serviceName foundation.NSFileProviderServiceName, itemURL foundation.NSURL) (foundation.NSXPCListenerEndpoint, error)
	// Requests a custom menu from the extension.
	MenuForMenuKind(menu FIMenuKind) appkit.NSMenu
	// Requests a badge for the given file or directory.
	RequestBadgeIdentifierForURL(url foundation.NSURL)
	SupportedServiceNamesForItemWithURL(itemURL foundation.NSURL) []string
	// The image for the extension’s toolbar button.
	ToolbarItemImage() appkit.NSImage
	// The name of the extension’s toolbar button.
	ToolbarItemName() string
	// The tooltip text for the extension’s toolbar button.
	ToolbarItemToolTip() string
}

An interface definition for the FIFinderSync class.

See: https://developer.apple.com/documentation/FinderSync/FIFinderSync-swift.class

type IFIFinderSyncController

type IFIFinderSyncController interface {
	foundation.INSExtensionContext

	// The directories managed by this extension.
	DirectoryURLs() foundation.INSSet
	SetDirectoryURLs(value foundation.INSSet)
	// Returns an array of selected items.
	SelectedItemURLs() []foundation.NSURL
	// Sets the badge for a file or directory.
	SetBadgeIdentifierForURL(badgeID string, url foundation.NSURL)
	// Sets the badge image and label for the given ID.
	SetBadgeImageLabelForBadgeIdentifier(image appkit.NSImage, label string, badgeID string)
	// Returns the URL of the Finder’s current target.
	TargetedURL() foundation.NSURL

	LastUsedDateForItemWithURL(itemURL foundation.NSURL) foundation.NSDate
	SetLastUsedDateForItemWithURLCompletion(lastUsedDate foundation.NSDate, itemURL foundation.NSURL, completion ErrorHandler)
	SetTagDataForItemWithURLCompletion(tagData foundation.NSData, itemURL foundation.NSURL, completion ErrorHandler)
	TagDataForItemWithURL(itemURL foundation.NSURL) foundation.NSData
}

An interface definition for the FIFinderSyncController class.

Managing the Finder Sync Controller

Instance Methods

See: https://developer.apple.com/documentation/FinderSync/FIFinderSyncController

type StringidDictionaryErrorHandler

type StringidDictionaryErrorHandler = func(*foundation.INSDictionary, error)

StringidDictionaryErrorHandler is the signature for a completion handler block.

Used by:

  • [FIFinderSync.ValuesForAttributesForItemWithURLCompletion]

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL