Skip to content

Commit

Permalink
GUI: Make dismiss button configurable, change default text back to di…
Browse files Browse the repository at this point in the history
…smiss (#1399)
  • Loading branch information
russellhancox authored Jul 23, 2024
1 parent f4ec2d5 commit 166c042
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Source/common/SNTConfigurator.h
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,11 @@
///
@property(readonly, nonatomic) NSString *eventDetailText;

///
/// This string represents the text to show on the "Dismiss" button in the UI instead of "Dismiss".
///
@property(readonly, nonatomic) NSString *dismissText;

///
/// In lockdown mode this is the message shown to the user when an unknown binary
/// is blocked. If this message is not configured, a reasonable default is provided.
Expand Down
10 changes: 10 additions & 0 deletions Source/common/SNTConfigurator.m
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ @implementation SNTConfigurator
static NSString *const kMoreInfoURLKey = @"MoreInfoURL";
static NSString *const kEventDetailURLKey = @"EventDetailURL";
static NSString *const kEventDetailTextKey = @"EventDetailText";
static NSString *const kDismissTextKey = @"DismissText";
static NSString *const kUnknownBlockMessage = @"UnknownBlockMessage";
static NSString *const kBannedBlockMessage = @"BannedBlockMessage";
static NSString *const kBannedUSBBlockMessage = @"BannedUSBBlockMessage";
Expand Down Expand Up @@ -227,6 +228,7 @@ - (instancetype)initWithSyncStateFile:(NSString *)syncStateFilePath
kMoreInfoURLKey : string,
kEventDetailURLKey : string,
kEventDetailTextKey : string,
kDismissTextKey : string,
kUnknownBlockMessage : string,
kBannedBlockMessage : string,
kBannedUSBBlockMessage : string,
Expand Down Expand Up @@ -409,6 +411,10 @@ + (NSSet *)keyPathsForValuesAffectingEventDetailText {
return [self configStateSet];
}

+ (NSSet *)keyPathsForValuesAffectingDismissText {
return [self configStateSet];
}

+ (NSSet *)keyPathsForValuesAffectingUnknownBlockMessage {
return [self configStateSet];
}
Expand Down Expand Up @@ -774,6 +780,10 @@ - (NSString *)eventDetailText {
return self.configState[kEventDetailTextKey];
}

- (NSString *)dismissText {
return self.configState[kDismissTextKey];
}

- (NSString *)unknownBlockMessage {
return self.configState[kUnknownBlockMessage];
}
Expand Down
3 changes: 2 additions & 1 deletion Source/gui/Resources/MessageWindow.xib
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<outlet property="foundFileCountLabel" destination="LHV-gV-vyf" id="Sr0-T2-xGx"/>
<outlet property="hashingIndicator" destination="VyY-Yg-JOe" id="Yq4-tZ-9ep"/>
<outlet property="openEventButton" destination="7ua-5a-uSd" id="9s4-ZA-Vlo"/>
<outlet property="dismissEventButton" destination="BbV-3h-mmL" id="5s4-ZB-xlo"/>
<outlet property="window" destination="9Bq-yh-54f" id="Uhs-WF-TV9"/>
</connections>
</customObject>
Expand Down Expand Up @@ -286,7 +287,7 @@ DQ
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="BbV-3h-mmL" userLabel="Dismiss Button">
<rect key="frame" x="271" y="28" width="124" height="34"/>
<buttonCell key="cell" type="push" title="Ignore" bezelStyle="rounded" alignment="center" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="XR6-Xa-gP4">
<buttonCell key="cell" type="push" title="Dismiss" bezelStyle="rounded" alignment="center" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="XR6-Xa-gP4">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
<string key="keyEquivalent" base64-UTF8="YES">
Expand Down
5 changes: 5 additions & 0 deletions Source/gui/SNTBinaryMessageWindowController.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@
///
@property(weak) IBOutlet NSButton *openEventButton;

///
/// Reference to the "Dismiss Event" button in the XIB. Used to update its title.
///
@property(weak) IBOutlet NSButton *dismissEventButton;

///
/// The execution event that this window is for
///
Expand Down
5 changes: 5 additions & 0 deletions Source/gui/SNTBinaryMessageWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ - (void)loadWindow {
}
}

NSString *dismissButtonText = [[SNTConfigurator configurator] dismissText];
if (dismissButtonText.length) {
[self.dismissEventButton setTitle:dismissButtonText];
}

if (!self.event.needsBundleHash) {
[self.bundleHashLabel removeFromSuperview];
[self.hashingIndicator removeFromSuperview];
Expand Down

0 comments on commit 166c042

Please sign in to comment.