Skip to content

Commit

Permalink
Restore ability to show/hide saved requests view within the split view
Browse files Browse the repository at this point in the history
  • Loading branch information
mmattozzi committed Jun 3, 2017
1 parent b32c6ec commit 3cc0b2e
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CRCconstants.h
Expand Up @@ -25,6 +25,8 @@ FOUNDATION_EXPORT NSString * const DISABLE_ANIMATIONS;
FOUNDATION_EXPORT NSString * const DISABLE_COOKIES;
FOUNDATION_EXPORT NSString * const FILE_REQUEST_BODY;
FOUNDATION_EXPORT NSString * const ALLOW_SELF_SIGNED_CERTS;
FOUNDATION_EXPORT NSString * const SHOW_SAVED_REQUESTS_MENU_TITLE;
FOUNDATION_EXPORT NSString * const HIDE_SAVED_REQUESTS_MENU_TITLE;

@interface CRCConstants : NSObject

Expand Down
2 changes: 2 additions & 0 deletions CRCconstants.m
Expand Up @@ -23,5 +23,7 @@ @implementation CRCConstants
NSString * const DISABLE_COOKIES = @"disableCookies";
NSString * const FILE_REQUEST_BODY = @"UIFileRequestBody";
NSString * const ALLOW_SELF_SIGNED_CERTS = @"allowSelfSignedCerts";
NSString * const SHOW_SAVED_REQUESTS_MENU_TITLE = @"Show Saved Requests Sidebar";
NSString * const HIDE_SAVED_REQUESTS_MENU_TITLE = @"Hide Saved Requests Sidebar";

@end
7 changes: 6 additions & 1 deletion English.lproj/MainMenu.xib
Expand Up @@ -316,7 +316,11 @@ CA
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="View" id="722">
<items>
<menuItem title="Show Request Drawer" keyEquivalent="d" id="724"/>
<menuItem title="Hide Saved Requests" keyEquivalent="d" id="724">
<connections>
<action selector="toggleVerticalSplitView:" target="494" id="k67-0K-c34"/>
</connections>
</menuItem>
<menuItem title="Syntax Highlighting" state="on" id="977">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
Expand Down Expand Up @@ -618,6 +622,7 @@ CA
<connections>
<outlet property="reGetResponseMenuItem" destination="1011" id="1017"/>
<outlet property="showLineNumbersMenuItem" destination="oAI-Y9-WOk" id="wYQ-JM-AIF"/>
<outlet property="showSavedRequestsMenuItem" destination="724" id="7io-Rr-E9d"/>
<outlet property="syntaxHighlightingMenuItem" destination="977" id="Iks-gq-rra"/>
<outlet property="themeMenuItem" destination="kVo-uI-8oy" id="fMz-e7-adV"/>
</connections>
Expand Down
4 changes: 3 additions & 1 deletion English.lproj/MainWindow.xib
Expand Up @@ -40,13 +40,15 @@
<outlet property="saveRequestSheet" destination="FYI-kr-p7V" id="srr-5G-aKQ"/>
<outlet property="savedOutlineView" destination="6EW-S5-dUa" id="8w9-Va-ixQ"/>
<outlet property="savedRequestsDataSource" destination="j9L-nT-ahO" id="n5a-vj-9tY"/>
<outlet property="savedRequestsOuterView" destination="0xb-Zo-den" id="acV-ya-D01"/>
<outlet property="savedRequestsView" destination="tkI-i7-sOk" id="uaI-Ib-3tu"/>
<outlet property="status" destination="o8R-4b-dZa" id="RqO-Q2-5W0"/>
<outlet property="submitButton" destination="HRn-fG-MnP" id="c4r-vK-5O6"/>
<outlet property="timeoutField" destination="rVK-IK-JAi" id="k0n-qk-G3u"/>
<outlet property="timeoutSheet" destination="Zgt-jB-9ey" id="brF-mc-oJH"/>
<outlet property="urlBox" destination="iUA-xE-Nsl" id="1dI-HK-tiP"/>
<outlet property="username" destination="ch1-QE-uW9" id="RCc-Td-afh"/>
<outlet property="verticalSplitView" destination="IIw-6L-Kew" id="76R-iH-nwN"/>
<outlet property="window" destination="4ya-OY-gbC" id="LMT-eK-0KK"/>
</connections>
</customObject>
Expand Down Expand Up @@ -1209,7 +1211,7 @@ Gw
<rect key="frame" x="0.0" y="0.0" width="362" height="243"/>
<clipView key="contentView" id="MEV-WD-mmO">
<rect key="frame" x="1" y="1" width="345" height="241"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<textView focusRingType="none" importsGraphics="NO" usesFontPanel="YES" findStyle="panel" continuousSpellChecking="YES" allowsUndo="YES" usesRuler="YES" allowsNonContiguousLayout="YES" spellingCorrection="YES" smartInsertDelete="YES" id="8IA-oo-6cZ">
<rect key="frame" x="0.0" y="0.0" width="345" height="241"/>
Expand Down
2 changes: 2 additions & 0 deletions core/CocoaRestClientAppDelegate.h
Expand Up @@ -54,6 +54,7 @@
@property (weak) IBOutlet NSMenuItem *reGetResponseMenuItem;
@property (weak) IBOutlet NSMenuItem *showLineNumbersMenuItem;
@property (weak) IBOutlet NSMenuItem *themeMenuItem;
@property (weak) IBOutlet NSMenuItem *showSavedRequestsMenuItem;

// Window management methods
- (void) addTabFromWindow:(NSWindow *)window;
Expand Down Expand Up @@ -109,6 +110,7 @@
// Rest of Option MenuItems just set SharedUserDefaults in IB

/* View Menu */
- (IBAction) toggleVerticalSplitView:(id)sender;
- (IBAction) syntaxHighlightingToggled:(id)sender;
- (IBAction) showLineNumbersToggled:(id)sender;
- (IBAction) openFastSearchSavedRequestsPanel:(id)sender;
Expand Down
23 changes: 23 additions & 0 deletions core/CocoaRestClientAppDelegate.m
Expand Up @@ -34,6 +34,7 @@ @implementation CocoaRestClientAppDelegate
@synthesize themeMenuItem;
@synthesize showLineNumbersMenuItem;
@synthesize aceViewFontSize;
@synthesize showSavedRequestsMenuItem;

#pragma mark -
#pragma mark Window Management
Expand Down Expand Up @@ -139,6 +140,12 @@ - (void) tabWasRemoved:(NSWindowController *)windowController {

- (void) setCurrentMainWindowController:(MainWindowController *)mainWindowController {
currentWindowController = mainWindowController;
if ([currentWindowController.savedRequestsOuterView isHidden]) {
[self.showSavedRequestsMenuItem setTitle:SHOW_SAVED_REQUESTS_MENU_TITLE];
}
else {
[self.showSavedRequestsMenuItem setTitle:HIDE_SAVED_REQUESTS_MENU_TITLE];
}
}

- (void) applicationWillTerminate: (NSNotification *)note {
Expand Down Expand Up @@ -519,6 +526,22 @@ - (IBAction) openTimeoutDialog:(id) sender {
#pragma mark -
#pragma mark View Menu

- (IBAction) toggleVerticalSplitView:(id)sender {
if ([currentWindowController.savedRequestsOuterView isHidden]) {
[currentWindowController.savedRequestsOuterView setHidden:NO];
[currentWindowController.verticalSplitView
setPosition:currentWindowController.lastSavedRequestsViewWidth
ofDividerAtIndex:0];
[self.showSavedRequestsMenuItem setTitle:HIDE_SAVED_REQUESTS_MENU_TITLE];
}
else {
currentWindowController.lastSavedRequestsViewWidth = [currentWindowController.savedRequestsOuterView frame].size.width;
[currentWindowController.savedRequestsOuterView setHidden:YES];
[self.showSavedRequestsMenuItem setTitle:SHOW_SAVED_REQUESTS_MENU_TITLE];
}
[currentWindowController.verticalSplitView adjustSubviews];
}

- (IBAction) syntaxHighlightingToggled:(id)sender {
NSInteger state = [((NSMenuItem *) sender) state];
if (state == NSOnState) {
Expand Down
3 changes: 3 additions & 0 deletions core/MainWindowController.h
Expand Up @@ -91,6 +91,9 @@
// Saved Requests
@property (weak) IBOutlet CRCDrawerView *savedRequestsView;
@property (weak) IBOutlet NSOutlineView *savedOutlineView;
@property (weak) IBOutlet NSSplitView *verticalSplitView;
@property (weak) IBOutlet NSView *savedRequestsOuterView;
@property CGFloat lastSavedRequestsViewWidth;

// For modal dialogs
@property (weak) IBOutlet NSPanel *saveRequestSheet;
Expand Down
3 changes: 3 additions & 0 deletions core/MainWindowController.m
Expand Up @@ -28,6 +28,9 @@ @implementation MainWindowController
@synthesize rawRequestBody;
@synthesize fileRequestBody;
@synthesize savedRequestsView;
@synthesize verticalSplitView;
@synthesize savedRequestsOuterView;
@synthesize lastSavedRequestsViewWidth;

#pragma mark -
#pragma mark Init and Window Methods
Expand Down

0 comments on commit 3cc0b2e

Please sign in to comment.