mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-26 05:40:56 +00:00
Implemented GSGuiBundle(); localized messages
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@11877 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
dc218d2c02
commit
f240a27224
1 changed files with 57 additions and 21 deletions
|
@ -71,6 +71,7 @@
|
||||||
#include <AppKit/NSDataLinkPanel.h>
|
#include <AppKit/NSDataLinkPanel.h>
|
||||||
#include <AppKit/NSHelpManager.h>
|
#include <AppKit/NSHelpManager.h>
|
||||||
|
|
||||||
|
#include <AppKit/GSGuiPrivate.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Base library exception handler
|
* Base library exception handler
|
||||||
|
@ -106,10 +107,15 @@ _NSAppKitUncaughtExceptionHandler (NSException *exception)
|
||||||
}
|
}
|
||||||
|
|
||||||
retVal = NSRunCriticalAlertPanel
|
retVal = NSRunCriticalAlertPanel
|
||||||
([NSString stringWithFormat: @"Critical Error in %@",
|
([NSString stringWithFormat:
|
||||||
|
GSGuiLocalizedString (@"Critical Error in %@", @""),
|
||||||
[[NSProcessInfo processInfo] processName]],
|
[[NSProcessInfo processInfo] processName]],
|
||||||
@"%@: %@", @"Abort", @"Ignore", DEBUG_BUTTON,
|
@"%@: %@",
|
||||||
[exception name], [exception reason]);
|
GSGuiLocalizedString (@"Abort", @""),
|
||||||
|
GSGuiLocalizedString (@"Ignore", @""),
|
||||||
|
GSGuiLocalizedString (DEBUG_BUTTON, @""),
|
||||||
|
[exception name],
|
||||||
|
[exception reason]);
|
||||||
|
|
||||||
/* The user wants to abort */
|
/* The user wants to abort */
|
||||||
if (retVal == NSAlertDefault)
|
if (retVal == NSAlertDefault)
|
||||||
|
@ -129,6 +135,15 @@ _NSAppKitUncaughtExceptionHandler (NSException *exception)
|
||||||
NSSetUncaughtExceptionHandler (_NSAppKitUncaughtExceptionHandler);
|
NSSetUncaughtExceptionHandler (_NSAppKitUncaughtExceptionHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* This is the bundle from where we load localization of messages. */
|
||||||
|
static NSBundle *guiBundle = nil;
|
||||||
|
|
||||||
|
/* Get the bundle. */
|
||||||
|
NSBundle *GSGuiBundle ()
|
||||||
|
{
|
||||||
|
return guiBundle;
|
||||||
|
}
|
||||||
|
|
||||||
@interface GSBackend : NSGraphicsContext
|
@interface GSBackend : NSGraphicsContext
|
||||||
{}
|
{}
|
||||||
+ (void) initializeBackend;
|
+ (void) initializeBackend;
|
||||||
|
@ -139,7 +154,7 @@ initialize_gnustep_backend(void)
|
||||||
{
|
{
|
||||||
static int first = 1;
|
static int first = 1;
|
||||||
|
|
||||||
if( first )
|
if (first)
|
||||||
{
|
{
|
||||||
Class backend;
|
Class backend;
|
||||||
|
|
||||||
|
@ -169,20 +184,25 @@ initialize_gnustep_backend(void)
|
||||||
break;
|
break;
|
||||||
path = nil;
|
path = nil;
|
||||||
}
|
}
|
||||||
NSCAssert(path != nil, @"Unable to load backend, aborting");
|
NSCAssert(path != nil,
|
||||||
|
GSGuiLocalizedString (@"Unable to load backend, aborting",
|
||||||
|
nil));
|
||||||
NSDebugLog(@"Loading Backend from %@", path);
|
NSDebugLog(@"Loading Backend from %@", path);
|
||||||
|
|
||||||
theBundle = [NSBundle bundleWithPath: path];
|
theBundle = [NSBundle bundleWithPath: path];
|
||||||
NSCAssert(theBundle != nil, @"Can't init backend bundle");
|
NSCAssert(theBundle != nil,
|
||||||
|
GSGuiLocalizedString (@"Can't init backend bundle", nil));
|
||||||
backend = [theBundle classNamed: @"GSBackend"];
|
backend = [theBundle classNamed: @"GSBackend"];
|
||||||
NSCAssert(backend, @"Can't load backend bundle");
|
NSCAssert(backend,
|
||||||
|
GSGuiLocalizedString (@"Can't load backend bundle", nil));
|
||||||
[backend initializeBackend];
|
[backend initializeBackend];
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
/* GSBackend will be in a separate library, so use the runtime
|
/* GSBackend will be in a separate library, so use the runtime
|
||||||
to find the class and avoid an unresolved reference problem */
|
to find the class and avoid an unresolved reference problem */
|
||||||
backend = [[NSBundle gnustepBundle] classNamed: @"GSBackend"];
|
backend = [[NSBundle gnustepBundle] classNamed: @"GSBackend"];
|
||||||
NSCAssert(backend, @"Can't find backend context");
|
NSCAssert(backend, GSGuiLocalizedString (@"Can't find backend context",
|
||||||
|
nil));
|
||||||
[backend initializeBackend];
|
[backend initializeBackend];
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -246,7 +266,7 @@ NSApplication *NSApp = nil;
|
||||||
{
|
{
|
||||||
if (place == NSWindowOut)
|
if (place == NSWindowOut)
|
||||||
{
|
{
|
||||||
NSLog(@"Argh - icon window ordered out");
|
NSLog (@"Argh - icon window ordered out");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -430,7 +450,10 @@ static NSCell* tileCell = nil;
|
||||||
|
|
||||||
NSDebugLog(@"Initialize NSApplication class\n");
|
NSDebugLog(@"Initialize NSApplication class\n");
|
||||||
[self setVersion: 1];
|
[self setVersion: 1];
|
||||||
|
|
||||||
|
/* Create the gui bundle we use to localize messages. */
|
||||||
|
guiBundle = [NSBundle bundleForLibrary: @"gnustep-gui"];
|
||||||
|
|
||||||
/* Save the base library exception handler */
|
/* Save the base library exception handler */
|
||||||
defaultUncaughtExceptionHandler = NSGetUncaughtExceptionHandler ();
|
defaultUncaughtExceptionHandler = NSGetUncaughtExceptionHandler ();
|
||||||
|
|
||||||
|
@ -486,7 +509,8 @@ static NSCell* tileCell = nil;
|
||||||
NSApp = self;
|
NSApp = self;
|
||||||
if (NSApp == nil)
|
if (NSApp == nil)
|
||||||
{
|
{
|
||||||
NSLog(@"Cannot allocate the application instance!\n");
|
NSLog(GSGuiLocalizedString
|
||||||
|
(@"Cannot allocate the application instance!\n", nil));
|
||||||
RELEASE (_app_init_pool);
|
RELEASE (_app_init_pool);
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
@ -552,7 +576,8 @@ static NSCell* tileCell = nil;
|
||||||
{
|
{
|
||||||
if ([NSBundle loadNibNamed: mainModelFile owner: self] == NO)
|
if ([NSBundle loadNibNamed: mainModelFile owner: self] == NO)
|
||||||
{
|
{
|
||||||
NSLog (@"Cannot load the main model file '%@'", mainModelFile);
|
NSLog (GSGuiLocalizedString (@"Cannot load the main model file '%@'",
|
||||||
|
nil), mainModelFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -667,7 +692,8 @@ static NSCell* tileCell = nil;
|
||||||
object: workspace
|
object: workspace
|
||||||
userInfo: userInfo];
|
userInfo: userInfo];
|
||||||
NS_HANDLER
|
NS_HANDLER
|
||||||
NSLog(@"Problem during launch app notification: %@",
|
NSLog(GSGuiLocalizedString (@"Problem during launch app notification: %@",
|
||||||
|
nil),
|
||||||
[localException reason]);
|
[localException reason]);
|
||||||
[localException raise];
|
[localException raise];
|
||||||
NS_ENDHANDLER
|
NS_ENDHANDLER
|
||||||
|
@ -1730,7 +1756,8 @@ IF_NO_GC(NSAssert([event retainCount] > 0, NSInternalInconsistencyException));
|
||||||
if (_infoPanel == nil)
|
if (_infoPanel == nil)
|
||||||
_infoPanel = [[GSInfoPanel alloc] initWithDictionary: options];
|
_infoPanel = [[GSInfoPanel alloc] initWithDictionary: options];
|
||||||
|
|
||||||
[_infoPanel setTitle: @"Info"];
|
[_infoPanel setTitle: GSGuiLocalizedString (@"Info",
|
||||||
|
@"Title of the Info Panel")];
|
||||||
[_infoPanel orderFront: self];
|
[_infoPanel orderFront: self];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1770,10 +1797,14 @@ IF_NO_GC(NSAssert([event retainCount] > 0, NSInternalInconsistencyException));
|
||||||
_windows_menu = nil;
|
_windows_menu = nil;
|
||||||
for (i = 0; i < j; ++i)
|
for (i = 0; i < j; ++i)
|
||||||
{
|
{
|
||||||
|
NSString *title;
|
||||||
anItem = [menuItems objectAtIndex: i];
|
anItem = [menuItems objectAtIndex: i];
|
||||||
|
title = [anItem title];
|
||||||
/* "Window" is for compatibility with menus ported from apple */
|
/* "Window" is for compatibility with menus ported from apple */
|
||||||
if (([[anItem title] compare: @"Windows"] == NSOrderedSame)
|
if (([title compare: GSGuiLocalizedString (@"Windows",
|
||||||
|| ([[anItem title] compare: @"Window"] == NSOrderedSame))
|
@"Title of Windows menu")]
|
||||||
|
== NSOrderedSame)
|
||||||
|
|| ([title compare: @"Window"] == NSOrderedSame))
|
||||||
{
|
{
|
||||||
_windows_menu = anItem;
|
_windows_menu = anItem;
|
||||||
break;
|
break;
|
||||||
|
@ -1955,7 +1986,8 @@ IF_NO_GC(NSAssert([event retainCount] > 0, NSInternalInconsistencyException));
|
||||||
for (i = 0; i < count; ++i)
|
for (i = 0; i < count; ++i)
|
||||||
{
|
{
|
||||||
anItem = [itemArray objectAtIndex: i];
|
anItem = [itemArray objectAtIndex: i];
|
||||||
if ([[anItem title] compare: @"Windows"] == NSOrderedSame)
|
if ([[anItem title] compare: GSGuiLocalizedString (@"Windows", nil)]
|
||||||
|
== NSOrderedSame)
|
||||||
{
|
{
|
||||||
_windows_menu = anItem;
|
_windows_menu = anItem;
|
||||||
break;
|
break;
|
||||||
|
@ -1963,7 +1995,8 @@ IF_NO_GC(NSAssert([event retainCount] > 0, NSInternalInconsistencyException));
|
||||||
}
|
}
|
||||||
if (_windows_menu == nil)
|
if (_windows_menu == nil)
|
||||||
{
|
{
|
||||||
_windows_menu = [_main_menu insertItemWithTitle: @"Windows"
|
_windows_menu = [_main_menu insertItemWithTitle:
|
||||||
|
GSGuiLocalizedString (@"Windows", nil)
|
||||||
action: 0
|
action: 0
|
||||||
keyEquivalent: @""
|
keyEquivalent: @""
|
||||||
atIndex: count];
|
atIndex: count];
|
||||||
|
@ -2148,7 +2181,7 @@ IF_NO_GC(NSAssert([event retainCount] > 0, NSInternalInconsistencyException));
|
||||||
- (void) reportException: (NSException *)anException
|
- (void) reportException: (NSException *)anException
|
||||||
{
|
{
|
||||||
if (anException)
|
if (anException)
|
||||||
NSLog(@"reported exception - %@", anException);
|
NSLog(GSGuiLocalizedString (@"reported exception - %@", nil), anException);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -2162,7 +2195,9 @@ IF_NO_GC(NSAssert([event retainCount] > 0, NSInternalInconsistencyException));
|
||||||
shouldTerminate = [_delegate applicationShouldTerminate: sender];
|
shouldTerminate = [_delegate applicationShouldTerminate: sender];
|
||||||
else
|
else
|
||||||
shouldTerminate = [[NSDocumentController sharedDocumentController]
|
shouldTerminate = [[NSDocumentController sharedDocumentController]
|
||||||
reviewUnsavedDocumentsWithAlertTitle:@"Quit" cancellable:YES];
|
reviewUnsavedDocumentsWithAlertTitle:
|
||||||
|
GSGuiLocalizedString (@"Quit", nil)
|
||||||
|
cancellable:YES];
|
||||||
|
|
||||||
if (shouldTerminate)
|
if (shouldTerminate)
|
||||||
{
|
{
|
||||||
|
@ -2178,7 +2213,8 @@ IF_NO_GC(NSAssert([event retainCount] > 0, NSInternalInconsistencyException));
|
||||||
|
|
||||||
// Tell the Workspace that we really did terminate
|
// Tell the Workspace that we really did terminate
|
||||||
userInfo = [NSDictionary dictionaryWithObject:
|
userInfo = [NSDictionary dictionaryWithObject:
|
||||||
[[NSProcessInfo processInfo] processName] forKey: @"NSApplicationName"];
|
[[NSProcessInfo processInfo] processName] forKey:
|
||||||
|
@"NSApplicationName"];
|
||||||
[[workspace notificationCenter]
|
[[workspace notificationCenter]
|
||||||
postNotificationName: NSWorkspaceDidTerminateApplicationNotification
|
postNotificationName: NSWorkspaceDidTerminateApplicationNotification
|
||||||
object: workspace
|
object: workspace
|
||||||
|
|
Loading…
Reference in a new issue