Hi,
In NSApplication: -setMainMenu, we search for setting our _windows_menu
ivar by comparing the title of the menu items of the main menu with
@"Windows" and @"Window".
Everything is fine except when your run an application that has been
translated to an other language and the menu item is not "Windows" (like
"Fen�tres" in french).
In that case, _windows_menu will always be nil and
NSApplication: -changeWindowsItem: title: filename: won't do anything
(ie., we won't have the list of opened windows in the [NSApplication
-windowsMenu]).
This problem comes from the fact that we are sharing the main menu for
each language. This problem is easy fixable if we use a "main nib" for
each different languages (like under OPENSTEP and MacOS-X) with its own
menu.
To fix this problem under GNUstep (if we don't want to use nibs for now),
I think we should introduce an ivar:
NSString *_windows_menu_title;
and a method:
- (void) setWindowsMenuTitle: (NSString *) theTitle; (that sets the ivar).
By default, this ivar will be set to "Windows". A developer could do
for example:
[NSApp setWindowsMenuTitle: @"Fen�tres"] (or any string it a different
language)
[NSApp setMainMenu: myMainMenu];
and things would be fine.
I've attached a small patch for NSApplicatio.{h,m}.
Anyone wants to share his/her opinion on this?
Ludo
--
Live as if you were to die tomorrow.
Learn as if you were to live forever.
- Gandhi
--- /tmp/gui/Headers/gnustep/gui/NSApplication.h Mon Sep 17 08:07:04 2001
+++ NSApplication.h Thu Nov 15 14:38:32 2001
@@ -82,6 +82,7 @@
NSMutableArray *_inactive;
NSWindow *_hidden_key;
GSInfoPanel *_infoPanel;
+ NSString *_windows_menu_title;
}
/*
@@ -296,6 +297,7 @@
#ifndef NO_GNUSTEP
- (NSWindow*) iconWindow;
+- (void) setWindowsMenuTitle: (NSString *) theTitle;
#endif
@end
--- /tmp/gui/Source/NSApplication.m Mon Sep 17 08:09:03 2001
+++ NSApplication.m Thu Nov 15 14:43:11 2001
@@ -523,6 +523,9 @@
RELEASE (_app_init_pool);
}
+
+ _windows_menu_title = @"Windows";
+
return self;
}
@@ -1777,7 +1780,8 @@
anItem = [menuItems objectAtIndex: i];
/* "Window" is for compatibility with menus ported from apple */
if (([[anItem title] compare: @"Windows"] == NSOrderedSame)
- || ([[anItem title] compare: @"Window"] == NSOrderedSame))
+ || ([[anItem title] compare: @"Window"] == NSOrderedSame)
+ || ([[anItem title] compare: _windows_menu_title] == NSOrderedSame) )
{
_windows_menu = anItem;
break;
@@ -1943,6 +1947,14 @@
}
}
+- (void) setWindowsMenuTitle: (NSString *) theTitle
+{
+ if (theTitle)
+ {
+ _windows_menu_title = theTitle;
+ }
+}
+
- (void) setWindowsMenu: (NSMenu*)aMenu
{
NSMenuItem *anItem;
@@ -1959,7 +1971,9 @@
for (i = 0; i < count; ++i)
{
anItem = [itemArray objectAtIndex: i];
- if ([[anItem title] compare: @"Windows"] == NSOrderedSame)
+ if ([[anItem title] compare: @"Windows"] == NSOrderedSame ||
+ [[anItem title] compare: @"Window"] == NSOrderedSame ||
+ [[anItem title] compare: _windows_menu_title] == NSOrderedSame)
{
_windows_menu = anItem;
break;
@@ -1967,7 +1981,7 @@
}
if (_windows_menu == nil)
{
- _windows_menu = [_main_menu insertItemWithTitle: @"Windows"
+ _windows_menu = [_main_menu insertItemWithTitle: _windows_menu_title
action: 0
keyEquivalent: @""
atIndex: count];