From c55ffebc406d7d2af3c71b2dace3ec7e3238fd55 Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Mon, 8 Oct 2012 14:26:01 +0000 Subject: - Fix the Quick Connect entry on the connection screen being a drag and drop target - Speculative fix for 10.6 & 10.5 connection screen padding/layout issues --- Source/SPConnectionController.h | 2 +- Source/SPConnectionController.m | 2 +- Source/SPConnectionControllerDelegate.m | 5 ++++- Source/SPConnectionControllerInitializer.m | 2 +- Source/SPFavoritesOutlineView.h | 3 +++ Source/SPFavoritesOutlineView.m | 14 +++++++++++++- Source/SPOutlineView.m | 7 ------- 7 files changed, 23 insertions(+), 12 deletions(-) diff --git a/Source/SPConnectionController.h b/Source/SPConnectionController.h index dda04343..6e439953 100644 --- a/Source/SPConnectionController.h +++ b/Source/SPConnectionController.h @@ -67,7 +67,7 @@ BOOL isConnecting; BOOL isEditingConnection; BOOL isTestingConnection; - + // Standard details NSInteger previousType; NSInteger type; diff --git a/Source/SPConnectionController.m b/Source/SPConnectionController.m index a6ca5f75..f6e23656 100644 --- a/Source/SPConnectionController.m +++ b/Source/SPConnectionController.m @@ -1720,7 +1720,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, { [[NSNotificationCenter defaultCenter] removeObserver:self]; [NSObject cancelPreviousPerformRequestsWithTarget:self]; - + // Unregister observers #ifndef SP_REFACTOR [self removeObserver:self forKeyPath:SPFavoriteTypeKey]; diff --git a/Source/SPConnectionControllerDelegate.m b/Source/SPConnectionControllerDelegate.m index 71ad1390..eee6f44d 100644 --- a/Source/SPConnectionControllerDelegate.m +++ b/Source/SPConnectionControllerDelegate.m @@ -303,7 +303,10 @@ static NSString *SPQuickConnectImageWhite = @"quick-connect-icon-white.pdf"; - (NSDragOperation)outlineView:(NSOutlineView *)outlineView validateDrop:(id )info proposedItem:(id)item proposedChildIndex:(NSInteger)childIndex { NSDragOperation result = NSDragOperationNone; - + + // Prevent the top level or the quick connect item from being a target + if (!item || item == quickConnectItem) return result; + // Prevent dropping favorites on other favorites (non-groups) if ((childIndex == NSOutlineViewDropOnItemIndex) && (![item isGroup])) return result; diff --git a/Source/SPConnectionControllerInitializer.m b/Source/SPConnectionControllerInitializer.m index 73ebcad8..b3f06691 100644 --- a/Source/SPConnectionControllerInitializer.m +++ b/Source/SPConnectionControllerInitializer.m @@ -62,7 +62,7 @@ static NSString *SPConnectionViewNibName = @"ConnectionView"; - (id)initWithDocument:(SPDatabaseDocument *)document { if ((self = [super init])) { - + // Weak reference dbDocument = document; diff --git a/Source/SPFavoritesOutlineView.h b/Source/SPFavoritesOutlineView.h index bc6a8b30..c2d8a8eb 100644 --- a/Source/SPFavoritesOutlineView.h +++ b/Source/SPFavoritesOutlineView.h @@ -31,5 +31,8 @@ // More info at @interface SPFavoritesOutlineView : NSOutlineView +{ + SInt32 systemVersion; +} @end diff --git a/Source/SPFavoritesOutlineView.m b/Source/SPFavoritesOutlineView.m index 08880ec8..69800606 100644 --- a/Source/SPFavoritesOutlineView.m +++ b/Source/SPFavoritesOutlineView.m @@ -37,6 +37,12 @@ static NSUInteger SPFavoritesOutlineViewUnindent = 14; @implementation SPFavoritesOutlineView +- (void) awakeFromNib +{ + systemVersion = 0; + Gestalt(gestaltSystemVersion, &systemVersion); +} + - (BOOL)acceptsFirstResponder { return YES; @@ -99,6 +105,11 @@ static NSUInteger SPFavoritesOutlineViewUnindent = 14; { NSRect superFrame = [super frameOfCellAtColumn:columnIndex row:rowIndex]; + // On system versions lower than Lion, don't alter padding + if (systemVersion < 0x1070) { + return superFrame; + } + return NSMakeRect(superFrame.origin.x - SPFavoritesOutlineViewUnindent, superFrame.origin.y, superFrame.size.width + SPFavoritesOutlineViewUnindent, superFrame.size.height); } @@ -110,7 +121,8 @@ static NSUInteger SPFavoritesOutlineViewUnindent = 14; { NSRect superFrame = [super frameOfOutlineCellAtRow:rowIndex]; - if (superFrame.origin.x > SPFavoritesOutlineViewUnindent) { + // On versions of Lion or above, amend the padding appropriately + if (systemVersion >= 0x1070 && superFrame.origin.x > SPFavoritesOutlineViewUnindent) { return NSMakeRect(superFrame.origin.x - SPFavoritesOutlineViewUnindent, superFrame.origin.y, superFrame.size.width, superFrame.size.height); } diff --git a/Source/SPOutlineView.m b/Source/SPOutlineView.m index 187876be..0170b4f5 100644 --- a/Source/SPOutlineView.m +++ b/Source/SPOutlineView.m @@ -34,13 +34,6 @@ @implementation SPOutlineView -- (id)init -{ - self = [super init]; - - return self; -} - /** * Right-click at row will select that row before ordering out the contextual menu * if not more than one row is selected. -- cgit v1.2.3