Skip to content
This repository has been archived by the owner on Nov 3, 2020. It is now read-only.

Commit

Permalink
Merge pull request #185 from wrutkowski/empty-recent-documents
Browse files Browse the repository at this point in the history
Added Open button on Home Window for empty Recent list
  • Loading branch information
mennenia committed Jan 13, 2016
2 parents 5dde7d1 + 15db573 commit 992f5f8
Show file tree
Hide file tree
Showing 10 changed files with 111 additions and 9 deletions.
37 changes: 35 additions & 2 deletions app/CocoaPods/Base.lproj/CPHomeWindowController.xib
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" fullSizeContentView="YES"/>
<windowPositionMask key="initialPositionMask" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="196" y="240" width="665" height="490"/>
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1440"/>
<rect key="screenRect" x="0.0" y="0.0" width="1920" height="1177"/>
<view key="contentView" id="se5-gp-TjO">
<rect key="frame" x="0.0" y="0.0" width="665" height="490"/>
<autoresizingMask key="autoresizingMask"/>
Expand Down Expand Up @@ -135,6 +135,29 @@
<autoresizingMask key="autoresizingMask"/>
</scroller>
</scrollView>
<customView translatesAutoresizingMaskIntoConstraints="NO" id="9pW-mq-gji">
<rect key="frame" x="432" y="0.0" width="233" height="490"/>
<subviews>
<button translatesAutoresizingMaskIntoConstraints="NO" id="o1v-Y5-7bX">
<rect key="frame" x="16" y="175" width="201" height="140"/>
<constraints>
<constraint firstAttribute="height" constant="140" id="Pyn-Xc-2H8"/>
</constraints>
<buttonCell key="cell" type="square" title="Open an existing Podfile" alternateTitle="Open an existing Podfile" bezelStyle="shadowlessSquare" image="OpenDocument" imagePosition="above" alignment="center" alternateImage="OpenDocumentSelected" inset="2" id="40v-7y-tY1">
<behavior key="behavior" lightByContents="YES"/>
<font key="font" metaFont="miniSystem"/>
</buttonCell>
<connections>
<action selector="openDocument:" target="-1" id="gKX-Z4-ley"/>
</connections>
</button>
</subviews>
<constraints>
<constraint firstItem="o1v-Y5-7bX" firstAttribute="leading" secondItem="9pW-mq-gji" secondAttribute="leading" constant="16" id="Ryc-0C-Yz3"/>
<constraint firstAttribute="trailing" secondItem="o1v-Y5-7bX" secondAttribute="trailing" constant="16" id="cNe-SU-0Ug"/>
<constraint firstItem="o1v-Y5-7bX" firstAttribute="centerY" secondItem="9pW-mq-gji" secondAttribute="centerY" id="rWx-BF-7pm"/>
</constraints>
</customView>
<box horizontalHuggingPriority="750" misplaced="YES" title="Box" boxType="separator" titlePosition="noTitle" translatesAutoresizingMaskIntoConstraints="NO" id="EzD-1M-8dC">
<rect key="frame" x="429" y="114" width="5" height="376"/>
<color key="borderColor" white="0.0" alpha="0.41999999999999998" colorSpace="calibratedWhite"/>
Expand Down Expand Up @@ -199,13 +222,17 @@
</textField>
</subviews>
<constraints>
<constraint firstItem="9pW-mq-gji" firstAttribute="centerY" secondItem="3Jq-7y-btG" secondAttribute="centerY" id="DLj-CW-6d6"/>
<constraint firstItem="09I-WM-Nv4" firstAttribute="top" secondItem="se5-gp-TjO" secondAttribute="top" constant="162" id="HK3-tO-Eun"/>
<constraint firstItem="9pW-mq-gji" firstAttribute="height" secondItem="3Jq-7y-btG" secondAttribute="height" id="SYQ-ac-gvi"/>
<constraint firstItem="09I-WM-Nv4" firstAttribute="leading" secondItem="se5-gp-TjO" secondAttribute="leading" id="TmG-Y2-ZOc"/>
<constraint firstAttribute="trailing" secondItem="3Jq-7y-btG" secondAttribute="trailing" id="Y7a-a5-JXb"/>
<constraint firstItem="EzD-1M-8dC" firstAttribute="top" secondItem="se5-gp-TjO" secondAttribute="top" id="iA7-Uv-qga"/>
<constraint firstItem="9pW-mq-gji" firstAttribute="width" secondItem="3Jq-7y-btG" secondAttribute="width" id="io8-78-kBB"/>
<constraint firstAttribute="bottom" secondItem="3Jq-7y-btG" secondAttribute="bottom" id="jue-MZ-Be6"/>
<constraint firstItem="EzD-1M-8dC" firstAttribute="leading" secondItem="09I-WM-Nv4" secondAttribute="trailing" constant="-1" id="jzI-hZ-hk6"/>
<constraint firstItem="3Jq-7y-btG" firstAttribute="leading" secondItem="EzD-1M-8dC" secondAttribute="trailing" id="rti-SZ-bwt"/>
<constraint firstItem="9pW-mq-gji" firstAttribute="centerX" secondItem="3Jq-7y-btG" secondAttribute="centerX" id="uDW-Wl-mqs"/>
<constraint firstItem="3Jq-7y-btG" firstAttribute="top" secondItem="se5-gp-TjO" secondAttribute="top" id="xCt-6i-kaX"/>
<constraint firstAttribute="bottom" secondItem="EzD-1M-8dC" secondAttribute="bottom" id="xRG-cZ-Yan"/>
</constraints>
Expand All @@ -219,7 +246,11 @@
</connections>
<point key="canvasLocation" x="528.5" y="415"/>
</window>
<customObject id="vg8-5r-eb7" customClass="CPRecentDocumentsController"/>
<customObject id="vg8-5r-eb7" customClass="CPRecentDocumentsController">
<connections>
<outlet property="openDocumentButton" destination="o1v-Y5-7bX" id="dwq-hg-9SY"/>
</connections>
</customObject>
<customObject id="TsL-KI-RcJ" customClass="CPExternalLinksHelper"/>
<customView translatesAutoresizingMaskIntoConstraints="NO" id="3g8-qK-y7T" customClass="BlueView" customModule="CocoaPods" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="432" height="474"/>
Expand Down Expand Up @@ -357,6 +388,8 @@ Command-Line Tools?</string>
<image name="CP-Term" width="420" height="120"/>
<image name="CocoaPodsAppOval" width="256" height="256"/>
<image name="ConsoleWindow" width="376" height="488"/>
<image name="OpenDocument" width="100" height="100"/>
<image name="OpenDocumentSelected" width="100" height="100"/>
<image name="Podfile-icon" width="34" height="48"/>
<image name="TransparentButtonBG" width="23" height="20"/>
<image name="TransparentButtonBGFilled" width="49" height="20"/>
Expand Down
2 changes: 1 addition & 1 deletion app/CocoaPods/CPRecentDocumentsController.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

/// Used to set the first responder once data has been loadded in
@property (nonatomic, readwrite, weak) IBOutlet NSTableView *documentsTableView;

@property (weak) IBOutlet NSButton *openDocumentButton;

@end

Expand Down
34 changes: 29 additions & 5 deletions app/CocoaPods/CPRecentDocumentsController.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,23 @@ @implementation CPRecentDocumentsController
- (void)awakeFromNib
{
[super awakeFromNib];

NSMutableAttributedString *attrTitle =
[[NSMutableAttributedString alloc] initWithString:NSLocalizedString(@"MAIN_WINDOW_OPEN_DOCUMENT_BUTTON_TITLE", nil)];
NSUInteger len = [attrTitle length];
NSRange range = NSMakeRange(0, len);
[attrTitle addAttribute:NSForegroundColorAttributeName value:[NSColor colorWithRed:217.0/255.0 green:217.0/255.0 blue:217.0/255.0 alpha:1.0] range:range];
[attrTitle addAttribute:NSFontAttributeName value:[NSFont systemFontOfSize:10.0] range:range];
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
paragraphStyle.alignment = NSTextAlignmentCenter;
[attrTitle addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:range];
[attrTitle fixAttributesInRange:range];
[self.openDocumentButton setAttributedTitle:attrTitle];
[attrTitle addAttribute:NSForegroundColorAttributeName value:[NSColor colorWithRed:192.0/255.0 green:192.0/255.0 blue:192.0/255.0 alpha:1.0] range:range];
[self.openDocumentButton setAttributedAlternateTitle:attrTitle];

[self setupRecentDocuments];

if (self.documentsTableView.numberOfRows > 0) {
NSIndexSet *indexes = [NSIndexSet indexSetWithIndex:0];
[self.documentsTableView selectRowIndexes:indexes byExtendingSelection:NO];
}
[self prepareData];
}

- (void)setupRecentDocuments
Expand All @@ -42,6 +53,19 @@ - (void)setupRecentDocuments
self.recentDocuments = documents;
}

- (void)prepareData
{
if ([self.recentDocuments count] > 0) {
NSIndexSet *indexes = [NSIndexSet indexSetWithIndex:0];
[self.documentsTableView selectRowIndexes:indexes byExtendingSelection:NO];
self.documentsTableView.hidden = NO;
self.openDocumentButton.hidden = YES;
} else {
self.documentsTableView.hidden = YES;
self.openDocumentButton.hidden = NO;
}
}

- (CPHomeWindowDocumentEntry *)projectDetailsAtURL:(NSURL *)url
{
NSFileManager *fileManager = [NSFileManager defaultManager];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "OpenDocument.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "OpenDocument@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "OpenDocumentSelected.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "OpenDocumentSelected@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion app/CocoaPods/Supporting Files/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@
"MAIN_WINDOW_TITLE" = "Welcome to CocoaPods";
"MAIN_WINDOW_OPEN_GUIDES_BUTTON_TITLE" = "Open Guides";
"MAIN_WINDOW_OPEN_SEARCH_BUTTON_TITLE" = "Open Search";
"MAIN_WINDOW_CHANGELOG_BUTTON_TITLE" = "What's New?";
"MAIN_WINDOW_CHANGELOG_BUTTON_TITLE" = "What's New?";
"MAIN_WINDOW_OPEN_DOCUMENT_BUTTON_TITLE" = "Open an existing Podfile";

0 comments on commit 992f5f8

Please sign in to comment.