mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-25 04:47:55 +00:00
Add Touch Bar support
This commit is contained in:
1 parent
f43b9f7f02
commit
d44a122a21
7 files changed
+201
No files matched your search
@@ -262,6 +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"; }; };
|
||||
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 */; };
|
||||
@@ -794,6 +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>"; };
|
||||
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>"; };
|
||||
@@ -1174,6 +1179,8 @@
|
||||
612DCBAE0D488BC60015DBEA /* SUUpdatePermissionPrompt.m */,
|
||||
7205C42F1E1215AD00E370AE /* SUUpdatePermissionResponse.h */,
|
||||
7205C4301E1215AD00E370AE /* SUUpdatePermissionResponse.m */,
|
||||
E1545EC31E1D7E0200FAECE8 /* SUTouchBar.h */,
|
||||
E1545EC41E1D7E0200FAECE8 /* SUTouchBar.m */,
|
||||
);
|
||||
name = "User Interface";
|
||||
sourceTree = "<group>";
|
||||
@@ -1377,6 +1384,7 @@
|
||||
6102FE4A0E07803800F85D09 /* SUDiskImageUnarchiver.h in Headers */,
|
||||
61299A2F09CA2DAB00B7442F /* SUDSAVerifier.h in Headers */,
|
||||
55E6F33319EC9F6C00005E76 /* SUErrors.h in Headers */,
|
||||
E1545EC51E1D7E0200FAECE8 /* SUTouchBar.h in Headers */,
|
||||
14652F8419A978C200959E44 /* SUExport.h in Headers */,
|
||||
7275F9C11B5F1F2900B1D19E /* SUFileManager.h in Headers */,
|
||||
722954C41D04E66F00ECF9CA /* SUFileOperationConstants.h in Headers */,
|
||||
@@ -1861,6 +1869,7 @@
|
||||
55C14F22136EF86000649790 /* SUStandardVersionComparator.m in Sources */,
|
||||
55C14F20136EF84300649790 /* SUStatusController.m in Sources */,
|
||||
55C14F23136EF86700649790 /* SUSystemProfiler.m in Sources */,
|
||||
E1EC2A301E21667000245715 /* SUTouchBar.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -2007,6 +2016,7 @@
|
||||
6196CFFA09C72149000DC222 /* SUStatusController.m in Sources */,
|
||||
61A2279D0D1CEE7600430CCD /* SUSystemProfiler.m in Sources */,
|
||||
72316BE41E0E1C7F0039EFD9 /* SUSystemUpdateInfo.m in Sources */,
|
||||
E1545EC61E1D7E0200FAECE8 /* SUTouchBar.m in Sources */,
|
||||
61B93A3D0DD02D7000DCD2F8 /* SUUIBasedUpdateDriver.m in Sources */,
|
||||
61299A8E09CA790200B7442F /* SUUnarchiver.m in Sources */,
|
||||
722589DB1E0B19F4005EA0B9 /* SUUnarchiverNotifier.m in Sources */,
|
||||
|
||||
Vendored
+27
@@ -11,6 +11,7 @@
|
||||
#import "SUAppcastItem.h"
|
||||
#import "SUApplicationInfo.h"
|
||||
#import "SUHost.h"
|
||||
#import "SUTouchBar.h"
|
||||
|
||||
@interface SUAutomaticUpdateAlert ()
|
||||
@property (strong) void(^completionBlock)(SUAutomaticInstallationChoice);
|
||||
@@ -88,4 +89,30 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (NSTouchBar *)makeTouchBar
|
||||
{
|
||||
NSButton *installButton, *laterButton, *cancelButton;
|
||||
for (NSView *control in self.window.contentView.subviews) {
|
||||
if ([control isKindOfClass:[NSButton class]]) {
|
||||
NSButton *button = (NSButton *)control;
|
||||
if (button.action == @selector(installNow:)) {
|
||||
installButton = button;
|
||||
} else if (button.action == @selector(installLater:)) {
|
||||
laterButton = button;
|
||||
} else if (button.action == @selector(doNotInstall:)) {
|
||||
cancelButton = button;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SUTouchBar *touchBar = [[SUTouchBar alloc] initWithIdentifier:self.className];
|
||||
[touchBar addButtonWithButton:cancelButton];
|
||||
[touchBar addSpace];
|
||||
[touchBar addButtonWithButton:laterButton];
|
||||
[touchBar addButtonWithButton:installButton];
|
||||
[touchBar addSpace];
|
||||
[touchBar addSpace];
|
||||
return touchBar;
|
||||
}
|
||||
|
||||
@end
|
||||
Vendored
+16
@@ -11,10 +11,12 @@
|
||||
#import "SUHost.h"
|
||||
#import "SULocalizations.h"
|
||||
#import "SUApplicationInfo.h"
|
||||
#import "SUTouchBar.h"
|
||||
|
||||
@interface SUStatusController ()
|
||||
@property (copy) NSString *title, *buttonTitle;
|
||||
@property (strong) SUHost *host;
|
||||
@property NSButton *touchBarButton;
|
||||
@end
|
||||
|
||||
@implementation SUStatusController
|
||||
@@ -27,6 +29,7 @@
|
||||
@synthesize actionButton;
|
||||
@synthesize progressBar;
|
||||
@synthesize statusTextField;
|
||||
@synthesize touchBarButton;
|
||||
|
||||
- (instancetype)initWithHost:(SUHost *)aHost
|
||||
{
|
||||
@@ -93,6 +96,10 @@
|
||||
[self.actionButton setTarget:target];
|
||||
[self.actionButton setAction:action];
|
||||
[self.actionButton setKeyEquivalent:isDefault ? @"\r" : @""];
|
||||
|
||||
self.touchBarButton.target = self.actionButton.target;
|
||||
self.touchBarButton.action = self.actionButton.action;
|
||||
self.touchBarButton.keyEquivalent = self.actionButton.keyEquivalent;
|
||||
|
||||
// 06/05/2008 Alex: Avoid a crash when cancelling during the extraction
|
||||
[self setButtonEnabled:(target != nil)];
|
||||
@@ -123,4 +130,13 @@
|
||||
[self.progressBar setUsesThreadedAnimation:YES];
|
||||
}
|
||||
|
||||
- (NSTouchBar *)makeTouchBar
|
||||
{
|
||||
SUTouchBar *touchBar = [[SUTouchBar alloc] initWithIdentifier:self.className];
|
||||
self.touchBarButton = [touchBar 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;
|
||||
}
|
||||
|
||||
@end
|
||||
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// SUTouchBar.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Yuxin Wang on 05/01/2017.
|
||||
// Copyright © 2017 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@class NSTouchBar;
|
||||
|
||||
@interface SUTouchBar : NSTouchBar
|
||||
|
||||
-(instancetype)initWithIdentifier:(NSString *)identifier;
|
||||
-(NSButton *)addButtonWithButton:(NSButton *)button;
|
||||
-(void)addSpace;
|
||||
|
||||
@end
|
||||
Vendored
+94
@@ -0,0 +1,94 @@
|
||||
//
|
||||
// SUTouchBar.m
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Yuxin Wang on 05/01/2017.
|
||||
// Copyright © 2017 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import "SUTouchBar.h"
|
||||
|
||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 101202
|
||||
|
||||
@interface SUTouchBar()
|
||||
|
||||
@property (copy) NSString* indentifier;
|
||||
@property NSMutableArray<NSTouchBarItem*> *touchBarItems;
|
||||
|
||||
@end
|
||||
|
||||
@implementation SUTouchBar
|
||||
|
||||
@synthesize indentifier;
|
||||
@synthesize touchBarItems;
|
||||
|
||||
-(instancetype)initWithIdentifier:(NSString *)anIdentifier
|
||||
{
|
||||
if (!(self = [super init]))
|
||||
return self;
|
||||
|
||||
self.indentifier = [NSString stringWithFormat:@"%@.%@", [NSBundle mainBundle].bundleIdentifier, anIdentifier];
|
||||
self.touchBarItems = [NSMutableArray arrayWithCapacity:6];
|
||||
|
||||
self.defaultItemIdentifiers = @[self.indentifier,];
|
||||
self.principalItemIdentifier = self.indentifier;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSTouchBarItem *)itemForIdentifier:(NSTouchBarItemIdentifier)identifier
|
||||
{
|
||||
if ([identifier isEqualToString:self.indentifier])
|
||||
return [NSGroupTouchBarItem groupItemWithIdentifier:self.indentifier items:self.touchBarItems];
|
||||
return [super itemForIdentifier:identifier];
|
||||
}
|
||||
|
||||
-(NSButton *)addButtonWithButton:(NSButton *)button
|
||||
{
|
||||
NSString *itemId = [self.indentifier stringByAppendingFormat:@".button-%lu", self.touchBarItems.count];
|
||||
NSCustomTouchBarItem *item = [[NSCustomTouchBarItem alloc] initWithIdentifier:itemId];
|
||||
|
||||
NSButton *buttonCopy = [NSButton buttonWithTitle:button.title target:button.target action:button.action];
|
||||
buttonCopy.keyEquivalent = button.keyEquivalent;
|
||||
buttonCopy.tag = button.tag;
|
||||
|
||||
item.view = buttonCopy;
|
||||
[self.touchBarItems addObject:item];
|
||||
return buttonCopy;
|
||||
}
|
||||
|
||||
-(void)addSpace
|
||||
{
|
||||
NSTouchBarItem *item = [super itemForIdentifier:NSTouchBarItemIdentifierFixedSpaceLarge];
|
||||
[self.touchBarItems addObject:item];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#else
|
||||
|
||||
@interface NSTouchBar : NSObject
|
||||
|
||||
@end
|
||||
|
||||
@implementation NSTouchBar
|
||||
|
||||
@end
|
||||
|
||||
@implementation SUTouchBar
|
||||
|
||||
-(instancetype)initWithIdentifier:(NSString *)identifier {
|
||||
return nil;
|
||||
}
|
||||
|
||||
-(NSButton *)addButtonWithButton:(NSButton *)button {
|
||||
return nil;
|
||||
}
|
||||
|
||||
-(void)addSpace {
|
||||
return nil;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
Vendored
+13
@@ -21,6 +21,7 @@
|
||||
#import "SUAppcastItem.h"
|
||||
#import "SUApplicationInfo.h"
|
||||
#import "SUSystemUpdateInfo.h"
|
||||
#import "SUTouchBar.h"
|
||||
|
||||
// WebKit protocols are not explicitly declared until 10.11 SDK, so
|
||||
// declare dummy protocols to keep the build working on earlier SDKs.
|
||||
@@ -316,4 +317,16 @@
|
||||
return webViewMenuItems;
|
||||
}
|
||||
|
||||
- (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;
|
||||
}
|
||||
|
||||
@end
|
||||
Vendored
+22
@@ -13,6 +13,7 @@
|
||||
#import "SUConstants.h"
|
||||
#import "SULocalizations.h"
|
||||
#import "SUApplicationInfo.h"
|
||||
#import "SUTouchBar.h"
|
||||
|
||||
@interface SUUpdatePermissionPrompt ()
|
||||
|
||||
@@ -160,4 +161,25 @@
|
||||
[NSApp stopModal];
|
||||
}
|
||||
|
||||
- (NSTouchBar *)makeTouchBar
|
||||
{
|
||||
NSButton *checkButton, *cancelButton;
|
||||
for (NSView *control in self.window.contentView.subviews) {
|
||||
if ([control isKindOfClass:[NSButton class]]) {
|
||||
NSButton *button = (NSButton *)control;
|
||||
if (button.action == @selector(finishPrompt:)) {
|
||||
if (button.tag == 1) {
|
||||
checkButton = button;
|
||||
} else if (button.tag == 0) {
|
||||
cancelButton = button;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
SUTouchBar *touchBar = [[SUTouchBar alloc] initWithIdentifier:self.className];
|
||||
[touchBar addButtonWithButton:cancelButton];
|
||||
[touchBar addButtonWithButton:checkButton];
|
||||
return touchBar;
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in new issue
Block a user