1 /*****************************************************************************
2 * prefs.m: MacOS X plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2002-2003 VideoLAN
5 * $Id: prefs.m,v 1.17 2003/03/06 10:15:37 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];
63 #define DIC_REL1(o_dic) \
65 o_e1 = [o_dic objectEnumerator]; \
66 while( (v1 = [o_e1 nextObject]) ) \
70 [o_dic removeAllObjects]; \
74 #define DIC_REL2(o_dic) \
76 o_e2 = [o_dic objectEnumerator]; \
77 while( (v2 = [o_e2 nextObject]) ) \
81 [o_dic removeAllObjects]; \
84 DIC_REL1(o_pref_panels);
86 DIC_REL1(o_scroll_views);
87 DIC_REL2(o_panel_views);
88 DIC_REL1(o_save_prefs);
96 - (BOOL)hasPrefs:(NSString *)o_module_name
100 char *psz_module_name;
103 psz_module_name = (char *)[o_module_name lossyCString];
105 /* look for module */
106 p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
108 for( i_index = 0; i_index < p_list->i_count; i_index++ )
110 p_parser = (module_t *)p_list->p_values[i_index].p_object ;
112 if( !strcmp( p_parser->psz_object_name, psz_module_name ) )
114 BOOL b_has_prefs = p_parser->i_config_items != 0;
115 vlc_list_release( p_list );
116 return( b_has_prefs );
120 vlc_list_release( p_list );
125 - (void)createPrefPanel:(NSString *)o_module_name
130 module_t *p_parser = NULL;
132 module_config_t *p_item;
133 char *psz_module_name;
136 NSPanel *o_panel; /* panel */
137 NSRect s_panel_rc; /* panel rect */
138 NSView *o_panel_view; /* panel view */
139 NSToolbar *o_toolbar; /* panel toolbar */
140 NSMutableDictionary *o_tb_items; /* panel toolbar items */
141 NSScrollView *o_scroll_view; /* panel scroll view */
142 NSRect s_scroll_rc; /* panel scroll view rect */
143 NSMutableDictionary *o_views; /* panel scroll view docviews */
145 NSRect s_rc; /* rect */
146 NSView *o_view; /* view */
147 NSRect s_vrc; /* view rect */
148 NSButton *o_button; /* button */
149 NSRect s_brc; /* button rect */
150 VLCTextField *o_text_field; /* input field / label */
152 o_panel = [o_pref_panels objectForKey: o_module_name];
156 [o_panel makeKeyAndOrderFront: nil];
160 psz_module_name = (char *)[o_module_name lossyCString];
162 /* Look for the selected module */
163 p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
165 for( i_index = 0; i_index < p_list->i_count; i_index++ )
167 p_parser = (module_t *)p_list->p_values[i_index].p_object ;
170 && !strcmp( psz_module_name, p_parser->psz_object_name ) )
176 if( !p_parser || i_index == p_list->i_count )
178 vlc_list_release( p_list );
182 /* We found it, now we can start building its configuration interface */
184 s_panel_rc = NSMakeRect( 0, 0, 450, 450 );
185 o_panel = [[NSPanel alloc] initWithContentRect: s_panel_rc
186 styleMask: NSTitledWindowMask
187 backing: NSBackingStoreBuffered
189 o_toolbar = [[NSToolbar alloc] initWithIdentifier: o_module_name];
190 [o_panel setTitle: [NSString stringWithFormat: @"%@ (%@)",
191 _NS("Preferences"), o_module_name]];
192 o_panel_view = [o_panel contentView];
194 s_scroll_rc = s_panel_rc;
195 s_scroll_rc.size.height -= 55; s_scroll_rc.origin.y += 55;
196 o_scroll_view = [[NSScrollView alloc] initWithFrame: s_scroll_rc];
197 [o_scroll_views setObject: o_scroll_view forKey: o_module_name];
198 [o_scroll_view setBorderType: NSGrooveBorder];
199 [o_scroll_view setHasVerticalScroller: YES];
200 [o_scroll_view setDrawsBackground: NO];
201 [o_scroll_view setRulersVisible: YES];
202 [o_panel_view addSubview: o_scroll_view];
204 o_tb_items = [[NSMutableDictionary alloc] init];
205 o_views = [[NSMutableDictionary alloc] init];
207 [o_save_prefs setObject: [[NSMutableArray alloc] init]
208 forKey: o_module_name];
210 /* Enumerate config options and add corresponding config boxes */
211 p_item = p_parser->p_config;
218 #define Y_ORIGIN (X_ORIGIN - 10)
220 #define CHECK_VIEW_HEIGHT \
222 float f_new_pos = s_rc.origin.y + s_rc.size.height + X_ORIGIN; \
223 if( f_new_pos > s_vrc.size.height ) \
225 s_vrc.size.height = f_new_pos; \
226 [o_view setFrame: s_vrc]; \
230 #define CONTROL_LABEL( label ) \
232 s_rc.origin.x += s_rc.size.width + 10; \
233 s_rc.size.width = s_vrc.size.width - s_rc.origin.x - X_ORIGIN - 20; \
234 o_text_field = [[NSTextField alloc] initWithFrame: s_rc]; \
235 [o_text_field setDrawsBackground: NO]; \
236 [o_text_field setBordered: NO]; \
237 [o_text_field setEditable: NO]; \
238 [o_text_field setSelectable: NO]; \
241 [o_text_field setStringValue: \
242 [NSApp localizedString: label]]; \
244 [o_text_field sizeToFit]; \
245 [o_view addSubview: [o_text_field autorelease]]; \
248 #define INPUT_FIELD( ctype, cname, label, w, msg, param, tip ) \
250 char * psz_duptip = NULL; \
251 if ( p_item->psz_longtext != NULL && [NSApp getEncoding] == NSISOLatin1StringEncoding ) \
252 psz_duptip = strdup(p_item->psz_longtext); \
253 s_rc.size.height = 25; \
254 s_rc.size.width = w; \
255 s_rc.origin.y += 10; \
257 o_text_field = [[VLCTextField alloc] initWithFrame: s_rc]; \
258 [o_text_field setAlignment: NSRightTextAlignment]; \
259 CONTROL_CONFIG( o_text_field, o_module_name, ctype, cname ); \
260 [o_text_field msg: param]; \
261 if ( psz_duptip != NULL ) \
263 [o_text_field setToolTip: [NSApp localizedString: \
264 vlc_wraptext(psz_duptip, PREFS_WRAP)]]; \
267 [o_view addSubview: [o_text_field autorelease]]; \
268 [[NSNotificationCenter defaultCenter] addObserver: self \
269 selector: @selector(configChanged:) \
270 name: NSControlTextDidChangeNotification \
271 object: o_text_field]; \
272 CONTROL_LABEL( label ); \
273 s_rc.origin.y += s_rc.size.height; \
274 s_rc.origin.x = X_ORIGIN; \
277 #define INPUT_FIELD_INTEGER( name, label, w, param, tip ) \
278 INPUT_FIELD( CONFIG_ITEM_INTEGER, name, label, w, setIntValue, param, tip )
279 #define INPUT_FIELD_FLOAT( name, label, w, param, tip ) \
280 INPUT_FIELD( CONFIG_ITEM_FLOAT, name, label, w, setFloatValue, param, tip )
281 #define INPUT_FIELD_STRING( name, label, w, param, tip ) \
282 INPUT_FIELD( CONFIG_ITEM_STRING, name, label, w, setStringValue, param, tip )
286 if( p_item->b_advanced && !config_GetInt( p_intf, "advanced" ) )
290 switch( p_item->i_type )
293 case CONFIG_HINT_CATEGORY:
297 NSToolbarItem *o_tbi;
299 o_label = [NSApp localizedString: p_item->psz_text];
300 o_tbi = [[NSToolbarItem alloc] initWithItemIdentifier: o_label];
301 [o_tbi setImage: [NSImage imageNamed: @"NSApplicationIcon"]];
302 [o_tbi setLabel: o_label];
303 [o_tbi setTarget: self];
304 [o_tbi setAction: @selector(selectPrefView:)];
306 o_key = [NSString stringWithFormat: @"%02d %@",
308 [o_tb_items setObject: o_tbi forKey: o_key];
310 s_vrc = s_scroll_rc; s_vrc.size.height -= 4;
311 o_view = [[VLCFlippedView alloc] initWithFrame: s_vrc];
312 [o_views setObject: o_view forKey: o_label];
314 s_rc.origin.x = X_ORIGIN;
315 s_rc.origin.y = Y_ORIGIN;
321 [o_scroll_view setDocumentView: o_view];
328 case CONFIG_ITEM_MODULE:
333 NSPopUpButton *o_modules;
334 NSButton *o_btn_select;
335 NSButton *o_btn_configure;
336 char * psz_duptip = NULL;
337 if ( p_item->psz_longtext != NULL && [NSApp getEncoding] == NSISOLatin1StringEncoding )
338 psz_duptip = strdup(p_item->psz_longtext);
340 #define MODULE_BUTTON( button, title, sel ) \
342 s_brc.size.height = 32; \
343 s_brc.origin.x += s_brc.size.width + 10; \
344 s_brc.size.width = s_crc.size.width - s_brc.origin.x - 10; \
345 button = [[NSButton alloc] initWithFrame: s_brc]; \
346 [button setButtonType: NSMomentaryPushInButton]; \
347 [button setBezelStyle: NSRoundedBezelStyle]; \
348 [button setTitle: title]; \
349 [button setTag: i_module_tag++]; \
350 [button setTarget: self]; \
351 [button setAction: @selector(sel)]; \
352 [o_cview addSubview: [button autorelease]]; \
355 s_rc.size.height = 107;
356 s_rc.size.width = s_vrc.size.width - X_ORIGIN * 2 - 20;
357 s_rc.origin.y += i_module_tag == 3 ? Y_ORIGIN : 20;
361 o_box = [[NSBox alloc] initWithFrame: s_rc];
362 [o_box setTitle: [NSApp localizedString: p_item->psz_text]];
363 [o_view addSubview: [o_box autorelease]];
364 s_rc.origin.y += s_rc.size.height + 10;
365 o_cview = [[VLCFlippedView alloc] initWithFrame: s_rc];
366 [o_box setContentView: [o_cview autorelease]];
367 s_crc = [o_cview bounds];
369 s_brc = NSMakeRect( 5, 10, 200, 30 );
370 o_modules = [[NSPopUpButton alloc] initWithFrame: s_brc];
371 [o_modules setTag: i_module_tag++];
372 [o_modules setTarget: self];
373 [o_modules setAction: @selector(moduleSelected:)];
374 if ( psz_duptip != NULL )
376 [o_modules setToolTip: [NSApp localizedString:
377 vlc_wraptext(psz_duptip, PREFS_WRAP)]];
380 [o_cview addSubview: [o_modules autorelease]];
382 MODULE_BUTTON( o_btn_configure, _NS("Configure"),
385 s_brc = NSMakeRect( 8, s_brc.origin.y + s_brc.size.height + 10,
387 o_text_field = [[VLCTextField alloc] initWithFrame: s_brc];
388 [o_text_field setTag: i_module_tag++];
389 [o_text_field setAlignment: NSLeftTextAlignment];
390 CONTROL_CONFIG( o_text_field, o_module_name,
391 CONFIG_ITEM_MODULE, p_item->psz_name );
392 [[NSNotificationCenter defaultCenter] addObserver: self
393 selector: @selector(configChanged:)
394 name: NSControlTextDidChangeNotification
395 object: o_text_field];
396 [o_cview addSubview: [o_text_field autorelease]];
399 MODULE_BUTTON( o_btn_select, _NS("Select"),
402 [o_modules addItemWithTitle: _NS("None")];
404 /* build a list of available modules */
406 for( i_index = 0; i_index < p_list->i_count; i_index++ )
408 p_parser = (module_t *)p_list->p_values[i_index].p_object ;
410 if( !strcmp( p_parser->psz_capability,
413 NSString *o_object_name = [NSString
414 stringWithCString: p_parser->psz_object_name];
415 [o_modules addItemWithTitle: o_object_name];
420 if( p_item->psz_value != NULL )
423 [NSString stringWithCString: p_item->psz_value];
425 [o_text_field setStringValue: o_value];
426 [o_modules selectItemWithTitle: o_value];
427 [o_btn_configure setEnabled: [self hasPrefs: o_value]];
431 [o_modules selectItemWithTitle: _NS("None")];
432 [o_btn_configure setEnabled: NO];
439 case CONFIG_ITEM_STRING:
440 case CONFIG_ITEM_FILE:
443 if( !p_item->ppsz_list )
445 char *psz_value = p_item->psz_value ?
446 p_item->psz_value : "";
448 INPUT_FIELD_STRING( p_item->psz_name, p_item->psz_text, 150,
449 [NSString stringWithCString: psz_value],
450 p_item->psz_longtext );
455 VLCComboBox *o_combo_box;
456 char * psz_duptip = NULL;
457 if ( p_item->psz_longtext != NULL && [NSApp getEncoding] == NSISOLatin1StringEncoding )
458 psz_duptip = strdup(p_item->psz_longtext);
460 s_rc.size.height = 27;
461 s_rc.size.width = 150;
466 o_combo_box = [[VLCComboBox alloc] initWithFrame: s_rc];
467 CONTROL_CONFIG( o_combo_box, o_module_name,
468 CONFIG_ITEM_STRING, p_item->psz_name );
469 if ( psz_duptip != NULL )
471 [o_combo_box setToolTip: [NSApp localizedString:
472 vlc_wraptext(psz_duptip, PREFS_WRAP)]];
475 [o_view addSubview: [o_combo_box autorelease]];
476 [[NSNotificationCenter defaultCenter] addObserver: self
477 selector: @selector(configChanged:)
478 name: NSControlTextDidChangeNotification
479 object: o_combo_box];
480 [[NSNotificationCenter defaultCenter] addObserver: self
481 selector: @selector(configChanged:)
482 name: NSComboBoxSelectionDidChangeNotification
483 object: o_combo_box];
485 for( i=0; p_item->ppsz_list[i]; i++ )
487 [o_combo_box addItemWithObjectValue:
488 [NSString stringWithCString: p_item->ppsz_list[i]]];
491 CONTROL_LABEL( p_item->psz_text );
493 s_rc.origin.y += s_rc.size.height;
494 s_rc.origin.x = X_ORIGIN;
500 case CONFIG_ITEM_INTEGER:
502 INPUT_FIELD_INTEGER( p_item->psz_name, p_item->psz_text, 70,
503 p_item->i_value, p_item->psz_longtext );
507 case CONFIG_ITEM_FLOAT:
509 INPUT_FIELD_FLOAT( p_item->psz_name, p_item->psz_text, 70,
510 p_item->f_value, p_item->psz_longtext );
514 case CONFIG_ITEM_BOOL:
516 VLCButton *o_btn_bool;
517 char * psz_duptip = NULL;
518 if ( p_item->psz_longtext != NULL && [NSApp getEncoding] == NSISOLatin1StringEncoding )
519 psz_duptip = strdup(p_item->psz_longtext);
521 s_rc.size.height = 27;
522 s_rc.size.width = s_vrc.size.width - X_ORIGIN * 2 - 20;
527 o_btn_bool = [[VLCButton alloc] initWithFrame: s_rc];
528 [o_btn_bool setButtonType: NSSwitchButton];
529 [o_btn_bool setIntValue: p_item->i_value];
530 [o_btn_bool setTitle:
531 [NSApp localizedString: p_item->psz_text]];
532 if ( psz_duptip != NULL )
534 [o_btn_bool setToolTip: [NSApp localizedString:
535 vlc_wraptext(psz_duptip, PREFS_WRAP)]];
538 [o_btn_bool setTarget: self];
539 [o_btn_bool setAction: @selector(configChanged:)];
540 CONTROL_CONFIG( o_btn_bool, o_module_name,
541 CONFIG_ITEM_BOOL, p_item->psz_name );
542 [o_view addSubview: [o_btn_bool autorelease]];
544 s_rc.origin.y += s_rc.size.height;
550 #undef INPUT_FIELD_INTEGER
551 #undef INPUT_FIELD_FLOAT
552 #undef INPUT_FIELD_STRING
554 #undef CHECK_VIEW_HEIGHT
559 while( p_item->i_type != CONFIG_HINT_END && p_item++ );
561 vlc_list_release( p_list );
563 [o_toolbars setObject: o_tb_items forKey: o_module_name];
564 [o_toolbar setDelegate: self];
565 [o_panel setToolbar: [o_toolbar autorelease]];
567 #define DEF_PANEL_BUTTON( tag, title, sel ) \
569 o_button = [[NSButton alloc] initWithFrame: s_rc]; \
570 [o_button setButtonType: NSMomentaryPushInButton]; \
571 [o_button setBezelStyle: NSRoundedBezelStyle]; \
572 [o_button setAction: @selector(sel)]; \
573 [o_button setTarget: self]; \
574 [o_button setTitle: title]; \
575 [o_button setTag: tag]; \
576 [o_panel_view addSubview: [o_button autorelease]]; \
579 s_rc.origin.y = s_panel_rc.origin.y + 14;
580 s_rc.size.height = 25; s_rc.size.width = 105;
581 s_rc.origin.x = s_panel_rc.size.width - s_rc.size.width - 14;
582 DEF_PANEL_BUTTON( 0, _NS("OK"), clickedApplyCancelOK: );
583 [o_panel setDefaultButtonCell: [o_button cell]];
585 s_rc.origin.x -= s_rc.size.width;
586 DEF_PANEL_BUTTON( 1, _NS("Cancel"), clickedApplyCancelOK: );
587 [o_button setKeyEquivalent: @"\E"];
589 s_rc.origin.x -= s_rc.size.width;
590 DEF_PANEL_BUTTON( 2, _NS("Apply"), clickedApplyCancelOK: );
591 [o_button setEnabled: NO];
593 #undef DEF_PANEL_BUTTON
595 [o_pref_panels setObject: o_panel forKey: o_module_name];
596 [o_panel_views setObject: o_views forKey: o_module_name];
599 [o_panel makeKeyAndOrderFront: nil];
602 - (void)destroyPrefPanel:(id)o_unknown
607 NSMutableArray *o_prefs;
608 NSMutableDictionary *o_dic;
609 NSScrollView *o_scroll_view;
610 NSString *o_module_name;
612 o_module_name = (NSString *)([o_unknown isKindOfClass: [NSTimer class]] ?
613 [o_unknown userInfo] : o_unknown);
615 #define DIC_REL(dic) \
617 o_dic = [dic objectForKey: o_module_name]; \
618 [dic removeObjectForKey: o_module_name]; \
619 o_e1 = [o_dic objectEnumerator]; \
620 while( (v1 = [o_e1 nextObject]) ) \
624 [o_dic removeAllObjects]; \
628 o_panel = [o_pref_panels objectForKey: o_module_name];
629 [o_pref_panels removeObjectForKey: o_module_name];
634 o_scroll_view = [o_scroll_views objectForKey: o_module_name];
635 [o_scroll_views removeObjectForKey: o_module_name];
636 [o_scroll_view release];
638 DIC_REL(o_panel_views);
640 o_prefs = [o_save_prefs objectForKey: o_module_name];
641 [o_save_prefs removeObjectForKey: o_module_name];
642 [o_prefs removeAllObjects];
649 - (void)selectPrefView:(id)sender
652 NSString *o_module_name;
653 NSScrollView *o_scroll_view;
654 NSMutableDictionary *o_views;
656 o_module_name = [[sender toolbar] identifier];
657 o_views = [o_panel_views objectForKey: o_module_name];
658 o_view = [o_views objectForKey: [sender label]];
660 o_scroll_view = [o_scroll_views objectForKey: o_module_name];
661 [o_scroll_view setDocumentView: o_view];
664 - (void)moduleSelected:(id)sender
666 NSButton *o_btn_config;
667 NSString *o_module_name;
668 BOOL b_has_prefs = NO;
670 o_module_name = [sender titleOfSelectedItem];
671 o_btn_config = [[sender superview] viewWithTag: [sender tag] + 1];
673 if( ![o_module_name isEqualToString: _NS("None")] )
675 b_has_prefs = [self hasPrefs: o_module_name];
678 [o_btn_config setEnabled: b_has_prefs];
681 - (void)configureModule:(id)sender
683 NSString *o_module_name;
684 NSPopUpButton *o_modules;
686 o_modules = [[sender superview] viewWithTag: [sender tag] - 1];
687 o_module_name = [o_modules titleOfSelectedItem];
689 [self createPrefPanel: o_module_name];
692 - (void)selectModule:(id)sender
694 NSString *o_module_name;
695 NSPopUpButton *o_modules;
696 NSTextField *o_module;
698 o_module = [[sender superview] viewWithTag: [sender tag] - 1];
699 o_modules = [[sender superview] viewWithTag: [sender tag] - 3];
700 o_module_name = [o_modules titleOfSelectedItem];
702 if( [o_module_name isEqualToString: _NS("None")] )
704 o_module_name = [NSString string];
707 [o_module setStringValue: o_module_name];
708 [self configChanged: o_module];
711 - (void)configChanged:(id)o_unknown
713 id o_vlc_config = [o_unknown isKindOfClass: [NSNotification class]] ?
714 [o_unknown object] : o_unknown;
716 NSString *o_module_name = [o_vlc_config moduleName];
717 NSPanel *o_pref_panel = [o_pref_panels objectForKey: o_module_name];
718 NSMutableArray *o_prefs = [o_save_prefs objectForKey: o_module_name];
720 if( [o_prefs indexOfObjectIdenticalTo: o_vlc_config] == NSNotFound )
722 NSView *o_pref_view = [o_pref_panel contentView];
723 NSButton *o_btn_apply = [o_pref_view viewWithTag: 2];
725 [o_prefs addObject: o_vlc_config];
726 [o_btn_apply setEnabled: YES];
730 - (void)clickedApplyCancelOK:(id)sender
733 NSEnumerator *o_enum;
734 BOOL b_adv_change = FALSE;
736 NSWindow *o_pref_panel = [[sender superview] window];
737 NSString *o_module_name = [[o_pref_panel toolbar] identifier];
739 if ( ![[sender title] isEqualToString: _NS("Cancel")] )
741 NSView *o_config_view = [sender superview];
742 NSWindow *o_config_panel = [o_config_view window];
743 NSButton *o_btn_apply = [o_config_view viewWithTag: 2];
744 NSString *o_module_name = [[o_config_panel toolbar] identifier];
745 NSMutableArray *o_prefs = [o_save_prefs objectForKey: o_module_name];
747 o_enum = [o_prefs objectEnumerator];
748 while( ( o_vlc_control = [o_enum nextObject] ) )
750 int i_type = [o_vlc_control configType];
751 NSString *o_name = [o_vlc_control configName];
752 char *psz_name = (char *)[o_name lossyCString];
757 case CONFIG_ITEM_MODULE:
758 case CONFIG_ITEM_STRING:
759 case CONFIG_ITEM_FILE:
764 o_value = [o_vlc_control stringValue];
765 psz_value = (char *)[o_value lossyCString];
767 config_PutPsz( p_intf, psz_name,
768 *psz_value ? psz_value : NULL );
772 case CONFIG_ITEM_INTEGER:
773 case CONFIG_ITEM_BOOL:
775 int i_value = [o_vlc_control intValue];
777 if( !strcmp( psz_name, "advanced" ) &&
778 ( config_GetInt( p_intf, "advanced" ) != i_value ) )
783 config_PutInt( p_intf, psz_name, i_value );
787 case CONFIG_ITEM_FLOAT:
789 float f_value = [o_vlc_control floatValue];
791 config_PutFloat( p_intf, psz_name, f_value );
798 [o_btn_apply setEnabled: NO];
799 [o_prefs removeAllObjects];
801 config_SaveConfigFile( p_intf, NULL );
804 if( ![[sender title] isEqualToString: _NS("Apply")] || b_adv_change )
806 [o_pref_panel close];
808 if( [self respondsToSelector: @selector(performSelectorOnMainThread:
809 withObject:waitUntilDone:)] )
811 [self performSelectorOnMainThread: @selector(destroyPrefPanel:)
812 withObject: o_module_name
817 [NSTimer scheduledTimerWithTimeInterval: 0.1
818 target: self selector: @selector(destroyPrefPanel:)
819 userInfo: o_module_name repeats: NO];
822 if( [[sender title] isEqualToString: _NS("Apply")] && b_adv_change )
824 [self createPrefPanel: o_module_name];
831 @implementation VLCPrefs (NSToolbarDelegate)
833 - (NSToolbarItem *)toolbar:(NSToolbar *)o_toolbar
834 itemForItemIdentifier:(NSString *)o_item_id
835 willBeInsertedIntoToolbar:(BOOL)b_flag
837 NSMutableDictionary *o_toolbar_items;
838 NSString *o_module_name = [o_toolbar identifier];
840 o_toolbar_items = [o_toolbars objectForKey: o_module_name];
841 if( o_toolbar_items == nil )
846 return( [o_toolbar_items objectForKey: o_item_id] );
849 - (NSArray *)toolbarAllowedItemIdentifiers:(NSToolbar*)o_toolbar
851 return( [self toolbarDefaultItemIdentifiers: o_toolbar] );
854 - (NSArray *)toolbarDefaultItemIdentifiers:(NSToolbar*)o_toolbar
857 NSMutableDictionary *o_toolbar_items;
858 NSString *o_module_name = [o_toolbar identifier];
860 o_toolbar_items = [o_toolbars objectForKey: o_module_name];
861 if( o_toolbar_items == nil )
866 o_ids = [[o_toolbar_items allKeys]
867 sortedArrayUsingSelector: @selector(compare:)];
874 @implementation VLCFlippedView
883 IMPL_CONTROL_CONFIG(Button);
884 IMPL_CONTROL_CONFIG(ComboBox);
885 IMPL_CONTROL_CONFIG(TextField);