Removed old commented-out code.
[CleverRabbit.git] / RTKCleverRabbitController.m
blob74a4e0c2ee40562b11f71e2b906b5a8140ac6dc5
1 //
2 //   RTKCleverRabbitController.m
3 //   (CleverRabbit.app)
4 //
5 //   Copyright (c) 2005 A. Karl Keller (http://karlk.net)
6 //
7 //   This code is open-source, free software, made available without warranty under
8 //   the terms of the GNU General Public License, either version 2 or later (see 
9 //   http://www.gnu.org/licenses/gpl.html or included copy); as such, it may be 
10 //   redistributed and/or modified in accordance with that document.
13 #import "RTKCleverRabbitController.h"
14 #import "RTKTigerDocument.h"
16 @implementation RTKCleverRabbitController
18 - (id)init
20         if(self = [super init]) {               
21                 // Set default preferences settings
22                 NSMutableDictionary * d = [NSMutableDictionary dictionary];
23                 
24                 [d setObject:@"KSCII" forKey:@"RTKEncodingSystem"];
25                 [d setObject:@"Phonemic" forKey:@"RTKInputSystem"];
26                 [d setObject:@"NewKrung" forKey:@"RTKScriptSystem"];
27                 [d setObject:@"^" forKey:@"RTKPlainTextDelimiter"];
28                 [d setObject:@"<return>" forKey:@"RTKPlainTextReturnCharacter"];
29                 [d setObject:[NSNumber numberWithBool:NO] forKey:@"RTKZVXSubstitution"];  
30                 [d setObject:[NSNumber numberWithBool:NO] forKey:@"RTKTransliterationOn"];  
31                 
32                 [d setObject:[NSNumber numberWithBool:NO] forKey:@"RTKHorizonatalSplitViewSizeSaved"];
33                 [d setObject:[NSNumber numberWithBool:NO] forKey:@"RTKSplitViewSizesWithTransliterationSaved"];
34                 [d setObject:[NSNumber numberWithBool:NO] forKey:@"RTKSplitViewSizesWithoutTransliterationSaved"];
35                 
36                 [d setObject:[NSNumber numberWithInt:700] forKey:@"RTKDocumentWidth"];  
37                 [d setObject:[NSNumber numberWithInt:500] forKey:@"RTKDocumentHeight"];  
38                 
39                 [d setObject:[NSNumber numberWithInt:100] forKey:@"RTKReferenceColumnWidth"];
40         [d setObject:[NSNumber numberWithInt:100] forKey:@"RTKLockColumnWidth"];
41         [d setObject:[NSNumber numberWithInt:100] forKey:@"RTKTypeColumnWidth"];
42                 [d setObject:[NSNumber numberWithInt:100] forKey:@"RTKRevisionColumnWidth"];  
43                 [d setObject:[NSNumber numberWithInt:100] forKey:@"RTKScriptColumnWidth"];  
44                 [d setObject:[NSNumber numberWithInt:100] forKey:@"RTKRomanColumnWidth"];  
45                 [d setObject:[NSNumber numberWithInt:100] forKey:@"RTKBackTranslationColumnWidth"];
46                 [d setObject:[NSNumber numberWithInt:100] forKey:@"RTKNotesColumnWidth"];  
47                 [d setObject:[NSNumber numberWithInt:100] forKey:@"RTKCheckingColumnWidth"];  
48                 
49                 [d setObject:@"Helvetica" forKey:@"RTKCommitteeFontName"];
50                 [d setObject:[NSNumber numberWithInt:48] forKey:@"RTKCommitteeFontSize"];
51                 [d setObject:@"Helvetica" forKey:@"RTKScriptFontName"];
52                 [d setObject:[NSNumber numberWithInt:12] forKey:@"RTKScriptFontSize"];
53                 [d setObject:@"Helvetica" forKey:@"RTKRomanFontName"];
54                 [d setObject:[NSNumber numberWithInt:12] forKey:@"RTKRomanFontSize"];
55                 [d setObject:@"Helvetica" forKey:@"RTKBackTranslationFontName"];
56                 [d setObject:[NSNumber numberWithInt:12] forKey:@"RTKBackTranslationFontSize"];
57                 [d setObject:@"Helvetica" forKey:@"RTKNotesFontName"];
58                 [d setObject:[NSNumber numberWithInt:12] forKey:@"RTKNotesFontSize"];
59                 [d setObject:@"Helvetica" forKey:@"RTKCheckingFontName"];
60                 [d setObject:[NSNumber numberWithInt:12] forKey:@"RTKCheckingFontSize"];
61         [d setObject:@"Helvetica" forKey:@"RTKPublishedFontName"];
62                 [d setObject:[NSNumber numberWithInt:12] forKey:@"RTKPublishedFontSize"];
64                 [d setValue:@"No Transcription" forKey:@"RTKTranscriptionType"];
65                 
66                 [[NSUserDefaults standardUserDefaults]
67                         registerDefaults:d];
68                 
69                 NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
70                 
71                 [nc addObserver:self 
72                            selector:@selector(changedCommitteeString:) 
73                                    name:@"RTKChangedCommitteeString" 
74                                  object:nil];
75                 
76                 [nc addObserver:self
77                selector:@selector(fontsChanged:)
78                    name:@"RTKFontsChanged"
79                  object:nil];
80         }
81         return self;
84 - (void)changedCommitteeString:(NSNotification *)aNotification
86         
87         NSUserDefaults * d = [NSUserDefaults standardUserDefaults];
88     NSFont *font = [NSFont fontWithName:(NSString *)[d valueForKey:@"RTKCommitteeFontName"]
89                                                                    size:[(NSString *) [d valueForKey:@"RTKCommitteeFontSize"] floatValue]];
90         if(font) {
91                 [committeeMeetingTextView setFont:font];
92         }
93     
94     //TODO Fix me
95         [committeeMeetingTextView setString:(NSString *) [[aNotification userInfo] objectForKey:@"string"]];
96     
99 - (void)fontsChanged:(NSNotification *)aNotification
101         NSUserDefaults * d = [NSUserDefaults standardUserDefaults];
102     NSFont *font = [NSFont fontWithName:(NSString *)[d valueForKey:@"RTKCommitteeFontName"]
103                                                                    size:[(NSString *) [d valueForKey:@"RTKCommitteeFontSize"] floatValue]];
104         if(font) {
105                 [committeeMeetingTextView setFont:font];
106         }
109 - (IBAction)openBugsAndFeatures:(id)sender
111     NSMutableString * path = [NSMutableString string];
112     
113     [path appendString:@"/usr/bin/open "];
114     [path appendString:[[NSBundle mainBundle] resourcePath]];
115     [path appendString:@"/bugsAndFeatures.txt"];
116     
117     system([path cString]);
120 #pragma mark -
123 - (NSMenuItem *)newVerseMenuItem
125     return newVerseMenuItem;
128 - (NSMenuItem *)deleteVerseMenuItem
130     return deleteVerseMenuItem;
133 - (NSMenuItem *)nextVerseMenuItem
135     return nextVerseMenuItem;
138 - (NSMenuItem *)previousVerseMenuItem
140     return previousVerseMenuItem;
143 - (NSMenuItem *)lockVerseMenuItem
145     return lockVerseMenuItem;
148 - (NSMenuItem *)newRevisionMenuItem
150     return newRevisionMenuItem;
153 - (NSMenuItem *)deleteRevisionMenuItem
155     return deleteRevisionMenuItem;
158 - (NSMenuItem *)nextRevisionMenuItem
160     return nextRevisionMenuItem;
163 - (NSMenuItem *)previousRevisionMenuItem
165     return previousRevisionMenuItem;
168 - (NSMenuItem *)lockRevisionMenuItem
170     return lockRevisionMenuItem;
173 #pragma mark -
174 #pragma mark drag and drop
176 - (void)setDraggedVersesArray:(NSArray *)versesArray
178     [versesArray retain];
179     [draggedVersesArray release];
180     draggedVersesArray = versesArray;
183 - (NSArray *)draggedVersesArray
185     return draggedVersesArray;
188 - (void)setDraggedVersesOwner:(id)sender
190     // TODO: This could lead to a memory leak when closing documents after dragging.
191     // FIX: Use clearDraggedVersesOwnerIfEqualTo method below when closing a document
192     [sender retain];
193     [draggedVersesOwner release];
194     draggedVersesOwner = sender;
197 - (void)clearDraggedVersesOwnerIfEqualTo:(id)sender
199     if(draggedVersesOwner == sender) {
200         [draggedVersesOwner release];
201         draggedVersesOwner = nil;
202     }
205 - (id)draggedVersesOwner
207     return draggedVersesOwner;
210 #pragma mark -
211 #pragma mark copy and paste
213 - (void)setCopiedVersesArray:(NSArray *)versesArray
215     [versesArray retain];
216     [copiedVersesArray release];
217     copiedVersesArray = versesArray;
220 - (NSArray *)copiedVersesArray
222     return copiedVersesArray;
225 #pragma mark -
227 - (void)dealloc
229     [draggedVersesArray release];
230     [draggedVersesOwner release];
231     [copiedVersesArray release];
232     
233     [super dealloc];
236 @end