Add auto-stop option

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@24789 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2007-03-06 21:44:40 +00:00
parent f11c2117f3
commit a069984c71
5 changed files with 5094 additions and 4449 deletions

View file

@ -1,3 +1,11 @@
2007-03-06 Richard Frith-Macdonald <rfm@gnu.org>
* configure.ac: Add check for syslog
* config.h.in: regenerate
* configure: regenerate
* Tools/gpbs.m: add --auto option to shut down when all connections
from apps requiring pasteboard services are closed.
2007-03-02 Fred Kiefer <FredKiefer@gmx.de>
* Source/cairo/CairoGState.m (-DPSinitmatrix, -GSCurrentCTM):

View file

@ -25,6 +25,7 @@
#include <Foundation/Foundation.h>
#include <AppKit/NSPasteboard.h>
#include <GNUstepGUI/GSPasteboardServer.h>
#include "config.h"
#include <fcntl.h>
#ifdef HAVE_SYSLOG_H
@ -44,11 +45,14 @@
#endif
static BOOL is_daemon = NO; /* Currently running as daemon. */
static BOOL auto_stop = NO; /* Stop when all connections closed. */
static char ebuf[2048];
static NSMutableArray *connections = nil;
#ifdef HAVE_SYSLOG
static int log_priority;
static int log_priority = LOG_DEBUG;
static void
gpbs_log (int prio)
@ -779,9 +783,19 @@ NSMutableDictionary *pasteboards = nil;
if ([owner isProxy] == YES)
{
Protocol *p = @protocol(GSPasteboardCallback);
Protocol *p = @protocol(GSPasteboardCallback);
NSConnection *c = [owner connectionForProxy];
[owner setProtocolForProxy: p];
/* If this is on a connection we don't know about, add it to our
* list of pasteboard connections so that we can track its removal
* in order to auto_stop if necessary.
*/
if ([connections indexOfObjectIdenticalTo: c] == NSNotFound)
{
[connections addObject: c];
}
}
/*
* If neither the new nor the old owner of the pasteboard is the X
@ -1002,14 +1016,19 @@ NSMutableDictionary *pasteboards = nil;
}
if ([connection isKindOfClass: [NSConnection class]])
{
NSEnumerator *e = [pasteboards objectEnumerator];
PasteboardObject *o;
NSEnumerator *e = [pasteboards objectEnumerator];
PasteboardObject *o;
while ((o = [e nextObject]) != nil)
{
[o checkConnection: connection];
}
}
[connections removeObjectIdenticalTo: connection];
if (auto_stop == YES && [connections count] == 0)
{
exit(EXIT_SUCCESS);
}
return self;
}
@ -1079,11 +1098,11 @@ ihandler(int sig)
const char *e;
/*
* Prevent recursion.
*/
if (beenHere == YES)
{
abort();
* Prevent recursion.
*/
if (beenHere == YES)
{
abort();
}
beenHere = YES;
@ -1148,6 +1167,10 @@ init(int argc, char** argv, char **env)
printf("--verbose\tMore verbose debug output\n");
exit(EXIT_SUCCESS);
}
else if ([a isEqualToString: @"--auto"] == YES)
{
auto_stop = YES;
}
else if ([a isEqualToString: @"--daemon"] == YES)
{
is_daemon = YES;
@ -1265,6 +1288,8 @@ main(int argc, char** argv, char **env)
name: NSConnectionDidDieNotification
object: (id)conn];
connections = [NSMutableArray new];
hostname = [[NSUserDefaults standardUserDefaults] stringForKey: @"NSHost"];
if ([hostname length] == 0
|| [[NSHost hostWithName: hostname] isEqual: [NSHost currentHost]] == YES)

View file

@ -23,9 +23,12 @@
/* Define if you have FcPatternCreate */
#undef HAVE_FC
/* Define if you have glitz */
/* Define if you have glitz-glx */
#undef HAVE_GLITZ_GLX
/* Define if you have glitz-wgl */
#undef HAVE_GLITZ_WGL
/* Define if you have the glx library */
#undef HAVE_GLX
@ -59,6 +62,12 @@
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the `syslog' function. */
#undef HAVE_SYSLOG
/* Define to 1 if you have the <syslog.h> header file. */
#undef HAVE_SYSLOG_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
@ -74,6 +83,9 @@
/* Define if you have XftDrawStringUtf8 */
#undef HAVE_UTF8
/* Define if you have the wgl library */
#undef HAVE_WGL
/* Define to 1 if you have the <X11/extensions/XShm.h> header file. */
#undef HAVE_X11_EXTENSIONS_XSHM_H

9472
configure vendored

File diff suppressed because it is too large Load diff

View file

@ -100,6 +100,12 @@ case "$target_os" in
LDFLAGS="$LDFLAGS -Wl,-R/usr/pkg/lib -L/usr/pkg/lib";;
esac
#--------------------------------------------------------------------
# These headers/functions needed by gpbs.m
#--------------------------------------------------------------------
AC_CHECK_HEADERS(syslog.h)
AC_CHECK_FUNCS(syslog)
#--------------------------------------------------------------------
# Find TIFF (Solaris requires this to find the correct library, even though
# it does not link directly to it)