mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 19:30:48 +00:00
Tweaks and debugging
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@17063 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
7a468350a5
commit
a5399b06c6
5 changed files with 71 additions and 22 deletions
|
@ -46,10 +46,21 @@
|
||||||
APPKIT_EXPORT NSString *NSStringPboardType;
|
APPKIT_EXPORT NSString *NSStringPboardType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pasteboard contains string color information
|
* Pasteboard contains color information
|
||||||
*/
|
*/
|
||||||
APPKIT_EXPORT NSString *NSColorPboardType;
|
APPKIT_EXPORT NSString *NSColorPboardType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pasteboard contains generic file content information (serialized)
|
||||||
|
* as written by [NSPasteboard-writeFileContents:] or
|
||||||
|
* [NSPasteboard-writeFileWrapper:]
|
||||||
|
*/
|
||||||
APPKIT_EXPORT NSString *NSFileContentsPboardType;
|
APPKIT_EXPORT NSString *NSFileContentsPboardType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pasteboard contains an array of filenames (serialized)
|
||||||
|
* as written by [NSPasteboard-setPropertyList:forType:]
|
||||||
|
*/
|
||||||
APPKIT_EXPORT NSString *NSFilenamesPboardType;
|
APPKIT_EXPORT NSString *NSFilenamesPboardType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1362,11 +1362,14 @@ GSPerformService(NSString *serviceItem, NSPasteboard *pboard, BOOL isFilter)
|
||||||
finishBy = [NSDate dateWithTimeIntervalSinceNow: seconds];
|
finishBy = [NSDate dateWithTimeIntervalSinceNow: seconds];
|
||||||
appPath = [service objectForKey: @"ServicePath"];
|
appPath = [service objectForKey: @"ServicePath"];
|
||||||
userData = [service objectForKey: @"NSUserData"];
|
userData = [service objectForKey: @"NSUserData"];
|
||||||
message = [service objectForKey: @"NSMessage"];
|
if (isFilter == YES)
|
||||||
if (isFilter == YES && [message length] == 0)
|
|
||||||
{
|
{
|
||||||
message = [service objectForKey: @"NSFilter"];
|
message = [service objectForKey: @"NSFilter"];
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
message = [service objectForKey: @"NSMessage"];
|
||||||
|
}
|
||||||
selName = [message stringByAppendingString: @":userData:error:"];
|
selName = [message stringByAppendingString: @":userData:error:"];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -209,6 +209,7 @@ static NSString *namePrefix = @"NSTypedFilenamesPboardType:";
|
||||||
{
|
{
|
||||||
NSMutableData *m = [NSMutableData dataWithCapacity: 1023];
|
NSMutableData *m = [NSMutableData dataWithCapacity: 1023];
|
||||||
NSString *filename;
|
NSString *filename;
|
||||||
|
NSString *path;
|
||||||
NSData *d;
|
NSData *d;
|
||||||
NSPipe *p;
|
NSPipe *p;
|
||||||
NSTask *t;
|
NSTask *t;
|
||||||
|
@ -217,8 +218,8 @@ static NSString *namePrefix = @"NSTypedFilenamesPboardType:";
|
||||||
/*
|
/*
|
||||||
* The data for an NSUnixStdio filter must be one or more filenames
|
* The data for an NSUnixStdio filter must be one or more filenames
|
||||||
*/
|
*/
|
||||||
if ([type isEqualToString: NSFilenamesPboardType] == NO
|
if ([fromType isEqualToString: NSFilenamesPboardType] == NO
|
||||||
&& [type hasPrefix: namePrefix] == NO)
|
&& [fromType hasPrefix: namePrefix] == NO)
|
||||||
{
|
{
|
||||||
[sender setData: [NSData data] forType: type];
|
[sender setData: [NSData data] forType: type];
|
||||||
return; // Not the name of a file to filter.
|
return; // Not the name of a file to filter.
|
||||||
|
@ -258,7 +259,12 @@ static NSString *namePrefix = @"NSTypedFilenamesPboardType:";
|
||||||
* Set up and launch task to filter the named file.
|
* Set up and launch task to filter the named file.
|
||||||
*/
|
*/
|
||||||
t = [NSTask new];
|
t = [NSTask new];
|
||||||
[t setLaunchPath: [info objectForKey: @"NSPortName"]];
|
path = [info objectForKey: @"NSExecutable"];
|
||||||
|
if ([path length] == 0)
|
||||||
|
{
|
||||||
|
path = [info objectForKey: @"NSPortName"];
|
||||||
|
}
|
||||||
|
[t setLaunchPath: path];
|
||||||
[t setArguments: [NSArray arrayWithObject: filename]];
|
[t setArguments: [NSArray arrayWithObject: filename]];
|
||||||
p = [NSPipe pipe];
|
p = [NSPipe pipe];
|
||||||
[t setStandardOutput: p];
|
[t setStandardOutput: p];
|
||||||
|
@ -267,7 +273,8 @@ static NSString *namePrefix = @"NSTypedFilenamesPboardType:";
|
||||||
/*
|
/*
|
||||||
* Read all the data that the task writes.
|
* Read all the data that the task writes.
|
||||||
*/
|
*/
|
||||||
while ((d = [[p fileHandleForReading] availableData]) != nil)
|
while ((d = [[p fileHandleForReading] availableData]) != nil
|
||||||
|
&& [d length] > 0)
|
||||||
{
|
{
|
||||||
[m appendData: d];
|
[m appendData: d];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,15 @@
|
||||||
NSServices = (
|
NSServices = (
|
||||||
|
{
|
||||||
|
NSFilter = cat;
|
||||||
|
NSInputMechanism = NSUnixStdio;
|
||||||
|
NSPortName = "/bin/cat";
|
||||||
|
NSSendTypes = (
|
||||||
|
NSFilenamesPboardType
|
||||||
|
);
|
||||||
|
NSReturnTypes = (
|
||||||
|
NSGeneralPboardType
|
||||||
|
);
|
||||||
|
},
|
||||||
{
|
{
|
||||||
NSPortName = ExampleServices;
|
NSPortName = ExampleServices;
|
||||||
NSFilter = md5;
|
NSFilter = md5;
|
||||||
|
|
|
@ -25,33 +25,50 @@
|
||||||
#include <Foundation/NSFileHandle.h>
|
#include <Foundation/NSFileHandle.h>
|
||||||
#include <Foundation/NSProcessInfo.h>
|
#include <Foundation/NSProcessInfo.h>
|
||||||
#include <Foundation/NSString.h>
|
#include <Foundation/NSString.h>
|
||||||
|
#include <Foundation/NSUserDefaults.h>
|
||||||
#include <AppKit/NSPasteboard.h>
|
#include <AppKit/NSPasteboard.h>
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char** argv, char **env_c)
|
main(int argc, char** argv, char **env_c)
|
||||||
{
|
{
|
||||||
CREATE_AUTORELEASE_POOL(pool);
|
CREATE_AUTORELEASE_POOL(pool);
|
||||||
NSFileHandle *fh;
|
NSFileHandle *fh;
|
||||||
NSData *data;
|
NSData *data;
|
||||||
NSString *string;
|
NSString *string;
|
||||||
NSPasteboard *pb;
|
NSPasteboard *pb;
|
||||||
|
NSUserDefaults *defs;
|
||||||
|
|
||||||
#ifdef GS_PASS_ARGUMENTS
|
#ifdef GS_PASS_ARGUMENTS
|
||||||
[NSProcessInfo initializeWithArguments:argv count:argc environment:env_c];
|
[NSProcessInfo initializeWithArguments:argv count:argc environment:env_c];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
NSLog(@"This program expects to read utf8 text from stdin -");
|
defs = [NSUserDefaults standardUserDefaults];
|
||||||
fh = [NSFileHandle fileHandleWithStandardInput];
|
string = [defs stringForKey: @"CatFile"];
|
||||||
data = [fh readDataToEndOfFile];
|
if (string != nil)
|
||||||
string = [[NSString alloc] initWithData: data
|
{
|
||||||
encoding: NSUTF8StringEncoding];
|
data = [NSSerializer serializePropertyList: string];
|
||||||
data = [NSSerializer serializePropertyList: string];
|
pb = [NSPasteboard pasteboardByFilteringData: data
|
||||||
|
ofType: NSFilenamesPboardType];
|
||||||
|
NSLog(@"Types: %@", [pb types]);
|
||||||
|
data = [pb dataForType: NSGeneralPboardType];
|
||||||
|
NSLog(@"Got %@", data);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NSLog(@"This program expects to read utf8 text from stdin -");
|
||||||
|
fh = [NSFileHandle fileHandleWithStandardInput];
|
||||||
|
data = [fh readDataToEndOfFile];
|
||||||
|
string = [[NSString alloc] initWithData: data
|
||||||
|
encoding: NSUTF8StringEncoding];
|
||||||
|
data = [NSSerializer serializePropertyList: string];
|
||||||
|
|
||||||
|
pb = [NSPasteboard pasteboardByFilteringData: data
|
||||||
|
ofType: NSStringPboardType];
|
||||||
|
NSLog(@"Types: %@", [pb types]);
|
||||||
|
data = [pb dataForType: @"md5Digest"];
|
||||||
|
NSLog(@"Got %@", data);
|
||||||
|
}
|
||||||
|
|
||||||
pb = [NSPasteboard pasteboardByFilteringData: data
|
|
||||||
ofType: NSStringPboardType];
|
|
||||||
NSLog(@"Types: %@", [pb types]);
|
|
||||||
data = [pb dataForType: @"md5Digest"];
|
|
||||||
NSLog(@"Got %@", data);
|
|
||||||
RELEASE(pool);
|
RELEASE(pool);
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue