mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-02 12:20:59 +00:00
Tidied source.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@3304 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
5735ef8ea1
commit
43092212c5
1 changed files with 529 additions and 442 deletions
273
Tools/gpbs.m
273
Tools/gpbs.m
|
@ -38,7 +38,6 @@
|
||||||
#include <Foundation/NSDictionary.h>
|
#include <Foundation/NSDictionary.h>
|
||||||
#include <Foundation/NSException.h>
|
#include <Foundation/NSException.h>
|
||||||
#include <Foundation/NSRunLoop.h>
|
#include <Foundation/NSRunLoop.h>
|
||||||
#include <Foundation/NSString.h>
|
|
||||||
#include <Foundation/NSTimer.h>
|
#include <Foundation/NSTimer.h>
|
||||||
#include <Foundation/NSValue.h>
|
#include <Foundation/NSValue.h>
|
||||||
#include <Foundation/NSException.h>
|
#include <Foundation/NSException.h>
|
||||||
|
@ -50,8 +49,10 @@
|
||||||
|
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
// dummy definitions provided here to
|
// dummy definitions provided here to
|
||||||
BOOL // avoid errors when not linking with
|
// avoid errors when not linking with
|
||||||
initialize_gnustep_backend(void) // a back end
|
// a back end
|
||||||
|
BOOL
|
||||||
|
initialize_gnustep_backend(void)
|
||||||
{
|
{
|
||||||
return YES; // dummy define
|
return YES; // dummy define
|
||||||
}
|
}
|
||||||
|
@ -120,7 +121,8 @@ NSMutableDictionary* pasteboards = nil;
|
||||||
{
|
{
|
||||||
PasteboardData* d = [PasteboardData alloc];
|
PasteboardData* d = [PasteboardData alloc];
|
||||||
|
|
||||||
if (d) {
|
if (d)
|
||||||
|
{
|
||||||
d->type = [aType retain];
|
d->type = [aType retain];
|
||||||
d->owner = [anObject retain];
|
d->owner = [anObject retain];
|
||||||
d->pboard = [anotherObject retain];
|
d->pboard = [anotherObject retain];
|
||||||
|
@ -135,7 +137,8 @@ NSMutableDictionary* pasteboards = nil;
|
||||||
{
|
{
|
||||||
id o;
|
id o;
|
||||||
|
|
||||||
if (owner && [owner isProxy] && [owner connectionForProxy] == c) {
|
if (owner && [owner isProxy] && [owner connectionForProxy] == c)
|
||||||
|
{
|
||||||
o = owner;
|
o = owner;
|
||||||
owner = nil;
|
owner = nil;
|
||||||
[o release];
|
[o release];
|
||||||
|
@ -143,7 +146,8 @@ NSMutableDictionary* pasteboards = nil;
|
||||||
pboard = nil;
|
pboard = nil;
|
||||||
[o release];
|
[o release];
|
||||||
}
|
}
|
||||||
if (pboard && [pboard isProxy] && [pboard connectionForProxy] == c) {
|
if (pboard && [pboard isProxy] && [pboard connectionForProxy] == c)
|
||||||
|
{
|
||||||
o = owner;
|
o = owner;
|
||||||
owner = nil;
|
owner = nil;
|
||||||
[o release];
|
[o release];
|
||||||
|
@ -164,7 +168,8 @@ NSMutableDictionary* pasteboards = nil;
|
||||||
|
|
||||||
- (NSData*) data
|
- (NSData*) data
|
||||||
{
|
{
|
||||||
if (verbose) {
|
if (verbose)
|
||||||
|
{
|
||||||
printf("get data for %x\n", (unsigned)self);
|
printf("get data for %x\n", (unsigned)self);
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
|
@ -172,12 +177,18 @@ NSMutableDictionary* pasteboards = nil;
|
||||||
|
|
||||||
- (NSData*) newDataWithVersion: (int)version
|
- (NSData*) newDataWithVersion: (int)version
|
||||||
{
|
{
|
||||||
if (data == nil && (owner && pboard)) {
|
if (data == nil && (owner && pboard))
|
||||||
if (hasGNUDataForType) {
|
{
|
||||||
[owner pasteboard: pboard provideDataForType: type andVersion: version];
|
if (hasGNUDataForType)
|
||||||
|
{
|
||||||
|
[owner pasteboard: pboard
|
||||||
|
provideDataForType: type
|
||||||
|
andVersion: version];
|
||||||
}
|
}
|
||||||
else if (hasStdDataForType) {
|
else if (hasStdDataForType)
|
||||||
[owner pasteboard: pboard provideDataForType: type];
|
{
|
||||||
|
[owner pasteboard: pboard
|
||||||
|
provideDataForType: type];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return [self data];
|
return [self data];
|
||||||
|
@ -195,7 +206,8 @@ NSMutableDictionary* pasteboards = nil;
|
||||||
|
|
||||||
- (void) setData: (NSData*)d
|
- (void) setData: (NSData*)d
|
||||||
{
|
{
|
||||||
if (verbose) {
|
if (verbose)
|
||||||
|
{
|
||||||
printf("set data for %x\n", (unsigned)self);
|
printf("set data for %x\n", (unsigned)self);
|
||||||
}
|
}
|
||||||
[d retain];
|
[d retain];
|
||||||
|
@ -250,27 +262,32 @@ NSMutableDictionary* pasteboards = nil;
|
||||||
{
|
{
|
||||||
PasteboardEntry* e = [PasteboardEntry alloc];
|
PasteboardEntry* e = [PasteboardEntry alloc];
|
||||||
|
|
||||||
if (e) {
|
if (e)
|
||||||
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
e->owner = [anOwner retain];
|
e->owner = [anOwner retain];
|
||||||
e->pboard = [aPboard retain];
|
e->pboard = [aPboard retain];
|
||||||
|
|
||||||
if (anOwner && [anOwner respondsToSelector:
|
if (anOwner && [anOwner respondsToSelector:
|
||||||
@selector(pasteboardChangedOwner:)]) {
|
@selector(pasteboardChangedOwner:)])
|
||||||
|
{
|
||||||
e->wantsChangedOwner = YES;
|
e->wantsChangedOwner = YES;
|
||||||
}
|
}
|
||||||
if (anOwner && [anOwner respondsToSelector:
|
if (anOwner && [anOwner respondsToSelector:
|
||||||
@selector(pasteboard:provideDataForType:)]) {
|
@selector(pasteboard:provideDataForType:)])
|
||||||
|
{
|
||||||
e->hasStdDataForType = YES;
|
e->hasStdDataForType = YES;
|
||||||
}
|
}
|
||||||
if (anOwner && [anOwner respondsToSelector:
|
if (anOwner && [anOwner respondsToSelector:
|
||||||
@selector(pasteboard:provideDataForType:andVersion:)]) {
|
@selector(pasteboard:provideDataForType:andVersion:)])
|
||||||
|
{
|
||||||
e->hasGNUDataForType = YES;
|
e->hasGNUDataForType = YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
e->items = [[NSMutableArray alloc] initWithCapacity:[someTypes count]];
|
e->items = [[NSMutableArray alloc] initWithCapacity:[someTypes count]];
|
||||||
for (i = 0; i < [someTypes count]; i++) {
|
for (i = 0; i < [someTypes count]; i++)
|
||||||
|
{
|
||||||
NSString* type = [someTypes objectAtIndex:i];
|
NSString* type = [someTypes objectAtIndex:i];
|
||||||
PasteboardData* d;
|
PasteboardData* d;
|
||||||
|
|
||||||
|
@ -296,22 +313,27 @@ NSMutableDictionary* pasteboards = nil;
|
||||||
BOOL GNUData = NO;
|
BOOL GNUData = NO;
|
||||||
|
|
||||||
if (newOwner && [newOwner respondsToSelector:
|
if (newOwner && [newOwner respondsToSelector:
|
||||||
@selector(pasteboardChangedOwner:)]) {
|
@selector(pasteboardChangedOwner:)])
|
||||||
|
{
|
||||||
wants = YES;
|
wants = YES;
|
||||||
}
|
}
|
||||||
if (newOwner && [newOwner respondsToSelector:
|
if (newOwner && [newOwner respondsToSelector:
|
||||||
@selector(pasteboard:provideDataForType:)]) {
|
@selector(pasteboard:provideDataForType:)])
|
||||||
|
{
|
||||||
StdData = YES;
|
StdData = YES;
|
||||||
}
|
}
|
||||||
if (newOwner && [newOwner respondsToSelector:
|
if (newOwner && [newOwner respondsToSelector:
|
||||||
@selector(pasteboard:provideDataForType:andVersion:)]) {
|
@selector(pasteboard:provideDataForType:andVersion:)])
|
||||||
|
{
|
||||||
GNUData = YES;
|
GNUData = YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < [newTypes count]; i++) {
|
for (i = 0; i < [newTypes count]; i++)
|
||||||
|
{
|
||||||
NSString* type = (NSString*)[newTypes objectAtIndex:i];
|
NSString* type = (NSString*)[newTypes objectAtIndex:i];
|
||||||
|
|
||||||
if ([self itemForType:type] == nil) {
|
if ([self itemForType:type] == nil)
|
||||||
|
{
|
||||||
PasteboardData* d;
|
PasteboardData* d;
|
||||||
|
|
||||||
d = [PasteboardData newWithType: type
|
d = [PasteboardData newWithType: type
|
||||||
|
@ -331,7 +353,8 @@ NSMutableDictionary* pasteboards = nil;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
id o;
|
id o;
|
||||||
|
|
||||||
if (owner && [owner isProxy] && [owner connectionForProxy] == c) {
|
if (owner && [owner isProxy] && [owner connectionForProxy] == c)
|
||||||
|
{
|
||||||
o = owner;
|
o = owner;
|
||||||
owner = nil;
|
owner = nil;
|
||||||
[o release];
|
[o release];
|
||||||
|
@ -339,7 +362,8 @@ NSMutableDictionary* pasteboards = nil;
|
||||||
pboard = nil;
|
pboard = nil;
|
||||||
[o release];
|
[o release];
|
||||||
}
|
}
|
||||||
if (pboard && [pboard isProxy] && [pboard connectionForProxy] == c) {
|
if (pboard && [pboard isProxy] && [pboard connectionForProxy] == c)
|
||||||
|
{
|
||||||
o = owner;
|
o = owner;
|
||||||
owner = nil;
|
owner = nil;
|
||||||
[o release];
|
[o release];
|
||||||
|
@ -348,11 +372,13 @@ NSMutableDictionary* pasteboards = nil;
|
||||||
[o release];
|
[o release];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = [items count]; i > 0; i--) {
|
for (i = [items count]; i > 0; i--)
|
||||||
|
{
|
||||||
PasteboardData* d = [items objectAtIndex: i-1];
|
PasteboardData* d = [items objectAtIndex: i-1];
|
||||||
|
|
||||||
[d checkConnection: c];
|
[d checkConnection: c];
|
||||||
if ([d data] == nil && [d owner] == nil) {
|
if ([d data] == nil && [d owner] == nil)
|
||||||
|
{
|
||||||
[items removeObjectAtIndex:i-1];
|
[items removeObjectAtIndex:i-1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -375,10 +401,12 @@ NSMutableDictionary* pasteboards = nil;
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
for (i = 0; i < [items count]; i++) {
|
for (i = 0; i < [items count]; i++)
|
||||||
|
{
|
||||||
PasteboardData* d = [items objectAtIndex:i];
|
PasteboardData* d = [items objectAtIndex:i];
|
||||||
|
|
||||||
if ([[d type] isEqual: type]) {
|
if ([[d type] isEqual: type])
|
||||||
|
{
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -392,28 +420,34 @@ NSMutableDictionary* pasteboards = nil;
|
||||||
|
|
||||||
NS_DURING
|
NS_DURING
|
||||||
{
|
{
|
||||||
if (wantsChangedOwner) {
|
if (wantsChangedOwner)
|
||||||
|
{
|
||||||
[a addObject: owner];
|
[a addObject: owner];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < [items count]; i++) {
|
for (i = 0; i < [items count]; i++)
|
||||||
|
{
|
||||||
PasteboardData* d = [items objectAtIndex:i];
|
PasteboardData* d = [items objectAtIndex:i];
|
||||||
|
|
||||||
if ([d wantsChangedOwner] && [a containsObject: [d owner]] == NO) {
|
if ([d wantsChangedOwner] && [a containsObject: [d owner]] == NO)
|
||||||
|
{
|
||||||
[a addObject: [d owner]];
|
[a addObject: [d owner]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wantsChangedOwner) {
|
if (wantsChangedOwner)
|
||||||
|
{
|
||||||
[a removeObject: owner];
|
[a removeObject: owner];
|
||||||
[owner pasteboardChangedOwner: pboard];
|
[owner pasteboardChangedOwner: pboard];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < [items count] && [a count] > 0; i++) {
|
for (i = 0; i < [items count] && [a count] > 0; i++)
|
||||||
|
{
|
||||||
PasteboardData* d = [items objectAtIndex:i];
|
PasteboardData* d = [items objectAtIndex:i];
|
||||||
id o = [d owner];
|
id o = [d owner];
|
||||||
|
|
||||||
if ([a containsObject: o]) {
|
if ([a containsObject: o])
|
||||||
|
{
|
||||||
[o pasteboardChangedOwner: [d pboard]];
|
[o pasteboardChangedOwner: [d pboard]];
|
||||||
[a removeObject: o];
|
[a removeObject: o];
|
||||||
}
|
}
|
||||||
|
@ -437,7 +471,8 @@ NSMutableDictionary* pasteboards = nil;
|
||||||
NSMutableArray* t = [NSMutableArray arrayWithCapacity: [items count]];
|
NSMutableArray* t = [NSMutableArray arrayWithCapacity: [items count]];
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
for (i = 0; i < [items count]; i++) {
|
for (i = 0; i < [items count]; i++)
|
||||||
|
{
|
||||||
PasteboardData* d = [items objectAtIndex:i];
|
PasteboardData* d = [items objectAtIndex:i];
|
||||||
[t addObject: [d type]];
|
[t addObject: [d type]];
|
||||||
}
|
}
|
||||||
|
@ -499,18 +534,22 @@ NSMutableDictionary* pasteboards = nil;
|
||||||
PasteboardObject* pb;
|
PasteboardObject* pb;
|
||||||
|
|
||||||
[dictionary_lock lock];
|
[dictionary_lock lock];
|
||||||
while (aName == nil) {
|
while (aName == nil)
|
||||||
|
{
|
||||||
aName = [NSString stringWithFormat: @"%dlocalName", number++];
|
aName = [NSString stringWithFormat: @"%dlocalName", number++];
|
||||||
if ([pasteboards objectForKey:aName] == nil) {
|
if ([pasteboards objectForKey:aName] == nil)
|
||||||
|
{
|
||||||
break; // This name is unique.
|
break; // This name is unique.
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
aName = nil; // Name already in use - try another.
|
aName = nil; // Name already in use - try another.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pb = [pasteboards objectForKey: aName];
|
pb = [pasteboards objectForKey: aName];
|
||||||
if (pb == nil) {
|
if (pb == nil)
|
||||||
|
{
|
||||||
pb = [PasteboardObject alloc];
|
pb = [PasteboardObject alloc];
|
||||||
pb->name = [aName retain];
|
pb->name = [aName retain];
|
||||||
pb->nextCount = 1;
|
pb->nextCount = 1;
|
||||||
|
@ -531,7 +570,8 @@ NSMutableDictionary* pasteboards = nil;
|
||||||
{
|
{
|
||||||
PasteboardEntry *e = [self entryByCount:count];
|
PasteboardEntry *e = [self entryByCount:count];
|
||||||
|
|
||||||
if (e) {
|
if (e)
|
||||||
|
{
|
||||||
[e addTypes: types owner: owner pasteboard: pb];
|
[e addTypes: types owner: owner pasteboard: pb];
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
@ -543,20 +583,25 @@ NSMutableDictionary* pasteboards = nil;
|
||||||
{
|
{
|
||||||
PasteboardEntry *e = nil;
|
PasteboardEntry *e = nil;
|
||||||
|
|
||||||
if (*count <= 0) {
|
if (*count <= 0)
|
||||||
|
{
|
||||||
e = current;
|
e = current;
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
e = [self entryByCount:*count];
|
e = [self entryByCount:*count];
|
||||||
}
|
}
|
||||||
if (e) {
|
if (e)
|
||||||
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
*count = [e refNum];
|
*count = [e refNum];
|
||||||
for (i = 0; i < [types count]; i++) {
|
for (i = 0; i < [types count]; i++)
|
||||||
|
{
|
||||||
NSString* key = [types objectAtIndex:i];
|
NSString* key = [types objectAtIndex:i];
|
||||||
|
|
||||||
if ([e itemForType: key] != nil) {
|
if ([e itemForType: key] != nil)
|
||||||
|
{
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -566,7 +611,8 @@ NSMutableDictionary* pasteboards = nil;
|
||||||
|
|
||||||
- (int) changeCount
|
- (int) changeCount
|
||||||
{
|
{
|
||||||
if (current) {
|
if (current)
|
||||||
|
{
|
||||||
return [current refNum];
|
return [current refNum];
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -576,7 +622,8 @@ NSMutableDictionary* pasteboards = nil;
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
for (i = 0; i < [history count]; i++) {
|
for (i = 0; i < [history count]; i++)
|
||||||
|
{
|
||||||
[[history objectAtIndex: i] checkConnection: c];
|
[[history objectAtIndex: i] checkConnection: c];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -587,20 +634,25 @@ NSMutableDictionary* pasteboards = nil;
|
||||||
{
|
{
|
||||||
PasteboardEntry *e = nil;
|
PasteboardEntry *e = nil;
|
||||||
|
|
||||||
if (flag) {
|
if (flag)
|
||||||
|
{
|
||||||
e = current;
|
e = current;
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
e = [self entryByCount:count];
|
e = [self entryByCount:count];
|
||||||
}
|
}
|
||||||
if (verbose) {
|
if (verbose)
|
||||||
|
{
|
||||||
printf("get data for type '%s' version %d\n",
|
printf("get data for type '%s' version %d\n",
|
||||||
[type cString], e ? [e refNum] : -1);
|
[type cString], e ? [e refNum] : -1);
|
||||||
}
|
}
|
||||||
if (e) {
|
if (e)
|
||||||
|
{
|
||||||
PasteboardData* d = [e itemForType: type];
|
PasteboardData* d = [e itemForType: type];
|
||||||
|
|
||||||
if (d) {
|
if (d)
|
||||||
|
{
|
||||||
return [d newDataWithVersion: [e refNum]];
|
return [d newDataWithVersion: [e refNum]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -626,7 +678,8 @@ NSMutableDictionary* pasteboards = nil;
|
||||||
ref:nextCount++];
|
ref:nextCount++];
|
||||||
[history addObject:current];
|
[history addObject:current];
|
||||||
[current release];
|
[current release];
|
||||||
if ([history count] > histLength) {
|
if ([history count] > histLength)
|
||||||
|
{
|
||||||
[history removeObjectAtIndex:0];
|
[history removeObjectAtIndex:0];
|
||||||
}
|
}
|
||||||
[old lostOwnership];
|
[old lostOwnership];
|
||||||
|
@ -636,17 +689,22 @@ NSMutableDictionary* pasteboards = nil;
|
||||||
|
|
||||||
- (PasteboardEntry*) entryByCount: (int)count
|
- (PasteboardEntry*) entryByCount: (int)count
|
||||||
{
|
{
|
||||||
if (current == nil) {
|
if (current == nil)
|
||||||
|
{
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
else if ([current refNum] == count) {
|
else if ([current refNum] == count)
|
||||||
|
{
|
||||||
return current;
|
return current;
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < [history count]; i++) {
|
for (i = 0; i < [history count]; i++)
|
||||||
if ([[history objectAtIndex:i] refNum] == count) {
|
{
|
||||||
|
if ([[history objectAtIndex:i] refNum] == count)
|
||||||
|
{
|
||||||
return (PasteboardEntry*)[history objectAtIndex:i];
|
return (PasteboardEntry*)[history objectAtIndex:i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -676,48 +734,61 @@ NSMutableDictionary* pasteboards = nil;
|
||||||
{
|
{
|
||||||
PasteboardEntry* e;
|
PasteboardEntry* e;
|
||||||
|
|
||||||
if (verbose) {
|
if (verbose)
|
||||||
|
{
|
||||||
printf("set data for type '%s' version %d\n",
|
printf("set data for type '%s' version %d\n",
|
||||||
[type cString], count);
|
[type cString], count);
|
||||||
}
|
}
|
||||||
e = [self entryByCount: count];
|
e = [self entryByCount: count];
|
||||||
if (e) {
|
if (e)
|
||||||
|
{
|
||||||
PasteboardData* d;
|
PasteboardData* d;
|
||||||
|
|
||||||
if (flag) {
|
if (flag)
|
||||||
|
{
|
||||||
d = [e itemForType: NSFileContentsPboardType];
|
d = [e itemForType: NSFileContentsPboardType];
|
||||||
if (d) {
|
if (d)
|
||||||
|
{
|
||||||
[d setData: data];
|
[d setData: data];
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
if (type && [type isEqual: NSFileContentsPboardType] == NO) {
|
if (type && [type isEqual: NSFileContentsPboardType] == NO)
|
||||||
|
{
|
||||||
d = [e itemForType: type];
|
d = [e itemForType: type];
|
||||||
if (d) {
|
if (d)
|
||||||
|
{
|
||||||
[d setData: data];
|
[d setData: data];
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
else if (type) {
|
else if (type)
|
||||||
|
{
|
||||||
d = [e itemForType: type];
|
d = [e itemForType: type];
|
||||||
if (d) {
|
if (d)
|
||||||
|
{
|
||||||
[d setData: data];
|
[d setData: data];
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -728,8 +799,10 @@ NSMutableDictionary* pasteboards = nil;
|
||||||
if (length > MAXHIST) length = MAXHIST;
|
if (length > MAXHIST) length = MAXHIST;
|
||||||
|
|
||||||
histLength = length;
|
histLength = length;
|
||||||
if (length < histLength) {
|
if (length < histLength)
|
||||||
while ([history count] > histLength) {
|
{
|
||||||
|
while ([history count] > histLength)
|
||||||
|
{
|
||||||
[history removeObjectAtIndex:0];
|
[history removeObjectAtIndex:0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -739,13 +812,16 @@ NSMutableDictionary* pasteboards = nil;
|
||||||
{
|
{
|
||||||
PasteboardEntry *e = nil;
|
PasteboardEntry *e = nil;
|
||||||
|
|
||||||
if (*count <= 0) {
|
if (*count <= 0)
|
||||||
|
{
|
||||||
e = current;
|
e = current;
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
e = [self entryByCount:*count];
|
e = [self entryByCount:*count];
|
||||||
}
|
}
|
||||||
if (e) {
|
if (e)
|
||||||
|
{
|
||||||
*count = [e refNum];
|
*count = [e refNum];
|
||||||
return [e types];
|
return [e types];
|
||||||
}
|
}
|
||||||
|
@ -778,8 +854,7 @@ NSMutableDictionary* pasteboards = nil;
|
||||||
|
|
||||||
- (NSConnection*) connection: ancestor didConnect: newConn
|
- (NSConnection*) connection: ancestor didConnect: newConn
|
||||||
{
|
{
|
||||||
[NotificationDispatcher
|
[NotificationDispatcher addObserver: self
|
||||||
addObserver: self
|
|
||||||
selector: @selector(connectionBecameInvalid:)
|
selector: @selector(connectionBecameInvalid:)
|
||||||
name: NSConnectionDidDieNotification
|
name: NSConnectionDidDieNotification
|
||||||
object: newConn];
|
object: newConn];
|
||||||
|
@ -791,15 +866,18 @@ NSMutableDictionary* pasteboards = nil;
|
||||||
{
|
{
|
||||||
id connection = [notification object];
|
id connection = [notification object];
|
||||||
|
|
||||||
if (connection == conn) {
|
if (connection == conn)
|
||||||
|
{
|
||||||
NSLog(@"Help - pasteboard server connection has died!\n");
|
NSLog(@"Help - pasteboard server connection has died!\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if ([connection isKindOf: [NSConnection class]]) {
|
if ([connection isKindOf: [NSConnection class]])
|
||||||
|
{
|
||||||
NSEnumerator *e = [pasteboards objectEnumerator];
|
NSEnumerator *e = [pasteboards objectEnumerator];
|
||||||
PasteboardObject *o;
|
PasteboardObject *o;
|
||||||
|
|
||||||
while ((o = [e nextObject]) != nil) {
|
while ((o = [e nextObject]) != nil)
|
||||||
|
{
|
||||||
[o checkConnection: connection];
|
[o checkConnection: connection];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -815,7 +893,8 @@ NSMutableDictionary* pasteboards = nil;
|
||||||
- init
|
- init
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
if (self) {
|
if (self)
|
||||||
|
{
|
||||||
permenant = [[NSMutableArray alloc] initWithCapacity:5];
|
permenant = [[NSMutableArray alloc] initWithCapacity:5];
|
||||||
/*
|
/*
|
||||||
* Create all the pasteboards which must persist forever and add them
|
* Create all the pasteboards which must persist forever and add them
|
||||||
|
@ -876,14 +955,16 @@ init(int argc, char** argv)
|
||||||
const char *options = "Hdv";
|
const char *options = "Hdv";
|
||||||
int sym;
|
int sym;
|
||||||
|
|
||||||
while ((sym = getopt(argc, argv, options)) != -1) {
|
while ((sym = getopt(argc, argv, options)) != -1)
|
||||||
switch(sym) {
|
{
|
||||||
|
switch(sym)
|
||||||
|
{
|
||||||
case 'H':
|
case 'H':
|
||||||
printf("%s -[%s]\n", argv[0], options);
|
printf("%s -[%s]\n", argv[0], options);
|
||||||
printf("GNU Pasteboard server\n");
|
printf("GNU Pasteboard server\n");
|
||||||
printf("-H for help\n");
|
printf("-H\tfor help\n");
|
||||||
printf("-d avoid fork() to make debugging easy\n");
|
printf("-d\tavoid fork() to make debugging easy\n");
|
||||||
printf("-v More verbose debug output\n");
|
printf("-v\tMore verbose debug output\n");
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|
||||||
case 'd':
|
case 'd':
|
||||||
|
@ -901,7 +982,8 @@ init(int argc, char** argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (sym = 0; sym < 32; sym++) {
|
for (sym = 0; sym < 32; sym++)
|
||||||
|
{
|
||||||
signal(sym, ihandler);
|
signal(sym, ihandler);
|
||||||
}
|
}
|
||||||
signal(SIGPIPE, SIG_IGN);
|
signal(SIGPIPE, SIG_IGN);
|
||||||
|
@ -910,11 +992,13 @@ init(int argc, char** argv)
|
||||||
signal(SIGHUP, SIG_IGN);
|
signal(SIGHUP, SIG_IGN);
|
||||||
signal(SIGTERM, ihandler);
|
signal(SIGTERM, ihandler);
|
||||||
|
|
||||||
if (debug == 0) {
|
if (debug == 0)
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
* Now fork off child process to run in background.
|
* Now fork off child process to run in background.
|
||||||
*/
|
*/
|
||||||
switch (fork()) {
|
switch (fork())
|
||||||
|
{
|
||||||
case -1:
|
case -1:
|
||||||
NSLog(@"gpbs - fork failed - bye.\n");
|
NSLog(@"gpbs - fork failed - bye.\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -931,7 +1015,8 @@ init(int argc, char** argv)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (verbose) {
|
if (verbose)
|
||||||
|
{
|
||||||
NSLog(@"Process backgrounded (running as daemon)\r\n");
|
NSLog(@"Process backgrounded (running as daemon)\r\n");
|
||||||
}
|
}
|
||||||
exit(0);
|
exit(0);
|
||||||
|
@ -943,6 +1028,8 @@ init(int argc, char** argv)
|
||||||
int
|
int
|
||||||
main(int argc, char** argv)
|
main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
|
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
||||||
|
|
||||||
init(argc, argv);
|
init(argc, argv);
|
||||||
|
|
||||||
// [NSObject enableDoubleReleaseCheck: YES];
|
// [NSObject enableDoubleReleaseCheck: YES];
|
||||||
|
@ -976,7 +1063,7 @@ main(int argc, char** argv)
|
||||||
NSLog(@"GNU pasteboard server startup.\n");
|
NSLog(@"GNU pasteboard server startup.\n");
|
||||||
}
|
}
|
||||||
[[NSRunLoop currentRunLoop] run];
|
[[NSRunLoop currentRunLoop] run];
|
||||||
|
[pool release];
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue