summaryrefslogtreecommitdiffstats
path: root/macosx/PrefsController.m
blob: 09414e1db21e9fc85402548e02b7b4f2333e8d4e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
#import "PrefsController.h"

@implementation PrefsController

- (void) awakeFromNib
{
    NSUserDefaults * defaults;
    NSDictionary   * appDefaults;
    
    /* Unless the user specified otherwise, default is to check
       for update  DefAdvancedx264Flags*/
    defaults    = [NSUserDefaults standardUserDefaults];

   	NSString *defDestDirectory =  @"~/Desktop";
	defDestDirectory = [defDestDirectory stringByExpandingTildeInPath];
	
	NSString *defSrcDirectory =  @"~/Desktop";
	defSrcDirectory = [defSrcDirectory stringByExpandingTildeInPath];

    appDefaults = [NSDictionary dictionaryWithObjectsAndKeys:
        @"YES",             @"CheckForUpdates",
        @"English",         @"DefaultLanguage",
        @"NO",              @"DefaultMpegName",
        @"YES",             @"DefaultCrf",
        @"NO",              @"DefaultDeinterlaceOn",
        @"YES",             @"DefaultPicSizeAutoiPod",
        @"NO",              @"PixelRatio",
        @"NO",              @"DefAdvancedx264FlagsShow",
        @"",                @"DefAdvancedx264Flags",
        @"YES",             @"DefaultPresetsDrawerShow",
        defDestDirectory,   @"LastDestinationDirectory",
        defSrcDirectory,    @"LastSourceDirectory",
        @"NO",              @"DefaultAutoNaming",
        @"NO",              @"DefaultChapterMarkers",
        @"NO",              @"ShowVerboseOutput",
        nil];
    
	[defaults registerDefaults: appDefaults];

	/* fUpdateCheck Check or uncheck according to the preferences */
    [fUpdateCheck setState: [defaults boolForKey:@"CheckForUpdates"] ?
        NSOnState : NSOffState];

	// Fill the languages combobox
    [fdefaultlanguage removeAllItems];
	[fdefaultlanguage addItemWithObjectValue: @"Afar"];
	[fdefaultlanguage addItemWithObjectValue: @"Abkhazian"];
	[fdefaultlanguage addItemWithObjectValue: @"Afrikaans"];
	[fdefaultlanguage addItemWithObjectValue: @"Albanian"];
	[fdefaultlanguage addItemWithObjectValue: @"Amharic"];
	[fdefaultlanguage addItemWithObjectValue: @"Arabic"];
	[fdefaultlanguage addItemWithObjectValue: @"Armenian"];
	[fdefaultlanguage addItemWithObjectValue: @"Assamese"];
	[fdefaultlanguage addItemWithObjectValue: @"Avestan"];
	[fdefaultlanguage addItemWithObjectValue: @"Aymara"];
	[fdefaultlanguage addItemWithObjectValue: @"Azerbaijani"];
	[fdefaultlanguage addItemWithObjectValue: @"Bashkir"];
	[fdefaultlanguage addItemWithObjectValue: @"Basque"];
	[fdefaultlanguage addItemWithObjectValue: @"Belarusian"];
	[fdefaultlanguage addItemWithObjectValue: @"Bengali"];
	[fdefaultlanguage addItemWithObjectValue: @"Bihari"];
	[fdefaultlanguage addItemWithObjectValue: @"Bislama"];
	[fdefaultlanguage addItemWithObjectValue: @"Bosnian"];
	[fdefaultlanguage addItemWithObjectValue: @"Breton"];
	[fdefaultlanguage addItemWithObjectValue: @"Bulgarian"];
	[fdefaultlanguage addItemWithObjectValue: @"Burmese"];
	[fdefaultlanguage addItemWithObjectValue: @"Catalan"];
	[fdefaultlanguage addItemWithObjectValue: @"Chamorro"];
	[fdefaultlanguage addItemWithObjectValue: @"Chechen"];
	[fdefaultlanguage addItemWithObjectValue: @"Chichewa; Nyanja"];
	[fdefaultlanguage addItemWithObjectValue: @"Chinese"];
	[fdefaultlanguage addItemWithObjectValue: @"Church Slavic"];
	[fdefaultlanguage addItemWithObjectValue: @"Chuvash"];
	[fdefaultlanguage addItemWithObjectValue: @"Cornish"];
	[fdefaultlanguage addItemWithObjectValue: @"Corsican"];
	[fdefaultlanguage addItemWithObjectValue: @"Croatian"];
	[fdefaultlanguage addItemWithObjectValue: @"Czech"];
	[fdefaultlanguage addItemWithObjectValue: @"Dansk"];
	[fdefaultlanguage addItemWithObjectValue: @"Deutsch"];
	[fdefaultlanguage addItemWithObjectValue: @"Dzongkha"];
	[fdefaultlanguage addItemWithObjectValue: @"English"];
	[fdefaultlanguage addItemWithObjectValue: @"Espanol"];
	[fdefaultlanguage addItemWithObjectValue: @"Esperanto"];
	[fdefaultlanguage addItemWithObjectValue: @"Estonian"];
	[fdefaultlanguage addItemWithObjectValue: @"Faroese"];
	[fdefaultlanguage addItemWithObjectValue: @"Fijian"];
	[fdefaultlanguage addItemWithObjectValue: @"Francais"];
	[fdefaultlanguage addItemWithObjectValue: @"Frisian"];
	[fdefaultlanguage addItemWithObjectValue: @"Georgian"];
	[fdefaultlanguage addItemWithObjectValue: @"Gaelic (Scots)"];
	[fdefaultlanguage addItemWithObjectValue: @"Gallegan"];
	[fdefaultlanguage addItemWithObjectValue: @"Greek, Modern ()"];
	[fdefaultlanguage addItemWithObjectValue: @"Guarani"];
	[fdefaultlanguage addItemWithObjectValue: @"Gujarati"];
	[fdefaultlanguage addItemWithObjectValue: @"Hebrew"];
	[fdefaultlanguage addItemWithObjectValue: @"Herero"];
	[fdefaultlanguage addItemWithObjectValue: @"Hindi"];
	[fdefaultlanguage addItemWithObjectValue: @"Hiri Motu"];
	[fdefaultlanguage addItemWithObjectValue: @"Inuktitut"];
	[fdefaultlanguage addItemWithObjectValue: @"Interlingue"];
	[fdefaultlanguage addItemWithObjectValue: @"Interlingua"];
	[fdefaultlanguage addItemWithObjectValue: @"Indonesian"];
	[fdefaultlanguage addItemWithObjectValue: @"Inupiaq"];
	[fdefaultlanguage addItemWithObjectValue: @"Irish"];
	[fdefaultlanguage addItemWithObjectValue: @"Islenska"];
	[fdefaultlanguage addItemWithObjectValue: @"Italian"];
	[fdefaultlanguage addItemWithObjectValue: @"Javanese"];
	[fdefaultlanguage addItemWithObjectValue: @"Japanese"];
	[fdefaultlanguage addItemWithObjectValue: @"Kalaallisut (Greenlandic)"];
	[fdefaultlanguage addItemWithObjectValue: @"Kannada"];
	[fdefaultlanguage addItemWithObjectValue: @"Kashmiri"];
	[fdefaultlanguage addItemWithObjectValue: @"Kazakh"];
	[fdefaultlanguage addItemWithObjectValue: @"Khmer"];
	[fdefaultlanguage addItemWithObjectValue: @"Kikuyu"];
	[fdefaultlanguage addItemWithObjectValue: @"Kinyarwanda"];
	[fdefaultlanguage addItemWithObjectValue: @"Kirghiz"];
	[fdefaultlanguage addItemWithObjectValue: @"Komi"];
	[fdefaultlanguage addItemWithObjectValue: @"Korean"];
	[fdefaultlanguage addItemWithObjectValue: @"Kuanyama"];
	[fdefaultlanguage addItemWithObjectValue: @"Kurdish"];
	[fdefaultlanguage addItemWithObjectValue: @"Lao"];
	[fdefaultlanguage addItemWithObjectValue: @"Latin"];
	[fdefaultlanguage addItemWithObjectValue: @"Latvian"];
	[fdefaultlanguage addItemWithObjectValue: @"Lingala"];
	[fdefaultlanguage addItemWithObjectValue: @"Lithuanian"];
	[fdefaultlanguage addItemWithObjectValue: @"Letzeburgesch"];
	[fdefaultlanguage addItemWithObjectValue: @"Macedonian"];
	[fdefaultlanguage addItemWithObjectValue: @"Magyar"];
	[fdefaultlanguage addItemWithObjectValue: @"Malay"];
	[fdefaultlanguage addItemWithObjectValue: @"Malayalam"];
	[fdefaultlanguage addItemWithObjectValue: @"Malagasy"];
	[fdefaultlanguage addItemWithObjectValue: @"Maltese"];
	[fdefaultlanguage addItemWithObjectValue: @"Manx"];
	[fdefaultlanguage addItemWithObjectValue: @"Maori"];
	[fdefaultlanguage addItemWithObjectValue: @"Marathi"];
	[fdefaultlanguage addItemWithObjectValue: @"Marshall"];
	[fdefaultlanguage addItemWithObjectValue: @"Moldavian"];
	[fdefaultlanguage addItemWithObjectValue: @"Mongolian"];
	[fdefaultlanguage addItemWithObjectValue: @"Nauru"];
	[fdefaultlanguage addItemWithObjectValue: @"Navajo"];
	[fdefaultlanguage addItemWithObjectValue: @"Ndebele, South"];
	[fdefaultlanguage addItemWithObjectValue: @"Ndebele, North"];
	[fdefaultlanguage addItemWithObjectValue: @"Ndonga"];
	[fdefaultlanguage addItemWithObjectValue: @"Nederlands"];
	[fdefaultlanguage addItemWithObjectValue: @"Nepali"];
	[fdefaultlanguage addItemWithObjectValue: @"Northern Sami"];
	[fdefaultlanguage addItemWithObjectValue: @"Norwegian"];
	[fdefaultlanguage addItemWithObjectValue: @"Norwegian Bokmal"];
	[fdefaultlanguage addItemWithObjectValue: @"Norwegian Nynorsk"];
	[fdefaultlanguage addItemWithObjectValue: @"Occitan (post 1500); Provencal"];
	[fdefaultlanguage addItemWithObjectValue: @"Oriya"];
	[fdefaultlanguage addItemWithObjectValue: @"Oromo"];
	[fdefaultlanguage addItemWithObjectValue: @"Ossetian; Ossetic"];
	[fdefaultlanguage addItemWithObjectValue: @"Panjabi"];
	[fdefaultlanguage addItemWithObjectValue: @"Persian"];
	[fdefaultlanguage addItemWithObjectValue: @"Pali"];
	[fdefaultlanguage addItemWithObjectValue: @"Polish"];
	[fdefaultlanguage addItemWithObjectValue: @"Portugues"];
	[fdefaultlanguage addItemWithObjectValue: @"Pushto"];
	[fdefaultlanguage addItemWithObjectValue: @"Quechua"];
	[fdefaultlanguage addItemWithObjectValue: @"Raeto-Romance"];
	[fdefaultlanguage addItemWithObjectValue: @"Romanian"];
	[fdefaultlanguage addItemWithObjectValue: @"Rundi"];
	[fdefaultlanguage addItemWithObjectValue: @"Russian"];
	[fdefaultlanguage addItemWithObjectValue: @"Sango"];
	[fdefaultlanguage addItemWithObjectValue: @"Sanskrit"];
	[fdefaultlanguage addItemWithObjectValue: @"Sardinian"];
	[fdefaultlanguage addItemWithObjectValue: @"Serbian"];
	[fdefaultlanguage addItemWithObjectValue: @"Sinhalese"];
	[fdefaultlanguage addItemWithObjectValue: @"Slovak"];
	[fdefaultlanguage addItemWithObjectValue: @"Slovenian"];
	[fdefaultlanguage addItemWithObjectValue: @"Samoan"];
	[fdefaultlanguage addItemWithObjectValue: @"Shona"];
	[fdefaultlanguage addItemWithObjectValue: @"Sindhi"];
	[fdefaultlanguage addItemWithObjectValue: @"Somali"];
	[fdefaultlanguage addItemWithObjectValue: @"Sotho, Southern"];
	[fdefaultlanguage addItemWithObjectValue: @"Sundanese"];
	[fdefaultlanguage addItemWithObjectValue: @"Suomi"];
	[fdefaultlanguage addItemWithObjectValue: @"Svenska"];
	[fdefaultlanguage addItemWithObjectValue: @"Swahili"];
	[fdefaultlanguage addItemWithObjectValue: @"Swati"];
	[fdefaultlanguage addItemWithObjectValue: @"Tahitian"];
	[fdefaultlanguage addItemWithObjectValue: @"Tamil"];
	[fdefaultlanguage addItemWithObjectValue: @"Tatar"];
	[fdefaultlanguage addItemWithObjectValue: @"Telugu"];
	[fdefaultlanguage addItemWithObjectValue: @"Tajik"];
	[fdefaultlanguage addItemWithObjectValue: @"Tagalog"];
	[fdefaultlanguage addItemWithObjectValue: @"Thai"];
	[fdefaultlanguage addItemWithObjectValue: @"Tibetan"];
	[fdefaultlanguage addItemWithObjectValue: @"Tigrinya"];
	[fdefaultlanguage addItemWithObjectValue: @"Tonga (Tonga Islands)"];
	[fdefaultlanguage addItemWithObjectValue: @"Tswana"];
	[fdefaultlanguage addItemWithObjectValue: @"Tsonga"];
	[fdefaultlanguage addItemWithObjectValue: @"Turkish"];
	[fdefaultlanguage addItemWithObjectValue: @"Turkmen"];
	[fdefaultlanguage addItemWithObjectValue: @"Twi"];
	[fdefaultlanguage addItemWithObjectValue: @"Uighur"];
	[fdefaultlanguage addItemWithObjectValue: @"Ukrainian"];
	[fdefaultlanguage addItemWithObjectValue: @"Urdu"];
	[fdefaultlanguage addItemWithObjectValue: @"Uzbek"];
	[fdefaultlanguage addItemWithObjectValue: @"Vietnamese"];
	[fdefaultlanguage addItemWithObjectValue: @"Volapk"];
	[fdefaultlanguage addItemWithObjectValue: @"Welsh"];
	[fdefaultlanguage addItemWithObjectValue: @"Wolof"];
	[fdefaultlanguage addItemWithObjectValue: @"Xhosa"];
	[fdefaultlanguage addItemWithObjectValue: @"Yiddish"];
	[fdefaultlanguage addItemWithObjectValue: @"Yoruba"];
	[fdefaultlanguage addItemWithObjectValue: @"Zhuang"];
	[fdefaultlanguage addItemWithObjectValue: @"Zulu"];
	[fdefaultlanguage setStringValue:@"English"];
	
	/* If a Default Language is selected then write it otherwise let English as default */
	
	if ([defaults stringForKey:@"DefaultLanguage"]!=NULL)
	{
		[fdefaultlanguage setStringValue:[defaults stringForKey:@"DefaultLanguage"]];
    }
	[fdefaultlanguage selectItemWithObjectValue:[defaults stringForKey:@"DefaultLanguage"]];

    


	/* fFileExtItunes Check or uncheck according to the preferences */
    [fFileExtItunes setState: [defaults boolForKey:@"DefaultMpegName"] ?
				  NSOnState : NSOffState];
	
	/* fDefCrf Check or uncheck according to the preferences*/
    [fDefCrf setState: [defaults boolForKey:@"DefaultCrf"] ?
		   NSOnState : NSOffState];
	
	/* fDefDeinterlace Check or uncheck according to the preferences*/
    [fDefDeinterlace setState: [defaults boolForKey:@"DefaultDeinterlaceOn"] ?
				   NSOnState : NSOffState];
	
	/* fDefPicSizeAutoSetipod Check or uncheck according to the preferences*/
    [fDefPicSizeAutoSetipod setState: [defaults boolForKey:@"DefaultPicSizeAutoiPod"] ?
						  NSOnState : NSOffState];
	/* fDefPixelRatio */
    [fDefPixelRatio setState: [defaults boolForKey:@"PixelRatio"] ?
				  NSOnState : NSOffState];
	
	/* fDefAdvancedx264FlagsShow */
    [fDefAdvancedx264FlagsShow setState: [defaults boolForKey:@"DefAdvancedx264FlagsShow"] ?
				  NSOnState : NSOffState];
	/* Insert default DefAdvanced x264 Flag here */
	if ([defaults stringForKey:@"DefAdvancedx264Flags"]!=NULL)
	{
	[fDefAdvancedx264FlagsView setStringValue:[defaults stringForKey:@"DefAdvancedx264Flags"]];
	}
	
	/* fDefPresetDrawerShow Check or uncheck according to the preferences*/
    [fDefPresetDrawerShow setState: [defaults boolForKey:@"DefaultPresetsDrawerShow"] ?
		   NSOnState : NSOffState];
	/* fDefAutoNaming Check or uncheck according to the preferences*/
    [fDefAutoNaming setState: [defaults boolForKey:@"DefaultAutoNaming"] ?
		   NSOnState : NSOffState];
	/* fDefChapterMarkers Check or uncheck according to the preferences*/
    [fDefChapterMarkers setState: [defaults boolForKey:@"DefaultChapterMarkers"] ?
		   NSOnState : NSOffState];
}


- (IBAction) OpenPanel: (id) sender;
{
    [NSApp runModalForWindow: fPanel];
}

- (IBAction) ClosePanel: (id) sender;
{
    [self CheckChanged: sender]; 
    [NSApp stopModal];
    [fPanel orderOut: sender];
}

- (IBAction) CheckChanged: (id) sender
{
    NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults];
    
    /* Check Update CheckForUpdates Set */
	if( [fUpdateCheck state] == NSOnState )
    {
        [defaults setObject:@"YES" forKey:@"CheckForUpdates"];
    }
    else
    {
        [defaults setObject:@"NO" forKey:@"CheckForUpdates"];
    }
	
	/* Preferred Language Combobox Set */

	[defaults setObject:[fdefaultlanguage objectValueOfSelectedItem]  forKey:@"DefaultLanguage"];


	/* File Extension Itunes Set */
	
	if( [fFileExtItunes state] == NSOnState )
    {
        [defaults setObject:@"YES" forKey:@"DefaultMpegName"];
    }
    else
    {
        [defaults setObject:@"NO" forKey:@"DefaultMpegName"];
    }
	
	/* Use CRF for constant mode */
	
	if( [fDefCrf state] == NSOnState )
    {
        [defaults setObject:@"YES" forKey:@"DefaultCrf"];
    }
    else
    {
        [defaults setObject:@"NO" forKey:@"DefaultCrf"];
    }

  /* Use Deinterlace on as a default*/
	
	if( [fDefDeinterlace state] == NSOnState )
    {
        [defaults setObject:@"YES" forKey:@"DefaultDeinterlaceOn"];
    }
    else
    {
        [defaults setObject:@"NO" forKey:@"DefaultDeinterlaceOn"];
    }
	
	  /* Use Picture size set to 640 upon x264 (iPod) Selection as a default*/
	
	if( [fDefPicSizeAutoSetipod state] == NSOnState )
    {
        [defaults setObject:@"YES" forKey:@"DefaultPicSizeAutoiPod"];
    }
    else
    {
        [defaults setObject:@"NO" forKey:@"DefaultPicSizeAutoiPod"];
    }
	
	  /* Use Pixel Ratio*/
	
	if( [fDefPixelRatio state] == NSOnState )
    {
        [defaults setObject:@"YES" forKey:@"PixelRatio"];
    }
    else
    {
        [defaults setObject:@"NO" forKey:@"PixelRatio"];
    }
 /* Show Chosen Advanced Flags to be used in main window*/
 if( [fDefAdvancedx264FlagsShow state] == NSOnState )
    {
        [defaults setObject:@"YES" forKey:@"DefAdvancedx264FlagsShow"];
    }
    else
    {
        [defaults setObject:@"NO" forKey:@"DefAdvancedx264FlagsShow"];
    }
		
	/*Advanced x264 Flag string into */
      [defaults setObject:[fDefAdvancedx264FlagsView stringValue]  forKey:@"DefAdvancedx264Flags"];	
	  
	    /* Show Presets Drawer upon launch*/
	
	if( [fDefPresetDrawerShow state] == NSOnState )
    {
        [defaults setObject:@"YES" forKey:@"DefaultPresetsDrawerShow"];
    }
    else
    {
        [defaults setObject:@"NO" forKey:@"DefaultPresetsDrawerShow"];
    }

    /* Use Auto Naming */
	
	if( [fDefAutoNaming state] == NSOnState )
    {
        [defaults setObject:@"YES" forKey:@"DefaultAutoNaming"];
    }
    else
    {
        [defaults setObject:@"NO" forKey:@"DefaultAutoNaming"];
    }
	/* Chapter Markers */
	if( [fDefChapterMarkers state] == NSOnState )
    {
        [defaults setObject:@"YES" forKey:@"DefaultChapterMarkers"];
    }
    else
    {
        [defaults setObject:@"NO" forKey:@"DefaultChapterMarkers"];
    }

}

@end