Test closing all apps

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@22375 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-Macdonald 2006-01-27 17:46:46 +00:00
parent bf85ef94ae
commit b4882e2268
5 changed files with 90 additions and 3 deletions

View file

@ -7,6 +7,11 @@
workspace manager process to do it.
Try to be consistent about asking workspace manager application to
perform tasks for us if it exists.
* Tools/gscloseall.m: Test tool to iterate through launched apps and
terminate them all.
* Tools/GNUmakefile:
* Tools/GNUmakefile.preamble:
Build new utility.
2006-01-22 Fred Kiefer <FredKiefer@gmx.de>

View file

@ -29,10 +29,12 @@ include ../config.make
include ../Version
SUBPROJECTS = $(BUILD_GSND)
TOOL_NAME = make_services set_show_service gopen gclose
TOOL_NAME = make_services set_show_service gopen gclose gcloseall
SERVICE_NAME = GSspell
# The source files to be compiled
gcloseall_OBJC_FILES = gcloseall.m
gclose_OBJC_FILES = gclose.m
gopen_OBJC_FILES = gopen.m

View file

@ -35,6 +35,7 @@ ADDITIONAL_LIB_DIRS += -L../Source/$(GNUSTEP_OBJ_DIR) -L../Model/$(GNUSTEP_OBJ_D
gpbs_TOOL_LIBS += -lgnustep-gui $(SYSTEM_LIBS)
set_show_service_TOOL_LIBS += -lgnustep-gui $(SYSTEM_LIBS)
gopen_TOOL_LIBS += -lgnustep-gui $(SYSTEM_LIBS)
gcloseall_TOOL_LIBS += -lgnustep-gui $(SYSTEM_LIBS)
GSspell_TOOL_LIBS += $(ADDITIONAL_DEPENDS)
# Additional libraries when linking applications

View file

@ -1,5 +1,4 @@
/* This tool opens the appropriate application from the command line
based on what type of file is being accessed.
/* This tool terminates a named application from the command line
Copyright (C) 2001 Free Software Foundation, Inc.

80
Tools/gcloseall.m Normal file
View file

@ -0,0 +1,80 @@
/* This tool terminates all applications.
Copyright (C) 2006 Free Software Foundation, Inc.
Written by: Richard Frith-Macdoanld <rfm@gnu.org>
Created: January 2006
This file is part of the GNUstep Project
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
You should have received a copy of the GNU General Public
License along with this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <Foundation/NSArray.h>
#include <Foundation/NSConnection.h>
#include <Foundation/NSString.h>
#include <Foundation/NSAutoreleasePool.h>
#include <Foundation/NSException.h>
#include <AppKit/NSApplication.h>
#include <AppKit/NSWorkspace.h>
int
main(int argc, char** argv, char **env_c)
{
CREATE_AUTORELEASE_POOL(pool);
NSWorkspace *workspace;
NSEnumerator *enumerator;
NSArray *launched;
NSDictionary *info;
#ifdef GS_PASS_ARGUMENTS
[NSProcessInfo initializeWithArguments:argv count:argc environment:env_c];
#endif
workspace = [NSWorkspace sharedWorkspace];
launched = [workspace launchedApplications];
enumerator = [launched objectEnumerator];
while ((info = [enumerator nextObject]) != nil)
{
NSString *port = [info objectForKey: @"NSApplicationName"];
GSPrintf(stdout, @"Terminating '%@'\n", port);
NS_DURING
{
id app;
/*
* Try to contact a running application.
*/
app = [NSConnection
rootProxyForConnectionWithRegisteredName: port host: @""];
NS_DURING
{
[app terminate: nil];
}
NS_HANDLER
{
/* maybe it terminated. */
}
NS_ENDHANDLER
}
NS_HANDLER
{
NSLog(@"Exception while attempting to terminate %@ - %@: %@",
port, [localException name], [localException reason]);
}
NS_ENDHANDLER
}
RELEASE(pool);
exit(EXIT_SUCCESS);
}