mirror of
https://github.com/gnustep/apps-gorm.git
synced 2025-02-23 19:51:00 +00:00
Add code to populate the popup button
This commit is contained in:
parent
60a88356cb
commit
ba6120dbed
2 changed files with 74 additions and 6 deletions
|
@ -1,17 +1,27 @@
|
|||
/* All rights reserved */
|
||||
|
||||
#ifndef GormLanguageController_H_INCLUDE
|
||||
#define GormLanguageController_H_INCLUDE
|
||||
#ifndef GormLanguageViewController_H_INCLUDE
|
||||
#define GormLanguageViewController_H_INCLUDE
|
||||
|
||||
#import <AppKit/NSViewController.h>
|
||||
#import <AppKit/NSPopUpButton.h>
|
||||
|
||||
@class NSDictionary, NSString;
|
||||
|
||||
@interface GormLanguageViewController : NSViewController
|
||||
{
|
||||
IBOutlet NSPopUpButton *sourceLanguage;
|
||||
IBOutlet NSPopUpButton *targetLanguage;
|
||||
IBOutlet id targetLanguage;
|
||||
IBOutlet id sourceLanguage;
|
||||
|
||||
NSDictionary *ldict;
|
||||
}
|
||||
|
||||
- (IBAction) updateTargetLanguage: (id)sender;
|
||||
- (IBAction) updateSourceLanguage: (id)sender;
|
||||
|
||||
- (NSString *) sourceLanguageIdentifier;
|
||||
- (NSString *) targetLanguageIdentifier;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
#endif // GormLanguageController_H_INCLUDE
|
||||
#endif // GormLanguageViewController_H_INCLUDE
|
||||
|
|
|
@ -1,7 +1,65 @@
|
|||
/* All rights reserved */
|
||||
|
||||
|
||||
#import <Foundation/NSString.h>
|
||||
#import <Foundation/NSDictionary.h>
|
||||
#import <Foundation/NSBundle.h>
|
||||
|
||||
#import <AppKit/NSPopUpButton.h>
|
||||
|
||||
#import "GormLanguageViewController.h"
|
||||
|
||||
@implementation GormLanguageViewController
|
||||
|
||||
- (void) viewDidLoad
|
||||
{
|
||||
NSString *path = [[self nibBundle] pathForResource: @"language-codes" ofType: @"plist"];
|
||||
|
||||
[super viewDidLoad];
|
||||
|
||||
ldict = [[NSDictionary alloc] initWithContentsOfFile: path];
|
||||
if (ldict != nil)
|
||||
{
|
||||
NSEnumerator *en = [ldict keyEnumerator];
|
||||
id k = nil;
|
||||
|
||||
while ((k = [en nextObject]) != nil)
|
||||
{
|
||||
NSString *v = [ldict objectForKey: k];
|
||||
NSString *itemTitle = [NSString stringWithFormat: @"%@ (%@)", k, v];
|
||||
|
||||
[targetLanguage addItemWithTitle: itemTitle];
|
||||
[sourceLanguage addItemWithTitle: itemTitle];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
RELEASE(ldict);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (IBAction) updateTargetLanguage: (id)sender
|
||||
{
|
||||
// Nothing yet...
|
||||
}
|
||||
|
||||
- (IBAction) updateSourceLanguage: (id)sender
|
||||
{
|
||||
// Nothing yet...
|
||||
}
|
||||
|
||||
- (NSString *) sourceLanguageIdentifier
|
||||
{
|
||||
NSInteger i = [sourceLanguage indexOfSelectedItem];
|
||||
return [[ldict allKeys] objectAtIndex: i];
|
||||
}
|
||||
|
||||
- (NSString *) targetLanguageIdentifier
|
||||
{
|
||||
NSInteger i = [sourceLanguage indexOfSelectedItem];
|
||||
return [[ldict allKeys] objectAtIndex: i];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in a new issue