Added translation and corrected infinite loop.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@21295 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Gregory John Casamento 2005-06-10 11:43:51 +00:00
parent 5ef54ee51b
commit 9d70705d9d
9 changed files with 97 additions and 75 deletions

View file

@ -1,3 +1,18 @@
2005-06-10 07:45 Gregory John Casamento <greg_casamento@yahoo.com>
* English.lproj/Gorm.gorm: Addition of "Translate" menu.
* GormCore/GormClassInspector.m: Corrected problem in
outlet and action data sources in tableView:setObjectValue:
tableColumn:row:
* GormCore/GormDocument.h: Added translate method, also added
selectClass:editClass: method declarations.
* GormCore/GormDocument.m Added translate method, also added
selectClass:editClass: method implementation.
* GormCore/GormProtocol.h: Added translate method declaration
to call from the menu.
* Gorm.m: Added translate method implementation which simply
calls the method on the currently active document.
2005-06-04 07:41 Gregory John Casamento <greg_casamento@yahoo.com>
* English.lproj/GormClassInspector.gorm: Updated to new .gorm file

View file

@ -2,74 +2,7 @@
"## Comment" = "Do NOT change this file, Gorm maintains it";
FirstResponder = {
Actions = (
"alignCenter:",
"alignLeft:",
"arrangeInFront:",
"capitalizeWord:",
"changeFont:",
"close:",
"copy:",
"copyRuler:",
"delete:",
"deleteForward:",
"deleteToBeginningOfParagraph:",
"deleteToEndOfParagraph:",
"deleteWordBackward:",
"deminiaturize:",
"fax:",
"hideOtherApplications:",
"loosenKerning:",
"lowercaseWord:",
"miniaturize:",
"moveBackward:",
"moveDown:",
"moveForward:",
"moveLeft:",
"moveToBeginningOfDocument:",
"moveToBeginningOfParagraph:",
"moveToEndOfLine:",
"moveUp:",
"moveWordBackward:",
"moveWordForward:",
"newDocument:",
"openDocument:",
"orderFront:",
"orderFrontDataLinkPanel:",
"orderFrontStandardAboutPanel:",
"orderOut:",
"pageUp:",
"pasteAsPlainText:",
"pasteFont:",
"performClose:",
"performZoom:",
"raiseBaseline:",
"runPageLayout:",
"saveAllDocuments:",
"saveDocumentAs:",
"scrollLineDown:",
"scrollPageDown:",
"scrollViaScroller:",
"selectLine:",
"selectParagraph:",
"selectToMark:",
"selectWord:",
"showGuessPanel:",
"showWindow:",
"subscript:",
"swapWithMark:",
"takeFloatValueFrom:",
"takeObjectValueFrom:",
"terminate:",
"toggle:",
"toggleRuler:",
"toggleTraditionalCharacterShape:",
"transposeWords:",
"turnOffLigatures:",
"unhide:",
"unscript:",
"useAllLigatures:",
"useStandardLigatures:",
"zoom:",
"translate:",
"orderFrontFontPanel:"
);
Super = NSObject;
@ -116,7 +49,8 @@
"createClassFiles:",
"loadClass:",
"preferencesPanel:",
"guideline:"
"guideline:",
"translate:"
);
Outlets = (
gormMenu,

Binary file not shown.

Binary file not shown.

5
Gorm.m
View file

@ -1151,6 +1151,11 @@
connectDestination = nil;
}
- (void) translate: (id)sender
{
[[self activeDocument] performSelector: @selector(translate)];
}
- (BOOL) validateMenuItem: (NSMenuItem*)item
{
GormDocument *active = (GormDocument*)[self activeDocument];

View file

@ -111,7 +111,7 @@ objectValueForTableColumn: (NSTableColumn *)tc
NSString *formattedOutlet = formatOutlet( (NSString *)anObject );
GormDocument *document = (GormDocument *)[(id <IB>)NSApp activeDocument];
if(![name isEqual: anObject])
if(![name isEqual: formattedOutlet])
{
BOOL removed = [document
removeConnectionsWithLabel: name
@ -127,7 +127,7 @@ objectValueForTableColumn: (NSTableColumn *)tc
// certain that names in the list are kept in sync.
[document collapseClass: currentClass];
[document reloadClasses];
[document selectClass: currentClass];
[document selectClass: currentClass editClass: NO];
}
}
}
@ -166,7 +166,7 @@ objectValueForTableColumn: (NSTableColumn *)tc
NSString *formattedAction = formatAction( (NSString *)anObject );
GormDocument *document = (GormDocument *)[(id <IB>)NSApp activeDocument];
if(![name isEqual: anObject])
if(![name isEqual: formattedAction])
{
BOOL removed = [document
removeConnectionsWithLabel: name
@ -182,7 +182,7 @@ objectValueForTableColumn: (NSTableColumn *)tc
// certain that names in the list are kept in sync.
[document collapseClass: currentClass];
[document reloadClasses];
[document selectClass: currentClass];
[document selectClass: currentClass editClass: NO];
}
}
}

View file

@ -109,6 +109,7 @@
andFileType: (NSString *)fileType;
- (void) changeToViewWithTag: (int)tag;
- (NSArray *) allManagedPboardTypes;
- (void) translate;
/* Managing classes */
- (GormClassManager*) classManager;
@ -120,6 +121,7 @@
- (id) createClassFiles: (id)sender;
- (id) instantiateClass: (id)sender;
- (void) selectClass: (NSString *)className;
- (void) selectClass: (NSString *)className editClass: (BOOL)flag;
- (BOOL) classIsSelected;
- (void) removeAllInstancesOfClass: (NSString *)classNamed;

View file

@ -1833,6 +1833,14 @@ static NSImage *fileImage = nil;
[classesView selectClass: className];
}
/**
* Select a class in the classes view
*/
- (void) selectClass: (NSString *)className editClass: (BOOL)flag
{
[classesView selectClass: className editClass: flag];
}
/**
* The sole purpose of this method is to clean up .gorm files from older
* versions of Gorm which might have some dangling references. This method
@ -1933,7 +1941,10 @@ static NSImage *fileImage = nil;
NSDictionary *substituteClasses = [palettesManager substituteClasses];
NSEnumerator *en = [substituteClasses keyEnumerator];
NSString *subClassName = nil;
unsigned int version = NSNotFound;
unsigned int
version = NSNotFound,
winversion = NSNotFound,
panversion = NSNotFound;
// If someone attempts to open a .gmodel using open or in a
// workspace manager, open it.. otherwise open the .gorm file.
@ -2142,7 +2153,9 @@ static NSImage *fileImage = nil;
* it was made by an older version of Gorm.
*/
version = [u versionForClassName: NSStringFromClass([GSWindowTemplate class])];
if(version == 0 || version == NSNotFound)
winversion = [u versionForClassName: NSStringFromClass([NSWindow class])];
panversion = [u versionForClassName: NSStringFromClass([NSPanel class])];
if(version == NSNotFound && (winversion != NSNotFound || panversion != NSNotFound))
{
isOlderArchive = YES;
}
@ -3794,6 +3807,58 @@ static NSImage *fileImage = nil;
return allTypes;
}
// language translation
- (void) translate
{
NSArray *fileTypes = [NSArray arrayWithObjects: @"strings", nil];
NSOpenPanel *oPanel = [NSOpenPanel openPanel];
int result;
[oPanel setAllowsMultipleSelection: NO];
[oPanel setCanChooseFiles: YES];
[oPanel setCanChooseDirectories: NO];
result = [oPanel runModalForDirectory: nil
file: nil
types: fileTypes];
if (result == NSOKButton)
{
NSString *filename = [oPanel filename];
NSDictionary *dictionary = [[NSString stringWithContentsOfFile: filename] propertyListFromStringsFileFormat];
NSEnumerator *en = [[self objects] objectEnumerator];
id obj = nil;
BOOL touched = NO;
while((obj = [en nextObject]) != nil)
{
if([obj respondsToSelector: @selector(setTitle:)] &&
[obj respondsToSelector: @selector(title)])
{
NSString *translation = [dictionary objectForKey: [obj title]];
if(translation != nil)
{
[obj setTitle: translation];
touched = YES;
}
}
else if([obj respondsToSelector: @selector(setStringValue:)] &&
[obj respondsToSelector: @selector(stringValue)])
{
NSString *translation = [dictionary objectForKey: [obj stringValue]];
if(translation != nil)
{
[obj setStringValue: translation];
touched = YES;
}
}
}
if(touched)
{
[self touch];
}
}
}
@end
@implementation GormDocument (MenuValidation)

View file

@ -86,6 +86,7 @@
// utility...
- (BOOL) documentNameIsUnique: (NSString *)filename;
- (void) translate: (id)sender;
@end
#endif