Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 24 additions & 5 deletions DiskArbitrator.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 52;
objectVersion = 60;
objects = {

/* Begin PBXAggregateTarget section */
Expand Down Expand Up @@ -300,10 +300,11 @@
29B97313FDCFA39411CA2CEA /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1130;
BuildIndependentTargetsInParallel = YES;
LastUpgradeCheck = 1520;
};
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "DiskArbitrator" */;
compatibilityVersion = "Xcode 11.0";
compatibilityVersion = "Xcode 15.0";
developmentRegion = en;
hasScannedForEncodings = 1;
knownRegions = (
Expand Down Expand Up @@ -442,8 +443,10 @@
CLANG_ENABLE_OBJC_WEAK = YES;
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO;
DEAD_CODE_STRIPPING = YES;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
MACOSX_DEPLOYMENT_TARGET = 14.2;
PRODUCT_NAME = "Disk Arbitrator.dmg";
};
name = Debug;
Expand All @@ -454,7 +457,9 @@
CLANG_ENABLE_OBJC_WEAK = YES;
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = YES;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
MACOSX_DEPLOYMENT_TARGET = 14.2;
PRODUCT_NAME = "Disk Arbitrator.dmg";
ZERO_LINK = NO;
};
Expand All @@ -469,15 +474,19 @@
CODE_SIGN_IDENTITY = "-";
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO;
DEAD_CODE_STRIPPING = YES;
ENABLE_HARDENED_RUNTIME = YES;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = Source/DiskArbitrator_Prefix.pch;
INFOPLIST_FILE = "Resources/DiskArbitrator-Info.plist";
INSTALL_PATH = "$(HOME)/Applications";
MACOSX_DEPLOYMENT_TARGET = 14.2;
PRODUCT_BUNDLE_IDENTIFIER = "us.burghardt.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "Disk Arbitrator";
PROVISIONING_PROFILE = "";
PROVISIONING_PROFILE_SPECIFIER = "";
};
name = Debug;
};
Expand All @@ -489,14 +498,18 @@
CLANG_WARN_OBJC_INTERFACE_IVARS = YES_ERROR;
CODE_SIGN_IDENTITY = "-";
COMBINE_HIDPI_IMAGES = YES;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_HARDENED_RUNTIME = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = Source/DiskArbitrator_Prefix.pch;
INFOPLIST_FILE = "Resources/DiskArbitrator-Info.plist";
INSTALL_PATH = "$(HOME)/Applications";
MACOSX_DEPLOYMENT_TARGET = 14.2;
PRODUCT_BUNDLE_IDENTIFIER = "us.burghardt.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "Disk Arbitrator";
PROVISIONING_PROFILE = "";
PROVISIONING_PROFILE_SPECIFIER = "";
};
name = Release;
};
Expand All @@ -515,13 +528,16 @@
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
DEAD_CODE_STRIPPING = YES;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
Expand All @@ -533,7 +549,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.12;
MACOSX_DEPLOYMENT_TARGET = 14.2;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
};
Expand All @@ -554,12 +570,15 @@
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
DEAD_CODE_STRIPPING = YES;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
Expand All @@ -570,7 +589,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.12;
MACOSX_DEPLOYMENT_TARGET = 14.2;
SDKROOT = macosx;
};
name = Release;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1130"
LastUpgradeVersion = "1520"
version = "1.8">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1130"
LastUpgradeVersion = "1520"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion Source/AttachDiskImageController.m
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ - (void)performAttachDiskImage
panel.allowsMultipleSelection = NO;
panel.message = NSLocalizedString(@"Select a disk image to attach:", nil);

panel.allowedFileTypes = [self.class diskImageFileExtensions];
panel.allowedContentTypes = [self.class diskImageFileExtensions];

[self.userInfo setObject:[NSNumber numberWithBool:YES] forKey:@"readOnly"];

Expand Down
8 changes: 4 additions & 4 deletions Source/DiskArbitratorAppController+Toolbar.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ @implementation AppController (AppControllerToolbar)

- (NSImage *)attachDiskImageIcon
{
NSImage *dmgIcon = [[NSWorkspace sharedWorkspace] iconForFileType:@"dmg"];
NSImage *dmgIcon = [[NSWorkspace sharedWorkspace] iconForFile:@"dmg"];
NSImage *plugImage = [NSImage imageNamed:@"ToolbarItem Attach Disk Plug"];

NSBitmapImageRep *compositedImage = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL pixelsWide:32 pixelsHigh:32 bitsPerSample:8 samplesPerPixel:4 hasAlpha:YES isPlanar:NO colorSpaceName:NSCalibratedRGBColorSpace bytesPerRow:0 bitsPerPixel:0];
Expand Down Expand Up @@ -75,10 +75,10 @@ - (NSToolbarItem *)toolbar:(NSToolbar *)toolbar itemForItemIdentifier:(NSString
//----------------------------------------------------------
- (NSArray *)toolbarAllowedItemIdentifiers:(NSToolbar *)toolbar {
return [NSArray arrayWithObjects:
NSToolbarSeparatorItemIdentifier,
//NSToolbarSeparatorItemIdentifier,
NSToolbarSpaceItemIdentifier,
NSToolbarFlexibleSpaceItemIdentifier,
NSToolbarCustomizeToolbarItemIdentifier,
//NSToolbarCustomizeToolbarItemIdentifier,
ToolbarItemInfoIdentifier,
ToolbarItemMountIdentifier,
ToolbarItemEjectIdentifier,
Expand All @@ -96,7 +96,7 @@ - (NSArray *)toolbarDefaultItemIdentifiers:(NSToolbar *)toolbar {
NSToolbarSpaceItemIdentifier,
ToolbarItemAttachDiskImageIdentifier,
NSToolbarFlexibleSpaceItemIdentifier,
NSToolbarCustomizeToolbarItemIdentifier,
//NSToolbarCustomizeToolbarItemIdentifier,
nil];
}

Expand Down
2 changes: 1 addition & 1 deletion Source/DiskArbitratorAppController.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@class Arbitrator;
@class Disk;

@interface AppController : NSObject // <NSApplicationDelegate>
@interface AppController : NSObject <NSToolbarItemValidation>// <NSApplicationDelegate> //https://www.reddit.com/r/macosprogramming/comments/19ai5u8/toolbar_validation/ //https://developer.apple.com/documentation/appkit/nstoolbaritemvalidation?language=objc

@property (assign) IBOutlet NSPanel *window;
@property (assign) IBOutlet NSMenu *statusMenu;
Expand Down
28 changes: 14 additions & 14 deletions Source/DiskArbitratorAppController.m
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ - (void)setStatusItemIconWithName:(NSString *)name
{
NSString *iconPath = [[NSBundle mainBundle] pathForResource:name ofType:@"png"];
NSImage *statusIcon = [[NSImage alloc] initWithContentsOfFile:iconPath];
statusItem.image = statusIcon;
statusItem.button.image = statusIcon;
}

- (void)refreshStatusItemIcon
Expand Down Expand Up @@ -83,8 +83,8 @@ - (void)applicationDidFinishLaunching:(NSNotification *)notification
self.statusItem = [bar statusItemWithLength:NSSquareStatusItemLength];
NSImage *altImage = [[NSImage imageNamed:@"StatusItem Disabled 1.png"] copy];
[altImage setTemplate:YES];
self.statusItem.alternateImage = altImage;
[self.statusItem setHighlightMode:YES];
self.statusItem.button.alternateImage = altImage;
[self.statusItem.button.cell setHighlightsBy:NSNoCellMask];
[self setStatusItemIconWithName:@"StatusItem Disabled 1"];
statusItem.menu = statusMenu;

Expand All @@ -105,7 +105,7 @@ - (void)applicationDidFinishLaunching:(NSNotification *)notification
window.collectionBehavior = NSWindowCollectionBehaviorCanJoinAllSpaces;
window.worksWhenModal = YES;

[tableView registerForDraggedTypes:[NSArray arrayWithObject:NSFilenamesPboardType]];
[tableView registerForDraggedTypes:[NSArray arrayWithObject:NSPasteboardTypeFileURL]];

if ([[NSUserDefaults standardUserDefaults] boolForKey:@"ShowMainWindowAtStartup"])
[window makeKeyAndOrderFront:self];
Expand Down Expand Up @@ -510,13 +510,13 @@ - (NSDragOperation)tableView:(NSTableView*)tv validateDrop:(id <NSDraggingInfo>)
Log(LOG_DEBUG, @"%s op: %ld info: %@", __func__, op, info);

NSPasteboard* pboard = [info draggingPasteboard];

if (op == NSDragOperationCopy && [pboard.types containsObject:NSFilenamesPboardType]) {
NSArray *files = [pboard propertyListForType:NSFilenamesPboardType];
if (op == NSDragOperationCopy && [pboard.types containsObject:NSPasteboardTypeFileURL])
{
NSArray *files = [pboard propertyListForType:NSPasteboardTypeFileURL];
NSArray *extensions = [AttachDiskImageController diskImageFileExtensions];

for (NSString *file in files) {
for (NSURL *file in files) {
if ([extensions containsObject:[file pathExtension]] == NO)
return NSDragOperationNone;
}
Expand Down Expand Up @@ -551,12 +551,12 @@ - (BOOL)tableView:(NSTableView *)aTableView acceptDrop:(id <NSDraggingInfo>)info

Log(LOG_DEBUG, @"%s", __func__);

if (operation == NSDragOperationCopy && [pboard.types containsObject:NSFilenamesPboardType] ) {
NSArray *files = [pboard propertyListForType:NSFilenamesPboardType];

if (operation == NSDragOperationCopy && [pboard.types containsObject:NSPasteboardTypeFileURL] ) {
NSArray *files = [pboard propertyListForType:NSPasteboardTypeFileURL];
Log(LOG_DEBUG, @"files: %@", files);

for (NSString *file in files)
for (NSURL *file in files)
[self performSelector:@selector(doAttachDiskImageAtPath:) withObject:file afterDelay:0.01];
}
return YES;
Expand Down