// // AboutWindowController.m // ReiKey // // Created by Patrick Wardle on 12/24/18. // Copyright © 2018 Objective-See. All rights reserved. // #import "consts.h" #import "utilities.h" #import "AboutWindowController.h" @implementation AboutWindowController @synthesize patrons; @synthesize versionLabel; //automatically called when nib is loaded // ->center window -(void)awakeFromNib { //center [self.window center]; } //automatically invoked when window is loaded // set to window to white, set app version, patrons, etc -(void)windowDidLoad { //version NSString* version = nil; //super [super windowDidLoad]; //not in dark mode? // make window white if(YES != isDarkMode()) { //make white self.window.backgroundColor = NSColor.whiteColor; } //grab app version version = getAppVersion(); if(nil == version) { //default version = @"unknown"; } //set version sting self.versionLabel.stringValue = version; //load patrons // <3 you guys & girls self.patrons.string = [NSString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"patrons" ofType:@"txt"] encoding:NSUTF8StringEncoding error:NULL]; if(nil == self.patrons.string) { //default self.patrons.string = @"error: failed to load patrons :/"; } //make 'Support Us' button first responder [self.window makeFirstResponder:[self.window.contentView viewWithTag:BUTTON_SUPPORT_US]]; return; } //automatically invoked when window is closing // ->make window unmodal -(void)windowWillClose:(NSNotification *)notification { //make un-modal [[NSApplication sharedApplication] stopModal]; return; } //automatically invoked when user clicks any of the buttons // ->perform actions, such as loading patreon or products URL -(IBAction)buttonHandler:(id)sender { //support us button if(((NSButton*)sender).tag == BUTTON_SUPPORT_US) { //open URL // ->invokes user's default browser [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:PATREON_URL]]; } //more info button else if(((NSButton*)sender).tag == BUTTON_MORE_INFO) { //open URL // ->invokes user's default browser [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:PRODUCT_URL]]; } return; } @end