From f704c99fa81f70f399618b1ffd9fee80210a18cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Berg?= Date: Mon, 5 Apr 2010 21:27:45 +0200 Subject: [PATCH] Add a NSUserDefaultsDidChangeNotification listener to PBGitHistoryController. Add method decl signatures for updateKeys and scrollSelectionToTopOfViewFrom: - Call preferencesChangedWithNotification: on self when the notification is received. This gives us the opportunity to refresh the history controller's commit list in case defaults like the relative dates option have changed. This makes the effect of switching that option while the prefs panel is still open instant. --- PBGitHistoryController.h | 2 ++ PBGitHistoryController.m | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/PBGitHistoryController.h b/PBGitHistoryController.h index 6d46ad1..b8bf8a3 100644 --- a/PBGitHistoryController.h +++ b/PBGitHistoryController.h @@ -76,9 +76,11 @@ - (IBAction) openSelectedFile:(id)sender; - (BOOL) selectCommit: (NSString*) commit; +- (void) updateKeys; - (void) updateQuicklookForce: (BOOL) force; +- (void) scrollSelectionToTopOfViewFrom:(NSInteger)oldIndex; // Moved over Sidebar methods - (IBAction) fetchPullPushAction:(id)sender; diff --git a/PBGitHistoryController.m b/PBGitHistoryController.m index 48895f8..6b77175 100644 --- a/PBGitHistoryController.m +++ b/PBGitHistoryController.m @@ -82,6 +82,12 @@ [repository addObserver:self forKeyPath:@"currentBranch" options:0 context:@"branchChange"]; [repository addObserver:self forKeyPath:@"refs" options:0 context:@"updateRefs"]; + NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; + [nc addObserver:self + selector:@selector(preferencesChangedWithNotification:) + name:NSUserDefaultsDidChangeNotification + object:nil]; + forceSelectionUpdate = YES; NSSize cellSpacing = [commitList intercellSpacing]; cellSpacing.height = 0; @@ -183,6 +189,10 @@ self.status = [NSString stringWithFormat:@"%d commits loaded", [[commitController arrangedObjects] count]]; } +- (void) preferencesChangedWithNotification:(NSNotification *)notification { + [[[repository windowForSheet] contentView] setNeedsDisplay:YES]; +} + - (void) restoreFileBrowserSelection { if (self.selectedCommitDetailsIndex != kHistoryTreeViewIndex)