diff options
author | Kevin Walzer <kw@codebykevin.com> | 2019-05-17 03:13:34 (GMT) |
---|---|---|
committer | Kevin Walzer <kw@codebykevin.com> | 2019-05-17 03:13:34 (GMT) |
commit | eb47f72e2905e940a3f2b3c81f9d0a8944df5143 (patch) | |
tree | 26c0526fa040d03d676ecd21d216b0b95d9db0ef /macosx/tkMacOSXServices.c | |
parent | 3726f38ebed5f4a444b0b3de64095649563eecf8 (diff) | |
download | tk-eb47f72e2905e940a3f2b3c81f9d0a8944df5143.zip tk-eb47f72e2905e940a3f2b3c81f9d0a8944df5143.tar.gz tk-eb47f72e2905e940a3f2b3c81f9d0a8944df5143.tar.bz2 |
Code and data type cleanup, thanks to Marc Culler for patch
Diffstat (limited to 'macosx/tkMacOSXServices.c')
-rw-r--r-- | macosx/tkMacOSXServices.c | 49 |
1 files changed, 31 insertions, 18 deletions
diff --git a/macosx/tkMacOSXServices.c b/macosx/tkMacOSXServices.c index 3340ba7..30e851d 100644 --- a/macosx/tkMacOSXServices.c +++ b/macosx/tkMacOSXServices.c @@ -50,9 +50,9 @@ int ServicesEventProc( @implementation TkService + (void) initialize { - NSArray *sendTypes = [NSArray arrayWithObjects:NSPasteboardTypeString, nil]; - - [NSApp registerServicesMenuSendTypes:sendTypes returnTypes:nil]; + NSArray *sendTypes = [NSArray arrayWithObjects:@"NSStringPboardType", + @"NSPasteboardTypeString", nil]; + [NSApp registerServicesMenuSendTypes:sendTypes returnTypes:sendTypes]; NSUpdateDynamicServices(); return; } @@ -61,7 +61,8 @@ int ServicesEventProc( - (id)validRequestorForSendType:(NSString *)sendType returnType:(NSString *)returnType { - if ([sendType isEqual:NSStringPboardType]) { + if ([sendType isEqualToString:@"NSStringPboardType"] || + [sendType isEqualToString:@"NSPasteboardTypeString"]) { return self; } return [super validRequestorForSendType:sendType returnType:returnType]; @@ -87,19 +88,26 @@ int ServicesEventProc( - (BOOL)writeSelectionToPasteboard:(NSPasteboard *)pboard types:(NSArray *)types { - NSArray *typesDeclared; - if ([types containsObject:NSStringPboardType] == NO) { + NSArray *typesDeclared = nil; + NSString *pboardType = nil; + for (NSString *typeString in types) { + if ([typeString isEqualToString:@"NSStringPboardType"] || + [typeString isEqualToString:@"NSPasteboardTypeString"]) { + typesDeclared = [NSArray arrayWithObject:typeString]; + pboardType = typeString; + break; + } + } + if (!typesDeclared) { return NO; } - Tcl_Eval(ServicesInterp,"selection get"); char *copystring; copystring = Tcl_GetString(Tcl_GetObjResult(ServicesInterp)); NSString *writestring = [NSString stringWithUTF8String:copystring]; - typesDeclared = [NSArray arrayWithObject:NSStringPboardType]; [pboard declareTypes:typesDeclared owner:nil]; - return [pboard setString:writestring forType:NSPasteboardTypeString]; + return [pboard setString:writestring forType:pboardType]; } @@ -112,7 +120,7 @@ int ServicesEventProc( userData:(NSString *)data error:(NSString **)error { - NSString *pboardString; + NSString *pboardString, *pboardType; NSArray *types = [pboard types]; Tcl_Event *event; @@ -121,19 +129,24 @@ int ServicesEventProc( * available to Tcl service. */ - if ([types containsObject:NSStringPboardType] && - (pboardString = [pboard stringForType:NSStringPboardType])) { - + for (NSString *typeString in types) { + if ([typeString isEqualToString:@"NSStringPboardType"] || + [typeString isEqualToString:@"NSPasteboardTypeString"]) { + pboardString = [pboard stringForType:typeString]; + pboardType = typeString; + break; + } + } + if (pboardString) { NSPasteboard *generalpasteboard = [NSPasteboard generalPasteboard]; - [generalpasteboard declareTypes:[NSArray - arrayWithObjects:NSStringPboardType, nil] owner:nil]; - [generalpasteboard setString:pboardString forType: NSPasteboardTypeString]; + [generalpasteboard declareTypes:[NSArray arrayWithObjects:pboardType, nil] + owner:nil]; + [generalpasteboard setString:pboardString forType:pboardType]; event = ckalloc(sizeof(Tcl_Event)); event->proc = ServicesEventProc; Tcl_QueueEvent((Tcl_Event *)event, TCL_QUEUE_TAIL); } } - @end @@ -205,7 +218,7 @@ int TkMacOSXRegisterServiceWidgetObjCmd ( * Initalize the package in the tcl interpreter, create tcl commands. */ -int Tk_MacOSXServices_Init( +int TkMacOSXServices_Init( Tcl_Interp *interp) { /* |