mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-24 04:38:16 +00:00
Use NSTouchBarDelegate to avoid subclassing NSTouchBar
This commit is contained in:
1 parent
6902b80ab6
commit
f795802d60
7 files changed
+66
-58
No files matched your search
@@ -262,9 +262,9 @@
|
||||
767B61AE1972D488004E0C3C /* SUGuidedPackageInstaller.m in Sources */ = {isa = PBXBuildFile; fileRef = 767B61AB1972D488004E0C3C /* SUGuidedPackageInstaller.m */; };
|
||||
A5BF4F1D1BC7668B007A052A /* SUTestWebServer.m in Sources */ = {isa = PBXBuildFile; fileRef = A5BF4F1C1BC7668B007A052A /* SUTestWebServer.m */; };
|
||||
C23E885B1BE7B24F0050BB73 /* SparkleTestCodeSignApp.enc.dmg in Resources */ = {isa = PBXBuildFile; fileRef = C23E88591BE7AF890050BB73 /* SparkleTestCodeSignApp.enc.dmg */; };
|
||||
E1545EC51E1D7E0200FAECE8 /* SUTouchBar.h in Headers */ = {isa = PBXBuildFile; fileRef = E1545EC31E1D7E0200FAECE8 /* SUTouchBar.h */; };
|
||||
E1545EC61E1D7E0200FAECE8 /* SUTouchBar.m in Sources */ = {isa = PBXBuildFile; fileRef = E1545EC41E1D7E0200FAECE8 /* SUTouchBar.m */; settings = {COMPILER_FLAGS = "-Wno-partial-availability"; }; };
|
||||
E1EC2A301E21667000245715 /* SUTouchBar.m in Sources */ = {isa = PBXBuildFile; fileRef = E1545EC41E1D7E0200FAECE8 /* SUTouchBar.m */; settings = {COMPILER_FLAGS = "-Wno-partial-availability"; }; };
|
||||
E1545EC51E1D7E0200FAECE8 /* SUTouchBarProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = E1545EC31E1D7E0200FAECE8 /* SUTouchBarProvider.h */; };
|
||||
E1545EC61E1D7E0200FAECE8 /* SUTouchBarProvider.m in Sources */ = {isa = PBXBuildFile; fileRef = E1545EC41E1D7E0200FAECE8 /* SUTouchBarProvider.m */; settings = {COMPILER_FLAGS = "-Wno-partial-availability"; }; };
|
||||
E1EC2A301E21667000245715 /* SUTouchBarProvider.m in Sources */ = {isa = PBXBuildFile; fileRef = E1545EC41E1D7E0200FAECE8 /* SUTouchBarProvider.m */; settings = {COMPILER_FLAGS = "-Wno-partial-availability"; }; };
|
||||
F8761EB11ADC5068000C9034 /* SUCodeSigningVerifierTest.m in Sources */ = {isa = PBXBuildFile; fileRef = F8761EB01ADC5068000C9034 /* SUCodeSigningVerifierTest.m */; };
|
||||
F8761EB31ADC50EB000C9034 /* SparkleTestCodeSignApp.zip in Resources */ = {isa = PBXBuildFile; fileRef = F8761EB21ADC50EB000C9034 /* SparkleTestCodeSignApp.zip */; };
|
||||
F8761EB61ADC5E7A000C9034 /* SUCodeSigningVerifier.m in Sources */ = {isa = PBXBuildFile; fileRef = 61B078CD15A5FB6100600039 /* SUCodeSigningVerifier.m */; };
|
||||
@@ -797,8 +797,8 @@
|
||||
A5BF4F1B1BC7668B007A052A /* SUTestWebServer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUTestWebServer.h; sourceTree = "<group>"; };
|
||||
A5BF4F1C1BC7668B007A052A /* SUTestWebServer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUTestWebServer.m; sourceTree = "<group>"; };
|
||||
C23E88591BE7AF890050BB73 /* SparkleTestCodeSignApp.enc.dmg */ = {isa = PBXFileReference; lastKnownFileType = file; path = SparkleTestCodeSignApp.enc.dmg; sourceTree = "<group>"; };
|
||||
E1545EC31E1D7E0200FAECE8 /* SUTouchBar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUTouchBar.h; sourceTree = "<group>"; };
|
||||
E1545EC41E1D7E0200FAECE8 /* SUTouchBar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUTouchBar.m; sourceTree = "<group>"; };
|
||||
E1545EC31E1D7E0200FAECE8 /* SUTouchBarProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUTouchBarProvider.h; sourceTree = "<group>"; };
|
||||
E1545EC41E1D7E0200FAECE8 /* SUTouchBarProvider.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUTouchBarProvider.m; sourceTree = "<group>"; };
|
||||
F8761EB01ADC5068000C9034 /* SUCodeSigningVerifierTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUCodeSigningVerifierTest.m; sourceTree = "<group>"; };
|
||||
F8761EB21ADC50EB000C9034 /* SparkleTestCodeSignApp.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; path = SparkleTestCodeSignApp.zip; sourceTree = "<group>"; };
|
||||
FA1941CA0D94A70100DD942E /* ConfigFrameworkDebug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = ConfigFrameworkDebug.xcconfig; sourceTree = "<group>"; };
|
||||
@@ -1179,8 +1179,8 @@
|
||||
612DCBAE0D488BC60015DBEA /* SUUpdatePermissionPrompt.m */,
|
||||
7205C42F1E1215AD00E370AE /* SUUpdatePermissionResponse.h */,
|
||||
7205C4301E1215AD00E370AE /* SUUpdatePermissionResponse.m */,
|
||||
E1545EC31E1D7E0200FAECE8 /* SUTouchBar.h */,
|
||||
E1545EC41E1D7E0200FAECE8 /* SUTouchBar.m */,
|
||||
E1545EC31E1D7E0200FAECE8 /* SUTouchBarProvider.h */,
|
||||
E1545EC41E1D7E0200FAECE8 /* SUTouchBarProvider.m */,
|
||||
);
|
||||
name = "User Interface";
|
||||
sourceTree = "<group>";
|
||||
@@ -1384,7 +1384,7 @@
|
||||
6102FE4A0E07803800F85D09 /* SUDiskImageUnarchiver.h in Headers */,
|
||||
61299A2F09CA2DAB00B7442F /* SUDSAVerifier.h in Headers */,
|
||||
55E6F33319EC9F6C00005E76 /* SUErrors.h in Headers */,
|
||||
E1545EC51E1D7E0200FAECE8 /* SUTouchBar.h in Headers */,
|
||||
E1545EC51E1D7E0200FAECE8 /* SUTouchBarProvider.h in Headers */,
|
||||
14652F8419A978C200959E44 /* SUExport.h in Headers */,
|
||||
7275F9C11B5F1F2900B1D19E /* SUFileManager.h in Headers */,
|
||||
722954C41D04E66F00ECF9CA /* SUFileOperationConstants.h in Headers */,
|
||||
@@ -1869,7 +1869,7 @@
|
||||
55C14F22136EF86000649790 /* SUStandardVersionComparator.m in Sources */,
|
||||
55C14F20136EF84300649790 /* SUStatusController.m in Sources */,
|
||||
55C14F23136EF86700649790 /* SUSystemProfiler.m in Sources */,
|
||||
E1EC2A301E21667000245715 /* SUTouchBar.m in Sources */,
|
||||
E1EC2A301E21667000245715 /* SUTouchBarProvider.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -2016,7 +2016,7 @@
|
||||
6196CFFA09C72149000DC222 /* SUStatusController.m in Sources */,
|
||||
61A2279D0D1CEE7600430CCD /* SUSystemProfiler.m in Sources */,
|
||||
72316BE41E0E1C7F0039EFD9 /* SUSystemUpdateInfo.m in Sources */,
|
||||
E1545EC61E1D7E0200FAECE8 /* SUTouchBar.m in Sources */,
|
||||
E1545EC61E1D7E0200FAECE8 /* SUTouchBarProvider.m in Sources */,
|
||||
61B93A3D0DD02D7000DCD2F8 /* SUUIBasedUpdateDriver.m in Sources */,
|
||||
61299A8E09CA790200B7442F /* SUUnarchiver.m in Sources */,
|
||||
722589DB1E0B19F4005EA0B9 /* SUUnarchiverNotifier.m in Sources */,
|
||||
|
||||
Vendored
+11
-9
@@ -11,18 +11,20 @@
|
||||
#import "SUAppcastItem.h"
|
||||
#import "SUApplicationInfo.h"
|
||||
#import "SUHost.h"
|
||||
#import "SUTouchBar.h"
|
||||
#import "SUTouchBarProvider.h"
|
||||
|
||||
@interface SUAutomaticUpdateAlert ()
|
||||
@property (strong) void(^completionBlock)(SUAutomaticInstallationChoice);
|
||||
@property (strong) SUAppcastItem *updateItem;
|
||||
@property (strong) SUHost *host;
|
||||
@property (strong) SUTouchBarProvider *touchBarProvider;
|
||||
@end
|
||||
|
||||
@implementation SUAutomaticUpdateAlert
|
||||
@synthesize host;
|
||||
@synthesize updateItem;
|
||||
@synthesize completionBlock;
|
||||
@synthesize touchBarProvider;
|
||||
|
||||
- (instancetype)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)aHost completionBlock:(void (^)(SUAutomaticInstallationChoice))block
|
||||
{
|
||||
@@ -105,14 +107,14 @@
|
||||
}
|
||||
}
|
||||
|
||||
SUTouchBar *touchBar = [[SUTouchBar alloc] initWithIdentifier:self.className];
|
||||
[touchBar addButtonWithButton:cancelButton];
|
||||
[touchBar addSpace];
|
||||
[touchBar addButtonWithButton:laterButton];
|
||||
[touchBar addButtonWithButton:installButton];
|
||||
[touchBar addSpace];
|
||||
[touchBar addSpace];
|
||||
return touchBar;
|
||||
self.touchBarProvider = [[SUTouchBarProvider alloc] initWithIdentifier:self.className];
|
||||
[self.touchBarProvider addButtonWithButton:cancelButton];
|
||||
[self.touchBarProvider addSpace];
|
||||
[self.touchBarProvider addButtonWithButton:laterButton];
|
||||
[self.touchBarProvider addButtonWithButton:installButton];
|
||||
[self.touchBarProvider addSpace];
|
||||
[self.touchBarProvider addSpace];
|
||||
return self.touchBarProvider.touchBar;
|
||||
}
|
||||
|
||||
@end
|
||||
Vendored
+6
-4
@@ -11,12 +11,13 @@
|
||||
#import "SUHost.h"
|
||||
#import "SULocalizations.h"
|
||||
#import "SUApplicationInfo.h"
|
||||
#import "SUTouchBar.h"
|
||||
#import "SUTouchBarProvider.h"
|
||||
|
||||
@interface SUStatusController ()
|
||||
@property (copy) NSString *title, *buttonTitle;
|
||||
@property (strong) SUHost *host;
|
||||
@property NSButton *touchBarButton;
|
||||
@property (strong) SUTouchBarProvider *touchBarProvider;
|
||||
@end
|
||||
|
||||
@implementation SUStatusController
|
||||
@@ -30,6 +31,7 @@
|
||||
@synthesize progressBar;
|
||||
@synthesize statusTextField;
|
||||
@synthesize touchBarButton;
|
||||
@synthesize touchBarProvider;
|
||||
|
||||
- (instancetype)initWithHost:(SUHost *)aHost
|
||||
{
|
||||
@@ -132,11 +134,11 @@
|
||||
|
||||
- (NSTouchBar *)makeTouchBar
|
||||
{
|
||||
SUTouchBar *touchBar = [[SUTouchBar alloc] initWithIdentifier:self.className];
|
||||
self.touchBarButton = [touchBar addButtonWithButton:self.actionButton];
|
||||
self.touchBarProvider = [[SUTouchBarProvider alloc] initWithIdentifier:self.className];
|
||||
self.touchBarButton = [self.touchBarProvider addButtonWithButton:self.actionButton];
|
||||
[self.touchBarButton bind:@"title" toObject:self.actionButton withKeyPath:@"title" options:nil];
|
||||
[self.touchBarButton bind:@"enabled" toObject:self.actionButton withKeyPath:@"enabled" options:nil];
|
||||
return touchBar;
|
||||
return self.touchBarProvider.touchBar;
|
||||
}
|
||||
|
||||
@end
|
||||
+4
-2
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// SUTouchBar.h
|
||||
// SUTouchBarProvider.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Yuxin Wang on 05/01/2017.
|
||||
@@ -10,7 +10,9 @@
|
||||
|
||||
@class NSTouchBar;
|
||||
|
||||
@interface SUTouchBar : NSTouchBar
|
||||
@interface SUTouchBarProvider : NSObject
|
||||
|
||||
@property (strong, readonly) NSTouchBar *touchBar;
|
||||
|
||||
-(instancetype)initWithIdentifier:(NSString *)identifier;
|
||||
-(NSButton *)addButtonWithButton:(NSButton *)button;
|
||||
+16
-19
@@ -1,46 +1,49 @@
|
||||
//
|
||||
// SUTouchBar.m
|
||||
// SUTouchBarProvider.m
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Yuxin Wang on 05/01/2017.
|
||||
// Copyright © 2017 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import "SUTouchBar.h"
|
||||
#import "SUTouchBarProvider.h"
|
||||
|
||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 101202
|
||||
|
||||
@interface SUTouchBar()
|
||||
@interface SUTouchBarProvider() <NSTouchBarDelegate>
|
||||
|
||||
@property (copy) NSString* indentifier;
|
||||
@property NSMutableArray<NSTouchBarItem*> *touchBarItems;
|
||||
|
||||
@end
|
||||
|
||||
@implementation SUTouchBar
|
||||
@implementation SUTouchBarProvider
|
||||
|
||||
@synthesize indentifier;
|
||||
@synthesize touchBarItems;
|
||||
@synthesize touchBar;
|
||||
|
||||
-(instancetype)initWithIdentifier:(NSString *)anIdentifier
|
||||
{
|
||||
if (!(self = [super init]))
|
||||
return self;
|
||||
|
||||
self.indentifier = [NSString stringWithFormat:@"%@.%@", [NSBundle mainBundle].bundleIdentifier, anIdentifier];
|
||||
self.touchBarItems = [NSMutableArray arrayWithCapacity:6];
|
||||
indentifier = [NSString stringWithFormat:@"%@.%@", [NSBundle mainBundle].bundleIdentifier, anIdentifier];
|
||||
touchBarItems = [NSMutableArray arrayWithCapacity:6];
|
||||
|
||||
self.defaultItemIdentifiers = @[self.indentifier,];
|
||||
self.principalItemIdentifier = self.indentifier;
|
||||
touchBar = [[NSTouchBar alloc] init];
|
||||
touchBar.defaultItemIdentifiers = @[indentifier,];
|
||||
touchBar.principalItemIdentifier = indentifier;
|
||||
touchBar.delegate = self;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSTouchBarItem *)itemForIdentifier:(NSTouchBarItemIdentifier)identifier
|
||||
- (NSTouchBarItem *)touchBar:(NSTouchBar * __unused)touchBar makeItemForIdentifier:(NSTouchBarItemIdentifier)identifier
|
||||
{
|
||||
if ([identifier isEqualToString:self.indentifier])
|
||||
return [NSGroupTouchBarItem groupItemWithIdentifier:self.indentifier items:self.touchBarItems];
|
||||
return [super itemForIdentifier:identifier];
|
||||
return nil;
|
||||
}
|
||||
|
||||
-(NSButton *)addButtonWithButton:(NSButton *)button
|
||||
@@ -59,7 +62,7 @@
|
||||
|
||||
-(void)addSpace
|
||||
{
|
||||
NSTouchBarItem *item = [super itemForIdentifier:NSTouchBarItemIdentifierFixedSpaceLarge];
|
||||
NSTouchBarItem *item = [[NSTouchBarItem alloc] initWithIdentifier:NSTouchBarItemIdentifierFixedSpaceLarge];
|
||||
[self.touchBarItems addObject:item];
|
||||
}
|
||||
|
||||
@@ -67,15 +70,9 @@
|
||||
|
||||
#else
|
||||
|
||||
@interface NSTouchBar : NSObject
|
||||
@implementation SUTouchBarProvider
|
||||
|
||||
@end
|
||||
|
||||
@implementation NSTouchBar
|
||||
|
||||
@end
|
||||
|
||||
@implementation SUTouchBar
|
||||
@synthesize touchBar;
|
||||
|
||||
-(instancetype)initWithIdentifier:(NSString *)identifier {
|
||||
return nil;
|
||||
Vendored
+12
-9
@@ -21,7 +21,7 @@
|
||||
#import "SUAppcastItem.h"
|
||||
#import "SUApplicationInfo.h"
|
||||
#import "SUSystemUpdateInfo.h"
|
||||
#import "SUTouchBar.h"
|
||||
#import "SUTouchBarProvider.h"
|
||||
|
||||
// WebKit protocols are not explicitly declared until 10.11 SDK, so
|
||||
// declare dummy protocols to keep the build working on earlier SDKs.
|
||||
@@ -48,6 +48,7 @@
|
||||
@property (weak) IBOutlet NSButton *installButton;
|
||||
@property (weak) IBOutlet NSButton *skipButton;
|
||||
@property (weak) IBOutlet NSButton *laterButton;
|
||||
@property (strong) SUTouchBarProvider *touchBarProvider;
|
||||
|
||||
@end
|
||||
|
||||
@@ -70,6 +71,8 @@
|
||||
@synthesize skipButton;
|
||||
@synthesize laterButton;
|
||||
|
||||
@synthesize touchBarProvider;
|
||||
|
||||
- (instancetype)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)aHost completionBlock:(void (^)(SUUpdateAlertChoice))block
|
||||
{
|
||||
self = [super initWithWindowNibName:@"SUUpdateAlert"];
|
||||
@@ -319,14 +322,14 @@
|
||||
|
||||
- (NSTouchBar *)makeTouchBar
|
||||
{
|
||||
SUTouchBar *touchBar = [[SUTouchBar alloc] initWithIdentifier:self.className];
|
||||
[touchBar addButtonWithButton:self.skipButton];
|
||||
[touchBar addSpace];
|
||||
[touchBar addButtonWithButton:self.laterButton];
|
||||
[touchBar addButtonWithButton:self.installButton];
|
||||
[touchBar addSpace];
|
||||
[touchBar addSpace];
|
||||
return touchBar;
|
||||
self.touchBarProvider = [[SUTouchBarProvider alloc] initWithIdentifier:self.className];
|
||||
[self.touchBarProvider addButtonWithButton:self.skipButton];
|
||||
[self.touchBarProvider addSpace];
|
||||
[self.touchBarProvider addButtonWithButton:self.laterButton];
|
||||
[self.touchBarProvider addButtonWithButton:self.installButton];
|
||||
[self.touchBarProvider addSpace];
|
||||
[self.touchBarProvider addSpace];
|
||||
return self.touchBarProvider.touchBar;
|
||||
}
|
||||
|
||||
@end
|
||||
Vendored
+7
-5
@@ -13,7 +13,7 @@
|
||||
#import "SUConstants.h"
|
||||
#import "SULocalizations.h"
|
||||
#import "SUApplicationInfo.h"
|
||||
#import "SUTouchBar.h"
|
||||
#import "SUTouchBarProvider.h"
|
||||
|
||||
@interface SUUpdatePermissionPrompt ()
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
@property (weak) IBOutlet NSView *moreInfoView;
|
||||
@property (weak) IBOutlet NSButton *moreInfoButton;
|
||||
@property (weak) IBOutlet NSTableView *profileTableView;
|
||||
@property (strong) SUTouchBarProvider *touchBarProvider;
|
||||
|
||||
@property (nonatomic, readonly) void (^reply)(SUUpdatePermissionResponse *);
|
||||
|
||||
@@ -42,6 +43,7 @@
|
||||
@synthesize moreInfoView;
|
||||
@synthesize moreInfoButton;
|
||||
@synthesize profileTableView;
|
||||
@synthesize touchBarProvider;
|
||||
|
||||
- (BOOL)shouldAskAboutProfile
|
||||
{
|
||||
@@ -176,10 +178,10 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
SUTouchBar *touchBar = [[SUTouchBar alloc] initWithIdentifier:self.className];
|
||||
[touchBar addButtonWithButton:cancelButton];
|
||||
[touchBar addButtonWithButton:checkButton];
|
||||
return touchBar;
|
||||
self.touchBarProvider = [[SUTouchBarProvider alloc] initWithIdentifier:self.className];
|
||||
[self.touchBarProvider addButtonWithButton:cancelButton];
|
||||
[self.touchBarProvider addButtonWithButton:checkButton];
|
||||
return self.touchBarProvider.touchBar;
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in new issue
Block a user