Revision: 5342
http://skim-app.svn.sourceforge.net/skim-app/?rev=5342&view=rev
Author: hofman
Date: 2009-05-01 12:02:06 +0000 (Fri, 01 May 2009)
Log Message:
-----------
implement dragging from thumbnail and snapshot tables, drag image data and file
promises
Modified Paths:
--------------
trunk/MainWindow.nib/classes.nib
trunk/MainWindow.nib/info.nib
trunk/MainWindow.nib/keyedobjects.nib
trunk/SKMainWindowController_UI.m
trunk/SKThumbnailTableView.m
Modified: trunk/MainWindow.nib/classes.nib
===================================================================
--- trunk/MainWindow.nib/classes.nib 2009-04-30 14:34:16 UTC (rev 5341)
+++ trunk/MainWindow.nib/classes.nib 2009-05-01 12:02:06 UTC (rev 5342)
@@ -56,6 +56,14 @@
</dict>
<dict>
<key>CLASS</key>
+ <string>NSApplication</string>
+ <key>LANGUAGE</key>
+ <string>ObjC</string>
+ <key>SUPERCLASS</key>
+ <string>NSResponder</string>
+ </dict>
+ <dict>
+ <key>CLASS</key>
<string>SKThumbnailTableView</string>
<key>LANGUAGE</key>
<string>ObjC</string>
@@ -507,14 +515,6 @@
</dict>
<dict>
<key>CLASS</key>
- <string>SKSegmentedControl</string>
- <key>LANGUAGE</key>
- <string>ObjC</string>
- <key>SUPERCLASS</key>
- <string>NSSegmentedControl</string>
- </dict>
- <dict>
- <key>CLASS</key>
<string>SKColorSwatch</string>
<key>LANGUAGE</key>
<string>ObjC</string>
@@ -528,19 +528,19 @@
</dict>
<dict>
<key>CLASS</key>
- <string>NSImageCell</string>
+ <string>SKSegmentedControl</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>SUPERCLASS</key>
- <string>NSCell</string>
+ <string>NSSegmentedControl</string>
</dict>
<dict>
<key>CLASS</key>
- <string>SKAnnotationTypeImageCell</string>
+ <string>NSImageCell</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>SUPERCLASS</key>
- <string>NSImageCell</string>
+ <string>NSCell</string>
</dict>
<dict>
<key>CLASS</key>
@@ -583,6 +583,14 @@
</dict>
<dict>
<key>CLASS</key>
+ <string>SKAnnotationTypeImageCell</string>
+ <key>LANGUAGE</key>
+ <string>ObjC</string>
+ <key>SUPERCLASS</key>
+ <string>NSImageCell</string>
+ </dict>
+ <dict>
+ <key>CLASS</key>
<string>BDSKCollapsibleView</string>
<key>LANGUAGE</key>
<string>ObjC</string>
Modified: trunk/MainWindow.nib/info.nib
===================================================================
--- trunk/MainWindow.nib/info.nib 2009-04-30 14:34:16 UTC (rev 5341)
+++ trunk/MainWindow.nib/info.nib 2009-05-01 12:02:06 UTC (rev 5342)
@@ -10,9 +10,7 @@
<integer>4</integer>
<key>IBOpenObjects</key>
<array>
- <integer>797</integer>
- <integer>225</integer>
- <integer>513</integer>
+ <integer>257</integer>
</array>
<key>IBSystem Version</key>
<string>9G55</string>
Modified: trunk/MainWindow.nib/keyedobjects.nib
===================================================================
(Binary files differ)
Modified: trunk/SKMainWindowController_UI.m
===================================================================
--- trunk/SKMainWindowController_UI.m 2009-04-30 14:34:16 UTC (rev 5341)
+++ trunk/SKMainWindowController_UI.m 2009-05-01 12:02:06 UTC (rev 5342)
@@ -296,6 +296,78 @@
}
}
+#pragma mark NSTableView datasource protocol
+
+// AppKit bug: need a dummy NSTableDataSource implementation, otherwise some
NSTableView delegate methods are ignored
+- (NSInteger)numberOfRowsInTableView:(NSTableView *)tv { return 0; }
+
+- (id)tableView:(NSTableView *)tv objectValueForTableColumn:(NSTableColumn
*)tableColumn row:(NSInteger)row { return nil; }
+
+- (BOOL)tableView:(NSTableView *)tv writeRowsWithIndexes:(NSIndexSet
*)rowIndexes toPasteboard:(NSPasteboard *)pboard {
+ if ([tv isEqual:thumbnailTableView]) {
+ NSUInteger idx = [rowIndexes firstIndex];
+ if (idx != NSNotFound) {
+ PDFPage *page = [[pdfView document] pageAtIndex:idx];
+ NSData *pdfData = [page dataRepresentation];
+ NSData *tiffData = [page TIFFDataForRect:[page
boundsForBox:[pdfView displayBox]]];
+ NSString *fileName = [NSString stringWithFormat:@"%@ - Page
%[email protected]", ([[[self document] displayName] stringByDeletingPathExtension] ?:
@"PDF"), [page displayLabel]];
+ [pboard declareTypes:[NSArray arrayWithObjects:NSPDFPboardType,
NSTIFFPboardType, NSFilesPromisePboardType, nil] owner:self];
+ [pboard setData:pdfData forType:NSPDFPboardType];
+ [pboard setData:tiffData forType:NSTIFFPboardType];
+ [pboard setPropertyList:[NSArray arrayWithObject:fileName]
forType:NSFilesPromisePboardType];
+ return YES;
+ }
+ } else if ([tv isEqual:snapshotTableView]) {
+ NSUInteger idx = [rowIndexes firstIndex];
+ if (idx != NSNotFound) {
+ SKSnapshotWindowController *snapshot = [self
objectInSnapshotsAtIndex:idx];
+ PDFPage *page = [[pdfView document] pageAtIndex:[snapshot
pageIndex]];
+ NSString *fileName = [NSString stringWithFormat:@"%@ - Page
%[email protected]", ([[[self document] displayName] stringByDeletingPathExtension] ?:
@"PDF"), [page displayLabel]];
+ [pboard declareTypes:[NSArray arrayWithObjects:NSTIFFPboardType,
NSFilesPromisePboardType, nil] owner:self];
+ [pboard setData:[[snapshot thumbnailWithSize:0.0]
TIFFRepresentation] forType:NSTIFFPboardType];
+ [pboard setPropertyList:[NSArray arrayWithObject:fileName]
forType:NSFilesPromisePboardType];
+ return YES;
+ }
+ }
+ return NO;
+}
+
+- (NSArray *)tableView:(NSTableView *)tv
namesOfPromisedFilesDroppedAtDestination:(NSURL *)dropDestination
forDraggedRowsWithIndexes:(NSIndexSet *)rowIndexes {
+ if ([tv isEqual:thumbnailTableView]) {
+ NSUInteger idx = [rowIndexes firstIndex];
+ if (idx != NSNotFound) {
+ PDFPage *page = [[pdfView document] pageAtIndex:idx];
+ NSString *fileName = [NSString stringWithFormat:@"%@ - Page %@",
([[[self document] displayName] stringByDeletingPathExtension] ?: @"PDF"),
[page displayLabel]];
+ NSString *basePath = [[dropDestination path]
stringByAppendingPathComponent:fileName];
+ NSString *path = [basePath stringByAppendingPathExtension:@"pdf"];
+ NSFileManager *fm = [NSFileManager defaultManager];
+ NSInteger i = 0;
+
+ while ([fm fileExistsAtPath:path])
+ path = [[basePath stringByAppendingFormat:@" - %ld",
(long)++i] stringByAppendingPathExtension:@"pdf"];
+ if ([[page dataRepresentation] writeToFile:path atomically:YES])
+ return [NSArray arrayWithObjects:[path lastPathComponent],
nil];
+ }
+ } else if ([tv isEqual:snapshotTableView]) {
+ NSUInteger idx = [rowIndexes firstIndex];
+ if (idx != NSNotFound) {
+ SKSnapshotWindowController *snapshot = [self
objectInSnapshotsAtIndex:idx];
+ PDFPage *page = [[pdfView document] pageAtIndex:[snapshot
pageIndex]];
+ NSString *fileName = [NSString stringWithFormat:@"%@ - Page %@",
([[[self document] displayName] stringByDeletingPathExtension] ?: @"PDF"),
[page displayLabel]];
+ NSString *basePath = [[dropDestination path]
stringByAppendingPathComponent:fileName];
+ NSString *path = [basePath stringByAppendingPathExtension:@"tiff"];
+ NSFileManager *fm = [NSFileManager defaultManager];
+ NSInteger i = 0;
+
+ while ([fm fileExistsAtPath:path])
+ path = [[basePath stringByAppendingFormat:@" - %ld",
(long)++i] stringByAppendingPathExtension:@"tiff"];
+ if ([[[snapshot thumbnailWithSize:0.0] TIFFRepresentation]
writeToFile:path atomically:YES])
+ return [NSArray arrayWithObjects:[path lastPathComponent],
nil];
+ }
+ }
+ return nil;
+}
+
#pragma mark NSTableView delegate protocol
- (void)tableViewSelectionDidChange:(NSNotification *)aNotification {
@@ -323,11 +395,6 @@
}
}
-// AppKit bug: need a dummy NSTableDataSource implementation, otherwise some
NSTableView delegate methods are ignored
-- (NSInteger)numberOfRowsInTableView:(NSTableView *)tv { return 0; }
-
-- (id)tableView:(NSTableView *)tv objectValueForTableColumn:(NSTableColumn
*)tableColumn row:(NSInteger)row { return nil; }
-
- (BOOL)tableView:(NSTableView *)tv commandSelectRow:(NSInteger)row {
if ([tv isEqual:thumbnailTableView]) {
NSRect rect = [[[pdfView document] pageAtIndex:row]
boundsForBox:kPDFDisplayBoxCropBox];
Modified: trunk/SKThumbnailTableView.m
===================================================================
--- trunk/SKThumbnailTableView.m 2009-04-30 14:34:16 UTC (rev 5341)
+++ trunk/SKThumbnailTableView.m 2009-05-01 12:02:06 UTC (rev 5342)
@@ -219,4 +219,8 @@
[super mouseDown:theEvent];
}
+- (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)flag {
+ return NSDragOperationEvery;
+}
+
@end
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Register Now & Save for Velocity, the Web Performance & Operations
Conference from O'Reilly Media. Velocity features a full day of
expert-led, hands-on workshops and two days of sessions from industry
leaders in dedicated Performance & Operations tracks. Use code vel09scf
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit