aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPWindowController.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-06-12 12:34:18 +0000
committerBibiko <bibiko@eva.mpg.de>2010-06-12 12:34:18 +0000
commit16fc04e9bae49425540d623933946ec4dc933d6f (patch)
treeb565bd5c6331ce3468f2ffaf1bb73a025f94f86c /Source/SPWindowController.m
parenta7247b9f9098b40f170f6b2bcd28a4e934a02dc5 (diff)
downloadsequelpro-16fc04e9bae49425540d623933946ec4dc933d6f.tar.gz
sequelpro-16fc04e9bae49425540d623933946ec4dc933d6f.tar.bz2
sequelpro-16fc04e9bae49425540d623933946ec4dc933d6f.zip
• added tooltip for tab view titles
- for selected tab view item show tooltip only if title is truncated - for unselected tab view items show the full display title as tooltip
Diffstat (limited to 'Source/SPWindowController.m')
-rw-r--r--Source/SPWindowController.m44
1 files changed, 43 insertions, 1 deletions
diff --git a/Source/SPWindowController.m b/Source/SPWindowController.m
index a19bcd08..23b1bc9b 100644
--- a/Source/SPWindowController.m
+++ b/Source/SPWindowController.m
@@ -281,7 +281,49 @@
*/
- (NSString *)tabView:(NSTabView *)aTabView toolTipForTabViewItem:(NSTabViewItem *)tabViewItem
{
- // Not yet implemented
+ PSMTabBarCell *theCell = [[tabBar cells] objectAtIndex:[tabView indexOfTabViewItem:tabViewItem]];
+
+ // If cell is selected show tooltip if truncated only
+ if([theCell tabState] & PSMTab_SelectedMask) {
+
+ CGFloat cellWidth = [theCell width];
+ CGFloat titleWidth = [theCell stringSize].width;
+ CGFloat closeButtonWidth = 0;
+
+ if([theCell hasCloseButton])
+ closeButtonWidth = [theCell closeButtonRectForFrame:[theCell frame]].size.width;
+
+ if(titleWidth > cellWidth - closeButtonWidth)
+ return [theCell title];
+
+ return @"";
+
+ // if cell is not selected show full title as tooltip
+ } else {
+ SPDatabaseDocument *doc = [tabViewItem identifier];
+ NSMutableString *tabTitle;
+
+ // Determine name details
+ NSString *pathName = @"";
+ if ([[[doc fileURL] path] length] && ![doc isUntitled])
+ pathName = [NSString stringWithFormat:@"%@ — ", [[[doc fileURL] path] lastPathComponent]];
+
+ if ([doc getConnection] == nil)
+ return [NSString stringWithFormat:@"%@%@", pathName, @"Sequel Pro"];
+
+ tabTitle = [NSMutableString string];
+ [tabTitle appendString:[doc name]];
+ if ([doc database]) {
+ if ([tabTitle length]) [tabTitle appendString:@"/"];
+ [tabTitle appendString:[doc database]];
+ }
+ if ([[doc table] length]) {
+ if ([tabTitle length]) [tabTitle appendString:@"/"];
+ [tabTitle appendString:[doc table]];
+ }
+ return tabTitle;
+ }
+
return @"";
}