aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPConnectionControllerInitializer.m
diff options
context:
space:
mode:
Diffstat (limited to 'Source/SPConnectionControllerInitializer.m')
-rw-r--r--Source/SPConnectionControllerInitializer.m29
1 files changed, 29 insertions, 0 deletions
diff --git a/Source/SPConnectionControllerInitializer.m b/Source/SPConnectionControllerInitializer.m
index 09847b98..e123f5a8 100644
--- a/Source/SPConnectionControllerInitializer.m
+++ b/Source/SPConnectionControllerInitializer.m
@@ -35,6 +35,7 @@ static NSString *SPConnectionViewNibName = @"ConnectionView";
@interface SPConnectionController ()
+- (void)_processFavoritesDataChange;
- (void)_reloadFavoritesViewData;
- (void)_selectNode:(SPTreeNode *)node;
- (void)_scrollToSelectedNode;
@@ -145,6 +146,10 @@ static NSString *SPConnectionViewNibName = @"ConnectionView";
selector:@selector(scrollViewFrameChanged:)
name:NSViewFrameDidChangeNotification
object:nil];
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(_processFavoritesDataChange:)
+ name:SPConnectionFavoritesChangedNotification
+ object:nil];
// Registered to be notified of changes to connection information
[self addObserver:self
@@ -286,6 +291,30 @@ static NSString *SPConnectionViewNibName = @"ConnectionView";
#pragma mark Private API
/**
+ * Responds to notifications that the favorites root has changed,
+ * and updates the interface to match.
+ */
+- (void)_processFavoritesDataChange:(NSNotification *)aNotification
+{
+
+ // Check the supplied notification for the sender; if the sender
+ // was this object, ignore it
+ if ([aNotification object] == self) return;
+
+ NSArray *selectedFavoriteNodes = [self selectedFavoriteNodes];
+
+ [self _reloadFavoritesViewData];
+
+ NSMutableIndexSet *selectionIndexes = [NSMutableIndexSet indexSet];
+ for (SPTreeNode *eachNode in selectedFavoriteNodes) {
+ NSInteger anIndex = [favoritesOutlineView rowForItem:eachNode];
+ if (anIndex == -1) continue;
+ [selectionIndexes addIndex:anIndex];
+ }
+ [favoritesOutlineView selectRowIndexes:selectionIndexes byExtendingSelection:NO];
+}
+
+/**
* Restores the outline views group nodes expansion state.
*
* @param node The node to traverse