Ticket #33813: patch-Lion.diff

File patch-Lion.diff, 8.4 KB (added by MaddTheSane (C.W. Betts), 12 years ago)

Patch file to go along with macclipboard-gimp

  • Makefile

    diff -uw macclipboard-gimp-0.7.orig/Makefile macclipboard-gimp-0.7/Makefile
     
    1 linkflags = -fnext-runtime -framework Cocoa -framework Carbon
     1linkflags = -framework Cocoa -framework Carbon
     2
     3GIMPTOOL = gimptool-2.0
    24
    35all : macclipboard
    46
    57macclipboard : 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
    79
    810install : macclipboard
    9         cp -p macclipboard $(HOME)/.gimp-2.0/plug-ins/
     11        $(GIMPTOOL) --install-bin macclipboard
    1012
    1113uninstall :
    12         rm -f $(HOME)/.gimp-2.0/plug-ins/macclipboard
     14        $(GIMPTOOL) --uninstall-bin macclipboard
    1315
    1416clean :
    1517        rm -f macclipboard
  • macclipboard.m

    diff -uw macclipboard-gimp-0.7.orig/macclipboard.m macclipboard-gimp-0.7/macclipboard.m
     
    3232/*
    3333The Mac clipboard ('pasteboard' or 'scrap') can contain data in multiple
    3434formats. The least common denominator for graphic data is 'PICT', a QuickDraw
    35 picture.
     35picture. However, QuickDraw, and by extension PICT, have been depricated and
     36aren't available under 64-bit code.
    3637
    3738Cocoa apps prefer TIFF, which also lets us transfer alpha channel data
    3839relatively reliably. When we post a TIFF, Cocoa does PICT translation for us.
     
    6970/* #include "config.h" */
    7071
    7172#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
    7283#include <Carbon/Carbon.h>
     84#endif
    7385
    7486#include <sys/types.h>
    7587#include <sys/stat.h>
     
    117129static gboolean clipboard_paste_service    (gboolean         interactive,
    118130                                            NSString        *service);
    119131
    120 
     132#if HAVE_QD_HEADERS
    121133/* PICT bits */
    122134static gboolean clipboard_offscreen_pict   (PicHandle         pic,
    123135                                            guchar            fill,
     
    143155                                            gint32            drawable_ID,
    144156                                            NSData           *data,
    145157                                            gint32           *image_out);
     158#endif
    146159
    147160/* Other image types */
    148161static gboolean clipboard_paste_bitmap     (gboolean          interactive,
     
    173186                                            gint32           drawable_ID,
    174187                                            NSData          *data);
    175188
     189#if HAVE_QD_HEADERS
    176190static gint32   clipboard_load_pict        (gboolean         interactive,
    177191                                            gchar            *filename);
     192#endif
    178193
    179194GimpPlugInInfo PLUG_IN_INFO =
    180195{
     
    291306                          1, 0,
    292307                          copy_args, NULL);
    293308
     309#ifndef HAVE_QD_HEADERS
    294310  gimp_install_procedure ("file_pict_load",
    295311                          "Loads files of Macintosh PICT file format",
    296312                          "Loads files of Macintosh PICT file format",
     
    308324                                    "pict",
    309325                                    "",
    310326                                    "");
     327#endif
    311328}
    312329
    313330static void
     
    324341  int interactive = (GIMP_RUN_INTERACTIVE==run_mode);
    325342  int ok = FALSE;
    326343 
    327   NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     344        NSAutoreleasePool *pool = [NSAutoreleasePool new];
    328345 
    329346  *nreturn_vals = 1;
    330347  *return_vals = values;
     
    348365    ok = clipboard_paste_service (interactive, @"Grab/Selection");
    349366  else if (strcmp (name, "plug_in_clipboard_grab_timed") == 0)
    350367    ok = clipboard_paste_service (interactive, @"Grab/Timed Screen");
     368#if HAVE_QD_HEADERS
    351369  else if (strcmp (name, "file_pict_load") == 0)
    352370    {
    353371      gint32 image = clipboard_load_pict (interactive, param[1].data.d_string);
     
    362380  else
    363381    {
    364382      values[0].data.d_status = GIMP_PDB_CALLING_ERROR;
    365       [pool release];
     383                [pool drain];
    366384      return;
    367385    }
     386#endif
    368387 
    369388  values[0].data.d_status = ok ? GIMP_PDB_SUCCESS : GIMP_PDB_EXECUTION_ERROR;
    370   [pool release];
     389        [pool drain];
    371390}
    372391
    373392/*
     
    523542    {
    524543      [board setData: [bitmap TIFFRepresentation] forType: NSTIFFPboardType];
    525544
     545#if HAVE_QD_HEADERS
    526546      /* Force conversion to PICT before we leave */
    527547      [board types];
    528548      [board dataForType: NSPICTPboardType];
     549#endif
    529550    }
     551        [bitmap release];
    530552
    531553  return TRUE;
    532554}
     
    553575{
    554576  NSApplication *app = [NSApplication sharedApplication];
    555577  [app registerServicesMenuSendTypes: nil
    556        returnTypes: [NSArray arrayWithObjects: NSTIFFPboardType, nil]];
     578                                                   returnTypes: [NSArray arrayWithObject: NSTIFFPboardType]];
    557579
    558580  NSPasteboard *board = [NSPasteboard pasteboardWithUniqueName];
    559581
     
    561583  if (NSPerformService(service, board))
    562584    return clipboard_paste_board (interactive, IMAGE_NONE, IMAGE_NONE, board);
    563585
    564   g_message (_("Couldn't run system service %s"), [service cString]);
     586        g_message (_("Couldn't run system service %s"), [service UTF8String]);
    565587  return FALSE;
    566588}
    567589
    568 
    569 
    570 
    571590/*
    572591 * Find pasteable image(s) from a given pasteboard and um... paste them.
    573592 */
     
    582601  NSString *type = [board availableTypeFromArray:
    583602    [NSArray arrayWithObjects:
    584603      NSTIFFPboardType,
     604#if HAVE_QD_HEADERS
    585605      NSPICTPboardType,
     606#endif
    586607      NSRTFDPboardType,
    587608      nil]];
    588609  if (type == nil)
     
    601622  if ([type isEqualToString: NSTIFFPboardType])
    602623    return clipboard_paste_bitmap (interactive, image_ID, drawable_ID,
    603624      [NSBitmapImageRep imageRepWithData: data], NULL);
     625#if HAVE_QD_HEADERS
    604626  else if ([type isEqualToString: NSPICTPboardType])
    605627    return clipboard_paste_pict (interactive, image_ID, drawable_ID, data, NULL);
     628#endif
    606629  else if ([type isEqualToString: NSRTFDPboardType])
    607630    return clipboard_paste_rtfd (interactive, image_ID, drawable_ID, data);
    608631
     
    610633  return FALSE;
    611634}
    612635
    613 
     636#if HAVE_QD_HEADERS
    614637/*
    615638 * Render a given PICT into a newly created offscreen 32-bit graphics
    616639 * world, returning some handy information about the bits.
     
    825848 
    826849  return retval;
    827850}
     851#endif
    828852
    829853static gboolean
    830854clipboard_paste_image (gboolean       interactive,
     
    975999      if (channels != (3 + alpha))
    9761000        {
    9771001          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");
    9791003          return FALSE;
    9801004        }
    9811005    }
     
    9861010      if (channels != (1 + alpha))
    9871011        {
    9881012          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");
    9901014          return FALSE;
    9911015        }
    9921016    }
     1017        /* Apparently black color spaces are depricated in Snow Leopard and later*/
    9931018  else if ([colorSpace isEqualToString: NSCalibratedBlackColorSpace] ||
    9941019           [colorSpace isEqualToString: NSDeviceBlackColorSpace])
    9951020    {
     
    9971022      if (channels != (1 + alpha))
    9981023        {
    9991024          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");
    10011026          return FALSE;
    10021027        }
    10031028    }
    10041029  else
    10051030    {
    1006       g_message (_("Unknown colorspace! %s"), [colorSpace cString]);
     1031                g_message (_("Unknown colorspace! %s"), [colorSpace UTF8String]);
    10071032      return FALSE;
    10081033    }
    10091034
     
    11321157                                [item regularFileContents]], NULL))
    11331158                        numCopied++;
    11341159                      else
    1135                         NSLog (@"Not a TIFF: %s", [item filename]);
     1160                                                        NSLog (@"Not a TIFF: %@", [item filename]);
    11361161                    }
    11371162                }
    11381163              if (numCopied == 0)
     
    11541179  return FALSE;
    11551180}
    11561181
     1182#if HAVE_QD_HEADERS
    11571183static gint32
    11581184clipboard_load_pict (gboolean  interactive,
    11591185                     gchar    *filename)
     
    11811207  g_message ("Could not open file %s", filename);
    11821208  return -1;
    11831209}
     1210#endif
     1211