1 /*****************************************************************************
2 * prefs.m: MacOS X plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2002-2003 VideoLAN
5 * $Id: prefs.m,v 1.18 2003/05/09 00:41:11 hartman Exp $
7 * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
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., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
27 #include <stdlib.h> /* malloc(), free() */
28 #include <sys/param.h> /* for MAXPATHLEN */
34 /*****************************************************************************
35 * VLCPrefs implementation
36 *****************************************************************************/
37 @implementation VLCPrefs
45 p_intf = [NSApp getIntf];
47 o_pref_panels = [[NSMutableDictionary alloc] init];
48 o_toolbars = [[NSMutableDictionary alloc] init];
49 o_scroll_views = [[NSMutableDictionary alloc] init];
50 o_panel_views = [[NSMutableDictionary alloc] init];
51 o_save_prefs = [[NSMutableDictionary alloc] init];
52 b_advanced = config_GetInt( p_intf, "advanced" );
64 #define DIC_REL1(o_dic) \
66 o_e1 = [o_dic objectEnumerator]; \
67 while( (v1 = [o_e1 nextObject]) ) \
71 [o_dic removeAllObjects]; \
75 #define DIC_REL2(o_dic) \
77 o_e2 = [o_dic objectEnumerator]; \
78 while( (v2 = [o_e2 nextObject]) ) \
82 [o_dic removeAllObjects]; \
85 DIC_REL1(o_pref_panels);
87 DIC_REL1(o_scroll_views);
88 DIC_REL2(o_panel_views);
89 DIC_REL1(o_save_prefs);
97 - (BOOL)hasPrefs:(NSString *)o_module_name
101 char *psz_module_name;
104 psz_module_name = (char *)[o_module_name lossyCString];
106 /* look for module */
107 p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
109 for( i_index = 0; i_index < p_list->i_count; i_index++ )
111 p_parser = (module_t *)p_list->p_values[i_index].p_object ;
113 if( !strcmp( p_parser->psz_object_name, psz_module_name ) )
115 BOOL b_has_prefs = p_parser->i_config_items != 0;
116 vlc_list_release( p_list );
117 return( b_has_prefs );
121 vlc_list_release( p_list );
126 - (void)createPrefPanel:(NSString *)o_module_name
131 module_t *p_parser = NULL;
133 module_config_t *p_item;
134 char *psz_module_name;
137 NSPanel *o_panel; /* panel */
138 NSRect s_panel_rc; /* panel rect */
139 NSView *o_panel_view; /* panel view */
140 NSToolbar *o_toolbar; /* panel toolbar */
141 NSMutableDictionary *o_tb_items; /* panel toolbar items */
142 NSScrollView *o_scroll_view; /* panel scroll view */
143 NSRect s_scroll_rc; /* panel scroll view rect */
144 NSMutableDictionary *o_views; /* panel scroll view docviews */
146 NSRect s_rc; /* rect */
147 NSView *o_view; /* view */
148 NSRect s_vrc; /* view rect */
149 NSButton *o_button; /* button */
150 NSRect s_brc; /* button rect */
151 VLCTextField *o_text_field; /* input field / label */
153 o_panel = [o_pref_panels objectForKey: o_module_name];
157 [o_panel makeKeyAndOrderFront: nil];
161 psz_module_name = (char *)[o_module_name lossyCString];
163 /* Look for the selected module */
164 p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
166 for( i_index = 0; i_index < p_list->i_count; i_index++ )
168 p_parser = (module_t *)p_list->p_values[i_index].p_object ;
171 && !strcmp( psz_module_name, p_parser->psz_object_name ) )
177 if( !p_parser || i_index == p_list->i_count )
179 vlc_list_release( p_list );
183 /* We found it, now we can start building its configuration interface */
185 s_panel_rc = NSMakeRect( 0, 0, 450, 450 );
186 o_panel = [[NSPanel alloc] initWithContentRect: s_panel_rc
187 styleMask: NSTitledWindowMask
188 backing: NSBackingStoreBuffered
190 o_toolbar = [[NSToolbar alloc] initWithIdentifier: o_module_name];
191 [o_panel setTitle: [NSString stringWithFormat: @"%@ (%@)",
192 _NS("Preferences"), o_module_name]];
193 o_panel_view = [o_panel contentView];
195 s_scroll_rc = s_panel_rc;
196 s_scroll_rc.size.height -= 55; s_scroll_rc.origin.y += 55;
197 o_scroll_view = [[NSScrollView alloc] initWithFrame: s_scroll_rc];
198 [o_scroll_views setObject: o_scroll_view forKey: o_module_name];
199 [o_scroll_view setBorderType: NSGrooveBorder];
200 [o_scroll_view setHasVerticalScroller: YES];
201 [o_scroll_view setDrawsBackground: NO];
202 [o_scroll_view setRulersVisible: YES];
203 [o_panel_view addSubview: o_scroll_view];
205 o_tb_items = [[NSMutableDictionary alloc] init];
206 o_views = [[NSMutableDictionary alloc] init];
208 [o_save_prefs setObject: [[NSMutableArray alloc] init]
209 forKey: o_module_name];
211 /* Enumerate config options and add corresponding config boxes */
212 p_item = p_parser->p_config;
219 #define Y_ORIGIN (X_ORIGIN - 10)
221 #define CHECK_VIEW_HEIGHT \
223 float f_new_pos = s_rc.origin.y + s_rc.size.height + X_ORIGIN; \
224 if( f_new_pos > s_vrc.size.height ) \
226 s_vrc.size.height = f_new_pos; \
227 [o_view setFrame: s_vrc]; \
231 #define CONTROL_LABEL( label ) \
233 s_rc.origin.x += s_rc.size.width + 10; \
234 s_rc.size.width = s_vrc.size.width - s_rc.origin.x - X_ORIGIN - 20; \
235 o_text_field = [[NSTextField alloc] initWithFrame: s_rc]; \
236 [o_text_field setDrawsBackground: NO]; \
237 [o_text_field setBordered: NO]; \
238 [o_text_field setEditable: NO]; \
239 [o_text_field setSelectable: NO]; \
242 [o_text_field setStringValue: \
243 [NSApp localizedString: label]]; \
245 [o_text_field sizeToFit]; \
246 [o_view addSubview: [o_text_field autorelease]]; \
249 #define INPUT_FIELD( ctype, cname, label, w, msg, param, tip ) \
251 char * psz_duptip = NULL; \
252 if ( p_item->psz_longtext != NULL && [NSApp getEncoding] == NSISOLatin1StringEncoding ) \
253 psz_duptip = strdup(p_item->psz_longtext); \
254 s_rc.size.height = 25; \
255 s_rc.size.width = w; \
256 s_rc.origin.y += 10; \
258 o_text_field = [[VLCTextField alloc] initWithFrame: s_rc]; \
259 [o_text_field setAlignment: NSRightTextAlignment]; \
260 CONTROL_CONFIG( o_text_field, o_module_name, ctype, cname ); \
261 [o_text_field msg: param]; \
262 if ( psz_duptip != NULL ) \
264 [o_text_field setToolTip: [NSApp localizedString: \
265 vlc_wraptext(psz_duptip, PREFS_WRAP)]]; \
268 [o_view addSubview: [o_text_field autorelease]]; \
269 [[NSNotificationCenter defaultCenter] addObserver: self \
270 selector: @selector(configChanged:) \
271 name: NSControlTextDidChangeNotification \
272 object: o_text_field]; \
273 CONTROL_LABEL( label ); \
274 s_rc.origin.y += s_rc.size.height; \
275 s_rc.origin.x = X_ORIGIN; \
278 #define INPUT_FIELD_INTEGER( name, label, w, param, tip ) \
279 INPUT_FIELD( CONFIG_ITEM_INTEGER, name, label, w, setIntValue, param, tip )
280 #define INPUT_FIELD_FLOAT( name, label, w, param, tip ) \
281 INPUT_FIELD( CONFIG_ITEM_FLOAT, name, label, w, setFloatValue, param, tip )
282 #define INPUT_FIELD_STRING( name, label, w, param, tip ) \
283 INPUT_FIELD( CONFIG_ITEM_STRING, name, label, w, setStringValue, param, tip )
287 if( p_item->b_advanced && !b_advanced )
291 switch( p_item->i_type )
294 case CONFIG_HINT_CATEGORY:
298 NSToolbarItem *o_tbi;
300 o_label = [NSApp localizedString: p_item->psz_text];
301 o_tbi = [[NSToolbarItem alloc] initWithItemIdentifier: o_label];
302 [o_tbi setImage: [NSImage imageNamed: @"NSApplicationIcon"]];
303 [o_tbi setLabel: o_label];
304 [o_tbi setTarget: self];
305 [o_tbi setAction: @selector(selectPrefView:)];
307 o_key = [NSString stringWithFormat: @"%02d %@",
309 [o_tb_items setObject: o_tbi forKey: o_key];
311 s_vrc = s_scroll_rc; s_vrc.size.height -= 4;
312 o_view = [[VLCFlippedView alloc] initWithFrame: s_vrc];
313 [o_views setObject: o_view forKey: o_label];
315 s_rc.origin.x = X_ORIGIN;
316 s_rc.origin.y = Y_ORIGIN;
322 [o_scroll_view setDocumentView: o_view];
329 case CONFIG_ITEM_MODULE:
334 NSPopUpButton *o_modules;
335 NSButton *o_btn_select;
336 NSButton *o_btn_configure;
337 char * psz_duptip = NULL;
338 if ( p_item->psz_longtext != NULL && [NSApp getEncoding] == NSISOLatin1StringEncoding )
339 psz_duptip = strdup(p_item->psz_longtext);
341 #define MODULE_BUTTON( button, title, sel ) \
343 s_brc.size.height = 32; \
344 s_brc.origin.x += s_brc.size.width + 10; \
345 s_brc.size.width = s_crc.size.width - s_brc.origin.x - 10; \
346 button = [[NSButton alloc] initWithFrame: s_brc]; \
347 [button setButtonType: NSMomentaryPushInButton]; \
348 [button setBezelStyle: NSRoundedBezelStyle]; \
349 [button setTitle: title]; \
350 [button setTag: i_module_tag++]; \
351 [button setTarget: self]; \
352 [button setAction: @selector(sel)]; \
353 [o_cview addSubview: [button autorelease]]; \
356 s_rc.size.height = 107;
357 s_rc.size.width = s_vrc.size.width - X_ORIGIN * 2 - 20;
358 s_rc.origin.y += i_module_tag == 3 ? Y_ORIGIN : 20;
362 o_box = [[NSBox alloc] initWithFrame: s_rc];
363 [o_box setTitle: [NSApp localizedString: p_item->psz_text]];
364 [o_view addSubview: [o_box autorelease]];
365 s_rc.origin.y += s_rc.size.height + 10;
366 o_cview = [[VLCFlippedView alloc] initWithFrame: s_rc];
367 [o_box setContentView: [o_cview autorelease]];
368 s_crc = [o_cview bounds];
370 s_brc = NSMakeRect( 5, 10, 200, 30 );
371 o_modules = [[NSPopUpButton alloc] initWithFrame: s_brc];
372 [o_modules setTag: i_module_tag++];
373 [o_modules setTarget: self];
374 [o_modules setAction: @selector(moduleSelected:)];
375 if ( psz_duptip != NULL )
377 [o_modules setToolTip: [NSApp localizedString:
378 vlc_wraptext(psz_duptip, PREFS_WRAP)]];
381 [o_cview addSubview: [o_modules autorelease]];
383 MODULE_BUTTON( o_btn_configure, _NS("Configure"),
386 s_brc = NSMakeRect( 8, s_brc.origin.y + s_brc.size.height + 10,
388 o_text_field = [[VLCTextField alloc] initWithFrame: s_brc];
389 [o_text_field setTag: i_module_tag++];
390 [o_text_field setAlignment: NSLeftTextAlignment];
391 CONTROL_CONFIG( o_text_field, o_module_name,
392 CONFIG_ITEM_MODULE, p_item->psz_name );
393 [[NSNotificationCenter defaultCenter] addObserver: self
394 selector: @selector(configChanged:)
395 name: NSControlTextDidChangeNotification
396 object: o_text_field];
397 [o_cview addSubview: [o_text_field autorelease]];
400 MODULE_BUTTON( o_btn_select, _NS("Select"),
403 [o_modules addItemWithTitle: _NS("None")];
405 /* build a list of available modules */
407 for( i_index = 0; i_index < p_list->i_count; i_index++ )
409 p_parser = (module_t *)p_list->p_values[i_index].p_object ;
411 if( !strcmp( p_parser->psz_capability,
414 NSString *o_object_name = [NSString
415 stringWithCString: p_parser->psz_object_name];
416 [o_modules addItemWithTitle: o_object_name];
421 if( p_item->psz_value != NULL )
424 [NSString stringWithCString: p_item->psz_value];
426 [o_text_field setStringValue: o_value];
427 [o_modules selectItemWithTitle: o_value];
428 [o_btn_configure setEnabled: [self hasPrefs: o_value]];
432 [o_modules selectItemWithTitle: _NS("None")];
433 [o_btn_configure setEnabled: NO];
440 case CONFIG_ITEM_STRING:
441 case CONFIG_ITEM_FILE:
442 case CONFIG_ITEM_DIRECTORY:
445 if( !p_item->ppsz_list )
447 char *psz_value = p_item->psz_value ?
448 p_item->psz_value : "";
450 INPUT_FIELD_STRING( p_item->psz_name, p_item->psz_text, 150,
451 [NSString stringWithCString: psz_value],
452 p_item->psz_longtext );
457 VLCComboBox *o_combo_box;
458 char * psz_duptip = NULL;
459 if ( p_item->psz_longtext != NULL && [NSApp getEncoding] == NSISOLatin1StringEncoding )
460 psz_duptip = strdup(p_item->psz_longtext);
462 s_rc.size.height = 27;
463 s_rc.size.width = 150;
468 o_combo_box = [[VLCComboBox alloc] initWithFrame: s_rc];
469 CONTROL_CONFIG( o_combo_box, o_module_name,
470 CONFIG_ITEM_STRING, p_item->psz_name );
471 if ( psz_duptip != NULL )
473 [o_combo_box setToolTip: [NSApp localizedString:
474 vlc_wraptext(psz_duptip, PREFS_WRAP)]];
477 [o_view addSubview: [o_combo_box autorelease]];
478 [[NSNotificationCenter defaultCenter] addObserver: self
479 selector: @selector(configChanged:)
480 name: NSControlTextDidChangeNotification
481 object: o_combo_box];
482 [[NSNotificationCenter defaultCenter] addObserver: self
483 selector: @selector(configChanged:)
484 name: NSComboBoxSelectionDidChangeNotification
485 object: o_combo_box];
487 for( i=0; p_item->ppsz_list[i]; i++ )
489 [o_combo_box addItemWithObjectValue:
490 [NSString stringWithCString: p_item->ppsz_list[i]]];
493 CONTROL_LABEL( p_item->psz_text );
495 s_rc.origin.y += s_rc.size.height;
496 s_rc.origin.x = X_ORIGIN;
502 case CONFIG_ITEM_INTEGER:
504 INPUT_FIELD_INTEGER( p_item->psz_name, p_item->psz_text, 70,
505 p_item->i_value, p_item->psz_longtext );
509 case CONFIG_ITEM_FLOAT:
511 INPUT_FIELD_FLOAT( p_item->psz_name, p_item->psz_text, 70,
512 p_item->f_value, p_item->psz_longtext );
516 case CONFIG_ITEM_BOOL:
518 VLCButton *o_btn_bool;
519 char * psz_duptip = NULL;
520 if ( p_item->psz_longtext != NULL && [NSApp getEncoding] == NSISOLatin1StringEncoding )
521 psz_duptip = strdup(p_item->psz_longtext);
523 s_rc.size.height = 27;
524 s_rc.size.width = s_vrc.size.width - X_ORIGIN * 2 - 20;
529 o_btn_bool = [[VLCButton alloc] initWithFrame: s_rc];
530 [o_btn_bool setButtonType: NSSwitchButton];
531 [o_btn_bool setIntValue: p_item->i_value];
532 [o_btn_bool setTitle:
533 [NSApp localizedString: p_item->psz_text]];
534 if ( psz_duptip != NULL )
536 [o_btn_bool setToolTip: [NSApp localizedString:
537 vlc_wraptext(psz_duptip, PREFS_WRAP)]];
540 [o_btn_bool setTarget: self];
541 [o_btn_bool setAction: @selector(configChanged:)];
542 CONTROL_CONFIG( o_btn_bool, o_module_name,
543 CONFIG_ITEM_BOOL, p_item->psz_name );
544 [o_view addSubview: [o_btn_bool autorelease]];
546 s_rc.origin.y += s_rc.size.height;
552 #undef INPUT_FIELD_INTEGER
553 #undef INPUT_FIELD_FLOAT
554 #undef INPUT_FIELD_STRING
556 #undef CHECK_VIEW_HEIGHT
561 while( p_item->i_type != CONFIG_HINT_END && p_item++ );
563 vlc_list_release( p_list );
565 [o_toolbars setObject: o_tb_items forKey: o_module_name];
566 [o_toolbar setDelegate: self];
567 [o_panel setToolbar: [o_toolbar autorelease]];
569 #define DEF_PANEL_BUTTON( tag, title, sel ) \
571 o_button = [[NSButton alloc] initWithFrame: s_rc]; \
572 [o_button setButtonType: NSMomentaryPushInButton]; \
573 [o_button setBezelStyle: NSRoundedBezelStyle]; \
574 [o_button setAction: @selector(sel)]; \
575 [o_button setTarget: self]; \
576 [o_button setTitle: title]; \
577 [o_button setTag: tag]; \
578 [o_panel_view addSubview: [o_button autorelease]]; \
581 s_rc.origin.y = s_panel_rc.origin.y + 14;
582 s_rc.size.height = 25; s_rc.size.width = 105;
583 s_rc.origin.x = s_panel_rc.size.width - s_rc.size.width - 14;
584 DEF_PANEL_BUTTON( 0, _NS("OK"), clickedApplyCancelOK: );
585 [o_panel setDefaultButtonCell: [o_button cell]];
587 s_rc.origin.x -= s_rc.size.width;
588 DEF_PANEL_BUTTON( 1, _NS("Cancel"), clickedApplyCancelOK: );
589 [o_button setKeyEquivalent: @"\E"];
592 o_button = [[NSButton alloc] initWithFrame: s_rc];
593 [o_button setButtonType: NSSwitchButton];
594 [o_button setAction: @selector(clickedApplyCancelOK:)];
595 [o_button setTarget: self];
596 [o_button setTitle: _NS("Advanced")];
597 [o_button setTag: 2];
598 [o_panel_view addSubview: [o_button autorelease]];
599 [o_button setState: b_advanced];
601 #undef DEF_PANEL_BUTTON
603 [o_pref_panels setObject: o_panel forKey: o_module_name];
604 [o_panel_views setObject: o_views forKey: o_module_name];
607 [o_panel makeKeyAndOrderFront: nil];
610 - (void)destroyPrefPanel:(id)o_unknown
615 NSMutableArray *o_prefs;
616 NSMutableDictionary *o_dic;
617 NSScrollView *o_scroll_view;
618 NSString *o_module_name;
620 o_module_name = (NSString *)([o_unknown isKindOfClass: [NSTimer class]] ?
621 [o_unknown userInfo] : o_unknown);
623 #define DIC_REL(dic) \
625 o_dic = [dic objectForKey: o_module_name]; \
626 [dic removeObjectForKey: o_module_name]; \
627 o_e1 = [o_dic objectEnumerator]; \
628 while( (v1 = [o_e1 nextObject]) ) \
632 [o_dic removeAllObjects]; \
636 o_panel = [o_pref_panels objectForKey: o_module_name];
637 [o_pref_panels removeObjectForKey: o_module_name];
642 o_scroll_view = [o_scroll_views objectForKey: o_module_name];
643 [o_scroll_views removeObjectForKey: o_module_name];
644 [o_scroll_view release];
646 DIC_REL(o_panel_views);
648 o_prefs = [o_save_prefs objectForKey: o_module_name];
649 [o_save_prefs removeObjectForKey: o_module_name];
650 [o_prefs removeAllObjects];
657 - (void)selectPrefView:(id)sender
660 NSString *o_module_name;
661 NSScrollView *o_scroll_view;
662 NSMutableDictionary *o_views;
664 o_module_name = [[sender toolbar] identifier];
665 o_views = [o_panel_views objectForKey: o_module_name];
666 o_view = [o_views objectForKey: [sender label]];
668 o_scroll_view = [o_scroll_views objectForKey: o_module_name];
669 [o_scroll_view setDocumentView: o_view];
672 - (void)moduleSelected:(id)sender
674 NSButton *o_btn_config;
675 NSString *o_module_name;
676 BOOL b_has_prefs = NO;
678 o_module_name = [sender titleOfSelectedItem];
679 o_btn_config = [[sender superview] viewWithTag: [sender tag] + 1];
681 if( ![o_module_name isEqualToString: _NS("None")] )
683 b_has_prefs = [self hasPrefs: o_module_name];
686 [o_btn_config setEnabled: b_has_prefs];
689 - (void)configureModule:(id)sender
691 NSString *o_module_name;
692 NSPopUpButton *o_modules;
694 o_modules = [[sender superview] viewWithTag: [sender tag] - 1];
695 o_module_name = [o_modules titleOfSelectedItem];
697 [self createPrefPanel: o_module_name];
700 - (void)selectModule:(id)sender
702 NSString *o_module_name;
703 NSPopUpButton *o_modules;
704 NSTextField *o_module;
706 o_module = [[sender superview] viewWithTag: [sender tag] - 1];
707 o_modules = [[sender superview] viewWithTag: [sender tag] - 3];
708 o_module_name = [o_modules titleOfSelectedItem];
710 if( [o_module_name isEqualToString: _NS("None")] )
712 o_module_name = [NSString string];
715 [o_module setStringValue: o_module_name];
716 [self configChanged: o_module];
719 - (void)configChanged:(id)o_unknown
721 id o_vlc_config = [o_unknown isKindOfClass: [NSNotification class]] ?
722 [o_unknown object] : o_unknown;
724 NSString *o_module_name = [o_vlc_config moduleName];
725 NSPanel *o_pref_panel = [o_pref_panels objectForKey: o_module_name];
726 NSMutableArray *o_prefs = [o_save_prefs objectForKey: o_module_name];
728 if( [o_prefs indexOfObjectIdenticalTo: o_vlc_config] == NSNotFound )
730 NSView *o_pref_view = [o_pref_panel contentView];
731 NSButton *o_btn_apply = [o_pref_view viewWithTag: 2];
733 [o_prefs addObject: o_vlc_config];
734 [o_btn_apply setEnabled: YES];
738 - (void)clickedApplyCancelOK:(id)sender
741 NSEnumerator *o_enum;
743 NSWindow *o_pref_panel = [[sender superview] window];
744 NSString *o_module_name = [[o_pref_panel toolbar] identifier];
745 NSView *o_config_view = [sender superview];
747 if ( [[sender title] isEqualToString: _NS("OK")] )
749 NSWindow *o_config_panel = [o_config_view window];
750 NSString *o_module_name = [[o_config_panel toolbar] identifier];
751 NSMutableArray *o_prefs = [o_save_prefs objectForKey: o_module_name];
753 o_enum = [o_prefs objectEnumerator];
754 while( ( o_vlc_control = [o_enum nextObject] ) )
756 int i_type = [o_vlc_control configType];
757 NSString *o_name = [o_vlc_control configName];
758 char *psz_name = (char *)[o_name lossyCString];
763 case CONFIG_ITEM_MODULE:
764 case CONFIG_ITEM_STRING:
765 case CONFIG_ITEM_FILE:
766 case CONFIG_ITEM_DIRECTORY:
771 o_value = [o_vlc_control stringValue];
772 psz_value = (char *)[o_value lossyCString];
774 config_PutPsz( p_intf, psz_name,
775 *psz_value ? psz_value : NULL );
779 case CONFIG_ITEM_INTEGER:
780 case CONFIG_ITEM_BOOL:
782 int i_value = [o_vlc_control intValue];
784 config_PutInt( p_intf, psz_name, i_value );
788 case CONFIG_ITEM_FLOAT:
790 float f_value = [o_vlc_control floatValue];
792 config_PutFloat( p_intf, psz_name, f_value );
799 [o_prefs removeAllObjects];
801 config_SaveConfigFile( p_intf, NULL );
803 if( [[sender title] isEqualToString: _NS("Advanced")] )
805 NSButton *o_btn_apply = [o_config_view viewWithTag: 2];
806 b_advanced = !b_advanced;
807 [o_btn_apply setState: b_advanced];
809 [o_pref_panel close];
811 if( [self respondsToSelector: @selector(performSelectorOnMainThread:
812 withObject:waitUntilDone:)] )
814 [self performSelectorOnMainThread: @selector(destroyPrefPanel:)
815 withObject: o_module_name
820 [NSTimer scheduledTimerWithTimeInterval: 0.1
821 target: self selector: @selector(destroyPrefPanel:)
822 userInfo: o_module_name repeats: NO];
825 if( [[sender title] isEqualToString: _NS("Advanced")] )
827 [self createPrefPanel: o_module_name];
833 @implementation VLCPrefs (NSToolbarDelegate)
835 - (NSToolbarItem *)toolbar:(NSToolbar *)o_toolbar
836 itemForItemIdentifier:(NSString *)o_item_id
837 willBeInsertedIntoToolbar:(BOOL)b_flag
839 NSMutableDictionary *o_toolbar_items;
840 NSString *o_module_name = [o_toolbar identifier];
842 o_toolbar_items = [o_toolbars objectForKey: o_module_name];
843 if( o_toolbar_items == nil )
848 return( [o_toolbar_items objectForKey: o_item_id] );
851 - (NSArray *)toolbarAllowedItemIdentifiers:(NSToolbar*)o_toolbar
853 return( [self toolbarDefaultItemIdentifiers: o_toolbar] );
856 - (NSArray *)toolbarDefaultItemIdentifiers:(NSToolbar*)o_toolbar
859 NSMutableDictionary *o_toolbar_items;
860 NSString *o_module_name = [o_toolbar identifier];
862 o_toolbar_items = [o_toolbars objectForKey: o_module_name];
863 if( o_toolbar_items == nil )
868 o_ids = [[o_toolbar_items allKeys]
869 sortedArrayUsingSelector: @selector(compare:)];
876 @implementation VLCFlippedView
885 IMPL_CONTROL_CONFIG(Button);
886 IMPL_CONTROL_CONFIG(ComboBox);
887 IMPL_CONTROL_CONFIG(TextField);