2 // RTKCleverRabbitController.m
5 // Copyright (c) 2005 A. Karl Keller (http://karlk.net)
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
20 if(self = [super init]) {
21 // Set default preferences settings
22 NSMutableDictionary * d = [NSMutableDictionary dictionary];
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"];
32 [d setObject:[NSNumber numberWithBool:NO] forKey:@"RTKHorizonatalSplitViewSizeSaved"];
33 [d setObject:[NSNumber numberWithBool:NO] forKey:@"RTKSplitViewSizesWithTransliterationSaved"];
34 [d setObject:[NSNumber numberWithBool:NO] forKey:@"RTKSplitViewSizesWithoutTransliterationSaved"];
36 [d setObject:[NSNumber numberWithInt:700] forKey:@"RTKDocumentWidth"];
37 [d setObject:[NSNumber numberWithInt:500] forKey:@"RTKDocumentHeight"];
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"];
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"];
66 [[NSUserDefaults standardUserDefaults]
69 NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
72 selector:@selector(changedCommitteeString:)
73 name:@"RTKChangedCommitteeString"
77 selector:@selector(fontsChanged:)
78 name:@"RTKFontsChanged"
84 - (void)changedCommitteeString:(NSNotification *)aNotification
87 NSUserDefaults * d = [NSUserDefaults standardUserDefaults];
88 NSFont *font = [NSFont fontWithName:(NSString *)[d valueForKey:@"RTKCommitteeFontName"]
89 size:[(NSString *) [d valueForKey:@"RTKCommitteeFontSize"] floatValue]];
91 [committeeMeetingTextView setFont:font];
95 [committeeMeetingTextView setString:(NSString *) [[aNotification userInfo] objectForKey:@"string"]];
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]];
105 [committeeMeetingTextView setFont:font];
109 - (IBAction)openBugsAndFeatures:(id)sender
111 NSMutableString * path = [NSMutableString string];
113 [path appendString:@"/usr/bin/open "];
114 [path appendString:[[NSBundle mainBundle] resourcePath]];
115 [path appendString:@"/bugsAndFeatures.txt"];
117 system([path cString]);
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;
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
193 [draggedVersesOwner release];
194 draggedVersesOwner = sender;
197 - (void)clearDraggedVersesOwnerIfEqualTo:(id)sender
199 if(draggedVersesOwner == sender) {
200 [draggedVersesOwner release];
201 draggedVersesOwner = nil;
205 - (id)draggedVersesOwner
207 return draggedVersesOwner;
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;
229 [draggedVersesArray release];
230 [draggedVersesOwner release];
231 [copiedVersesArray release];