1 /*****************************************************************************
2 * simple_prefs.m: Simple Preferences for Mac OS X
3 *****************************************************************************
4 * Copyright (C) 2008 the VideoLAN team
7 * Authors: Felix Paul Kühne <fkuehne at videolan dot org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 #import "simple_prefs.h"
28 static NSString* VLCSPrefsToolbarIdentifier = @"Our Simple Preferences Toolbar Identifier";
29 static NSString* VLCIntfSettingToolbarIdentifier = @"Intf Settings Item Identifier";
30 static NSString* VLCAudioSettingToolbarIdentifier = @"Audio Settings Item Identifier";
31 static NSString* VLCVideoSettingToolbarIdentifier = @"Video Settings Item Identifier";
32 static NSString* VLCOSDSettingToolbarIdentifier = @"Subtitles Settings Item Identifier";
33 static NSString* VLCInputSettingToolbarIdentifier = @"Input Settings Item Identifier";
34 static NSString* VLCHotkeysSettingToolbarIdentifier = @"Hotkeys Settings Item Identifier";
36 @implementation VLCSimplePrefs
38 static VLCSimplePrefs *_o_sharedInstance = nil;
40 + (VLCSimplePrefs *)sharedInstance
42 return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init];
47 if (_o_sharedInstance) {
51 _o_sharedInstance = [super init];
54 return _o_sharedInstance;
59 [o_currentlyShownCategoryView release];
60 [o_sprefs_toolbar release];
62 [o_hotkeySettings release];
63 [o_hotkeyDescriptions release];
64 [o_hotkeysNonUseableKeys release];
66 if( o_keyInTransition )
67 [o_keyInTransition release];
73 - (NSString *)OSXKeyToString:(int)val
75 NSMutableString *o_temp_str = [[[NSMutableString alloc] init] autorelease];
76 if( val & KEY_MODIFIER_CTRL )
77 [o_temp_str appendString: [NSString stringWithUTF8String: "\xE2\x8C\x83"]];
78 if( val & KEY_MODIFIER_ALT )
79 [o_temp_str appendString: [NSString stringWithUTF8String: "\xE2\x8C\xA5"]];
80 if( val & KEY_MODIFIER_SHIFT )
81 [o_temp_str appendString: [NSString stringWithUTF8String: "\xE2\x87\xA7"]];
82 if( val & KEY_MODIFIER_COMMAND )
83 [o_temp_str appendString: [NSString stringWithUTF8String: "\xE2\x8C\x98"]];
85 unsigned int i_keys = sizeof(vlc_keys)/sizeof(key_descriptor_t);
86 for( unsigned int i = 0; i< i_keys; i++ )
88 if( vlc_keys[i].i_key_code == (val& ~KEY_MODIFIER) )
90 if( vlc_keys[i].psz_key_string )
91 [o_temp_str appendString: [NSString stringWithUTF8String: vlc_keys[i].psz_key_string]];
93 o_temp_str = @"Unset";
103 /* setup the toolbar */
104 o_sprefs_toolbar = [[[NSToolbar alloc] initWithIdentifier: VLCSPrefsToolbarIdentifier] autorelease];
105 [o_sprefs_toolbar setAllowsUserCustomization: NO];
106 [o_sprefs_toolbar setAutosavesConfiguration: NO];
107 [o_sprefs_toolbar setDisplayMode: NSToolbarDisplayModeIconAndLabel];
108 [o_sprefs_toolbar setSizeMode: NSToolbarSizeModeRegular];
109 [o_sprefs_toolbar setDelegate: self];
110 [o_sprefs_win setToolbar: o_sprefs_toolbar];
112 /* setup useful stuff */
113 /* TODO: hard-code this instead of one-the-run generation */
114 o_hotkeysNonUseableKeys = [[NSArray arrayWithObjects:
115 [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'c'],
116 [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'x'],
117 [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'v'],
118 [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'a'],
119 [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|','],
120 [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'h'],
121 [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|KEY_MODIFIER_ALT|'h'],
122 [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|KEY_MODIFIER_SHIFT|'o'],
123 [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'o'],
124 [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'d'],
125 [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'n'],
126 [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'s'],
127 [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'z'],
128 [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'l'],
129 [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'r'],
130 [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'0'],
131 [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'1'],
132 [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'2'],
133 [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'3'],
134 [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'m'],
135 [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'q'],
136 [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'w'],
137 [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|KEY_MODIFIER_SHIFT|'w'],
138 [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|KEY_MODIFIER_SHIFT|'c'],
139 [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|KEY_MODIFIER_SHIFT|'p'],
140 [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'i'],
141 [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'e'],
142 [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|KEY_MODIFIER_SHIFT|'e'],
143 [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'b'],
144 [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|KEY_MODIFIER_SHIFT|'m'],
145 [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|KEY_MODIFIER_CTRL|'m'],
146 [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|'?'],
147 [NSNumber numberWithInt: KEY_MODIFIER_COMMAND|KEY_MODIFIER_ALT|'?'],
151 - (NSToolbarItem *) toolbar: (NSToolbar *)o_sprefs_toolbar
152 itemForItemIdentifier: (NSString *)o_itemIdent
153 willBeInsertedIntoToolbar: (BOOL)b_willBeInserted
155 NSToolbarItem *o_toolbarItem = nil;
157 #define CreateToolbarItem( o_name, o_desc, o_img, sel ) \
158 o_toolbarItem = [[[NSToolbarItem alloc] initWithItemIdentifier: o_itemIdent] autorelease]; \
160 [o_toolbarItem setLabel: o_name]; \
161 [o_toolbarItem setPaletteLabel: o_desc]; \
163 [o_toolbarItem setToolTip: o_desc]; \
164 [o_toolbarItem setImage: [NSImage imageNamed: o_img]]; \
166 [o_toolbarItem setTarget: self]; \
167 [o_toolbarItem setAction: @selector( sel )]; \
169 [o_toolbarItem setEnabled: YES]; \
170 [o_toolbarItem setAutovalidates: YES]
172 if( [o_itemIdent isEqual: VLCIntfSettingToolbarIdentifier] )
174 CreateToolbarItem( _NS("Interface"), _NS("Interface Settings"), @"spref_cone_Interface_64", showInterfaceSettings );
176 else if( [o_itemIdent isEqual: VLCAudioSettingToolbarIdentifier] )
178 CreateToolbarItem( _NS("Audio"), _NS("General Audio Settings"), @"spref_cone_Audio_64", showAudioSettings );
180 else if( [o_itemIdent isEqual: VLCVideoSettingToolbarIdentifier] )
182 CreateToolbarItem( _NS("Video"), _NS("General Video Settings"), @"spref_cone_Video_64", showVideoSettings );
184 else if( [o_itemIdent isEqual: VLCOSDSettingToolbarIdentifier] )
186 CreateToolbarItem( _NS("Subtitles & OSD"), _NS("Subtitles & OSD Settings"), @"spref_cone_Subtitles_64", showOSDSettings );
188 else if( [o_itemIdent isEqual: VLCInputSettingToolbarIdentifier] )
190 CreateToolbarItem( _NS("Input & Codecs"), _NS("Input & Codec settings"), @"spref_cone_Input_64", showInputSettings );
192 else if( [o_itemIdent isEqual: VLCHotkeysSettingToolbarIdentifier] )
194 CreateToolbarItem( _NS("Hotkeys"), _NS("Hotkeys settings"), @"spref_cone_Hotkeys_64", showHotkeySettings );
197 return o_toolbarItem;
200 - (NSArray *)toolbarDefaultItemIdentifiers: (NSToolbar *)toolbar
202 return [NSArray arrayWithObjects: VLCIntfSettingToolbarIdentifier, VLCAudioSettingToolbarIdentifier, VLCVideoSettingToolbarIdentifier,
203 VLCOSDSettingToolbarIdentifier, VLCInputSettingToolbarIdentifier, VLCHotkeysSettingToolbarIdentifier, NSToolbarFlexibleSpaceItemIdentifier, nil];
206 - (NSArray *)toolbarAllowedItemIdentifiers: (NSToolbar *)toolbar
208 return [NSArray arrayWithObjects: VLCIntfSettingToolbarIdentifier, VLCAudioSettingToolbarIdentifier, VLCVideoSettingToolbarIdentifier,
209 VLCOSDSettingToolbarIdentifier, VLCInputSettingToolbarIdentifier, VLCHotkeysSettingToolbarIdentifier, NSToolbarFlexibleSpaceItemIdentifier, nil];
212 - (NSArray *)toolbarSelectableItemIdentifiers:(NSToolbar *)toolbar
214 return [NSArray arrayWithObjects: VLCIntfSettingToolbarIdentifier, VLCAudioSettingToolbarIdentifier, VLCVideoSettingToolbarIdentifier,
215 VLCOSDSettingToolbarIdentifier, VLCInputSettingToolbarIdentifier, VLCHotkeysSettingToolbarIdentifier, nil];
221 [o_audio_dolby_txt setStringValue: _NS("Force detection of Dolby Surround")];
222 [o_audio_effects_box setTitle: _NS("Effects")];
223 [o_audio_enable_ckb setTitle: _NS("Enable Audio")];
224 [o_audio_general_box setTitle: _NS("General Audio")];
225 [o_audio_headphone_ckb setTitle: _NS("Headphone surround effect")];
226 [o_audio_lang_txt setStringValue: _NS("Preferred Audio language")];
227 [o_audio_last_ckb setTitle: _NS("Enable Last.fm submissions")];
228 [o_audio_lastpwd_txt setStringValue: _NS("Password")];
229 [o_audio_lastuser_txt setStringValue: _NS("User name")];
230 [o_audio_norm_ckb setTitle: _NS("Volume normalizer")];
231 [o_audio_spdif_ckb setTitle: _NS("Use S/PDIF when available")];
232 [o_audio_visual_txt setStringValue: _NS("Visualization")];
233 [o_audio_vol_txt setStringValue: _NS("Default Volume")];
236 [o_hotkeys_change_btn setTitle: _NS("Change")];
237 [o_hotkeys_change_win setTitle: _NS("Change Hotkey")];
238 [o_hotkeys_change_cancel_btn setTitle: _NS("Cancel")];
239 [o_hotkeys_change_ok_btn setTitle: _NS("OK")];
240 [o_hotkeys_clear_btn setTitle: _NS("Clear")];
241 [o_hotkeys_lbl setStringValue: _NS("Select an action to change the associated hotkey:")];
242 [[[o_hotkeys_listbox tableColumnWithIdentifier: @"action"] headerCell] setStringValue: _NS("Action")];
243 [[[o_hotkeys_listbox tableColumnWithIdentifier: @"shortcut"] headerCell] setStringValue: _NS("Shortcut")];
246 [o_input_access_box setTitle: _NS("Access Filter")];
247 [o_input_avi_txt setStringValue: _NS("Repair AVI Files")];
248 [o_input_bandwidth_ckb setTitle: _NS("Bandwidth limiter")];
249 [o_input_cachelevel_txt setStringValue: _NS("Default Caching Level")];
250 [o_input_caching_box setTitle: _NS("Caching")];
251 [o_input_dump_ckb setTitle: _NS("Dump")];
252 [o_input_httpproxy_txt setStringValue: _NS("HTTP Proxy")];
253 [o_input_mux_box setTitle: _NS("Codecs / Muxers")];
254 [o_input_net_box setTitle: _NS("Network")];
255 [o_input_postproc_txt setStringValue: _NS("Post-Processing Quality")];
256 [o_input_record_ckb setTitle: _NS("Record")];
257 [o_input_rtsp_ckb setTitle: _NS("Use RTP over RTSP (TCP)")];
258 [o_input_serverport_txt setStringValue: _NS("Default Server Port")];
259 [o_input_timeshift_ckb setTitle: _NS("Timeshift")];
262 [o_intf_art_txt setStringValue: _NS("Album art download policy")];
263 [o_intf_embedded_ckb setTitle: _NS("Add controls to the video window")];
264 [o_intf_fspanel_ckb setTitle: _NS("Show Fullscreen Controller")];
265 [o_intf_lang_txt setStringValue: _NS("Language")];
266 [o_intf_meta_ckb setTitle: _NS("Fetch the metadata from the Internet")];
267 [o_intf_network_box setTitle: _NS("Privacy / Network Interaction")];
269 /* Subtitles and OSD */
270 [o_osd_encoding_txt setStringValue: _NS("Default Encoding")];
271 [o_osd_font_box setTitle: _NS("Display Settings")];
272 [o_osd_font_btn setTitle: _NS("Browse...")];
273 [o_osd_font_color_txt setStringValue: _NS("Font Color")];
274 [o_osd_font_effect_txt setStringValue: _NS("Effect")];
275 [o_osd_font_size_txt setStringValue: _NS("Font Size")];
276 [o_osd_font_txt setStringValue: _NS("Font")];
277 [o_osd_lang_box setTitle: _NS("Subtitle Languages")];
278 [o_osd_lang_txt setStringValue: _NS("Preferred Subtitle Language")];
279 [o_osd_osd_box setTitle: _NS("On Screen Display")];
280 [o_osd_osd_ckb setTitle: _NS("Enable OSD")];
283 [[o_sprefs_basicFull_matrix cellAtRow: 0 column: 0] setStringValue: _NS("Basic")];
284 [[o_sprefs_basicFull_matrix cellAtRow: 0 column: 1] setStringValue: _NS("All")];
285 [o_sprefs_cancel_btn setTitle: _NS("Cancel")];
286 [o_sprefs_reset_btn setTitle: _NS("Reset Preferences")];
287 [o_sprefs_save_btn setTitle: _NS("Save")];
288 [o_sprefs_win setTitle: _NS("Preferences")];
291 [o_video_black_ckb setTitle: _NS("Black screens in Fullscreen mode")];
292 [o_video_device_txt setStringValue: _NS("Display device")];
293 [o_video_display_box setTitle: _NS("Display")];
294 [o_video_enable_ckb setTitle: _NS("Enable Video")];
295 [o_video_fullscreen_ckb setTitle: _NS("Fullscreen")];
296 [o_video_onTop_ckb setTitle: _NS("Always on top")];
297 [o_video_output_txt setStringValue: _NS("Display device")];
298 [o_video_skipFrames_ckb setTitle: _NS("Skip frames")];
299 [o_video_snap_box setTitle: _NS("Video snapshots")];
300 [o_video_snap_folder_btn setTitle: _NS("Browse...")];
301 [o_video_snap_folder_txt setStringValue: _NS("Folder")];
302 [o_video_snap_format_txt setStringValue: _NS("Format")];
303 [o_video_snap_prefix_txt setStringValue: _NS("Prefix")];
304 [o_video_snap_seqnum_ckb setTitle: _NS("Sequential numbering")];
307 - (void)resetControls
309 module_config_t *p_item;
313 #define SetupIntList( object, name ) \
314 [object removeAllItems]; \
315 p_item = config_FindConfig( VLC_OBJECT(p_intf), name ); \
316 for( i = 0; i < p_item->i_list; i++ ) \
318 if( p_item->ppsz_list_text[i] != NULL) \
319 [object addItemWithTitle: _NS( p_item->ppsz_list_text[i] )]; \
321 [object addItemWithTitle: [NSString stringWithUTF8String: p_item->ppsz_list[i]]]; \
323 if( p_item->value.i < [object numberOfItems] ) \
324 [object selectItemAtIndex: p_item->value.i]; \
326 [object selectItemAtIndex: 0]
328 #define SetupStringList( object, name ) \
329 [object removeAllItems]; \
331 p_item = config_FindConfig( VLC_OBJECT(p_intf), name ); \
332 for( i = 0; p_item->ppsz_list[i] != nil; i++ ) \
334 [object addItemWithTitle: _NS( p_item->ppsz_list_text[i] )]; \
335 if( p_item->value.psz && !strcmp( p_item->value.psz, p_item->ppsz_list[i] ) ) \
338 [object selectItemAtIndex: y]
340 /**********************
341 * interface settings *
342 **********************/
343 SetupStringList( o_intf_lang_pop, "language" );
344 SetupIntList( o_intf_art_pop, "album-art" );
346 [o_intf_meta_ckb setState: config_GetInt( p_intf, "fetch-meta" )];
347 [o_intf_fspanel_ckb setState: config_GetInt( p_intf, "macosx-fspanel" )];
348 [o_intf_embedded_ckb setState: config_GetInt( p_intf, "embedded-video" )];
353 [o_audio_enable_ckb setState: config_GetInt( p_intf, "audio" )];
354 [o_audio_vol_fld setIntValue: config_GetInt( p_intf, "volume" )];
355 [o_audio_vol_sld setIntValue: config_GetInt( p_intf, "volume" )];
357 [o_audio_spdif_ckb setState: config_GetInt( p_intf, "spdif" )];
359 SetupIntList( o_audio_dolby_pop, "force-dolby-surround" );
361 [o_audio_lang_fld setStringValue: [NSString stringWithUTF8String: config_GetPsz( p_intf, "audio-language" )]];
363 [o_audio_headphone_ckb setState: config_GetInt( p_intf, "headphone-dolby" )];
365 psz_tmp = config_GetPsz( p_intf, "audio-filter" );
367 [o_audio_norm_ckb setState: (int)strstr( psz_tmp, "normvol" )];
368 [o_audio_norm_fld setFloatValue: config_GetFloat( p_intf, "norm-max-level" )];
371 msg_Warn( p_intf, "visualizer not implemented!" );
373 /* Last.FM is optional */
374 if( module_Exists( p_intf, "audioscrobbler" ) )
376 [o_audio_lastuser_fld setStringValue: [NSString stringWithUTF8String: config_GetPsz( p_intf, "lastfm-username" )]];
377 [o_audio_lastpwd_fld setStringValue: [NSString stringWithUTF8String: config_GetPsz( p_intf, "lastfm-password" )]];
379 if( config_ExistIntf( VLC_OBJECT( p_intf ), "audioscrobbler" ) )
380 [o_audio_last_ckb setState: NSOnState];
382 [o_audio_last_ckb setState: NSOffState];
388 [o_video_enable_ckb setState: config_GetInt( p_intf, "video" )];
389 [o_video_fullscreen_ckb setState: config_GetInt( p_intf, "fullscreen" )];
390 [o_video_onTop_ckb setState: config_GetInt( p_intf, "video-on-top" )];
391 [o_video_skipFrames_ckb setState: config_GetInt( p_intf, "skip-frames" )];
392 [o_video_black_ckb setState: config_GetInt( p_intf, "macosx-black" )];
394 msg_Warn( p_intf, "vout module and display device selectors not implemented!" );
396 if( config_GetPsz( p_intf, "snapshot-path" ) != NULL )
397 [o_video_snap_folder_fld setStringValue: [NSString stringWithUTF8String: config_GetPsz( p_intf, "snapshot-path" )]];
398 [o_video_snap_prefix_fld setStringValue: [NSString stringWithUTF8String: config_GetPsz( p_intf, "snapshot-prefix" )]];
399 [o_video_snap_seqnum_ckb setState: config_GetInt( p_intf, "snapshot-sequential" )];
401 p_item = config_FindConfig( VLC_OBJECT(p_intf), "snapshot-format" );
402 for( i = 0; p_item->ppsz_list[i] != nil; i++ )
404 [o_video_snap_format_pop addItemWithTitle: [NSString stringWithUTF8String: p_item->ppsz_list[i]]];
405 if( p_item->value.psz && !strcmp( p_item->value.psz, p_item->ppsz_list[i] ) )
408 [o_video_snap_format_pop selectItemAtIndex: y];
410 /***************************
411 * input & codecs settings *
412 ***************************/
413 [o_input_serverport_fld setIntValue: config_GetInt( p_intf, "server-port" )];
414 if( config_GetPsz( p_intf, "http-proxy" ) != NULL )
415 [o_input_httpproxy_fld setStringValue: [NSString stringWithUTF8String: config_GetPsz( p_intf, "http-proxy" )]];
416 [o_input_postproc_fld setIntValue: config_GetInt( p_intf, "ffmpeg-pp-q" )];
418 SetupIntList( o_input_avi_pop, "avi-index" );
420 [o_input_rtsp_ckb setState: config_GetInt( p_intf, "rtsp-tcp" )];
422 psz_tmp = config_GetPsz( p_intf, "access-filter" );
425 [o_input_record_ckb setState: (int)strstr( psz_tmp, "record" )];
426 [o_input_dump_ckb setState: (int)strstr( psz_tmp, "dump" )];
427 [o_input_bandwidth_ckb setState: (int)strstr( psz_tmp, "bandwidth" )];
428 [o_input_timeshift_ckb setState: (int)strstr( psz_tmp, "timeshift" )];
431 [o_input_cachelevel_pop removeAllItems];
432 [o_input_cachelevel_pop addItemsWithTitles:
433 [NSArray arrayWithObjects: _NS("Custom"), _NS("Lowest latency"), _NS("Low latency"), _NS("Normal"),
434 _NS("High latency"), _NS("Higher latency"), nil]];
435 [[o_input_cachelevel_pop itemAtIndex: 0] setTag: 0];
436 [[o_input_cachelevel_pop itemAtIndex: 1] setTag: 100];
437 [[o_input_cachelevel_pop itemAtIndex: 2] setTag: 200];
438 [[o_input_cachelevel_pop itemAtIndex: 3] setTag: 300];
439 [[o_input_cachelevel_pop itemAtIndex: 4] setTag: 400];
440 [[o_input_cachelevel_pop itemAtIndex: 5] setTag: 500];
442 #define TestCaC( name ) \
443 b_cache_equal = b_cache_equal && \
444 ( i_cache == config_GetInt( p_intf, name ) )
446 #define TestCaCi( name, int ) \
447 b_cache_equal = b_cache_equal && \
448 ( ( i_cache * int ) == config_GetInt( p_intf, name ) )
450 /* Select the accurate value of the PopupButton */
451 bool b_cache_equal = true;
452 int i_cache = config_GetInt( p_intf, "file-caching");
454 TestCaC( "udp-caching" );
455 if( module_Exists (p_intf, "dvdread") )
456 TestCaC( "dvdread-caching" );
457 if( module_Exists (p_intf, "dvdnav") )
458 TestCaC( "dvdnav-caching" );
459 TestCaC( "tcp-caching" );
460 TestCaC( "fake-caching" );
461 TestCaC( "cdda-caching" );
462 TestCaC( "screen-caching" );
463 TestCaC( "vcd-caching" );
464 TestCaCi( "rtsp-caching", 4 );
465 TestCaCi( "ftp-caching", 2 );
466 TestCaCi( "http-caching", 4 );
467 if(module_Exists (p_intf, "access_realrtsp"))
468 TestCaCi( "realrtsp-caching", 10 );
469 TestCaCi( "mms-caching", 19 );
471 [o_input_cachelevel_pop selectItemWithTag: i_cache];
473 [o_input_cachelevel_pop selectItemWithTitle: _NS("Custom")];
475 /*********************
476 * subtitle settings *
477 *********************/
478 [o_osd_osd_ckb setState: config_GetInt( p_intf, "osd" )];
480 [o_osd_encoding_pop removeAllItems];
482 p_item = config_FindConfig( VLC_OBJECT(p_intf), "subsdec-encoding" );
483 for( i = 0; p_item->ppsz_list[i] != nil; i++ )
485 if( p_item->ppsz_list[i] != "" )
486 [o_osd_encoding_pop addItemWithTitle: _NS( p_item->ppsz_list[i] )];
488 [o_osd_encoding_pop addItemWithTitle: @" "];
490 if( p_item->value.psz && !strcmp( p_item->value.psz, p_item->ppsz_list[i] ) )
493 [o_osd_encoding_pop selectItemAtIndex: y];
495 [o_osd_lang_fld setStringValue: [NSString stringWithUTF8String: config_GetPsz( p_intf, "sub-language" )]];
496 if( config_GetPsz( p_intf, "freetype-font" ) != NULL )
497 [o_osd_font_fld setStringValue: [NSString stringWithUTF8String: config_GetPsz( p_intf, "freetype-font" )]];
499 SetupIntList( o_osd_font_color_pop, "freetype-color" );
500 SetupIntList( o_osd_font_size_pop, "freetype-rel-fontsize" );
501 SetupIntList( o_osd_font_effect_pop, "freetype-effect" );
503 /********************
505 ********************/
506 struct hotkey *p_hotkeys = p_intf->p_libvlc->p_hotkeys;
507 o_hotkeySettings = [[NSMutableArray alloc] init];
508 NSMutableArray *o_tempArray_desc = [[NSMutableArray alloc] init];
513 p_item = config_FindConfig( VLC_OBJECT(p_intf), p_hotkeys[i].psz_action );
517 [o_tempArray_desc addObject: _NS( p_item->psz_text )];
518 [o_hotkeySettings addObject: [NSNumber numberWithInt: p_item->value.i]];
522 o_hotkeyDescriptions = [[NSArray alloc] initWithArray: o_tempArray_desc copyItems: YES];
523 [o_tempArray_desc release];
524 [o_hotkeys_listbox reloadData];
527 - (void)showSimplePrefs
529 /* we want to show the interface settings, if no category was chosen */
530 if( [o_sprefs_toolbar selectedItemIdentifier] == nil )
532 [o_sprefs_toolbar setSelectedItemIdentifier: VLCIntfSettingToolbarIdentifier];
533 [self showInterfaceSettings];
536 [self resetControls];
538 [o_sprefs_win makeKeyAndOrderFront: self];
541 - (IBAction)buttonAction:(id)sender
543 if( sender == o_sprefs_cancel_btn )
544 [o_sprefs_win orderOut: sender];
545 else if( sender == o_sprefs_save_btn )
547 [self saveChangedSettings];
548 [o_sprefs_win orderOut: sender];
550 else if( sender == o_sprefs_reset_btn )
551 NSBeginInformationalAlertSheet( _NS("Reset Preferences"), _NS("Cancel"),
552 _NS("Continue"), nil, o_sprefs_win, self,
553 @selector(sheetDidEnd: returnCode: contextInfo:), NULL, nil,
554 _NS("Beware this will reset the VLC media player preferences.\n"
555 "Are you sure you want to continue?") );
556 else if( sender == o_sprefs_basicFull_matrix )
558 [o_sprefs_win orderOut: self];
559 [[[VLCMain sharedInstance] getPreferences] showPrefs];
560 [self resetControls];
563 msg_Err( p_intf, "unknown buttonAction sender" );
566 - (void)sheetDidEnd:(NSWindow *)o_sheet
567 returnCode:(int)i_return
568 contextInfo:(void *)o_context
570 if( i_return == NSAlertAlternateReturn )
572 config_ResetAll( p_intf );
573 b_intfSettingChanged = b_videoSettingChanged = b_audioSettingChanged = YES;
574 [self resetControls];
578 - (void)saveChangedSettings
580 module_config_t *p_item;
584 #define SaveIntList( object, name ) \
585 p_item = config_FindConfig( VLC_OBJECT(p_intf), name ); \
586 if( [object indexOfSelectedItem] >= 0 ) \
587 config_PutInt( p_intf, name, p_item->pi_list[[object indexOfSelectedItem]] ); \
589 config_PutInt( p_intf, name, [object intValue] ) \
591 #define SaveStringList( object, name ) \
592 p_item = config_FindConfig( VLC_OBJECT(p_intf), name ); \
593 if( [object indexOfSelectedItem] >= 0 ) \
594 config_PutPsz( p_intf, name, strdup( p_item->ppsz_list[[object indexOfSelectedItem]] ) ); \
596 config_PutPsz( p_intf, name, strdup( [[VLCMain sharedInstance] delocalizeString: [object stringValue]] ) )
598 /**********************
599 * interface settings *
600 **********************/
601 if( b_intfSettingChanged )
603 SaveStringList( o_intf_lang_pop, "language" );
604 SaveIntList( o_intf_art_pop, "album-art" );
606 config_PutInt( p_intf, "fetch-meta", [o_intf_meta_ckb state] );
607 config_PutInt( p_intf, "macosx-fspanel", [o_intf_fspanel_ckb state] );
608 config_PutInt( p_intf, "embedded-video", [o_intf_embedded_ckb state] );
610 /* okay, let's save our changes to vlcrc */
611 i = config_SaveConfigFile( p_intf, "main" );
612 i = config_SaveConfigFile( p_intf, "macosx" );
616 msg_Err( p_intf, "An error occurred while saving the Interface settings using SimplePrefs (%i)", i );
620 b_intfSettingChanged = NO;
626 if( b_audioSettingChanged )
628 config_PutInt( p_intf, "audio", [o_audio_enable_ckb state] );
629 config_PutInt( p_intf, "volume", [o_audio_vol_sld intValue] );
630 config_PutInt( p_intf, "spdif", [o_audio_spdif_ckb state] );
632 SaveIntList( o_audio_dolby_pop, "force-dolby-surround" );
634 config_PutPsz( p_intf, "audio-language", [[o_audio_lang_fld stringValue] UTF8String] );
635 config_PutInt( p_intf, "headphone-dolby", [o_audio_headphone_ckb state] );
637 psz_tmp = config_GetPsz( p_intf, "audio-filter" );
639 config_PutPsz( p_intf, "audio-filter", "volnorm" );
640 else if( (int)strstr( psz_tmp, "normvol" ) == NO )
642 /* work-around a GCC 4.0.1 bug */
643 psz_tmp = (char *)[[NSString stringWithFormat: @"%s:volnorm", psz_tmp] UTF8String];
644 config_PutPsz( p_intf, "audio-filter", psz_tmp );
648 psz_tmp = (char *)[[[NSString stringWithUTF8String: psz_tmp] stringByTrimmingCharactersInSet: [NSCharacterSet characterSetWithCharactersInString:@":volnorm"]] UTF8String];
649 psz_tmp = (char *)[[[NSString stringWithUTF8String: psz_tmp] stringByTrimmingCharactersInSet: [NSCharacterSet characterSetWithCharactersInString:@"volnorm:"]] UTF8String];
650 psz_tmp = (char *)[[[NSString stringWithUTF8String: psz_tmp] stringByTrimmingCharactersInSet: [NSCharacterSet characterSetWithCharactersInString:@"volnorm"]] UTF8String];
651 config_PutPsz( p_intf, "audio-filter", psz_tmp );
653 config_PutFloat( p_intf, "norm-max-level", [o_audio_norm_fld floatValue] );
655 msg_Warn( p_intf, "visualizer not implemented!" );
657 /* Last.FM is optional */
658 if( module_Exists( p_intf, "audioscrobbler" ) )
660 if( [o_audio_last_ckb state] == NSOnState )
661 config_AddIntf( VLC_OBJECT( p_intf ), "audioscrobbler" );
663 config_RemoveIntf( VLC_OBJECT( p_intf ), "audioscrobbler" );
665 config_PutPsz( p_intf, "lastfm-username", [[o_audio_lastuser_fld stringValue] UTF8String] );
666 config_PutPsz( p_intf, "lastfm-password", [[o_audio_lastuser_fld stringValue] UTF8String] );
669 /* okay, let's save our changes to vlcrc */
670 i = config_SaveConfigFile( p_intf, "main" );
671 i = i + config_SaveConfigFile( p_intf, "audioscrobbler" );
672 i = i + config_SaveConfigFile( p_intf, "volnorm" );
676 msg_Err( p_intf, "An error occurred while saving the Audio settings using SimplePrefs (%i)", i );
679 b_audioSettingChanged = NO;
685 if( b_videoSettingChanged )
687 config_PutInt( p_intf, "video", [o_video_enable_ckb state] );
688 config_PutInt( p_intf, "fullscreen", [o_video_fullscreen_ckb state] );
689 config_PutInt( p_intf, "video-on-top", [o_video_onTop_ckb state] );
690 config_PutInt( p_intf, "skip-frames", [o_video_skipFrames_ckb state] );
691 config_PutInt( p_intf, "macosx-black", [o_video_black_ckb state] );
693 msg_Warn( p_intf, "vout module and display device selectors not implemented!" );
695 config_PutPsz( p_intf, "snapshot-path", [[o_video_snap_folder_fld stringValue] UTF8String] );
696 config_PutPsz( p_intf, "snapshot-prefix", [[o_video_snap_prefix_fld stringValue] UTF8String] );
697 config_PutInt( p_intf, "snapshot-sequential", [o_video_snap_seqnum_ckb state] );
699 if( [o_video_snap_format_pop indexOfSelectedItem] >= 0 )
700 config_PutPsz( p_intf, "snapshot-format", [[[o_video_snap_format_pop selectedItem] title] UTF8String] );
702 i = config_SaveConfigFile( p_intf, "main" );
703 i = i + config_SaveConfigFile( p_intf, "macosx" );
707 msg_Err( p_intf, "An error occurred while saving the Video settings using SimplePrefs (%i)", i );
710 b_videoSettingChanged = NO;
713 /***************************
714 * input & codecs settings *
715 ***************************/
716 if( b_inputSettingChanged )
718 config_PutInt( p_intf, "server-port", [o_input_serverport_fld intValue] );
719 config_PutPsz( p_intf, "http-proxy", [[o_input_httpproxy_fld stringValue] UTF8String] );
720 config_PutInt( p_intf, "ffmpeg-pp-q", [o_input_postproc_fld intValue] );
722 SaveIntList( o_input_avi_pop, "avi-index" );
724 config_PutInt( p_intf, "rtsp-tcp", [o_input_rtsp_ckb state] );
726 #define CaCi( name, int ) config_PutInt( p_intf, name, int * [[o_input_cachelevel_pop selectedItem] tag] )
727 #define CaC( name ) CaCi( name, 1 )
728 msg_Dbg( p_intf, "Adjusting all cache values at: %i", [[o_input_cachelevel_pop selectedItem] tag] );
729 CaC( "udp-caching" );
730 if( module_Exists (p_intf, "dvdread" ) )
732 CaC( "dvdread-caching" );
733 i = i + config_SaveConfigFile( p_intf, "dvdread" );
735 if( module_Exists (p_intf, "dvdnav" ) )
737 CaC( "dvdnav-caching" );
738 i = i + config_SaveConfigFile( p_intf, "dvdnav" );
740 CaC( "tcp-caching" ); CaC( "vcd-caching" );
741 CaC( "fake-caching" ); CaC( "cdda-caching" ); CaC( "file-caching" );
742 CaC( "screen-caching" );
743 CaCi( "rtsp-caching", 4 ); CaCi( "ftp-caching", 2 );
744 CaCi( "http-caching", 4 );
745 if( module_Exists (p_intf, "access_realrtsp" ) )
747 CaCi( "realrtsp-caching", 10 );
748 i = i + config_SaveConfigFile( p_intf, "access_realrtsp" );
750 CaCi( "mms-caching", 19 );
752 #define SaveAccessFilter( object, name ) \
753 if( [object state] == NSOnState ) \
757 [o_temp appendString: name]; \
761 [o_temp appendFormat: @":%@", name]; \
765 NSMutableString *o_temp = [[NSMutableString alloc] init];
766 SaveAccessFilter( o_input_record_ckb, @"record" );
767 SaveAccessFilter( o_input_dump_ckb, @"dump" );
768 SaveAccessFilter( o_input_bandwidth_ckb, @"bandwidth" );
769 SaveAccessFilter( o_input_timeshift_ckb, @"timeshift" );
770 config_PutPsz( p_intf, "access-filter", [o_temp UTF8String] );
773 i = config_SaveConfigFile( p_intf, "main" );
774 i = i + config_SaveConfigFile( p_intf, "ffmpeg" );
775 i = i + config_SaveConfigFile( p_intf, "access_http" );
776 i = i + config_SaveConfigFile( p_intf, "access_file" );
777 i = i + config_SaveConfigFile( p_intf, "access_tcp" );
778 i = i + config_SaveConfigFile( p_intf, "access_fake" );
779 i = i + config_SaveConfigFile( p_intf, "cdda" );
780 i = i + config_SaveConfigFile( p_intf, "screen" );
781 i = i + config_SaveConfigFile( p_intf, "vcd" );
782 i = i + config_SaveConfigFile( p_intf, "access_ftp" );
783 i = i + config_SaveConfigFile( p_intf, "access_mms" );
784 i = i + config_SaveConfigFile( p_intf, "live555" );
788 msg_Err( p_intf, "An error occurred while saving the Input settings using SimplePrefs (%i)", i );
791 b_inputSettingChanged = NO;
794 /**********************
795 * subtitles settings *
796 **********************/
797 if( b_osdSettingChanged )
799 config_PutInt( p_intf, "osd", [o_osd_osd_ckb state] );
801 if( [o_osd_encoding_pop indexOfSelectedItem] >= 0 )
802 config_PutPsz( p_intf, "subsdec-encoding", [[[o_osd_encoding_pop selectedItem] title] UTF8String] );
804 config_PutPsz( p_intf, "sub-language", [[o_osd_lang_fld stringValue] UTF8String] );
805 config_PutPsz( p_intf, "freetype-font", [[o_osd_font_fld stringValue] UTF8String] );
807 SaveIntList( o_osd_font_color_pop, "freetype-color" );
808 SaveIntList( o_osd_font_size_pop, "freetype-rel-fontsize" );
809 SaveIntList( o_osd_font_effect_pop, "freetype-effect" );
811 i = config_SaveConfigFile( p_intf, NULL );
815 msg_Err( p_intf, "An error occurred while saving the OSD/Subtitle settings using SimplePrefs (%i)", i );
818 b_osdSettingChanged = NO;
821 /********************
823 ********************/
824 if( b_hotkeyChanged )
826 struct hotkey *p_hotkeys = p_intf->p_libvlc->p_hotkeys;
828 while( i < [o_hotkeySettings count] )
830 config_PutInt( p_intf, p_hotkeys[i].psz_action, [[o_hotkeySettings objectAtIndex: i-1] intValue] );
834 i = config_SaveConfigFile( p_intf, "main" );
838 msg_Err( p_intf, "An error occurred while saving the Hotkey settings using SimplePrefs (%i)", i );
841 b_hotkeyChanged = NO;
845 - (void)showSettingsForCategory: (id)o_new_category_view
847 NSRect o_win_rect, o_view_rect, o_old_view_rect;
848 o_win_rect = [o_sprefs_win frame];
849 o_view_rect = [o_new_category_view frame];
851 if( o_currentlyShownCategoryView != nil )
853 /* restore our window's height, if we've shown another category previously */
854 o_old_view_rect = [o_currentlyShownCategoryView frame];
855 o_win_rect.size.height = o_win_rect.size.height - o_old_view_rect.size.height;
857 /* remove our previous category view */
858 [o_currentlyShownCategoryView removeFromSuperviewWithoutNeedingDisplay];
861 o_win_rect.size.height = o_win_rect.size.height + o_view_rect.size.height;
863 [o_sprefs_win displayIfNeeded];
864 [o_sprefs_win setFrame: o_win_rect display:YES animate: YES];
866 [o_new_category_view setFrame: NSMakeRect( 0,
867 [o_sprefs_controls_box frame].size.height,
868 o_view_rect.size.width,
869 o_view_rect.size.height )];
870 [o_new_category_view setNeedsDisplay: YES];
871 [o_new_category_view setAutoresizesSubviews: YES];
872 [[o_sprefs_win contentView] addSubview: o_new_category_view];
874 /* keep our current category for further reference */
875 [o_currentlyShownCategoryView release];
876 o_currentlyShownCategoryView = o_new_category_view;
877 [o_currentlyShownCategoryView retain];
880 - (IBAction)interfaceSettingChanged:(id)sender
882 b_intfSettingChanged = YES;
885 - (void)showInterfaceSettings
887 msg_Dbg( p_intf, "showing interface settings" );
888 [self showSettingsForCategory: o_intf_view];
891 - (IBAction)audioSettingChanged:(id)sender
893 if( sender == o_audio_vol_sld )
894 [o_audio_vol_fld setIntValue: [o_audio_vol_sld intValue]];
896 if( sender == o_audio_vol_fld )
897 [o_audio_vol_sld setIntValue: [o_audio_vol_fld intValue]];
899 b_audioSettingChanged = YES;
902 - (void)showAudioSettings
904 msg_Dbg( p_intf, "showing audio settings" );
905 [self showSettingsForCategory: o_audio_view];
908 - (IBAction)videoSettingChanged:(id)sender
910 if( sender == o_video_snap_folder_btn )
912 o_selectFolderPanel = [[NSOpenPanel alloc] init];
913 [o_selectFolderPanel setCanChooseDirectories: YES];
914 [o_selectFolderPanel setCanChooseFiles: NO];
915 [o_selectFolderPanel setResolvesAliases: YES];
916 [o_selectFolderPanel setAllowsMultipleSelection: NO];
917 [o_selectFolderPanel setMessage: _NS("Choose the folder to save your video snapshots to.")];
918 [o_selectFolderPanel setCanCreateDirectories: YES];
919 [o_selectFolderPanel setPrompt: _NS("Choose")];
920 [o_selectFolderPanel beginSheetForDirectory: nil file: nil modalForWindow: o_sprefs_win
922 didEndSelector: @selector(savePanelDidEnd:returnCode:contextInfo:)
923 contextInfo: o_video_snap_folder_btn];
926 b_videoSettingChanged = YES;
929 - (void)savePanelDidEnd:(NSOpenPanel * )panel returnCode: (int)returnCode contextInfo: (void *)contextInfo
931 if( returnCode == NSOKButton )
933 if( contextInfo == o_video_snap_folder_btn )
935 [o_video_snap_folder_fld setStringValue: [o_selectFolderPanel filename]];
936 b_videoSettingChanged = YES;
938 else if( contextInfo == o_osd_font_btn )
940 [o_osd_font_fld setStringValue: [o_selectFolderPanel filename]];
941 b_osdSettingChanged = YES;
945 [o_selectFolderPanel release];
948 - (void)showVideoSettings
950 msg_Dbg( p_intf, "showing video settings" );
951 [self showSettingsForCategory: o_video_view];
954 - (IBAction)osdSettingChanged:(id)sender
956 if( sender == o_osd_font_btn )
958 o_selectFolderPanel = [[NSOpenPanel alloc] init];
959 [o_selectFolderPanel setCanChooseDirectories: NO];
960 [o_selectFolderPanel setCanChooseFiles: YES];
961 [o_selectFolderPanel setResolvesAliases: YES];
962 [o_selectFolderPanel setAllowsMultipleSelection: NO];
963 [o_selectFolderPanel setMessage: _NS("Choose the font to display your Subtitles with.")];
964 [o_selectFolderPanel setCanCreateDirectories: NO];
965 [o_selectFolderPanel setPrompt: _NS("Choose")];
966 [o_selectFolderPanel setAllowedFileTypes: [NSArray arrayWithObjects: @"dfont", @"ttf", @"otf", @"FFIL", nil]];
967 [o_selectFolderPanel beginSheetForDirectory: @"/System/Library/Fonts/" file: nil modalForWindow: o_sprefs_win
969 didEndSelector: @selector(savePanelDidEnd:returnCode:contextInfo:)
970 contextInfo: o_osd_font_btn];
973 b_osdSettingChanged = YES;
976 - (void)showOSDSettings
978 msg_Dbg( p_intf, "showing OSD settings" );
979 [self showSettingsForCategory: o_osd_view];
982 - (IBAction)inputSettingChanged:(id)sender
984 b_inputSettingChanged = YES;
987 - (void)showInputSettings
989 msg_Dbg( p_intf, "showing Input Settings" );
990 [self showSettingsForCategory: o_input_view];
993 - (IBAction)hotkeySettingChanged:(id)sender
995 if( sender == o_hotkeys_change_btn || sender == o_hotkeys_listbox )
997 [o_hotkeys_change_lbl setStringValue: [NSString stringWithFormat: _NS("Press new keys for\n\"%@\""),
998 [o_hotkeyDescriptions objectAtIndex: [o_hotkeys_listbox selectedRow]]]];
999 [o_hotkeys_change_keys_lbl setStringValue: [self OSXKeyToString:[[o_hotkeySettings objectAtIndex: [o_hotkeys_listbox selectedRow]] intValue]]];
1000 [o_hotkeys_change_taken_lbl setStringValue: @""];
1001 [o_hotkeys_change_win setInitialFirstResponder: [o_hotkeys_change_win contentView]];
1002 [o_hotkeys_change_win makeFirstResponder: [o_hotkeys_change_win contentView]];
1003 [NSApp runModalForWindow: o_hotkeys_change_win];
1005 else if( sender == o_hotkeys_change_cancel_btn )
1008 [o_hotkeys_change_win close];
1010 else if( sender == o_hotkeys_change_ok_btn )
1013 if(! o_keyInTransition )
1016 [o_hotkeys_change_win close];
1017 msg_Err( p_intf, "internal error prevented the hotkey switch" );
1021 b_hotkeyChanged = YES;
1023 i_returnValue = [o_hotkeySettings indexOfObject: o_keyInTransition];
1024 if( i_returnValue != NSNotFound )
1025 [o_hotkeySettings replaceObjectAtIndex: i_returnValue withObject: [[NSNumber numberWithInt: 0] retain]];
1027 [o_hotkeySettings replaceObjectAtIndex: [o_hotkeys_listbox selectedRow] withObject: [o_keyInTransition retain]];
1030 [o_hotkeys_change_win close];
1032 [o_hotkeys_listbox reloadData];
1034 else if( sender == o_hotkeys_clear_btn )
1036 [o_hotkeySettings replaceObjectAtIndex: [o_hotkeys_listbox selectedRow] withObject: [NSNumber numberWithInt: 0]];
1037 [o_hotkeys_listbox reloadData];
1038 b_hotkeyChanged = YES;
1042 - (void)showHotkeySettings
1044 msg_Dbg( p_intf, "showing HotKey Settings" );
1045 [self showSettingsForCategory: o_hotkeys_view];
1048 - (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView
1050 return [o_hotkeySettings count];
1053 - (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
1055 if( [[aTableColumn identifier] isEqualToString: @"action"] )
1056 return [o_hotkeyDescriptions objectAtIndex: rowIndex];
1057 else if( [[aTableColumn identifier] isEqualToString: @"shortcut"] )
1058 return [self OSXKeyToString: [[o_hotkeySettings objectAtIndex: rowIndex] intValue]];
1061 msg_Err( p_intf, "unknown TableColumn identifier (%s)!", [[aTableColumn identifier] UTF8String] );
1066 - (void)changeHotkeyTo: (int)i_theNewKey
1069 i_returnValue = [o_hotkeysNonUseableKeys indexOfObject: [NSNumber numberWithInt: i_theNewKey]];
1070 if( i_returnValue != NSNotFound || i_theNewKey == 0 )
1072 [o_hotkeys_change_keys_lbl setStringValue: _NS("Invalid combination")];
1073 [o_hotkeys_change_taken_lbl setStringValue: _NS("Regrettably, these keys cannot be assigned as hotkey shortcuts.")];
1074 [o_hotkeys_change_ok_btn setEnabled: NO];
1079 if( o_keyInTransition )
1080 [o_keyInTransition release];
1081 o_keyInTransition = [[NSNumber numberWithInt: i_theNewKey] retain];
1083 o_temp = [self OSXKeyToString: i_theNewKey];
1085 [o_hotkeys_change_keys_lbl setStringValue: o_temp];
1087 i_returnValue = [o_hotkeySettings indexOfObject: o_keyInTransition];
1088 if( i_returnValue != NSNotFound )
1089 [o_hotkeys_change_taken_lbl setStringValue: [NSString stringWithFormat:
1090 _NS("This combination is already taken by \"%@\"."),
1091 [self OSXKeyToString:[[o_hotkeyDescriptions objectAtIndex: i_returnValue] intValue]]]];
1093 [o_hotkeys_change_taken_lbl setStringValue: @""];
1095 [o_hotkeys_change_ok_btn setEnabled: YES];
1101 /********************
1102 * hotkeys settings *
1103 ********************/
1105 @implementation VLCHotkeyChangeWindow
1107 - (BOOL)resignFirstResponder
1109 /* We need to stay the first responder or we'll miss the user's input */
1113 - (void)keyDown:(NSEvent *)o_theEvent
1115 int i_nonReadableKey = 0;
1117 if( [o_theEvent modifierFlags] & NSControlKeyMask )
1118 i_nonReadableKey = i_nonReadableKey | KEY_MODIFIER_CTRL;
1120 if( [o_theEvent modifierFlags] & NSAlternateKeyMask )
1121 i_nonReadableKey = i_nonReadableKey | KEY_MODIFIER_ALT;
1123 if( [o_theEvent modifierFlags] & NSShiftKeyMask )
1124 i_nonReadableKey = i_nonReadableKey | KEY_MODIFIER_SHIFT;
1126 if( [o_theEvent modifierFlags] & NSCommandKeyMask )
1127 i_nonReadableKey = i_nonReadableKey | KEY_MODIFIER_COMMAND;
1129 if( [o_theEvent modifierFlags] & NSFunctionKeyMask )
1132 key = [[o_theEvent charactersIgnoringModifiers] characterAtIndex: 0];
1137 i_nonReadableKey = i_nonReadableKey | KEY_ESC;
1139 case NSF1FunctionKey:
1140 i_nonReadableKey = i_nonReadableKey | KEY_F1;
1142 case NSF2FunctionKey:
1143 i_nonReadableKey = i_nonReadableKey | KEY_F2;
1145 case NSF3FunctionKey:
1146 i_nonReadableKey = i_nonReadableKey | KEY_F3;
1148 case NSF4FunctionKey:
1149 i_nonReadableKey = i_nonReadableKey | KEY_F4;
1151 case NSF5FunctionKey:
1152 i_nonReadableKey = i_nonReadableKey | KEY_F5;
1154 case NSF6FunctionKey:
1155 i_nonReadableKey = i_nonReadableKey | KEY_F6;
1157 case NSF7FunctionKey:
1158 i_nonReadableKey = i_nonReadableKey | KEY_F7;
1160 case NSF8FunctionKey:
1161 i_nonReadableKey = i_nonReadableKey | KEY_F8;
1163 case NSF9FunctionKey:
1164 i_nonReadableKey = i_nonReadableKey | KEY_F9;
1166 case NSF10FunctionKey:
1167 i_nonReadableKey = i_nonReadableKey | KEY_F10;
1169 case NSF11FunctionKey:
1170 i_nonReadableKey = i_nonReadableKey | KEY_F11;
1172 case NSF12FunctionKey:
1173 i_nonReadableKey = i_nonReadableKey | KEY_F12;
1175 case NSInsertFunctionKey:
1176 i_nonReadableKey = i_nonReadableKey | KEY_INSERT;
1178 case NSHomeFunctionKey:
1179 i_nonReadableKey = i_nonReadableKey | KEY_HOME;
1181 case NSEndFunctionKey:
1182 i_nonReadableKey = i_nonReadableKey | KEY_END;
1184 case NSPageUpFunctionKey:
1185 i_nonReadableKey = i_nonReadableKey | KEY_PAGEUP;
1187 case NSPageDownFunctionKey:
1188 i_nonReadableKey = i_nonReadableKey | KEY_PAGEDOWN;
1190 case NSMenuFunctionKey:
1191 i_nonReadableKey = i_nonReadableKey | KEY_MENU;
1193 case NSTabCharacter:
1194 i_nonReadableKey = i_nonReadableKey | KEY_TAB;
1196 case NSDeleteCharacter:
1197 i_nonReadableKey = i_nonReadableKey | KEY_DELETE;
1199 case NSBackspaceCharacter:
1200 i_nonReadableKey = i_nonReadableKey | KEY_BACKSPACE;
1202 case NSUpArrowFunctionKey:
1203 i_nonReadableKey = i_nonReadableKey | KEY_UP;
1205 case NSDownArrowFunctionKey:
1206 i_nonReadableKey = i_nonReadableKey | KEY_DOWN;
1208 case NSRightArrowFunctionKey:
1209 i_nonReadableKey = i_nonReadableKey | KEY_RIGHT;
1211 case NSLeftArrowFunctionKey:
1212 i_nonReadableKey = i_nonReadableKey | KEY_LEFT;
1214 case NSEnterCharacter:
1215 i_nonReadableKey = i_nonReadableKey | KEY_ENTER;
1219 msg_Warn( VLCIntf, "user pressed unknown function key" );
1220 i_nonReadableKey = 0;
1227 if( [[o_theEvent charactersIgnoringModifiers] isEqualToString: @" "] )
1228 i_nonReadableKey = i_nonReadableKey | KEY_SPACE;
1230 i_nonReadableKey = i_nonReadableKey | StringToKey( (char *)[[[o_theEvent charactersIgnoringModifiers] lowercaseString] UTF8String] );
1233 [[[VLCMain sharedInstance] getSimplePreferences] changeHotkeyTo: i_nonReadableKey];