From 03e9392ac6895e98f4c10eac38c82435ebb0956f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Str=C3=BCder?= Date: Wed, 20 Oct 2010 19:19:00 +0200 Subject: [PATCH 1/2] Save and restore SplitView positions --- PBGitHistoryController.m | 3 ++- PBNiceSplitView.h | 3 +++ PBNiceSplitView.m | 41 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/PBGitHistoryController.m b/PBGitHistoryController.m index a9fde362b..3f9f9c6ec 100644 --- a/PBGitHistoryController.m +++ b/PBGitHistoryController.m @@ -43,6 +43,7 @@ - (void)awakeFromNib [[commitList headerView] setMenu:[self tableColumnMenu]]; [historySplitView setTopMin:33.0 andBottomMin:100.0]; [historySplitView uncollapse]; + [historySplitView restoreDefault:@"splitpos"]; [super awakeFromNib]; } @@ -205,7 +206,7 @@ - (void) removeView [commitController removeObserver:self forKeyPath:@"selection"]; [treeController removeObserver:self forKeyPath:@"selection"]; [repository removeObserver:self forKeyPath:@"currentBranch"]; - + [historySplitView saveDefault:@"splitpos"]; [super removeView]; } diff --git a/PBNiceSplitView.h b/PBNiceSplitView.h index f5969e71d..5d3fe72f6 100644 --- a/PBNiceSplitView.h +++ b/PBNiceSplitView.h @@ -12,4 +12,7 @@ } +- (void) restoreDefault: (NSString *) defaultName; +- (void) saveDefault: (NSString *) defaultName; + @end diff --git a/PBNiceSplitView.m b/PBNiceSplitView.m index 994e6d4c0..3470c0dbd 100644 --- a/PBNiceSplitView.m +++ b/PBNiceSplitView.m @@ -42,4 +42,45 @@ - (CGFloat)dividerThickness return 10.0; } +- (void) restoreDefault: (NSString *) defaultName +{ + NSString * string = [[NSUserDefaults standardUserDefaults] objectForKey: defaultName]; + + if (string == nil) + return; // there was no saved default + + NSScanner* scanner = [NSScanner scannerWithString: string]; + NSRect r0, r1; + + BOOL didScan = + [scanner scanFloat: &(r0.origin.x)] && + [scanner scanFloat: &(r0.origin.y)] && + [scanner scanFloat: &(r0.size.width)] && + [scanner scanFloat: &(r0.size.height)] && + [scanner scanFloat: &(r1.origin.x)] && + [scanner scanFloat: &(r1.origin.y)] && + [scanner scanFloat: &(r1.size.width)] && + [scanner scanFloat: &(r1.size.height)]; + + if (didScan == NO) + return; // probably should throw an exception at this point + + [[[self subviews] objectAtIndex: 0] setFrame: r0]; + [[[self subviews] objectAtIndex: 1] setFrame: r1]; + + [self adjustSubviews]; +} + +- (void) saveDefault: (NSString *) defaultName +{ + NSRect r0 = [[[self subviews] objectAtIndex: 0] frame]; + NSRect r1 = [[[self subviews] objectAtIndex: 1] frame]; + + NSString * string = [NSString stringWithFormat: @"%f %f %f %f %f %f %f %f", + r0.origin.x, r0.origin.y, r0.size.width, r0.size.height, + r1.origin.x, r1.origin.y, r1.size.width, r1.size.height]; + + [[NSUserDefaults standardUserDefaults] setObject: string forKey: defaultName]; +} + @end From 27f6a7b470fcb9ed7120793b8b098350da176d92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Stru=CC=88der?= Date: Fri, 11 Mar 2011 12:49:37 +0100 Subject: [PATCH 2/2] update gitignore and project props --- .gitignore | 2 ++ GitX.xcodeproj/project.pbxproj | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/.gitignore b/.gitignore index 3367a4e77..40ccf2ea2 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,5 @@ build/revision *.xcodeproj/*.tm_build_errors *.tmproj Nightly.app.zip + +.DS_Store \ No newline at end of file diff --git a/GitX.xcodeproj/project.pbxproj b/GitX.xcodeproj/project.pbxproj index 8f8f62ce3..55e9b60f9 100644 --- a/GitX.xcodeproj/project.pbxproj +++ b/GitX.xcodeproj/project.pbxproj @@ -779,7 +779,14 @@ isa = PBXProject; buildConfigurationList = 26FC0A880875C7B200E6366F /* Build configuration list for PBXProject "GitX" */; compatibilityVersion = "Xcode 3.1"; + developmentRegion = English; hasScannedForEncodings = 1; + knownRegions = ( + English, + Japanese, + French, + German, + ); mainGroup = 29B97314FDCFA39411CA2CEA /* GitTest */; projectDirPath = ""; projectRoot = "";