Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Have the preferences window remember the last view

  • Loading branch information...
commit ca846bc6eb40240fab0e17bce0e26dbc3ffb981a 1 parent 27d4b22
@brotherbard authored
View
1  DBPrefsWindowController.h
@@ -71,5 +71,6 @@
- (void)crossFadeView:(NSView *)oldView withView:(NSView *)newView;
- (NSRect)frameForView:(NSView *)view;
+- (NSString *)defaultViewIdentifier;
@end
View
18 DBPrefsWindowController.m
@@ -211,9 +211,9 @@ - (IBAction)showWindow:(id)sender
[toolbar release];
}
- NSString *firstIdentifier = [toolbarIdentifiers objectAtIndex:0];
- [[[self window] toolbar] setSelectedItemIdentifier:firstIdentifier];
- [self displayViewForIdentifier:firstIdentifier animate:NO];
+ NSString *identifier = [self defaultViewIdentifier];
+ [[[self window] toolbar] setSelectedItemIdentifier:identifier];
+ [self displayViewForIdentifier:identifier animate:NO];
[[self window] center];
@@ -406,4 +406,16 @@ - (NSRect)frameForView:(NSView *)view
+#pragma mark -
+#pragma mark Default View
+
+
+- (NSString *)defaultViewIdentifier
+{
+ return [toolbarIdentifiers objectAtIndex:0];
+}
+
+
+
+
@end
View
18 PBPrefsWindowController.m
@@ -9,6 +9,8 @@
#import "PBPrefsWindowController.h"
#import "PBGitRepository.h"
+#define kPreferenceViewIdentifier @"PBGitXPreferenceViewIdentifier"
+
@implementation PBPrefsWindowController
# pragma mark DBPrefsWindowController overrides
@@ -23,6 +25,22 @@ - (void)setupToolbar
[self addView:updatesPrefsView label:@"Updates"];
}
+- (void)displayViewForIdentifier:(NSString *)identifier animate:(BOOL)animate
+{
+ [super displayViewForIdentifier:identifier animate:animate];
+
+ [[NSUserDefaults standardUserDefaults] setObject:identifier forKey:kPreferenceViewIdentifier];
+}
+
+- (NSString *)defaultViewIdentifier
+{
+ NSString *identifier = [[NSUserDefaults standardUserDefaults] objectForKey:kPreferenceViewIdentifier];
+ if (identifier)
+ return identifier;
+
+ return [super defaultViewIdentifier];
+}
+
#pragma mark -
#pragma mark Delegate methods

0 comments on commit ca846bc

Please sign in to comment.
Something went wrong with that request. Please try again.