From 745bce2ae3f3f2bd84fcffcf0e71d26283e813f0 Mon Sep 17 00:00:00 2001 From: Russell Stadler Date: Wed, 23 Jan 2019 09:52:50 -0800 Subject: [PATCH 1/6] Sort Local hosts when loading As mentioned in Issues #160 and #140, the list of hosts is not alphabetized in newer versions of macOS. This change is a feeble attempt by me to sort the `hostsFiles` array as it's populated. It seems to have built successfully on my machine but I'm extremely new to the world of Obj-C development so it would not surprise me in the least if this does something in a bad or easily improved way. That is, I added a way to Sort (`NSSortDescriptor`) and call it immediately after every time we `addObject` to `hostsFiles` during `loadFiles` in LocalHostsController.m. Doing this after every addition seems like it might be a poor choice from a performance perspective. Moreover, it may be wholly unnecessary when used in some environments where this issue doesn't present. I went with it anyway because I didn't know how else to approach this, nor how to conditionally use this logic only when I know it to be necessary. --- Source/LocalHostsController.m | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Source/LocalHostsController.m b/Source/LocalHostsController.m index 6eff81f..815bb71 100644 --- a/Source/LocalHostsController.m +++ b/Source/LocalHostsController.m @@ -76,6 +76,9 @@ - (void)loadFiles } [hostsFiles addObject:hosts]; + // grossly sorting array every time we add a host? Probably there is a better way. + NSSortDescriptor *sort = [NSSortDescriptor sortDescriptorWithKey:@"name" ascending:YES]; + [hostsFiles sortUsingDescriptors:[NSArray arrayWithObject:sort]]; } } } From b983bb2dd6039c036bcd68ab5f2f9374e621c481 Mon Sep 17 00:00:00 2001 From: timepigeon Date: Mon, 19 Oct 2020 12:03:33 +0200 Subject: [PATCH 2/6] Move host file storage to "~/Library/Application Support/Gas Mask" --- Source/FileUtil.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/FileUtil.m b/Source/FileUtil.m index 4f02f90..424919f 100644 --- a/Source/FileUtil.m +++ b/Source/FileUtil.m @@ -27,7 +27,7 @@ @implementation FileUtil + (NSString*)dataDirectory { if (dataDirectory == nil) { - NSArray *array = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES); + NSArray *array = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES); dataDirectory = [[array objectAtIndex:0] stringByAppendingString:@"/Gas Mask/"]; } return dataDirectory; From 4399896c5241f528816dbb070456d3e9d1fee1ad Mon Sep 17 00:00:00 2001 From: oliveratgithub Date: Sun, 12 Mar 2023 19:29:22 +0100 Subject: [PATCH 3/6] Replaces deprecated `currentAppearance` & `setCurrentAppearance` --- Source/Util.m | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Source/Util.m b/Source/Util.m index 2193bd4..9e0d19b 100755 --- a/Source/Util.m +++ b/Source/Util.m @@ -54,8 +54,12 @@ + (BOOL) restartDNSResponder + (BOOL) isDarkMode { - NSAppearance *appearance = NSAppearance.currentAppearance; - return appearance.name == NSAppearanceNameDarkAqua; + NSAppearance *currentAppearance = NSAppearance.currentDrawingAppearance; + if (@available(macOS 10.14, *)) { + return currentAppearance.name == NSAppearanceNameDarkAqua; + } else { + return [[NSColor controlTextColor] isEqual:[NSColor whiteColor]]; + } } @end From bc6d00c262d7220f946510e7a91f202c1f8393cd Mon Sep 17 00:00:00 2001 From: oliveratgithub Date: Sun, 12 Mar 2023 19:31:14 +0100 Subject: [PATCH 4/6] Replaces deprecated method `draggedImage` --- Source/HostsListView.m | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Source/HostsListView.m b/Source/HostsListView.m index e2c22b0..0dc6817 100755 --- a/Source/HostsListView.m +++ b/Source/HostsListView.m @@ -40,12 +40,12 @@ @implementation HostsListView - (void)awakeFromNib { - [self registerForDraggedTypes:[NSArray arrayWithObjects:NSPasteboardTypeString, NSFilenamesPboardType, nil]]; + [self registerForDraggedTypes:[NSArray arrayWithObjects:NSPasteboardTypeString, NSPasteboardTypeFileURL, nil]]; [self setDraggingSourceOperationMask:NSDragOperationEvery forLocal:YES]; [self setDraggingSourceOperationMask:NSDragOperationEvery forLocal:NO]; - [self setSelectionHighlightStyle:NSTableViewSelectionHighlightStyleSourceList]; - + [self setStyle:NSTableViewStyleSourceList]; + NSTableColumn *tableColumn = [self tableColumnWithIdentifier:kColumnIdName]; cell = [[Cell alloc] init]; [cell setEditable:YES]; @@ -98,7 +98,7 @@ - (void)removeBadgesFromGroups #pragma mark - #pragma mark NSDraggingSource -- (void)draggedImage:(NSImage *)image endedAt:(NSPoint)screenPoint operation:(NSDragOperation)operation +- (void)draggingSession:(NSDraggingSession *)session endedAtPoint:(NSPoint)screenPoint operation:(NSDragOperation)operation { // Dragged item ended up in Trash if (operation == NSDragOperationDelete) { @@ -106,7 +106,7 @@ - (void)draggedImage:(NSImage *)image endedAt:(NSPoint)screenPoint operation:(NS [nc postNotificationName:DraggedFileShouldBeRemovedNotification object:nil]; } else { - [super draggedImage:image endedAt:screenPoint operation:operation]; + [super draggingSession:session endedAtPoint:screenPoint operation:operation]; } } From b83709ee0223d5052adfc4784e05ebd7b77322a0 Mon Sep 17 00:00:00 2001 From: oliveratgithub Date: Sun, 12 Mar 2023 19:32:35 +0100 Subject: [PATCH 5/6] Bump sparkle-project/Sparkle to version 2.3.2 --- .../project.xcworkspace/xcshareddata/swiftpm/Package.resolved | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gas Mask.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Gas Mask.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index d18c63f..1d3e60b 100755 --- a/Gas Mask.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Gas Mask.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -14,8 +14,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/sparkle-project/Sparkle.git", "state" : { - "revision" : "7918c1c8fc68baa37917eeaa67286b077ad5e393", - "version" : "1.27.1" + "revision" : "dda155c7d3ef38c53d29f8584cb2aad2a1a54dba", + "version" : "2.3.2" } } ], From cee8fc3de66b1d272eb99caf29b7eb587be06350 Mon Sep 17 00:00:00 2001 From: oliveratgithub Date: Sun, 12 Mar 2023 19:40:04 +0100 Subject: [PATCH 6/6] Bump 2ndalpha/gasmask to version 0.8.7 --- Info.plist | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Info.plist b/Info.plist index bee1ca8..9a5c422 100755 --- a/Info.plist +++ b/Info.plist @@ -42,7 +42,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 0.8.6 + 0.8.7 CFBundleSignature ???? CFBundleURLTypes @@ -59,7 +59,7 @@ CFBundleVersion - 0.8.6 + 0.8.7 LSMinimumSystemVersion ${MACOSX_DEPLOYMENT_TARGET} LSUIElement