File tree Expand file tree Collapse file tree 2 files changed +41
-3
lines changed Expand file tree Collapse file tree 2 files changed +41
-3
lines changed Original file line number Diff line number Diff line change 8
8
9
9
#import " Sparkle.framework/Headers/Sparkle.h"
10
10
11
- @interface MMSparkle2Delegate : NSObject <SPUUpdaterDelegate, SPUStandardUserDriverDelegate>;
11
+ NS_ASSUME_NONNULL_BEGIN
12
+
13
+ @interface MMSparkle2Delegate : NSObject <SPUUpdaterDelegate, SPUStandardUserDriverDelegate, SUVersionDisplay>;
12
14
13
15
// SPUUpdaterDelegate
14
- - (nonnull NSSet <NSString *> *)allowedChannelsForUpdater:(nonnull SPUUpdater *)updater;
16
+ - (NSSet <NSString *> *)allowedChannelsForUpdater:(SPUUpdater *)updater;
15
17
16
18
// SPUStandardUserDriverDelegate
17
- // No need to implement anything for now. Default behaviors work fine.
19
+ - (_Nullable id <SUVersionDisplay>)standardUserDriverRequestsVersionDisplayer;
20
+
21
+ // SUVersionDisplay
22
+ - (NSString *)formatUpdateDisplayVersionFromUpdate:(SUAppcastItem *)update andBundleDisplayVersion:(NSString * _Nonnull __autoreleasing * _Nonnull)inOutBundleDisplayVersion withBundleVersion:(NSString *)bundleVersion;
23
+
24
+ - (NSString *)formatBundleDisplayVersion:(NSString *)bundleDisplayVersion withBundleVersion:(NSString *)bundleVersion matchingUpdate:(SUAppcastItem * _Nullable)matchingUpdate;
18
25
19
26
@end
20
27
28
+ NS_ASSUME_NONNULL_END
29
+
21
30
#endif
Original file line number Diff line number Diff line change @@ -24,6 +24,35 @@ @implementation MMSparkle2Delegate;
24
24
return [NSSet <NSString *> set];
25
25
}
26
26
27
+ - (_Nullable id <SUVersionDisplay>)standardUserDriverRequestsVersionDisplayer
28
+ {
29
+ return self;
30
+ }
31
+
32
+ // / MacVim has a non-standard way of using "bundle version" and "display version",
33
+ // / where the display version is the upstream Vim version, and the bundle version
34
+ // / is the release number of MacVim itself. The release number is more useful to
35
+ // / know when updating MacVim, but both should be displayed. Format them nicely so
36
+ // / it's clear to the user which is which. By default Sparkle would only show display
37
+ // / version which is problematic as that wouldn't show the release number which we
38
+ // / care about.
39
+ NSString * formatVersionString (NSString * bundleVersion, NSString * displayVersion)
40
+ {
41
+ return [NSString stringWithFormat: @" r%@ (Vim %@ )" , bundleVersion, displayVersion];
42
+ }
43
+
44
+ - (NSString *)formatUpdateDisplayVersionFromUpdate : (SUAppcastItem *)update andBundleDisplayVersion : (NSString * _Nonnull __autoreleasing * _Nonnull)inOutBundleDisplayVersion withBundleVersion : (NSString *)bundleVersion
45
+ {
46
+ *inOutBundleDisplayVersion = formatVersionString (bundleVersion, *inOutBundleDisplayVersion);
47
+ return formatVersionString (update.versionString , update.displayVersionString );
48
+ }
49
+
50
+ - (NSString *)formatBundleDisplayVersion : (NSString *)bundleDisplayVersion withBundleVersion : (NSString *)bundleVersion matchingUpdate : (SUAppcastItem * _Nullable)matchingUpdate
51
+ {
52
+ return formatVersionString (bundleVersion, bundleDisplayVersion);
53
+ }
54
+
55
+
27
56
@end ;
28
57
29
58
#endif
You can’t perform that action at this time.
0 commit comments