X-Git-Url: https://code.grnet.gr/git/pithos-macos/blobdiff_plain/8aa8e10c814559deee44735d37da80d685481af8..e8e3d71e3b001f4783889dcab46bf356f488b279:/pithos-macos/PithosBrowserController.m diff --git a/pithos-macos/PithosBrowserController.m b/pithos-macos/PithosBrowserController.m index d753e9f..e8f0743 100644 --- a/pithos-macos/PithosBrowserController.m +++ b/pithos-macos/PithosBrowserController.m @@ -109,11 +109,9 @@ @implementation PithosBrowserController @synthesize pithos; -@synthesize accountNode; -@synthesize verticalSplitView, horizontalSplitView, leftTopView, leftBottomView, outlineView, browser, outlineViewMenu, browserMenu; +@synthesize pithosAccountManager, accountNode; @synthesize draggedNodes, draggedParentNode; @synthesize clipboardNodes, clipboardParentNode, clipboardCopy; -@synthesize activityTextField, activityProgressIndicator; #pragma mark - #pragma Object Lifecycle @@ -211,15 +209,15 @@ [activityProgressIndicator setMaxValue:1.0]; activityFacility = [PithosActivityFacility defaultPithosActivityFacility]; - self.accountNode = [[PithosAccountNode alloc] initWithPithos:pithos]; + self.accountNode = [[PithosAccountNode alloc] initWithPithosAccountManager:pithosAccountManager andPithos:pithos]; containersNode = [[PithosEmptyNode alloc] initWithDisplayName:@"CONTAINERS" icon:nil]; containersNodeChildren = [[NSMutableArray alloc] init]; sharedNode = [[PithosEmptyNode alloc] initWithDisplayName:@"SHARED" icon:nil]; - mySharedNode = [[PithosAccountNode alloc] initWithPithos:pithos]; + mySharedNode = [[PithosAccountNode alloc] initWithPithosAccountManager:pithosAccountManager andPithos:pithos]; mySharedNode.displayName = @"shared by me"; mySharedNode.shared = YES; mySharedNode.icon = [[NSWorkspace sharedWorkspace] iconForFileType:NSFileTypeForHFSTypeCode(kUserIcon)]; - othersSharedNode = [[PithosSharingAccountsNode alloc] initWithPithos:pithos]; + othersSharedNode = [[PithosSharingAccountsNode alloc] initWithPithosAccountManager:pithosAccountManager andPithos:pithos]; othersSharedNode.displayName = @"shared with me"; othersSharedNode.icon = [[NSWorkspace sharedWorkspace] iconForFileType:NSFileTypeForHFSTypeCode(kGroupIcon)]; @@ -239,7 +237,7 @@ // Request for browser refresh [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pithosBrowserRefreshNeeded:) - name:@"PithosBrowserRefreshNeeeded" + name:@"PithosBrowserRefreshNeeded" object:nil]; } @@ -279,6 +277,10 @@ [downloadCallbackQueue cancelAllOperations]; [downloadCallbackQueue setSuspended:YES]; + [accountNode pithosNodeWillBeRemoved]; + [mySharedNode pithosNodeWillBeRemoved]; + [othersSharedNode pithosNodeWillBeRemoved]; + rootNode = nil; [browser loadColumnZero]; [containersNodeChildren removeAllObjects]; @@ -336,10 +338,13 @@ [downloadCallbackQueue setSuspended:NO]; accountNode.pithos = pithos; + accountNode.pithosAccountManager = pithosAccountManager; [accountNode forceRefresh]; mySharedNode.pithos = pithos; + mySharedNode.pithosAccountManager = pithosAccountManager; [mySharedNode forceRefresh]; othersSharedNode.pithos = pithos; + othersSharedNode.pithosAccountManager = pithosAccountManager; [othersSharedNode forceRefresh]; // [activityFacility reset]; @@ -398,6 +403,10 @@ #pragma mark Observers - (void)pithosNodeChildrenUpdated:(NSNotification *)notification { + if (![NSThread isMainThread]) { + [self performSelectorOnMainThread:@selector(pithosNodeChildrenUpdated:) withObject:notification waitUntilDone:NO]; + return; + } PithosNode *node = (PithosNode *)[notification object]; if ((node == accountNode) || ![node.pithos isEqualTo:pithos]) return; @@ -412,6 +421,10 @@ } - (void)pithosAccountNodeChildrenUpdated:(NSNotification *)notification { + if (![NSThread isMainThread]) { + [self performSelectorOnMainThread:@selector(pithosAccountNodeChildrenUpdated:) withObject:notification waitUntilDone:NO]; + return; + } BOOL containerPithosFound = NO; BOOL containerTrashFound = NO; NSMutableIndexSet *removedContainersNodeChildren = [NSMutableIndexSet indexSet]; @@ -485,6 +498,10 @@ #pragma mark Actions - (IBAction)forceRefresh:(id)sender { + if (![NSThread isMainThread]) { + [self performSelectorOnMainThread:@selector(forceRefresh:) withObject:sender waitUntilDone:NO]; + return; + } if (editingItem) return; if (sender) @@ -498,6 +515,10 @@ } - (IBAction)refresh:(id)sender { + if (![NSThread isMainThread]) { + [self performSelectorOnMainThread:@selector(refresh:) withObject:sender waitUntilDone:NO]; + return; + } if (editingItem) return; if ([[NSApp currentEvent] modifierFlags] & NSShiftKeyMask) { @@ -1940,9 +1961,9 @@ forDraggedRowsWithIndexes:(NSIndexSet *)rowIndexes inColumn:(NSInteger)column { - (CGFloat)splitView:(NSSplitView *)splitView constrainMinCoordinate:(CGFloat)proposedMinimumPosition ofSubviewAt:(NSInteger)dividerIndex { if (splitView == verticalSplitView) - return 120; + return 140; else - return ([horizontalSplitView bounds].size.height - 108); + return ([horizontalSplitView bounds].size.height - 142); } - (CGFloat)splitView:(NSSplitView *)splitView constrainMaxCoordinate:(CGFloat)proposedMaximumPosition ofSubviewAt:(NSInteger)dividerIndex { @@ -1952,17 +1973,12 @@ forDraggedRowsWithIndexes:(NSIndexSet *)rowIndexes inColumn:(NSInteger)column { return ([horizontalSplitView bounds].size.height - 108); } -- (CGFloat)splitView:(NSSplitView *)splitView constrainSplitPosition:(CGFloat)proposedPosition ofSubviewAt:(NSInteger)dividerIndex { - if (splitView == verticalSplitView) { - if (proposedPosition < 120) - return 120; - else if (proposedPosition > 220) - return 220; - else - return proposedPosition; - } else { - return ([horizontalSplitView bounds].size.height - 108); +- (BOOL)splitView:(NSSplitView *)splitView shouldAdjustSizeOfSubview:(NSView *)view { + if (((splitView == verticalSplitView) && (view == leftView)) || + ((splitView == horizontalSplitView) && (view == leftBottomView))) { + return NO; } + return YES; } #pragma mark -