]> granicus.if.org Git - transmission/commitdiff
update some fields in the inspector and main window for magnetized transfers
authorMitchell Livingston <livings124@transmissionbt.com>
Fri, 27 Nov 2009 20:47:03 +0000 (20:47 +0000)
committerMitchell Livingston <livings124@transmissionbt.com>
Fri, 27 Nov 2009 20:47:03 +0000 (20:47 +0000)
macosx/DragOverlayWindow.m
macosx/InfoWindowController.m
macosx/MessageWindowController.m
macosx/Torrent.m
macosx/en.lproj/Localizable.strings

index f031e7b44b7cec15f820cb1ce9e93b9e97f4b120..786c7fbc4aa728b897eef34546da6805663e5a0c 100644 (file)
@@ -35,8 +35,8 @@
     {
         fLib = lib;
         
-        [self setBackgroundColor: [NSColor colorWithCalibratedWhite: 0.0f alpha: 0.5f]];
-        [self setAlphaValue: 0.0f];
+        [self setBackgroundColor: [NSColor colorWithCalibratedWhite: 0.0 alpha: 0.5]];
+        [self setAlphaValue: 0.0];
         [self setOpaque: NO];
         [self setHasShadow: NO];
         
 
 - (void) setURL: (NSString *) url
 {
+    #warning get magnet image/phrase
     [[self contentView] setOverlay: [NSImage imageNamed: @"Globe.png"]
         mainLine: NSLocalizedString(@"Web Address", "Drag overlay -> url") subLine: url];
     [self fadeIn];
         [fFadeInAnimation stopAnimation];
         [fFadeOutAnimation setCurrentProgress: 1.0 - [fFadeInAnimation currentProgress]];
     }
-    if ([self alphaValue] > 0.0f)
+    if ([self alphaValue] > 0.0)
         [fFadeOutAnimation startAnimation];
 }
 
index 60c10df37b79d2535b58f1b5ed6a7250ba5d1051..3a3008ec36d0ef9859160b0a365aa73d6f858006 100644 (file)
@@ -1140,7 +1140,7 @@ typedef enum
 
 - (void) resetInfo
 {
-    NSUInteger numberSelected = [fTorrents count];
+    const NSUInteger numberSelected = [fTorrents count];
     if (numberSelected != 1)
     {
         if (numberSelected > 0)
@@ -1151,19 +1151,51 @@ typedef enum
                                             "Inspector -> selected torrents"), numberSelected]];
         
             uint64_t size = 0;
-            NSInteger fileCount = 0;
+            NSUInteger fileCount = 0, magnetCount = 0;
             for (Torrent * torrent in fTorrents)
             {
                 size += [torrent size];
                 fileCount += [torrent fileCount];
+                if ([torrent isMagnet])
+                    ++magnetCount;
             }
             
-            [fBasicInfoField setStringValue: [NSString stringWithFormat: @"%@, %@",
-                [NSString stringWithFormat: NSLocalizedString(@"%d files", "Inspector -> selected torrents"), fileCount],
-                [NSString stringWithFormat: NSLocalizedString(@"%@ total", "Inspector -> selected torrents"),
-                [NSString stringForFileSize: size]]]];
-            [fBasicInfoField setToolTip: [NSString stringWithFormat: NSLocalizedString(@"%llu bytes", "Inspector -> selected torrents"),
-                                            size]];
+            NSMutableArray * fileStrings = [NSMutableArray arrayWithCapacity: 2];
+            if (fileCount > 0)
+            {
+                NSString * fileString;
+                if (fileCount == 1)
+                    fileString = NSLocalizedString(@"1 file", "Inspector -> selected torrents");
+                else
+                    fileString = [NSString stringWithFormat: NSLocalizedString(@"%d files", "Inspector -> selected torrents"), fileCount];
+                [fileStrings addObject: fileString];
+            }
+            if (magnetCount > 0)
+            {
+                NSString * magnetString;
+                if (magnetCount == 1)
+                    magnetString = NSLocalizedString(@"1 magnetized transfer", "Inspector -> selected torrents");
+                else
+                    magnetString = [NSString stringWithFormat: NSLocalizedString(@"%d magnetized transfers",
+                                    "Inspector -> selected torrents"), magnetCount];
+                [fileStrings addObject: magnetString];
+            }
+            
+            NSString * fileString = [fileStrings componentsJoinedByString: @" + "];
+            
+            if (magnetCount < numberSelected)
+            {
+                [fBasicInfoField setStringValue: [NSString stringWithFormat: @"%@, %@", fileString,
+                    [NSString stringWithFormat: NSLocalizedString(@"%@ total", "Inspector -> selected torrents"),
+                        [NSString stringForFileSize: size]]]];
+                [fBasicInfoField setToolTip: [NSString stringWithFormat: NSLocalizedString(@"%llu bytes", "Inspector -> selected torrents"),
+                                                size]];
+            }
+            else
+            {
+                [fBasicInfoField setStringValue: fileString];
+                [fBasicInfoField setToolTip: nil];
+            }
         }
         else
         {
@@ -1291,24 +1323,34 @@ typedef enum
         [fNameField setStringValue: name];
         [fNameField setToolTip: name];
         
-        NSString * basicString = [NSString stringForFileSize: [torrent size]];
-        if ([torrent isFolder])
+        if (![torrent isMagnet])
         {
-            NSString * fileString;
-            NSInteger fileCount = [torrent fileCount];
-            if (fileCount == 1)
-                fileString = NSLocalizedString(@"1 file", "Inspector -> selected torrents");
-            else
-                fileString= [NSString stringWithFormat: NSLocalizedString(@"%d files", "Inspector -> selected torrents"), fileCount];
-            basicString = [NSString stringWithFormat: @"%@, %@", fileString, basicString];
+            NSString * basicString = [NSString stringForFileSize: [torrent size]];
+            if ([torrent isFolder])
+            {
+                NSString * fileString;
+                NSInteger fileCount = [torrent fileCount];
+                if (fileCount == 1)
+                    fileString = NSLocalizedString(@"1 file", "Inspector -> selected torrents");
+                else
+                    fileString= [NSString stringWithFormat: NSLocalizedString(@"%d files", "Inspector -> selected torrents"), fileCount];
+                basicString = [NSString stringWithFormat: @"%@, %@", fileString, basicString];
+            }
+            [fBasicInfoField setStringValue: basicString];
+            [fBasicInfoField setToolTip: [NSString stringWithFormat: NSLocalizedString(@"%llu bytes", "Inspector -> selected torrents"),
+                                            [torrent size]]];
+        }
+        else
+        {
+            [fBasicInfoField setStringValue: NSLocalizedString(@"Magnetized transfer", "Inspector -> selected torrents")];
+            [fBasicInfoField setToolTip: nil];
         }
-        [fBasicInfoField setStringValue: basicString];
-        [fBasicInfoField setToolTip: [NSString stringWithFormat: NSLocalizedString(@"%llu bytes", "Inspector -> selected torrents"),
-                                        [torrent size]]];
         
+        NSString * piecesString = ![torrent isMagnet] ? [NSString stringWithFormat: @"%d, %@", [torrent pieceCount],
+                                        [NSString stringForFileSize: [torrent pieceSize]]] : @"";
+        [fPiecesField setStringValue: piecesString];
+                                        
         NSString * hashString = [torrent hashString];
-        [fPiecesField setStringValue: [NSString stringWithFormat: @"%d, %@", [torrent pieceCount],
-                                        [NSString stringForFileSize: [torrent pieceSize]]]];
         [fHashField setStringValue: hashString];
         [fHashField setToolTip: hashString];
         [fSecureField setStringValue: [torrent privateTorrent]
index 0f8063876efcdd198820423125db6b479bbb3019..11f38c54e8baa31598bd1815e7dee5ef0009d4a3 100644 (file)
         NSString * name = currentMessage->name != NULL ? [NSString stringWithUTF8String: currentMessage->name]
                             : [[NSProcessInfo processInfo] processName];
         
-        NSString * file = [NSString stringWithFormat: @"%@:%d", [[NSString stringWithUTF8String: currentMessage->file] lastPathComponent],
+        NSString * file = [[[NSString stringWithUTF8String: currentMessage->file] lastPathComponent] stringByAppendingFormat: @":%d",
                             currentMessage->line];
         
         NSDictionary * message  = [NSDictionary dictionaryWithObjectsAndKeys:
index 0d3e916ec1fbe6ba7dd14741fb657181f056c04f..ce54c11565beb1ff4d35052da8485d482da1d7c2 100644 (file)
@@ -917,8 +917,11 @@ int trashDataFile(const char * filename)
 {
     if ([self isMagnet])
     {
-        NSString * progressString = [NSString localizedStringWithFormat: @"%.2f%% of torrent metadata retrieved",
-                                        fStat->metadataPercentComplete];
+        NSString * progressString = fStat->metadataPercentComplete > 0.0
+                    ? [NSString localizedStringWithFormat: NSLocalizedString(@"%.2f%% of torrent metadata retrieved",
+                        "Torrent -> progress string"), fStat->metadataPercentComplete]
+                    : NSLocalizedString(@"torrent metadata needed", "Torrent -> progress string");
+        
         return [NSString stringWithFormat: @"%@ - %@", NSLocalizedString(@"Magnetized transfer", "Torrent -> progress string"),
                                             progressString];
     }
index b14a09ff1cd974dfa126ec22abc227597ba4e983..ab4b11f062663636242606ab8d6a120ce197815e 100644 (file)
Binary files a/macosx/en.lproj/Localizable.strings and b/macosx/en.lproj/Localizable.strings differ