diff -uw macclipboard-gimp-0.7.orig/Makefile macclipboard-gimp-0.7/Makefile
|
|
|
1 | | linkflags = -fnext-runtime -framework Cocoa -framework Carbon |
| 1 | linkflags = -framework Cocoa -framework Carbon |
| 2 | |
| 3 | GIMPTOOL = gimptool-2.0 |
2 | 4 | |
3 | 5 | all : macclipboard |
4 | 6 | |
5 | 7 | macclipboard : macclipboard.m clipboard_xfer.h |
6 | | gcc -I/sw/include `gimptool-2.0 --cflags` `gimptool-2.0 --libs` $(linkflags) macclipboard.m -o macclipboard |
| 8 | gcc `$(GIMPTOOL) --cflags` `$(GIMPTOOL) --libs` $(LDFLAGS) $(CFLAGS) $(linkflags) macclipboard.m -o macclipboard |
7 | 9 | |
8 | 10 | install : macclipboard |
9 | | cp -p macclipboard $(HOME)/.gimp-2.0/plug-ins/ |
| 11 | $(GIMPTOOL) --install-bin macclipboard |
10 | 12 | |
11 | 13 | uninstall : |
12 | | rm -f $(HOME)/.gimp-2.0/plug-ins/macclipboard |
| 14 | $(GIMPTOOL) --uninstall-bin macclipboard |
13 | 15 | |
14 | 16 | clean : |
15 | 17 | rm -f macclipboard |
diff -uw macclipboard-gimp-0.7.orig/macclipboard.m macclipboard-gimp-0.7/macclipboard.m
|
|
|
32 | 32 | /* |
33 | 33 | The Mac clipboard ('pasteboard' or 'scrap') can contain data in multiple |
34 | 34 | formats. The least common denominator for graphic data is 'PICT', a QuickDraw |
35 | | picture. |
| 35 | picture. However, QuickDraw, and by extension PICT, have been depricated and |
| 36 | aren't available under 64-bit code. |
36 | 37 | |
37 | 38 | Cocoa apps prefer TIFF, which also lets us transfer alpha channel data |
38 | 39 | relatively reliably. When we post a TIFF, Cocoa does PICT translation for us. |
… |
… |
|
69 | 70 | /* #include "config.h" */ |
70 | 71 | |
71 | 72 | #import <Cocoa/Cocoa.h> |
| 73 | #ifdef __LP64__ |
| 74 | #define HAVE_QD_HEADERS 0 |
| 75 | #else |
| 76 | #ifdef __MAC_10_7 |
| 77 | #define HAVE_QD_HEADERS 0 |
| 78 | #else |
| 79 | #define HAVE_QD_HEADERS 1 |
| 80 | #endif |
| 81 | #endif |
| 82 | #if HAVE_QD_HEADERS |
72 | 83 | #include <Carbon/Carbon.h> |
| 84 | #endif |
73 | 85 | |
74 | 86 | #include <sys/types.h> |
75 | 87 | #include <sys/stat.h> |
… |
… |
|
117 | 129 | static gboolean clipboard_paste_service (gboolean interactive, |
118 | 130 | NSString *service); |
119 | 131 | |
120 | | |
| 132 | #if HAVE_QD_HEADERS |
121 | 133 | /* PICT bits */ |
122 | 134 | static gboolean clipboard_offscreen_pict (PicHandle pic, |
123 | 135 | guchar fill, |
… |
… |
|
143 | 155 | gint32 drawable_ID, |
144 | 156 | NSData *data, |
145 | 157 | gint32 *image_out); |
| 158 | #endif |
146 | 159 | |
147 | 160 | /* Other image types */ |
148 | 161 | static gboolean clipboard_paste_bitmap (gboolean interactive, |
… |
… |
|
173 | 186 | gint32 drawable_ID, |
174 | 187 | NSData *data); |
175 | 188 | |
| 189 | #if HAVE_QD_HEADERS |
176 | 190 | static gint32 clipboard_load_pict (gboolean interactive, |
177 | 191 | gchar *filename); |
| 192 | #endif |
178 | 193 | |
179 | 194 | GimpPlugInInfo PLUG_IN_INFO = |
180 | 195 | { |
… |
… |
|
291 | 306 | 1, 0, |
292 | 307 | copy_args, NULL); |
293 | 308 | |
| 309 | #ifndef HAVE_QD_HEADERS |
294 | 310 | gimp_install_procedure ("file_pict_load", |
295 | 311 | "Loads files of Macintosh PICT file format", |
296 | 312 | "Loads files of Macintosh PICT file format", |
… |
… |
|
308 | 324 | "pict", |
309 | 325 | "", |
310 | 326 | ""); |
| 327 | #endif |
311 | 328 | } |
312 | 329 | |
313 | 330 | static void |
… |
… |
|
324 | 341 | int interactive = (GIMP_RUN_INTERACTIVE==run_mode); |
325 | 342 | int ok = FALSE; |
326 | 343 | |
327 | | NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; |
| 344 | NSAutoreleasePool *pool = [NSAutoreleasePool new]; |
328 | 345 | |
329 | 346 | *nreturn_vals = 1; |
330 | 347 | *return_vals = values; |
… |
… |
|
348 | 365 | ok = clipboard_paste_service (interactive, @"Grab/Selection"); |
349 | 366 | else if (strcmp (name, "plug_in_clipboard_grab_timed") == 0) |
350 | 367 | ok = clipboard_paste_service (interactive, @"Grab/Timed Screen"); |
| 368 | #if HAVE_QD_HEADERS |
351 | 369 | else if (strcmp (name, "file_pict_load") == 0) |
352 | 370 | { |
353 | 371 | gint32 image = clipboard_load_pict (interactive, param[1].data.d_string); |
… |
… |
|
362 | 380 | else |
363 | 381 | { |
364 | 382 | values[0].data.d_status = GIMP_PDB_CALLING_ERROR; |
365 | | [pool release]; |
| 383 | [pool drain]; |
366 | 384 | return; |
367 | 385 | } |
| 386 | #endif |
368 | 387 | |
369 | 388 | values[0].data.d_status = ok ? GIMP_PDB_SUCCESS : GIMP_PDB_EXECUTION_ERROR; |
370 | | [pool release]; |
| 389 | [pool drain]; |
371 | 390 | } |
372 | 391 | |
373 | 392 | /* |
… |
… |
|
523 | 542 | { |
524 | 543 | [board setData: [bitmap TIFFRepresentation] forType: NSTIFFPboardType]; |
525 | 544 | |
| 545 | #if HAVE_QD_HEADERS |
526 | 546 | /* Force conversion to PICT before we leave */ |
527 | 547 | [board types]; |
528 | 548 | [board dataForType: NSPICTPboardType]; |
| 549 | #endif |
529 | 550 | } |
| 551 | [bitmap release]; |
530 | 552 | |
531 | 553 | return TRUE; |
532 | 554 | } |
… |
… |
|
553 | 575 | { |
554 | 576 | NSApplication *app = [NSApplication sharedApplication]; |
555 | 577 | [app registerServicesMenuSendTypes: nil |
556 | | returnTypes: [NSArray arrayWithObjects: NSTIFFPboardType, nil]]; |
| 578 | returnTypes: [NSArray arrayWithObject: NSTIFFPboardType]]; |
557 | 579 | |
558 | 580 | NSPasteboard *board = [NSPasteboard pasteboardWithUniqueName]; |
559 | 581 | |
… |
… |
|
561 | 583 | if (NSPerformService(service, board)) |
562 | 584 | return clipboard_paste_board (interactive, IMAGE_NONE, IMAGE_NONE, board); |
563 | 585 | |
564 | | g_message (_("Couldn't run system service %s"), [service cString]); |
| 586 | g_message (_("Couldn't run system service %s"), [service UTF8String]); |
565 | 587 | return FALSE; |
566 | 588 | } |
567 | 589 | |
568 | | |
569 | | |
570 | | |
571 | 590 | /* |
572 | 591 | * Find pasteable image(s) from a given pasteboard and um... paste them. |
573 | 592 | */ |
… |
… |
|
582 | 601 | NSString *type = [board availableTypeFromArray: |
583 | 602 | [NSArray arrayWithObjects: |
584 | 603 | NSTIFFPboardType, |
| 604 | #if HAVE_QD_HEADERS |
585 | 605 | NSPICTPboardType, |
| 606 | #endif |
586 | 607 | NSRTFDPboardType, |
587 | 608 | nil]]; |
588 | 609 | if (type == nil) |
… |
… |
|
601 | 622 | if ([type isEqualToString: NSTIFFPboardType]) |
602 | 623 | return clipboard_paste_bitmap (interactive, image_ID, drawable_ID, |
603 | 624 | [NSBitmapImageRep imageRepWithData: data], NULL); |
| 625 | #if HAVE_QD_HEADERS |
604 | 626 | else if ([type isEqualToString: NSPICTPboardType]) |
605 | 627 | return clipboard_paste_pict (interactive, image_ID, drawable_ID, data, NULL); |
| 628 | #endif |
606 | 629 | else if ([type isEqualToString: NSRTFDPboardType]) |
607 | 630 | return clipboard_paste_rtfd (interactive, image_ID, drawable_ID, data); |
608 | 631 | |
… |
… |
|
610 | 633 | return FALSE; |
611 | 634 | } |
612 | 635 | |
613 | | |
| 636 | #if HAVE_QD_HEADERS |
614 | 637 | /* |
615 | 638 | * Render a given PICT into a newly created offscreen 32-bit graphics |
616 | 639 | * world, returning some handy information about the bits. |
… |
… |
|
825 | 848 | |
826 | 849 | return retval; |
827 | 850 | } |
| 851 | #endif |
828 | 852 | |
829 | 853 | static gboolean |
830 | 854 | clipboard_paste_image (gboolean interactive, |
… |
… |
|
975 | 999 | if (channels != (3 + alpha)) |
976 | 1000 | { |
977 | 1001 | g_message (_("Don't understand %d-channel image in RGB image (%s; alpha: %s)"), |
978 | | channels, [colorSpace cString], alpha ? "yes" : "no"); |
| 1002 | channels, [colorSpace UTF8String], alpha ? "yes" : "no"); |
979 | 1003 | return FALSE; |
980 | 1004 | } |
981 | 1005 | } |
… |
… |
|
986 | 1010 | if (channels != (1 + alpha)) |
987 | 1011 | { |
988 | 1012 | g_message (_("Don't understand %d-channel image in grayscale image (%s; alpha: %s)"), |
989 | | channels, [colorSpace cString], alpha ? "yes" : "no"); |
| 1013 | channels, [colorSpace UTF8String], alpha ? "yes" : "no"); |
990 | 1014 | return FALSE; |
991 | 1015 | } |
992 | 1016 | } |
| 1017 | /* Apparently black color spaces are depricated in Snow Leopard and later*/ |
993 | 1018 | else if ([colorSpace isEqualToString: NSCalibratedBlackColorSpace] || |
994 | 1019 | [colorSpace isEqualToString: NSDeviceBlackColorSpace]) |
995 | 1020 | { |
… |
… |
|
997 | 1022 | if (channels != (1 + alpha)) |
998 | 1023 | { |
999 | 1024 | g_message (_("Don't understand %d-channel image in grayscale image (%s; alpha: %s)"), |
1000 | | channels, [colorSpace cString], alpha ? "yes" : "no"); |
| 1025 | channels, [colorSpace UTF8String], alpha ? "yes" : "no"); |
1001 | 1026 | return FALSE; |
1002 | 1027 | } |
1003 | 1028 | } |
1004 | 1029 | else |
1005 | 1030 | { |
1006 | | g_message (_("Unknown colorspace! %s"), [colorSpace cString]); |
| 1031 | g_message (_("Unknown colorspace! %s"), [colorSpace UTF8String]); |
1007 | 1032 | return FALSE; |
1008 | 1033 | } |
1009 | 1034 | |
… |
… |
|
1132 | 1157 | [item regularFileContents]], NULL)) |
1133 | 1158 | numCopied++; |
1134 | 1159 | else |
1135 | | NSLog (@"Not a TIFF: %s", [item filename]); |
| 1160 | NSLog (@"Not a TIFF: %@", [item filename]); |
1136 | 1161 | } |
1137 | 1162 | } |
1138 | 1163 | if (numCopied == 0) |
… |
… |
|
1154 | 1179 | return FALSE; |
1155 | 1180 | } |
1156 | 1181 | |
| 1182 | #if HAVE_QD_HEADERS |
1157 | 1183 | static gint32 |
1158 | 1184 | clipboard_load_pict (gboolean interactive, |
1159 | 1185 | gchar *filename) |
… |
… |
|
1181 | 1207 | g_message ("Could not open file %s", filename); |
1182 | 1208 | return -1; |
1183 | 1209 | } |
| 1210 | #endif |
| 1211 | |