git.ithinksw.org
/
ITKit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Enabling garbage collection support.
[ITKit.git]
/
ITKeyComboPanel.m
diff --git
a/ITKeyComboPanel.m
b/ITKeyComboPanel.m
old mode 100755
(executable)
new mode 100644
(file)
index
e10ffc0
..
4fd3ff0
--- a/
ITKeyComboPanel.m
+++ b/
ITKeyComboPanel.m
@@
-1,157
+1,107
@@
-//
-// ITKeyComboPanel.m
-//
-// Created by Quentin Carnicelli on Sun Aug 03 2003.
-// Copyright (c) 2003 iThink Software. All rights reserved.
-//
-
#import "ITKeyComboPanel.h"
#import "ITKeyComboPanel.h"
-
#import "ITHotKey.h"
#import "ITKeyCombo.h"
#import "ITKeyBroadcaster.h"
#import "ITHotKeyCenter.h"
#import "ITHotKey.h"
#import "ITKeyCombo.h"
#import "ITKeyBroadcaster.h"
#import "ITHotKeyCenter.h"
-#if __PROTEIN__
-#import "NSObjectAdditions.h"
-#endif
-
@implementation ITKeyComboPanel
static id _sharedKeyComboPanel = nil;
@implementation ITKeyComboPanel
static id _sharedKeyComboPanel = nil;
-+ (id)sharedPanel
-{
- if( _sharedKeyComboPanel == nil )
- {
++ (id)sharedPanel {
+ if (!_sharedKeyComboPanel) {
_sharedKeyComboPanel = [[self alloc] init];
_sharedKeyComboPanel = [[self alloc] init];
-
- #if __PROTEIN__
- [_sharedKeyComboPanel releaseOnTerminate];
- #endif
}
}
-
return _sharedKeyComboPanel;
}
return _sharedKeyComboPanel;
}
-- (id)init
-{
- return [self initWithWindowNibName: @"ITKeyComboPanel"];
+- (id)init {
+ return [self initWithWindowNibName:@"ITKeyComboPanel"];
}
}
-- (void)dealloc
-{
- [[NSNotificationCenter defaultCenter] removeObserver: self];
+- (void)dealloc {
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
[mKeyName release];
[mKeyName release];
- [mTitleFormat release];
-
[super dealloc];
}
[super dealloc];
}
-- (void)windowDidLoad
-{
- mTitleFormat = [[mTitleField stringValue] retain];
-
- [[NSNotificationCenter defaultCenter]
- addObserver: self
- selector: @selector( noteKeyBroadcast: )
- name: ITKeyBroadcasterKeyEvent
- object: mKeyBcaster];
+- (void)windowDidLoad {
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(noteKeyBroadcast:) name:ITKeyBroadcasterKeyEvent object:mKeyBcaster];
}
}
-- (void)_refreshContents
-{
- if( mComboField )
- [mComboField setStringValue: [mKeyCombo description]];
-
- if( mTitleField )
- [mTitleField setStringValue: [NSString stringWithFormat: mTitleFormat, mKeyName]];
+- (void)_refreshContents
{
+
if (mComboField)
{
+ [mComboField setStringValue:[mKeyCombo description]];
+ }
+ if (mTitleField) {
+ [mTitleField setStringValue:mKeyName];
+ }
}
}
-- (int)runModal
-{
+- (int)runModal {
int resultCode;
int resultCode;
-
+
[self window]; //Force us to load
[self window]; //Force us to load
-
+
[self _refreshContents];
[[self window] center];
[self _refreshContents];
[[self window] center];
- [self showWindow:
self];
- resultCode = [[NSApplication sharedApplication] runModalForWindow:
[self window]];
+ [self showWindow:self];
+ resultCode = [[NSApplication sharedApplication] runModalForWindow:[self window]];
[self close];
[self close];
-
+
return resultCode;
}
return resultCode;
}
-- (void)runModalForHotKey: (ITHotKey*)hotKey
-{
+- (void)runModalForHotKey:(ITHotKey *)hotKey {
int resultCode;
int resultCode;
- [self setKeyBindingName:
[hotKey name]];
- [self setKeyCombo:
[hotKey keyCombo]];
+ [self setKeyBindingName:[hotKey name]];
+ [self setKeyCombo:[hotKey keyCombo]];
resultCode = [self runModal];
resultCode = [self runModal];
- if( resultCode == NSOKButton )
- {
- [hotKey setKeyCombo: [self keyCombo]];
- [[ITHotKeyCenter sharedCenter] registerHotKey: hotKey];
+ if (resultCode == NSOKButton) {
+ [hotKey setKeyCombo:[self keyCombo]];
+ [[ITHotKeyCenter sharedCenter] registerHotKey:hotKey];
}
}
}
}
-#pragma mark -
-
-- (void)setKeyCombo: (ITKeyCombo*)combo
-{
- [combo retain];
- [mKeyCombo release];
- mKeyCombo = combo;
+- (void)setKeyCombo:(ITKeyCombo *)combo {
+ [mKeyCombo autorelease];
+ mKeyCombo = [combo retain];
[self _refreshContents];
}
[self _refreshContents];
}
-- (ITKeyCombo*)keyCombo
-{
+- (ITKeyCombo *)keyCombo {
return mKeyCombo;
}
return mKeyCombo;
}
-- (void)setKeyBindingName: (NSString*)name
-{
- [name retain];
- [mKeyName release];
- mKeyName = name;
+- (void)setKeyBindingName:(NSString *)name {
+ [mKeyName autorelease];
+ mKeyName = [name retain];
[self _refreshContents];
}
[self _refreshContents];
}
-- (NSString*)keyBindingName
-{
+- (NSString *)keyBindingName {
return mKeyName;
}
return mKeyName;
}
-#pragma mark -
-
-- (IBAction)ok: (id)sender
-{
- [[NSApplication sharedApplication] stopModalWithCode: NSOKButton];
+- (IBAction)ok:(id)sender {
+ [[NSApplication sharedApplication] stopModalWithCode:NSOKButton];
}
}
-- (IBAction)cancel: (id)sender
-{
- [[NSApplication sharedApplication] stopModalWithCode: NSCancelButton];
+- (IBAction)cancel:(id)sender {
+ [[NSApplication sharedApplication] stopModalWithCode:NSCancelButton];
}
}
-- (IBAction)clear: (id)sender
-{
- [self setKeyCombo: [ITKeyCombo clearKeyCombo]];
- [[NSApplication sharedApplication] stopModalWithCode: NSOKButton];
+- (IBAction)clear:(id)sender {
+ [self setKeyCombo:[ITKeyCombo clearKeyCombo]];
+ [[NSApplication sharedApplication] stopModalWithCode:NSOKButton];
}
}
-- (void)noteKeyBroadcast: (NSNotification*)note
-{
- ITKeyCombo* keyCombo;
-
- keyCombo = [[note userInfo] objectForKey: @"keyCombo"];
-
- [self setKeyCombo: keyCombo];
+- (void)noteKeyBroadcast:(NSNotification *)note {
+ ITKeyCombo *keyCombo = [[note userInfo] objectForKey:@"keyCombo"];
+ [self setKeyCombo:keyCombo];
}
@end
}
@end