Changeset 2108
- Timestamp:
- Jun 17, 2007, 12:26:52 AM (15 years ago)
- Location:
- branches/file_selection/macosx
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/file_selection/macosx/Controller.m
r2100 r2108 934 934 - (void) createFile: (id) sender 935 935 { 936 [CreatorWindowController createTorrentFile ];936 [CreatorWindowController createTorrentFile: fLib]; 937 937 } 938 938 -
branches/file_selection/macosx/CreatorWindowController.h
r2102 r2108 24 24 25 25 #import <Cocoa/Cocoa.h> 26 #import "transmission.h" 26 27 #import "makemeta.h" 27 28 … … 29 30 { 30 31 IBOutlet NSImageView * fIcon, * fLocationIcon; 31 IBOutlet NSTextField * fNameField, * fStatusField, * fPiecesField, * fLocationField, 32 * fTrackerField, * fTorrentNameField; 32 IBOutlet NSTextField * fNameField, * fStatusField, * fPiecesField, * fTrackerField, * fLocationField; 33 33 IBOutlet NSTextView * fCommentView; 34 34 IBOutlet NSButton * fPrivateCheck; 35 35 36 meta_info_builder_t * fInfo; 36 IBOutlet NSWindow * fProgressWindow; 37 IBOutlet NSProgressIndicator * fProgressIndicator; 38 39 tr_metainfo_builder_t * fInfo; 37 40 NSString * fPath, * fLocation; 38 41 } 39 42 40 + (void) createTorrentFile; 43 + (void) createTorrentFile: (tr_handle_t *) handle; 44 45 - (id) initWithWindowNibName: (NSString *) name handle: (tr_handle_t *) handle path: (NSString *) path; 41 46 42 47 - (void) setLocation: (id) sender; -
branches/file_selection/macosx/CreatorWindowController.m
r2106 r2108 28 28 #define DEFAULT_SAVE_LOCATION @"~/Desktop/" 29 29 30 #warning rename?31 30 @interface CreatorWindowController (Private) 32 31 33 32 + (NSString *) chooseFile; 34 - (void) setPath: (NSString *) path; 35 - (void) locationSheetClosed: (NSOpenPanel *) openPanel returnCode: (int) code contextInfo: (void *) info; 33 - (void) locationSheetClosed: (NSSavePanel *) openPanel returnCode: (int) code contextInfo: (void *) info; 36 34 37 35 @end … … 39 37 @implementation CreatorWindowController 40 38 41 + (void) createTorrentFile 39 + (void) createTorrentFile: (tr_handle_t *) handle 42 40 { 43 41 //get file/folder for torrent … … 46 44 return; 47 45 48 CreatorWindowController * creator = [[self alloc] initWithWindowNibName: @"Creator"]; 49 [creator setPath: path]; 46 CreatorWindowController * creator = [[self alloc] initWithWindowNibName: @"Creator" handle: handle path: path]; 50 47 [creator showWindow: nil]; 51 48 } 52 49 50 - (id) initWithWindowNibName: (NSString *) name handle: (tr_handle_t *) handle path: (NSString *) path 51 { 52 if ((self = [super initWithWindowNibName: name])) 53 { 54 fPath = [path retain]; 55 fInfo = tr_metaInfoBuilderCreate(handle, [fPath UTF8String]); 56 if (fInfo->fileCount == 0) 57 { 58 NSAlert * alert = [[[NSAlert alloc] init] autorelease]; 59 [alert addButtonWithTitle: NSLocalizedString(@"OK", "Create torrent -> no files -> button")]; 60 [alert setMessageText: NSLocalizedString(@"This folder contains no files.", 61 "Create torrent -> no files -> title")]; 62 [alert setInformativeText: NSLocalizedString(@"There must be at least one file in a folder to create a torrent file.", 63 "Create torrent -> no files -> warning")]; 64 [alert setAlertStyle: NSWarningAlertStyle]; 65 66 [alert runModal]; 67 68 [self release]; 69 return nil; 70 } 71 } 72 return self; 73 } 74 53 75 - (void) awakeFromNib 54 76 { 55 fInfo = tr_metaInfoBuilderCreate([fPath UTF8String]);56 57 #warning if count == 0, end58 59 77 NSString * name = [fPath lastPathComponent]; 60 78 … … 75 93 { 76 94 NSString * fileString; 77 78 95 int count = fInfo->fileCount; 79 96 if (count != 1) … … 88 105 fInfo->pieceCount, [NSString stringForFileSize: fInfo->pieceSize]]]; 89 106 90 fLocation = [[DEFAULT_SAVE_LOCATION stringByExpandingTildeInPath] retain]; 91 [fLocationIcon setImage: [[NSWorkspace sharedWorkspace] iconForFile: fLocation]]; 107 fLocation = [[[DEFAULT_SAVE_LOCATION stringByAppendingPathComponent: [name stringByAppendingPathExtension: @"torrent"]] 108 stringByExpandingTildeInPath] retain]; 109 [fLocationIcon setImage: [[NSWorkspace sharedWorkspace] iconForFile: [fLocation stringByDeletingLastPathComponent]]]; 92 110 [fLocationField setStringValue: [fLocation stringByAbbreviatingWithTildeInPath]]; 93 111 [fLocationField setToolTip: fLocation]; 94 95 [fTorrentNameField setStringValue: [name stringByAppendingPathExtension: @"torrent"]];96 112 } 97 113 … … 110 126 - (void) setLocation: (id) sender 111 127 { 112 NS OpenPanel * panel = [NSOpenPanel openPanel];128 NSSavePanel * panel = [NSSavePanel savePanel]; 113 129 114 130 [panel setPrompt: @"Select"]; 115 [panel setAllowsMultipleSelection: NO]; 116 [panel setCanChooseFiles: NO]; 117 [panel setCanChooseDirectories: YES]; 118 [panel setCanCreateDirectories: YES]; 119 120 [panel beginSheetForDirectory: nil file: nil types: nil modalForWindow: [self window] modalDelegate: self 131 [panel setRequiredFileType: @"torrent"]; 132 [panel setCanSelectHiddenExtension: YES]; 133 134 [panel beginSheetForDirectory: nil file: [fLocation lastPathComponent] modalForWindow: [self window] modalDelegate: self 121 135 didEndSelector: @selector(locationSheetClosed:returnCode:contextInfo:) contextInfo: nil]; 122 136 } … … 145 159 trackerString = [@"http://" stringByAppendingString: trackerString]; 146 160 147 NSString * torrentName = [fTorrentNameField stringValue]; 148 if ([[torrentName pathExtension] caseInsensitiveCompare: @"torrent"] != NSOrderedSame) 149 { 150 NSAlert * alert = [[[NSAlert alloc] init] autorelease]; 151 [alert addButtonWithTitle: NSLocalizedString(@"OK", "Create torrent -> torrent extension warning -> button")]; 152 [alert setMessageText: NSLocalizedString(@"Torrents must end in \".torrent\".", 153 "Create torrent -> torrent extension warning -> title")]; 154 [alert setInformativeText: NSLocalizedString(@"Add this file extension to create the torrent.", 155 "Create torrent -> torrent extension warning -> warning")]; 156 [alert setAlertStyle: NSWarningAlertStyle]; 157 158 [alert beginSheetModalForWindow: [self window] modalDelegate: self didEndSelector: nil contextInfo: nil]; 159 return; 160 } 161 //[NSApp beginSheet: fProgressWindow modalForWindow: [self window] modalDelegate: self didEndSelector: nil contextInfo: nil]; 161 162 162 163 #warning fix 163 tr_makeMetaInfo(fInfo, NULL, self, [[fLocation stringByAppendingPathComponent: torrentName] UTF8String], 164 [trackerString UTF8String], [[fCommentView string] UTF8String], [fPrivateCheck state] == NSOnState); 165 166 #warning add to T 167 168 [[self window] close]; 164 tr_makeMetaInfo(fInfo, [fLocation UTF8String], [trackerString UTF8String], [[fCommentView string] UTF8String], 165 [fPrivateCheck state] == NSOnState); 166 167 #warning move to "check" method 168 /*#warning add to T 169 170 [[self window] close];*/ 169 171 } 170 172 … … 199 201 } 200 202 201 - (void) setPath: (NSString *) path 202 { 203 fPath = [path retain]; 204 } 205 206 - (void) locationSheetClosed: (NSOpenPanel *) openPanel returnCode: (int) code contextInfo: (void *) info 203 - (void) locationSheetClosed: (NSSavePanel *) panel returnCode: (int) code contextInfo: (void *) info 207 204 { 208 205 if (code == NSOKButton) 209 206 { 210 207 [fLocation release]; 211 fLocation = [[ [openPanel filenames] objectAtIndex: 0] retain];208 fLocation = [[panel filename] retain]; 212 209 213 [fLocationIcon setImage: [[NSWorkspace sharedWorkspace] iconForFile: fLocation]];210 [fLocationIcon setImage: [[NSWorkspace sharedWorkspace] iconForFile: [fLocation stringByDeletingLastPathComponent]]]; 214 211 [fLocationField setStringValue: [fLocation stringByAbbreviatingWithTildeInPath]]; 215 212 [fLocationField setToolTip: fLocation]; -
branches/file_selection/macosx/English.lproj/Creator.nib/classes.nib
r2101 r2108 13 13 fPiecesField = NSTextField; 14 14 fPrivateCheck = NSButton; 15 fProgressIndicator = NSProgressIndicator; 16 fProgressWindow = NSWindow; 15 17 fStatusField = NSTextField; 16 fTorrentNameField = NSTextField;17 18 fTrackerField = NSTextField; 18 19 }; -
branches/file_selection/macosx/English.lproj/Creator.nib/info.nib
r2101 r2108 9 9 <key>IBOpenObjects</key> 10 10 <array> 11 <integer>45</integer> 11 12 <integer>5</integer> 12 13 </array>
Note: See TracChangeset
for help on using the changeset viewer.