mirror of
https://github.com/gnustep/apps-gorm.git
synced 2025-04-23 06:20:47 +00:00
Add accessory view and methods to handle doing XLIFF export from Gorm application
This commit is contained in:
parent
ba6120dbed
commit
08d5367812
12 changed files with 100 additions and 27 deletions
|
@ -2,6 +2,7 @@
|
|||
"## Comment" = "Do NOT change this file, Gorm maintains it";
|
||||
FirstResponder = {
|
||||
Actions = (
|
||||
"addAttributeToClass:",
|
||||
"alignSelectedObjects:",
|
||||
"arrangeSelectedObjects:",
|
||||
"createClassFiles:",
|
||||
|
@ -20,7 +21,7 @@
|
|||
"loadImage:",
|
||||
"loadPalette:",
|
||||
"loadSound:",
|
||||
"addAttributeToClass:",
|
||||
"exportXLIFFDocument:",
|
||||
"orderFrontFontPanel:",
|
||||
"palettes:",
|
||||
"preferencesPanel:",
|
||||
|
@ -103,7 +104,8 @@
|
|||
"instantiateClass:",
|
||||
"loadClass:",
|
||||
"addAttributeToClass:",
|
||||
"remove:"
|
||||
"remove:",
|
||||
"exportXLIFFDocument:"
|
||||
);
|
||||
Outlets = (
|
||||
gormMenu,
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -67,6 +67,7 @@ Gorm_APPLICATION_ICON=Gorm.tiff
|
|||
Gorm_RESOURCE_FILES = \
|
||||
GormInfo.plist \
|
||||
Resources/Defaults.plist \
|
||||
Resources/language-codes.plist \
|
||||
Palettes/0Menus/0Menus.palette \
|
||||
Palettes/1Windows/1Windows.palette \
|
||||
Palettes/2Controls/2Controls.palette \
|
||||
|
@ -89,21 +90,23 @@ Gorm_RESOURCE_FILES = \
|
|||
Images/GormSourceTag.tiff \
|
||||
Images/GormTargetTag.tiff \
|
||||
Images/GormLinkImage.tiff \
|
||||
Images/GormTesting.tiff \
|
||||
|
||||
Images/GormTesting.tiff
|
||||
|
||||
Gorm_LOCALIZED_RESOURCE_FILES = \
|
||||
Gorm.gorm \
|
||||
GormLanguageViewController.gorm \
|
||||
Gorm.rtfd
|
||||
|
||||
Gorm_LANGUAGES = \
|
||||
English
|
||||
|
||||
Gorm_HEADERS = \
|
||||
GormAppDelegate.h
|
||||
GormAppDelegate.h \
|
||||
GormLanguageViewController.h
|
||||
|
||||
Gorm_OBJC_FILES = \
|
||||
GormAppDelegate.m \
|
||||
GormLanguageViewController.m \
|
||||
main.m
|
||||
|
||||
-include GNUmakefile.preamble
|
||||
|
|
|
@ -23,18 +23,28 @@
|
|||
* USA.
|
||||
*/
|
||||
|
||||
#include <GormCore/GormCore.h>
|
||||
#include <GormCore/GormPrefs.h>
|
||||
#ifndef GormAppDelegate_H_INCLUDE
|
||||
#define GormAppDelegate_H_INCLUDE
|
||||
|
||||
#include <GNUstepBase/GSObjCRuntime.h>
|
||||
#import <AppKit/NSSavePanel.h>
|
||||
|
||||
#import <GormCore/GormCore.h>
|
||||
#import <GormCore/GormPrefs.h>
|
||||
|
||||
#import <GNUstepBase/GSObjCRuntime.h>
|
||||
|
||||
@class NSDictionary;
|
||||
@class NSImage;
|
||||
@class NSMenu;
|
||||
@class NSMutableArray;
|
||||
@class NSSet;
|
||||
@class GormLanguageViewController;
|
||||
|
||||
@interface GormAppDelegate : GormAbstractDelegate
|
||||
@interface GormAppDelegate : GormAbstractDelegate <NSOpenSavePanelDelegate>
|
||||
{
|
||||
@private
|
||||
GormLanguageViewController *_vc;
|
||||
}
|
||||
|
||||
// preferences
|
||||
- (IBAction) preferencesPanel: (id) sender;
|
||||
|
@ -74,7 +84,12 @@
|
|||
- (IBAction) palettes: (id) sender;
|
||||
- (IBAction) loadPalette: (id) sender;
|
||||
|
||||
// Translation
|
||||
- (IBAction) exportXLIFFDocument: (id)sender;
|
||||
|
||||
// Print
|
||||
- (IBAction) print: (id)sender;
|
||||
|
||||
@end
|
||||
|
||||
#endif // GormAppDelegate_H_INCLUDE
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#import <AppKit/NSMenu.h>
|
||||
|
||||
#import "GormAppDelegate.h"
|
||||
#import "GormLanguageViewController.h"
|
||||
|
||||
@implementation GormAppDelegate
|
||||
|
||||
|
@ -570,6 +571,48 @@
|
|||
[[self palettesManager] openPalette: sender];
|
||||
}
|
||||
|
||||
// Translation
|
||||
- (IBAction) exportXLIFFDocument: (id)sender;
|
||||
{
|
||||
NSSavePanel *savePanel = [NSSavePanel savePanel];
|
||||
NSBundle *bundle = [NSBundle bundleForClass: [GormLanguageViewController class]];
|
||||
NSModalResponse result = 0;
|
||||
|
||||
_vc = [[GormLanguageViewController alloc] initWithNibName: @"GormLanguageViewController"
|
||||
bundle: bundle];
|
||||
|
||||
|
||||
NSDebugLog(@"view = %@, _vc = %@", [_vc view], _vc);
|
||||
|
||||
[savePanel setTitle: @"Export XLIFF"];
|
||||
[savePanel setAccessoryView: [_vc view]];
|
||||
[savePanel setDelegate: self];
|
||||
|
||||
result = [savePanel runModal];
|
||||
if (NSModalResponseOK == result)
|
||||
{
|
||||
NSString *filename = [[savePanel URL] path];
|
||||
[(GormDocument *)[self activeDocument] exportXLIFFDocumentWithName: filename
|
||||
withSourceLanguage: [_vc sourceLanguageIdentifier]
|
||||
andTargetLanguage: [_vc targetLanguageIdentifier]];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSString *) panel: (id)sender
|
||||
userEnteredFilename: (NSString *)filename
|
||||
confirmed: (BOOL)flag
|
||||
{
|
||||
if (flag == YES)
|
||||
{
|
||||
NSLog(@"Writing the document... %@", filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"%@ not saved", filename);
|
||||
}
|
||||
return filename;
|
||||
}
|
||||
|
||||
// Print
|
||||
|
||||
- (IBAction) print: (id) sender
|
||||
|
|
|
@ -12,6 +12,9 @@
|
|||
IBOutlet id targetLanguage;
|
||||
IBOutlet id sourceLanguage;
|
||||
|
||||
NSString *sourceLanguageIdentifier;
|
||||
NSString *targetLanguageIdentifier;
|
||||
|
||||
NSDictionary *ldict;
|
||||
}
|
||||
|
|
@ -13,25 +13,37 @@
|
|||
|
||||
- (void) viewDidLoad
|
||||
{
|
||||
NSString *path = [[self nibBundle] pathForResource: @"language-codes" ofType: @"plist"];
|
||||
|
||||
[super viewDidLoad];
|
||||
NSBundle *bundle = [NSBundle bundleForClass: [self class]];
|
||||
NSString *path = [bundle pathForResource: @"language-codes" ofType: @"plist"];
|
||||
|
||||
ldict = [[NSDictionary alloc] initWithContentsOfFile: path];
|
||||
if (ldict != nil)
|
||||
[super viewDidLoad];
|
||||
if (path != nil)
|
||||
{
|
||||
NSEnumerator *en = [ldict keyEnumerator];
|
||||
id k = nil;
|
||||
[targetLanguage removeAllItems];
|
||||
[sourceLanguage removeAllItems];
|
||||
|
||||
while ((k = [en nextObject]) != nil)
|
||||
NSLog(@"path = %@", path);
|
||||
|
||||
ldict = [[NSDictionary alloc] initWithContentsOfFile: path];
|
||||
if (ldict != nil)
|
||||
{
|
||||
NSString *v = [ldict objectForKey: k];
|
||||
NSString *itemTitle = [NSString stringWithFormat: @"%@ (%@)", k, v];
|
||||
NSEnumerator *en = [ldict keyEnumerator];
|
||||
id k = nil;
|
||||
|
||||
[targetLanguage addItemWithTitle: itemTitle];
|
||||
[sourceLanguage addItemWithTitle: itemTitle];
|
||||
while ((k = [en nextObject]) != nil)
|
||||
{
|
||||
NSString *v = [ldict objectForKey: k];
|
||||
NSString *itemTitle = [NSString stringWithFormat: @"%@ (%@)", k, v];
|
||||
|
||||
[targetLanguage addItemWithTitle: itemTitle];
|
||||
[sourceLanguage addItemWithTitle: itemTitle];
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"Unable to load language codes");
|
||||
}
|
||||
}
|
||||
|
||||
- (void) dealloc
|
|
@ -65,7 +65,6 @@ GormCore_HEADER_FILES = \
|
|||
GormImageInspector.h \
|
||||
GormInspectorsManager.h \
|
||||
GormInternalViewEditor.h \
|
||||
GormLanguageViewController.h \
|
||||
GormMatrixEditor.h \
|
||||
GormNSPanel.h \
|
||||
GormNSSplitViewInspector.h \
|
||||
|
@ -140,7 +139,6 @@ GormCore_OBJC_FILES = \
|
|||
GormImageInspector.m \
|
||||
GormInspectorsManager.m \
|
||||
GormInternalViewEditor.m \
|
||||
GormLanguageViewController.m \
|
||||
GormMatrixEditor.m \
|
||||
GormNSPanel.m \
|
||||
GormNSSplitViewInspector.m \
|
||||
|
@ -254,9 +252,7 @@ GormCore_RESOURCE_FILES = \
|
|||
Images/tabtop_nib.tiff \
|
||||
Images/titleOnly_nib.tiff \
|
||||
Resources/VersionProfiles.plist \
|
||||
Resources/ClassInformation.plist \
|
||||
Resources/language-codes.plist
|
||||
|
||||
Resources/ClassInformation.plist
|
||||
|
||||
GormCore_LANGUAGES = English
|
||||
|
||||
|
@ -273,7 +269,6 @@ GormCore_LOCALIZED_RESOURCE_FILES = \
|
|||
GormImageInspector.gorm \
|
||||
GormInconsistenciesPanel.gorm \
|
||||
GormInspectorPanel.gorm \
|
||||
GormLanguageViewController.gorm \
|
||||
GormNSSplitViewInspector.gorm \
|
||||
GormObjectInspector.gorm \
|
||||
GormPalettePanel.gorm \
|
||||
|
|
Loading…
Reference in a new issue