Revision: 29150
          http://sourceforge.net/p/bibdesk/svn/29150
Author:   hofman
Date:     2025-04-20 16:24:49 +0000 (Sun, 20 Apr 2025)
Log Message:
-----------
Truncate head of title only for remote URLs, and tail for files.

Modified Paths:
--------------
    trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m

Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m      2025-04-20 
15:52:50 UTC (rev 29149)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m      2025-04-20 
16:24:49 UTC (rev 29150)
@@ -114,10 +114,12 @@
 @public;
     NSString   *_name;
     NSUInteger  _label;
+    BOOL        _isFile;
 }
 - (id)initWithURL:(NSURL *)aURL;
 @property (nonatomic, readonly) NSString *name;
 @property (nonatomic, readonly) NSUInteger label;
+@property (nonatomic, readonly) BOOL isFile;
 @end
 
 #pragma mark -
@@ -245,7 +247,7 @@
 // only declare methods here to shut the compiler up if we can't rearrange
 - (FVIcon *)iconAtIndex:(NSUInteger)anIndex;
 - (FVIcon *)_cachedIconForURL:(NSURL *)aURL;
-- (void)_getDisplayName:(NSString **)name andLabel:(NSUInteger *)label 
forURL:(NSURL *)aURL;
+- (void)_getDisplayName:(NSString **)name label:(NSUInteger *)label 
isFile:(BOOL *)isFile forURL:(NSURL *)aURL;
 - (NSSize)_paddingForScale:(CGFloat)scale;
 - (void)_recalculateGridSize;
 - (void)_reloadIcons;
@@ -403,7 +405,7 @@
     _titleCell = [[NSTextFieldCell alloc] initTextCell:@""];
     [_titleCell setFont:[NSFont systemFontOfSize:12.0]];
     [_titleCell setTextColor:[NSColor 
respondsToSelector:@selector(labelColor)] ? [NSColor labelColor] : [NSColor 
darkGrayColor]];
-    [_titleCell setLineBreakMode:NSLineBreakByTruncatingHead];
+    [_titleCell setLineBreakMode:NSLineBreakByTruncatingTail];
     [_titleCell setAlignment:NSTextAlignmentCenter];
     
     // @@ Dark mode
@@ -863,7 +865,7 @@
 
 - (NSUInteger)numberOfIcons { return [_orderedURLs count]; }
 
-- (void)_getDisplayName:(NSString **)name andLabel:(NSUInteger *)label 
forURL:(NSURL *)aURL;
+- (void)_getDisplayName:(NSString **)name label:(NSUInteger *)label 
isFile:(BOOL *)isFile forURL:(NSURL *)aURL;
 {
     _FVURLInfo *info = [_infoTable objectForKey:aURL];
     if (nil == info) {
@@ -872,6 +874,7 @@
     }
     if (name) *name = [info name];
     if (label) *label = [info label];
+    if (isFile) *isFile = [info isFile];
 }
 
 - (FVIcon *)_cachedIconForURL:(NSURL *)aURL;
@@ -2514,9 +2517,13 @@
                         
                         NSString *name, *subtitle = [self subtitleAtIndex:i];
                         NSUInteger label;
-                        [self _getDisplayName:&name andLabel:&label 
forURL:[self URLAtIndex:i]];
+                        BOOL isFile;
+                        NSURL *aURL = [self URLAtIndex:i];
+                        [self _getDisplayName:&name label:&label 
isFile:&isFile forURL:aURL];
                         CGFloat titleHeight = [_titleCell cellSize].height;
                         
+                        // for remote URLs the information is probably in the 
tail
+                        [_titleCell setLineBreakMode:isFile ? 
NSLineBreakByTruncatingTail : NSLineBreakByTruncatingHead];
                         [_titleCell setStringValue:name ?: @""];
                         if (label > 0) {
                             NSRect labelRect = [self 
centerScanRect:NSInsetRect(textRect, 2.0, 0.0)];
@@ -4768,6 +4775,7 @@
 
 @synthesize name=_name;
 @synthesize label=_label;
+@synthesize isFile=_isFile;
 
 - (id)initWithURL:(NSURL *)aURL;
 {
@@ -4779,8 +4787,10 @@
                 _name = [aURL lastPathComponent];
             else
                 _name = [name copy];
+            _isFile = YES;
         } else if ([FVIcon isMissingFileURL:aURL]) {
             _name = [aURL lastPathComponent];
+            _isFile = YES;
         } else {
             NSString *name = [aURL absoluteString];
             NSRange range = [name rangeOfString:@"://"];
@@ -4791,6 +4801,7 @@
 #else
             _name = [[name 
stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding] copy];
 #endif
+            _isFile = NO;
         }
         _label = [FVFinderLabel finderLabelForURL:aURL];
     }

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
Bibdesk-commit mailing list
Bibdesk-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to