Skip to content

Commit 097e278

Browse files
lolgearlucasderraugh
authored andcommitted
Windows Separation Remastered: About (#600)
* application: main menu welcome window has been extracted into separate xib. * application: windows welcome window has been incapsulated. * application: app delegate loading from xibs has been added. welcome window has been introduced. * application: project has been updated. * application: app delegate loading xibs from bundle has been added. * application: main menu about panel has been extracted into separate xib. * application: windows about panel has been incapsulated. * application: app delegate about panel has been introduced. * application: project has been updated. * application: window loading category has been added. * application: windows about panel xib has been renamed. * application: about panel has become independent. * application: app delegate about panel has been instantiated on demand. * application: project has been updated. * Revert "application: project has been updated." 5b41d79 * application: windows xibs about panel has been renamed. * application: about panel window controller has been introduced. * application: windows xibs about panel window controller has been added. * application: app delegate about panel window controller has been added. * application: about panel cleanup. * application: app delegate about panel property has been removed. * application: about panel unnecessary loadWindow invocation has been removed. * application: about panel custom subclass has been removed. * application: app delegate about panel new api has been adopted. * application: about panel window controller has been renamed. * application: app delegate about window controller lazy property has been added. * application: about panel has been eliminated. * application: window loading category has been removed. * application: project has been updated. * application: about window controller xib has been introduced.
1 parent 3ba8da7 commit 097e278

File tree

7 files changed

+174
-83
lines changed

7 files changed

+174
-83
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//
2+
// AboutWindowController.h
3+
// Application
4+
//
5+
// Created by Dmitry Lobanov on 08.10.2019.
6+
//
7+
8+
#import <AppKit/AppKit.h>
9+
10+
NS_ASSUME_NONNULL_BEGIN
11+
12+
@interface AboutWindowController : NSWindowController
13+
@property(assign, nonatomic, readwrite) BOOL updatePending;
14+
@end
15+
16+
NS_ASSUME_NONNULL_END
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
//
2+
// AboutWindowController.m
3+
// Application
4+
//
5+
// Created by Dmitry Lobanov on 08.10.2019.
6+
//
7+
8+
#import "AboutWindowController.h"
9+
10+
@interface AboutWindowController ()
11+
@property(nonatomic, weak) IBOutlet NSTextField* versionTextField;
12+
@property(nonatomic, weak) IBOutlet NSTextField* copyrightTextField;
13+
@end
14+
15+
@implementation AboutWindowController
16+
17+
- (instancetype)init {
18+
return [super initWithWindowNibName:@"AboutWindowController"];
19+
}
20+
21+
- (void)windowDidLoad {
22+
[super windowDidLoad];
23+
[self populateWithDataWhenUpdateIsPending:self.updatePending];
24+
}
25+
26+
- (void)populateWithDataWhenUpdateIsPending:(BOOL)updatePending {
27+
NSString *version = nil;
28+
#if DEBUG
29+
version = @"DEBUG";
30+
#else
31+
if (updatePending) {
32+
version = NSLocalizedString(@"Update Pending", nil);
33+
} else {
34+
version = [NSString stringWithFormat:NSLocalizedString(@"Version %@ (%@)", nil), [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"], [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]];
35+
}
36+
#endif
37+
self.versionTextField.stringValue = version;
38+
self.copyrightTextField.stringValue = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSHumanReadableCopyright"];
39+
}
40+
41+
@end

GitUp/Application/AppDelegate.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@
3131
@property(nonatomic, weak) IBOutlet NSTextField* authenticationNameTextField;
3232
@property(nonatomic, weak) IBOutlet NSSecureTextField* authenticationPasswordTextField;
3333

34-
@property(nonatomic, strong) IBOutlet NSPanel* aboutPanel;
35-
@property(nonatomic, weak) IBOutlet NSTextField* versionTextField;
36-
@property(nonatomic, weak) IBOutlet NSTextField* copyrightTextField;
37-
3834
+ (instancetype)sharedDelegate;
3935
+ (BOOL)loadPlainTextAuthenticationFormKeychainForURL:(NSURL*)url user:(NSString*)user username:(NSString**)username password:(NSString**)password allowInteraction:(BOOL)allowInteraction;
4036
+ (void)savePlainTextAuthenticationToKeychainForURL:(NSURL*)url withUsername:(NSString*)username password:(NSString*)password;

GitUp/Application/AppDelegate.m

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#import "ToolProtocol.h"
3030
#import "GARawTracker.h"
3131

32+
#import "AboutWindowController.h"
3233
#import "WelcomeWindow.h"
3334

3435
#define __ENABLE_SUDDEN_TERMINATION__ 1
@@ -42,6 +43,7 @@
4243
#define kToolInstallPath @"/usr/local/bin/" kToolName
4344

4445
@interface AppDelegate () <NSUserNotificationCenterDelegate, SUUpdaterDelegate>
46+
@property(nonatomic, strong) AboutWindowController *aboutWindowController;
4547
@property(nonatomic, strong) WelcomeWindow* welcomeWindow;
4648
@end
4749

@@ -59,6 +61,15 @@ @implementation AppDelegate {
5961
CFMessagePortRef _messagePort;
6062
}
6163

64+
#pragma mark - Properties
65+
- (AboutWindowController *)aboutWindowController {
66+
if (!_aboutWindowController) {
67+
_aboutWindowController = [[AboutWindowController alloc] init];
68+
}
69+
return _aboutWindowController;
70+
}
71+
72+
#pragma mark - Initialize
6273
+ (void)initialize {
6374
NSDictionary* defaults = @{
6475
GICommitMessageViewUserDefaultKey_ShowInvisibleCharacters : @(YES),
@@ -550,17 +561,8 @@ - (IBAction)viewIssues:(id)sender {
550561
}
551562

552563
- (IBAction)showAboutPanel:(id)sender {
553-
#if DEBUG
554-
_versionTextField.stringValue = @"DEBUG";
555-
#else
556-
if (_updatePending) {
557-
_versionTextField.stringValue = NSLocalizedString(@"Update Pending", nil);
558-
} else {
559-
_versionTextField.stringValue = [NSString stringWithFormat:NSLocalizedString(@"Version %@ (%@)", nil), [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"], [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]];
560-
}
561-
#endif
562-
_copyrightTextField.stringValue = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSHumanReadableCopyright"];
563-
[_aboutPanel makeKeyAndOrderFront:nil];
564+
self.aboutWindowController.updatePending = _updatePending;
565+
[self.aboutWindowController showWindow:nil];
564566
}
565567

566568
- (IBAction)showPreferences:(id)sender {
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="15400" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
3+
<dependencies>
4+
<deployment identifier="macosx"/>
5+
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="15400"/>
6+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
7+
</dependencies>
8+
<objects>
9+
<customObject id="-2" userLabel="File's Owner" customClass="AboutWindowController">
10+
<connections>
11+
<outlet property="copyrightTextField" destination="c4g-uo-jg9" id="FZS-IB-oJd"/>
12+
<outlet property="versionTextField" destination="HZC-36-Grr" id="gj4-PL-6SR"/>
13+
<outlet property="window" destination="sHg-NM-pfN" id="nBk-tW-g4b"/>
14+
</connections>
15+
</customObject>
16+
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
17+
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
18+
<window title="About GitUp" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" restorable="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" frameAutosaveName="about" animationBehavior="default" id="sHg-NM-pfN" userLabel="About">
19+
<windowStyleMask key="styleMask" titled="YES" closable="YES"/>
20+
<rect key="contentRect" x="612" y="242" width="276" height="363"/>
21+
<rect key="screenRect" x="0.0" y="0.0" width="1440" height="900"/>
22+
<view key="contentView" id="3kP-0M-wu8">
23+
<rect key="frame" x="0.0" y="0.0" width="276" height="363"/>
24+
<autoresizingMask key="autoresizingMask"/>
25+
<subviews>
26+
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="AhE-7e-PYf">
27+
<rect key="frame" x="74" y="204" width="128" height="128"/>
28+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
29+
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="NSApplicationIcon" id="T7r-iI-qVo"/>
30+
</imageView>
31+
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="IyS-21-Jxl">
32+
<rect key="frame" x="86" y="166" width="104" height="17"/>
33+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
34+
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" allowsUndo="NO" sendsActionOnEndEditing="YES" alignment="center" title="GitUp" id="T8z-Ql-Nrv">
35+
<font key="font" metaFont="systemBold"/>
36+
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
37+
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
38+
</textFieldCell>
39+
</textField>
40+
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" setsMaxLayoutWidthAtFirstLayout="YES" translatesAutoresizingMaskIntoConstraints="NO" id="d1d-Xw-Yrr">
41+
<rect key="frame" x="18" y="83" width="240" height="28"/>
42+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
43+
<textFieldCell key="cell" allowsUndo="NO" sendsActionOnEndEditing="YES" alignment="center" id="J3Y-wR-GFR">
44+
<font key="font" metaFont="label" size="11"/>
45+
<string key="title">Concept &amp; code by Pierre-Olivier Latour
46+
UI design by Wayne Fan</string>
47+
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
48+
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
49+
</textFieldCell>
50+
</textField>
51+
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" setsMaxLayoutWidthAtFirstLayout="YES" translatesAutoresizingMaskIntoConstraints="NO" id="c4g-uo-jg9">
52+
<rect key="frame" x="26" y="40" width="224" height="28"/>
53+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
54+
<textFieldCell key="cell" allowsUndo="NO" sendsActionOnEndEditing="YES" alignment="center" title="&lt;COPYRIGHT&gt;" id="LbE-vT-Rsk">
55+
<font key="font" metaFont="label" size="11"/>
56+
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
57+
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
58+
</textFieldCell>
59+
</textField>
60+
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" setsMaxLayoutWidthAtFirstLayout="YES" translatesAutoresizingMaskIntoConstraints="NO" id="mcm-my-4sq">
61+
<rect key="frame" x="18" y="20" width="240" height="12"/>
62+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
63+
<textFieldCell key="cell" allowsUndo="NO" sendsActionOnEndEditing="YES" alignment="center" title="libgit2 is Copyright © the libgit2 contributors" id="tT8-4H-E7b">
64+
<font key="font" metaFont="menu" size="9"/>
65+
<color key="textColor" name="secondaryLabelColor" catalog="System" colorSpace="catalog"/>
66+
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
67+
</textFieldCell>
68+
</textField>
69+
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="HZC-36-Grr">
70+
<rect key="frame" x="38" y="141" width="200" height="17"/>
71+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
72+
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" allowsUndo="NO" sendsActionOnEndEditing="YES" alignment="center" title="&lt;VERSION&gt;" id="yn6-7n-hPc">
73+
<font key="font" metaFont="system"/>
74+
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
75+
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
76+
</textFieldCell>
77+
</textField>
78+
</subviews>
79+
</view>
80+
<point key="canvasLocation" x="114" y="441.5"/>
81+
</window>
82+
</objects>
83+
<resources>
84+
<image name="NSApplicationIcon" width="32" height="32"/>
85+
</resources>
86+
</document>

GitUp/Application/Base.lproj/MainMenu.xib

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,6 @@ You must close and reopen any opened repositories in GitUp after changing this s
521521
</window>
522522
<customObject id="Voe-Tx-rLC" customClass="AppDelegate">
523523
<connections>
524-
<outlet property="aboutPanel" destination="sHg-NM-pfN" id="nuH-JO-Zxx"/>
525524
<outlet property="authenticationNameTextField" destination="ohd-U6-h7y" id="jfG-3a-a5h"/>
526525
<outlet property="authenticationPasswordTextField" destination="Uio-D2-Dnt" id="nNT-Jn-Q9Y"/>
527526
<outlet property="authenticationURLTextField" destination="fBP-U8-T31" id="JUd-Sw-FSA"/>
@@ -530,12 +529,10 @@ You must close and reopen any opened repositories in GitUp after changing this s
530529
<outlet property="cloneRecursiveButton" destination="V3d-LG-L26" id="iSp-hX-Jc0"/>
531530
<outlet property="cloneURLTextField" destination="KgY-GJ-dY0" id="qXq-61-cKm"/>
532531
<outlet property="cloneWindow" destination="6SP-eN-0Kv" id="Bd8-7b-vpr"/>
533-
<outlet property="copyrightTextField" destination="c4g-uo-jg9" id="l3W-uq-nyp"/>
534532
<outlet property="preferencesTabView" destination="anN-jw-l7x" id="zP7-18-Z2X"/>
535533
<outlet property="preferencesToolbar" destination="YkS-ea-UXD" id="eZX-nc-ex8"/>
536534
<outlet property="preferencesWindow" destination="3qV-q4-a6k" id="yO6-yX-KBA"/>
537535
<outlet property="themePopUpButton" destination="aYx-qQ-zM6" id="NeK-Gb-prC"/>
538-
<outlet property="versionTextField" destination="HZC-36-Grr" id="qyt-nZ-xv3"/>
539536
</connections>
540537
</customObject>
541538
<menu title="Main Menu" systemMenu="main" id="AYu-sK-qS6">
@@ -1098,74 +1095,9 @@ Gw
10981095
</view>
10991096
<point key="canvasLocation" x="-709" y="619.5"/>
11001097
</window>
1101-
<window title="About GitUp" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" restorable="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" frameAutosaveName="about" animationBehavior="default" id="sHg-NM-pfN" userLabel="About" customClass="NSPanel">
1102-
<windowStyleMask key="styleMask" titled="YES" closable="YES"/>
1103-
<rect key="contentRect" x="612" y="242" width="276" height="363"/>
1104-
<rect key="screenRect" x="0.0" y="0.0" width="1440" height="900"/>
1105-
<view key="contentView" id="3kP-0M-wu8">
1106-
<rect key="frame" x="0.0" y="0.0" width="276" height="363"/>
1107-
<autoresizingMask key="autoresizingMask"/>
1108-
<subviews>
1109-
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="AhE-7e-PYf">
1110-
<rect key="frame" x="74" y="204" width="128" height="128"/>
1111-
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
1112-
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="NSApplicationIcon" id="T7r-iI-qVo"/>
1113-
</imageView>
1114-
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="IyS-21-Jxl">
1115-
<rect key="frame" x="86" y="166" width="104" height="17"/>
1116-
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
1117-
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" allowsUndo="NO" sendsActionOnEndEditing="YES" alignment="center" title="GitUp" id="T8z-Ql-Nrv">
1118-
<font key="font" metaFont="systemBold"/>
1119-
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
1120-
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
1121-
</textFieldCell>
1122-
</textField>
1123-
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" setsMaxLayoutWidthAtFirstLayout="YES" translatesAutoresizingMaskIntoConstraints="NO" id="d1d-Xw-Yrr">
1124-
<rect key="frame" x="18" y="83" width="240" height="28"/>
1125-
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
1126-
<textFieldCell key="cell" allowsUndo="NO" sendsActionOnEndEditing="YES" alignment="center" id="J3Y-wR-GFR">
1127-
<font key="font" metaFont="label" size="11"/>
1128-
<string key="title">Concept &amp; code by Pierre-Olivier Latour
1129-
UI design by Wayne Fan</string>
1130-
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
1131-
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
1132-
</textFieldCell>
1133-
</textField>
1134-
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" setsMaxLayoutWidthAtFirstLayout="YES" translatesAutoresizingMaskIntoConstraints="NO" id="c4g-uo-jg9">
1135-
<rect key="frame" x="26" y="40" width="224" height="28"/>
1136-
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
1137-
<textFieldCell key="cell" allowsUndo="NO" sendsActionOnEndEditing="YES" alignment="center" title="&lt;COPYRIGHT&gt;" id="LbE-vT-Rsk">
1138-
<font key="font" metaFont="label" size="11"/>
1139-
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
1140-
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
1141-
</textFieldCell>
1142-
</textField>
1143-
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" setsMaxLayoutWidthAtFirstLayout="YES" translatesAutoresizingMaskIntoConstraints="NO" id="mcm-my-4sq">
1144-
<rect key="frame" x="18" y="20" width="240" height="12"/>
1145-
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
1146-
<textFieldCell key="cell" allowsUndo="NO" sendsActionOnEndEditing="YES" alignment="center" title="libgit2 is Copyright © the libgit2 contributors" id="tT8-4H-E7b">
1147-
<font key="font" metaFont="label" size="9"/>
1148-
<color key="textColor" name="secondaryLabelColor" catalog="System" colorSpace="catalog"/>
1149-
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
1150-
</textFieldCell>
1151-
</textField>
1152-
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="HZC-36-Grr">
1153-
<rect key="frame" x="38" y="141" width="200" height="17"/>
1154-
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
1155-
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" allowsUndo="NO" sendsActionOnEndEditing="YES" alignment="center" title="&lt;VERSION&gt;" id="yn6-7n-hPc">
1156-
<font key="font" metaFont="system"/>
1157-
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
1158-
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
1159-
</textFieldCell>
1160-
</textField>
1161-
</subviews>
1162-
</view>
1163-
<point key="canvasLocation" x="114" y="441.5"/>
1164-
</window>
11651098
<userDefaultsController representsSharedInstance="YES" id="AR1-cq-KNa"/>
11661099
</objects>
11671100
<resources>
1168-
<image name="NSApplicationIcon" width="32" height="32"/>
11691101
<image name="icon_advanced" width="32" height="32"/>
11701102
<image name="icon_general" width="32" height="32"/>
11711103
</resources>

0 commit comments

Comments
 (0)