Skip to content

Commit

Permalink
Add a NSUserDefaultsDidChangeNotification listener to PBGitHistoryCon…
Browse files Browse the repository at this point in the history
…troller.

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.
  • Loading branch information
andreberg committed Apr 5, 2010
1 parent 4ed7911 commit f704c99
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions PBGitHistoryController.h
Expand Up @@ -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;
Expand Down
10 changes: 10 additions & 0 deletions PBGitHistoryController.m
Expand Up @@ -82,6 +82,12 @@ - (void)awakeFromNib
[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;
Expand Down Expand Up @@ -183,6 +189,10 @@ - (void) updateStatus
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)
Expand Down

0 comments on commit f704c99

Please sign in to comment.