Coverts to Objective-C ARC.
This commit is contained in:
parent
aa8f36b92f
commit
0f05e245a5
|
@ -821,6 +821,7 @@
|
|||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_IMPLICIT_SIGN_CONVERSION = NO;
|
||||
|
@ -872,6 +873,7 @@
|
|||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_IMPLICIT_SIGN_CONVERSION = NO;
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1240"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "6A0D4EA115FC0D2D00ABF4B3"
|
||||
BuildableName = "McBopomofo.app"
|
||||
BlueprintName = "McBopomofo"
|
||||
ReferencedContainer = "container:McBopomofo.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
</Testables>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "6A0D4EA115FC0D2D00ABF4B3"
|
||||
BuildableName = "McBopomofo.app"
|
||||
BlueprintName = "McBopomofo"
|
||||
ReferencedContainer = "container:McBopomofo.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "6A0D4EA115FC0D2D00ABF4B3"
|
||||
BuildableName = "McBopomofo.app"
|
||||
BlueprintName = "McBopomofo"
|
||||
ReferencedContainer = "container:McBopomofo.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
|
@ -39,7 +39,6 @@
|
|||
@interface AppDelegate : NSObject <NSApplicationDelegate>
|
||||
{
|
||||
@private
|
||||
NSWindow *_window;
|
||||
NSURLConnection *_updateCheckConnection;
|
||||
BOOL _currentUpdateCheckIsForced;
|
||||
NSMutableData *_receivingData;
|
||||
|
@ -51,5 +50,5 @@
|
|||
- (void)checkForUpdateForced:(BOOL)forced;
|
||||
- (void)showPreferences;
|
||||
|
||||
@property (assign, nonatomic) IBOutlet NSWindow *window;
|
||||
@property (weak, nonatomic) IBOutlet NSWindow *window;
|
||||
@end
|
||||
|
|
|
@ -53,9 +53,8 @@ static const NSTimeInterval kTimeoutInterval = 60.0;
|
|||
|
||||
- (void)dealloc
|
||||
{
|
||||
[_preferencesWindowController release];
|
||||
[_updateCheckConnection release];
|
||||
[super dealloc];
|
||||
_preferencesWindowController = nil;
|
||||
_updateCheckConnection = nil;
|
||||
}
|
||||
|
||||
- (void)applicationDidFinishLaunching:(NSNotification *)inNotification
|
||||
|
@ -124,7 +123,6 @@ static const NSTimeInterval kTimeoutInterval = 60.0;
|
|||
#endif
|
||||
|
||||
if (_receivingData) {
|
||||
[_receivingData release];
|
||||
_receivingData = nil;
|
||||
}
|
||||
|
||||
|
@ -147,9 +145,7 @@ static const NSTimeInterval kTimeoutInterval = 60.0;
|
|||
{
|
||||
BOOL isForcedCheck = _currentUpdateCheckIsForced;
|
||||
|
||||
[_receivingData release];
|
||||
_receivingData = nil;
|
||||
[_updateCheckConnection release];
|
||||
_updateCheckConnection = nil;
|
||||
_currentUpdateCheckIsForced = NO;
|
||||
|
||||
|
@ -172,9 +168,7 @@ static const NSTimeInterval kTimeoutInterval = 60.0;
|
|||
|
||||
BOOL isForcedCheck = _currentUpdateCheckIsForced;
|
||||
|
||||
[_receivingData release];
|
||||
_receivingData = nil;
|
||||
[_updateCheckConnection release];
|
||||
_updateCheckConnection = nil;
|
||||
_currentUpdateCheckIsForced = NO;
|
||||
|
||||
|
@ -226,9 +220,7 @@ static const NSTimeInterval kTimeoutInterval = 60.0;
|
|||
}
|
||||
return;
|
||||
}
|
||||
[_updateNextStepURL release];
|
||||
_updateNextStepURL = nil;
|
||||
_updateNextStepURL = [siteInfoURL retain];
|
||||
_updateNextStepURL = siteInfoURL;
|
||||
|
||||
NSDictionary *versionDescriptions = [plist objectForKey:@"Description"];
|
||||
NSString *versionDescription = @"";
|
||||
|
@ -268,13 +260,11 @@ static const NSTimeInterval kTimeoutInterval = 60.0;
|
|||
[[NSWorkspace sharedWorkspace] openURL:_updateNextStepURL];
|
||||
}
|
||||
|
||||
[_updateNextStepURL release];
|
||||
_updateNextStepURL = nil;
|
||||
}
|
||||
|
||||
- (void)nonModalAlertWindowControllerDidCancel:(OVNonModalAlertWindowController *)controller
|
||||
{
|
||||
[_updateNextStepURL release];
|
||||
_updateNextStepURL = nil;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@
|
|||
|
||||
- (NSUInteger)candidateIndexAtKeyLabelIndex:(NSUInteger)index;
|
||||
|
||||
@property (assign, weak, nonatomic) id<VTCandidateControllerDelegate> delegate;
|
||||
@property (weak, nonatomic) id<VTCandidateControllerDelegate> delegate;
|
||||
@property (assign, nonatomic) NSUInteger selectedCandidateIndex;
|
||||
|
||||
@property (assign, nonatomic) BOOL visible;
|
||||
|
|
|
@ -36,10 +36,9 @@
|
|||
|
||||
- (void)dealloc
|
||||
{
|
||||
[_keyLabels release];
|
||||
[_keyLabelFont release];
|
||||
[_candidateFont release];
|
||||
[super dealloc];
|
||||
_keyLabels = nil;
|
||||
_keyLabelFont = nil;
|
||||
_candidateFont = nil;
|
||||
}
|
||||
|
||||
- (id)initWithWindow:(NSWindow *)window
|
||||
|
@ -47,11 +46,10 @@
|
|||
self = [super initWithWindow:window];
|
||||
if (self) {
|
||||
// populate the default values
|
||||
_keyLabels = [[NSArray arrayWithObjects:@"1", @"2", @"3", @"4", @"5", @"6", @"7", @"8", @"9", nil] retain];
|
||||
_keyLabelFont = [[NSFont systemFontOfSize:14.0] retain];
|
||||
_candidateFont = [[NSFont systemFontOfSize:18.0] retain];
|
||||
_keyLabels = @[@"1", @"2", @"3", @"4", @"5", @"6", @"7", @"8", @"9"];
|
||||
_keyLabelFont = [NSFont systemFontOfSize:14.0];
|
||||
_candidateFont = [NSFont systemFontOfSize:18.0];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,10 +40,9 @@
|
|||
|
||||
- (void)dealloc
|
||||
{
|
||||
[_candidateView release];
|
||||
[_prevPageButton release];
|
||||
[_nextPageButton release];
|
||||
[super dealloc];
|
||||
_candidateView = nil;
|
||||
_prevPageButton = nil;
|
||||
_nextPageButton = nil;
|
||||
}
|
||||
|
||||
- (id)init
|
||||
|
@ -51,7 +50,7 @@
|
|||
NSRect contentRect = NSMakeRect(128.0, 128.0, 0.0, 0.0);
|
||||
NSUInteger styleMask = NSBorderlessWindowMask | NSNonactivatingPanelMask;
|
||||
|
||||
NSPanel *panel = [[[NSPanel alloc] initWithContentRect:contentRect styleMask:styleMask backing:NSBackingStoreBuffered defer:NO] autorelease];
|
||||
NSPanel *panel = [[NSPanel alloc] initWithContentRect:contentRect styleMask:styleMask backing:NSBackingStoreBuffered defer:NO];
|
||||
[panel setLevel:kCGPopUpMenuWindowLevel];
|
||||
[panel setHasShadow:YES];
|
||||
|
||||
|
|
|
@ -50,5 +50,5 @@
|
|||
@property (readonly, nonatomic) NSSize sizeForView;
|
||||
@property (assign, nonatomic) NSUInteger highlightedIndex;
|
||||
@property (assign, nonatomic) SEL action;
|
||||
@property (weak, assign, nonatomic) id target;
|
||||
@property (weak, nonatomic) id target;
|
||||
@end
|
||||
|
|
|
@ -39,26 +39,18 @@ NS_INLINE CGFloat max(CGFloat a, CGFloat b) { return a > b ? a : b; }
|
|||
|
||||
- (void)dealloc
|
||||
{
|
||||
[_keyLabels release];
|
||||
[_displayedCandidates release];
|
||||
[_keyLabelAttrDict release];
|
||||
[_candidateAttrDict release];
|
||||
[_elementWidths release];
|
||||
[super dealloc];
|
||||
_keyLabels = nil;
|
||||
_displayedCandidates = nil;
|
||||
_keyLabelAttrDict = nil;
|
||||
_candidateAttrDict = nil;
|
||||
_elementWidths = nil;
|
||||
}
|
||||
|
||||
- (void)setKeyLabels:(NSArray *)labels displayedCandidates:(NSArray *)candidates
|
||||
{
|
||||
NSUInteger count = min([labels count], [candidates count]);
|
||||
id tmp;
|
||||
|
||||
tmp = _keyLabels;
|
||||
_keyLabels = [[labels subarrayWithRange:NSMakeRange(0, count)] retain];
|
||||
[tmp release];
|
||||
|
||||
tmp = _displayedCandidates;
|
||||
_displayedCandidates = [[candidates subarrayWithRange:NSMakeRange(0, count)] retain];
|
||||
[tmp release];
|
||||
_keyLabels = [labels subarrayWithRange:NSMakeRange(0, count)];
|
||||
_displayedCandidates = [candidates subarrayWithRange:NSMakeRange(0, count)];
|
||||
|
||||
NSMutableArray *newWidths = [NSMutableArray array];
|
||||
|
||||
|
@ -72,32 +64,24 @@ NS_INLINE CGFloat max(CGFloat a, CGFloat b) { return a > b ? a : b; }
|
|||
[newWidths addObject:[NSNumber numberWithDouble:width]];
|
||||
}
|
||||
|
||||
tmp = _elementWidths;
|
||||
_elementWidths = [newWidths retain];
|
||||
[tmp release];
|
||||
_elementWidths = newWidths;
|
||||
}
|
||||
|
||||
- (void)setKeyLabelFont:(NSFont *)labelFont candidateFont:(NSFont *)candidateFont
|
||||
{
|
||||
NSMutableParagraphStyle *paraStyle = [[[NSParagraphStyle defaultParagraphStyle] mutableCopy] autorelease];
|
||||
NSMutableParagraphStyle *paraStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
|
||||
[paraStyle setAlignment:NSCenterTextAlignment];
|
||||
|
||||
id tmp;
|
||||
tmp = _keyLabelAttrDict;
|
||||
_keyLabelAttrDict = [[NSDictionary dictionaryWithObjectsAndKeys:
|
||||
_keyLabelAttrDict = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
labelFont, NSFontAttributeName,
|
||||
paraStyle, NSParagraphStyleAttributeName,
|
||||
[NSColor blackColor], NSForegroundColorAttributeName,
|
||||
nil] retain];
|
||||
[tmp release];
|
||||
|
||||
tmp = _candidateAttrDict;
|
||||
_candidateAttrDict = [[NSDictionary dictionaryWithObjectsAndKeys:
|
||||
nil];
|
||||
_candidateAttrDict = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
candidateFont, NSFontAttributeName,
|
||||
paraStyle, NSParagraphStyleAttributeName,
|
||||
[NSColor textColor], NSForegroundColorAttributeName,
|
||||
nil] retain];
|
||||
[tmp release];
|
||||
nil];
|
||||
|
||||
CGFloat labelFontSize = [labelFont pointSize];
|
||||
CGFloat candidateFontSize = [candidateFont pointSize];
|
||||
|
@ -165,7 +149,7 @@ NS_INLINE CGFloat max(CGFloat a, CGFloat b) { return a > b ? a : b; }
|
|||
if (index == _highlightedIndex) {
|
||||
[[NSColor selectedTextBackgroundColor] setFill];
|
||||
|
||||
activeCandidateAttr = [[_candidateAttrDict mutableCopy] autorelease];
|
||||
activeCandidateAttr = [_candidateAttrDict mutableCopy];
|
||||
[(NSMutableDictionary *)activeCandidateAttr setObject:[NSColor selectedTextColor] forKey:NSForegroundColorAttributeName];
|
||||
}
|
||||
else {
|
||||
|
@ -230,9 +214,12 @@ NS_INLINE CGFloat max(CGFloat a, CGFloat b) { return a > b ? a : b; }
|
|||
_trackingHighlightedIndex = 0;
|
||||
[self setNeedsDisplay:YES];
|
||||
|
||||
# pragma clang diagnostic push
|
||||
# pragma clang diagnostic ignored "-Warc-performSelector-leaks"
|
||||
if (triggerAction && _target && _action) {
|
||||
[_target performSelector:_action withObject:self];
|
||||
}
|
||||
# pragma clang diagnostic pop
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -57,21 +57,13 @@ static const CGFloat kCandidateTextLeftMarginWithMandatedTableViewPadding = 0.0;
|
|||
CGFloat _candidateTextLeftMargin;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[_candidateTextParagraphStyle release];
|
||||
[_keyLabelStripView release];
|
||||
[_scrollView release];
|
||||
[_tableView release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (id)init
|
||||
{
|
||||
NSRect contentRect = NSMakeRect(128.0, 128.0, 0.0, 0.0);
|
||||
NSUInteger styleMask = NSBorderlessWindowMask | NSNonactivatingPanelMask;
|
||||
|
||||
NSPanel *panel = [[[NSPanel alloc] initWithContentRect:contentRect styleMask:styleMask backing:NSBackingStoreBuffered defer:NO] autorelease];
|
||||
NSPanel *panel = [[NSPanel alloc] initWithContentRect:contentRect styleMask:styleMask backing:NSBackingStoreBuffered defer:NO];
|
||||
[panel setLevel:kCGPopUpMenuWindowLevel];
|
||||
[panel setHasShadow:YES];
|
||||
|
||||
|
@ -100,8 +92,8 @@ static const CGFloat kCandidateTextLeftMarginWithMandatedTableViewPadding = 0.0;
|
|||
[_tableView setDataSource:self];
|
||||
[_tableView setDelegate:self];
|
||||
|
||||
NSTableColumn *column = [[[NSTableColumn alloc] initWithIdentifier:@"candidate"] autorelease];
|
||||
[column setDataCell:[[[NSTextFieldCell alloc] init] autorelease]];
|
||||
NSTableColumn *column = [[NSTableColumn alloc] initWithIdentifier:@"candidate"];
|
||||
[column setDataCell:[[NSTextFieldCell alloc] init]];
|
||||
[column setEditable:NO];
|
||||
|
||||
_candidateTextPadding = kCandidateTextPadding;
|
||||
|
@ -238,7 +230,7 @@ static const CGFloat kCandidateTextLeftMarginWithMandatedTableViewPadding = 0.0;
|
|||
candidate = [_delegate candidateController:self candidateAtIndex:row];
|
||||
}
|
||||
|
||||
NSAttributedString *attrString = [[[NSAttributedString alloc] initWithString:candidate attributes:[NSDictionary dictionaryWithObjectsAndKeys:_candidateFont, NSFontAttributeName, _candidateTextParagraphStyle, NSParagraphStyleAttributeName, nil]] autorelease];
|
||||
NSAttributedString *attrString = [[NSAttributedString alloc] initWithString:candidate attributes:[NSDictionary dictionaryWithObjectsAndKeys:_candidateFont, NSFontAttributeName, _candidateTextParagraphStyle, NSParagraphStyleAttributeName, nil]];
|
||||
|
||||
// we do more work than what this method is expected to; normally not a good practice, but for the amount of data (9 to 10 rows max), we can afford the overhead
|
||||
|
||||
|
|
|
@ -35,9 +35,8 @@
|
|||
|
||||
- (void)dealloc
|
||||
{
|
||||
[_keyLabelFont release];
|
||||
[_keyLabels release];
|
||||
[super dealloc];
|
||||
_keyLabelFont = nil;
|
||||
_keyLabels = nil;
|
||||
}
|
||||
|
||||
- (id)initWithFrame:(NSRect)frameRect
|
||||
|
@ -71,7 +70,7 @@
|
|||
NSColor *darkGray = [NSColor colorWithDeviceWhite:0.7 alpha:1.0];
|
||||
NSColor *lightGray = [NSColor colorWithDeviceWhite:0.8 alpha:1.0];
|
||||
|
||||
NSMutableParagraphStyle *style = [[[NSParagraphStyle defaultParagraphStyle] mutableCopy] autorelease];
|
||||
NSMutableParagraphStyle *style = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
|
||||
[style setAlignment:NSCenterTextAlignment];
|
||||
|
||||
NSDictionary *textAttr = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
|
|
|
@ -160,14 +160,11 @@ public:
|
|||
delete _builder;
|
||||
}
|
||||
|
||||
[_composingBuffer release];
|
||||
|
||||
[_candidates release];
|
||||
|
||||
// the two client pointers are weak pointers (i.e. we don't retain them)
|
||||
// therefore we don't do anything about it
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (id)initWithServer:(IMKServer *)server delegate:(id)delegate client:(id)client
|
||||
|
@ -206,8 +203,8 @@ public:
|
|||
- (NSMenu *)menu
|
||||
{
|
||||
// a menu instance (autoreleased) is requested every time the user click on the input menu
|
||||
NSMenu *menu = [[[NSMenu alloc] initWithTitle:LocalizationNotNeeded(@"Input Method Menu")] autorelease];
|
||||
NSMenuItem *preferenceMenuItem = [[[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"McBopomofo Preferences", @"") action:@selector(showPreferences:) keyEquivalent:@""] autorelease];
|
||||
NSMenu *menu = [[NSMenu alloc] initWithTitle:LocalizationNotNeeded(@"Input Method Menu")];
|
||||
NSMenuItem *preferenceMenuItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"McBopomofo Preferences", @"") action:@selector(showPreferences:) keyEquivalent:@""];
|
||||
[menu addItem:preferenceMenuItem];
|
||||
|
||||
// If Option key is pressed, show the learning-related menu
|
||||
|
@ -218,7 +215,7 @@ public:
|
|||
|
||||
BOOL learningEnabled = ![[NSUserDefaults standardUserDefaults] boolForKey:kDisableUserCandidateSelectionLearning];
|
||||
|
||||
NSMenuItem *learnMenuItem = [[[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Enable Selection Learning", @"") action:@selector(toggleLearning:) keyEquivalent:@""] autorelease];
|
||||
NSMenuItem *learnMenuItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Enable Selection Learning", @"") action:@selector(toggleLearning:) keyEquivalent:@""];
|
||||
if (learningEnabled) {
|
||||
[learnMenuItem setState:NSOnState];
|
||||
}
|
||||
|
@ -230,20 +227,20 @@ public:
|
|||
|
||||
if (learningEnabled) {
|
||||
NSString *clearMenuItemTitle = [NSString stringWithFormat:NSLocalizedString(@"Clear Learning Dictionary (%ju Items)", @""), (uintmax_t)[gCandidateLearningDictionary count]];
|
||||
NSMenuItem *clearMenuItem = [[[NSMenuItem alloc] initWithTitle:clearMenuItemTitle action:@selector(clearLearningDictionary:) keyEquivalent:@""] autorelease];
|
||||
NSMenuItem *clearMenuItem = [[NSMenuItem alloc] initWithTitle:clearMenuItemTitle action:@selector(clearLearningDictionary:) keyEquivalent:@""];
|
||||
[menu addItem:clearMenuItem];
|
||||
|
||||
|
||||
NSMenuItem *dumpMenuItem = [[[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Dump Learning Data to Console", @"") action:@selector(dumpLearningDictionary:) keyEquivalent:@""] autorelease];
|
||||
NSMenuItem *dumpMenuItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Dump Learning Data to Console", @"") action:@selector(dumpLearningDictionary:) keyEquivalent:@""];
|
||||
[menu addItem:dumpMenuItem];
|
||||
}
|
||||
}
|
||||
#endif //DEBUG
|
||||
|
||||
NSMenuItem *updateCheckItem = [[[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Check for Updates…", @"") action:@selector(checkForUpdate:) keyEquivalent:@""] autorelease];
|
||||
NSMenuItem *updateCheckItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Check for Updates…", @"") action:@selector(checkForUpdate:) keyEquivalent:@""];
|
||||
[menu addItem:updateCheckItem];
|
||||
|
||||
NSMenuItem *aboutMenuItem = [[[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"About McBopomofo…", @"") action:@selector(showAbout:) keyEquivalent:@""] autorelease];
|
||||
NSMenuItem *aboutMenuItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"About McBopomofo…", @"") action:@selector(showAbout:) keyEquivalent:@""];
|
||||
[menu addItem:aboutMenuItem];
|
||||
|
||||
return menu;
|
||||
|
@ -464,7 +461,7 @@ public:
|
|||
NSDictionary *attrDict = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
[NSNumber numberWithInt:NSUnderlineStyleSingle], NSUnderlineStyleAttributeName,
|
||||
[NSNumber numberWithInt:0], NSMarkedClauseSegmentAttributeName, nil];
|
||||
NSMutableAttributedString *attrString = [[[NSMutableAttributedString alloc] initWithString:composedText attributes:attrDict] autorelease];
|
||||
NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:composedText attributes:attrDict];
|
||||
|
||||
// the selection range is where the cursor is, with the length being 0 and replacement range NSNotFound,
|
||||
// i.e. the client app needs to take care of where to put ths composing buffer
|
||||
|
@ -1540,7 +1537,7 @@ void LTLoadLanguageModel()
|
|||
|
||||
// TODO: Change this
|
||||
NSString *userDictFile = [userDictPath stringByAppendingPathComponent:@"UserCandidatesCache.plist"];
|
||||
gUserCandidatesDictionaryPath = [userDictFile retain];
|
||||
gUserCandidatesDictionaryPath = userDictFile;
|
||||
|
||||
exists = [[NSFileManager defaultManager] fileExistsAtPath:userDictFile isDirectory:&isDir];
|
||||
if (exists && !isDir) {
|
||||
|
|
|
@ -31,7 +31,8 @@
|
|||
+ (NSArray *)allInstalledInputSources
|
||||
{
|
||||
CFArrayRef list = TISCreateInputSourceList(NULL, true);
|
||||
return [NSMakeCollectable(list) autorelease];
|
||||
return (__bridge NSArray *)list;
|
||||
// return [NSMakeCollectable(list) autorelease];
|
||||
}
|
||||
|
||||
+ (TISInputSourceRef)inputSourceForProperty:(CFStringRef)inPropertyKey stringValue:(NSString *)inValue
|
||||
|
@ -39,16 +40,15 @@
|
|||
CFTypeID stringID = CFStringGetTypeID();
|
||||
|
||||
for (id source in [self allInstalledInputSources]) {
|
||||
CFTypeRef property = TISGetInputSourceProperty((TISInputSourceRef)source, inPropertyKey);
|
||||
CFTypeRef property = TISGetInputSourceProperty((__bridge TISInputSourceRef)source, inPropertyKey);
|
||||
if (!property || CFGetTypeID(property) != stringID) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (inValue && [inValue compare:(NSString *)property] == NSOrderedSame) {
|
||||
return (TISInputSourceRef)source;
|
||||
if (inValue && [inValue compare:(__bridge NSString *)property] == NSOrderedSame) {
|
||||
return (__bridge TISInputSourceRef)source;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -74,9 +74,9 @@
|
|||
BOOL enabled = NO;
|
||||
|
||||
for (id source in [self allInstalledInputSources]) {
|
||||
TISInputSourceRef inputSource = (TISInputSourceRef)source;
|
||||
NSString *bundleID = (NSString *)TISGetInputSourceProperty(inputSource, kTISPropertyBundleID);
|
||||
NSString *mode = (NSString *)TISGetInputSourceProperty(inputSource, kTISPropertyInputModeID);
|
||||
TISInputSourceRef inputSource = (__bridge TISInputSourceRef)source;
|
||||
NSString *bundleID = (__bridge NSString *)TISGetInputSourceProperty(inputSource, kTISPropertyBundleID);
|
||||
NSString *mode = (NSString *)CFBridgingRelease(TISGetInputSourceProperty(inputSource, kTISPropertyInputModeID));
|
||||
if (mode && [bundleID isEqualToString:inID]) {
|
||||
BOOL modeEnabled = [self enableInputSource:inputSource];
|
||||
if (!modeEnabled) {
|
||||
|
@ -98,7 +98,7 @@
|
|||
|
||||
+ (BOOL)registerInputSource:(NSURL *)inBundleURL
|
||||
{
|
||||
OSStatus status = TISRegisterInputSource((CFURLRef)inBundleURL);
|
||||
OSStatus status = TISRegisterInputSource((__bridge CFURLRef)inBundleURL);
|
||||
return status == noErr;
|
||||
}
|
||||
@end
|
||||
|
|
|
@ -20,11 +20,11 @@
|
|||
@interface OVNonModalAlertWindowController : NSWindowController
|
||||
{
|
||||
@private
|
||||
NSTextField *_titleTextField;
|
||||
NSTextField *_contentTextField;
|
||||
NSButton *_confirmButton;
|
||||
NSButton *_cancelButton;
|
||||
id<OVNonModalAlertWindowControllerDelegate> _delegate;
|
||||
// NSTextField *_titleTextField;
|
||||
// NSTextField *_contentTextField;
|
||||
// NSButton *_confirmButton;
|
||||
// NSButton *_cancelButton;
|
||||
// id<OVNonModalAlertWindowControllerDelegate> _delegate;
|
||||
}
|
||||
|
||||
+ (OVNonModalAlertWindowController *)sharedInstance;
|
||||
|
|
|
@ -36,10 +36,10 @@
|
|||
@interface PreferencesWindowController : NSWindowController
|
||||
{
|
||||
@private
|
||||
NSPopUpButton *_fontSizePopUpButton;
|
||||
NSPopUpButton *_basisKeyboardLayoutButton;
|
||||
NSPopUpButton *__weak _fontSizePopUpButton;
|
||||
NSPopUpButton *__weak _basisKeyboardLayoutButton;
|
||||
}
|
||||
- (IBAction)updateBasisKeyboardLayoutAction:(id)sender;
|
||||
@property (assign, nonatomic) IBOutlet NSPopUpButton *fontSizePopUpButton;
|
||||
@property (assign, nonatomic) IBOutlet NSPopUpButton *basisKeyboardLayoutButton;
|
||||
@property (weak, nonatomic) IBOutlet NSPopUpButton *fontSizePopUpButton;
|
||||
@property (weak, nonatomic) IBOutlet NSPopUpButton *basisKeyboardLayoutButton;
|
||||
@end
|
||||
|
|
|
@ -68,10 +68,10 @@ static NSString *const kBasisKeyboardLayoutPreferenceKey = @"BasisKeyboardLayout
|
|||
continue;
|
||||
}
|
||||
|
||||
NSString *sourceID = (NSString *)TISGetInputSourceProperty(source, kTISPropertyInputSourceID);
|
||||
NSString *localizedName = (NSString *)TISGetInputSourceProperty(source, kTISPropertyLocalizedName);
|
||||
NSString *sourceID = (__bridge NSString *)TISGetInputSourceProperty(source, kTISPropertyInputSourceID);
|
||||
NSString *localizedName = (__bridge NSString *)TISGetInputSourceProperty(source, kTISPropertyLocalizedName);
|
||||
|
||||
NSMenuItem *item = [[[NSMenuItem alloc] init] autorelease];
|
||||
NSMenuItem *item = [[NSMenuItem alloc] init];
|
||||
[item setTitle:localizedName];
|
||||
[item setRepresentedObject:sourceID];
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ static NSString *const kConnectionName = @"McBopomofo_1_Connection";
|
|||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
@autoreleasepool {
|
||||
|
||||
// register and enable the input source (along with all its input modes)
|
||||
if (argc > 1 && !strcmp(argv[1], "install")) {
|
||||
|
@ -64,7 +64,6 @@ int main(int argc, char *argv[])
|
|||
|
||||
if (!status) {
|
||||
NSLog(@"Fatal error: Cannot register input source %@ at %@.", bundleID, [bundleURL absoluteString]);
|
||||
[pool drain];
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -72,7 +71,6 @@ int main(int argc, char *argv[])
|
|||
// if it still doesn't register successfully, bail.
|
||||
if (!inputSource) {
|
||||
NSLog(@"Fatal error: Cannot find input source %@ after registration.", bundleID);
|
||||
[pool drain];
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -84,12 +82,10 @@ int main(int argc, char *argv[])
|
|||
|
||||
if (!status) {
|
||||
NSLog(@"Fatal error: Cannot enable input source %@.", bundleID);
|
||||
[pool drain];
|
||||
return -1;
|
||||
}
|
||||
if (![OVInputSourceHelper inputSourceEnabled:inputSource]){
|
||||
NSLog(@"Fatal error: Cannot enable input source %@.", bundleID);
|
||||
[pool drain];
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -110,26 +106,22 @@ int main(int argc, char *argv[])
|
|||
NSString *mainNibName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"NSMainNibFile"];
|
||||
if (!mainNibName) {
|
||||
NSLog(@"Fatal error: NSMainNibFile key not defined in Info.plist.");
|
||||
[pool drain];
|
||||
return -1;
|
||||
}
|
||||
|
||||
BOOL loadResult = [[NSBundle mainBundle] loadNibNamed:mainNibName owner:[NSApplication sharedApplication] topLevelObjects:NULL];
|
||||
if (!loadResult) {
|
||||
NSLog(@"Fatal error: Cannot load %@.", mainNibName);
|
||||
[pool drain];
|
||||
return -1;
|
||||
}
|
||||
|
||||
IMKServer *server = [[IMKServer alloc] initWithName:kConnectionName bundleIdentifier:[[NSBundle mainBundle] bundleIdentifier]];
|
||||
if (!server) {
|
||||
NSLog(@"Fatal error: Cannot initialize input method server with connection %@.", kConnectionName);
|
||||
[pool drain];
|
||||
return -1;
|
||||
}
|
||||
|
||||
[[NSApplication sharedApplication] run];
|
||||
[server release];
|
||||
[pool drain];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue