1 /*****************************************************************************
2 * prefs.m: MacOS X plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2002-2003 VideoLAN
5 * $Id: prefs.m,v 1.31 2003/06/06 00:38:41 hartman Exp $
7 * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
8 * Derk-Jan Hartman <thedj at users.sf.net>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
23 *****************************************************************************/
25 /*****************************************************************************
27 *****************************************************************************/
28 #include <stdlib.h> /* malloc(), free() */
29 #include <sys/param.h> /* for MAXPATHLEN */
35 /*****************************************************************************
36 * VLCPrefs implementation
37 *****************************************************************************/
38 @implementation VLCPrefs
46 o_empty_view = [[NSView alloc] init];
54 [o_empty_view release];
60 p_intf = [NSApp getIntf];
61 b_advanced = config_GetInt( p_intf, "advanced" );
64 [o_advanced_ckb setState: b_advanced];
65 [o_prefs_view setBorderType: NSGrooveBorder];
66 [o_prefs_view setHasVerticalScroller: YES];
67 [o_prefs_view setDrawsBackground: NO];
68 [o_prefs_view setRulersVisible: YES];
69 [o_prefs_view setDocumentView: o_empty_view];
70 [o_tree selectRow:0 byExtendingSelection:NO];
75 [o_prefs_window setTitle: _NS("Preferences")];
76 [o_save_btn setTitle: _NS("Save")];
77 [o_cancel_btn setTitle: _NS("Cancel")];
78 [o_reset_btn setTitle: _NS("Reset All")];
79 [o_advanced_ckb setTitle: _NS("Advanced")];
84 [o_prefs_window center];
85 [o_prefs_window makeKeyAndOrderFront:self];
88 - (IBAction)savePrefs: (id)sender
90 config_SaveConfigFile( p_intf, NULL );
91 [o_prefs_window orderOut:self];
94 - (IBAction)closePrefs: (id)sender
96 [o_prefs_window orderOut:self];
99 - (IBAction)resetAll: (id)sender
101 NSBeginInformationalAlertSheet(_NS("Reset Preferences"), @"Cancel", @"Continue",
102 nil, o_prefs_window, self, @selector(sheetDidEnd: returnCode: contextInfo:), NULL, nil,
103 _NS("Beware this will reset your VLC Media Player config file.\n"
104 "Are you sure you want to continue?") );
107 - (void)sheetDidEnd:(NSWindow *)o_sheet returnCode:(int)i_return contextInfo:(void *)o_context
109 if( i_return == NSAlertAlternateReturn )
111 config_ResetAll( p_intf );
112 [self showViewForID: [[o_tree itemAtRow:[o_tree selectedRow]] getObjectID]
113 andName: [[o_tree itemAtRow:[o_tree selectedRow]] getName]];
117 - (IBAction)advancedToggle: (id)sender
119 b_advanced = !b_advanced;
120 [o_advanced_ckb setState: b_advanced];
121 [self showViewForID: [[o_tree itemAtRow:[o_tree selectedRow]] getObjectID]
122 andName: [[o_tree itemAtRow:[o_tree selectedRow]] getName]];
125 - (void)loadConfigTree
130 - (void)outlineViewSelectionIsChanging:(NSNotification *)o_notification
134 - (void)outlineViewSelectionDidChange:(NSNotification *)o_notification
136 [self showViewForID: [[o_tree itemAtRow:[o_tree selectedRow]] getObjectID]
137 andName: [[o_tree itemAtRow:[o_tree selectedRow]] getName]];
140 - (void)configChanged:(id)o_unknown
142 id o_vlc_config = [o_unknown isKindOfClass: [NSNotification class]] ?
143 [o_unknown object] : o_unknown;
145 int i_type = [o_vlc_config configType];
146 NSString *o_name = [o_vlc_config configName];
147 char *psz_name = (char *)[o_name UTF8String];
152 case CONFIG_ITEM_MODULE:
155 module_t *p_a_module;
156 int i_id = [[o_vlc_config selectedItem] tag];
158 p_a_module = (module_t *)vlc_object_get( p_intf, i_id );
159 if( p_a_module == NULL || p_a_module->i_object_type != VLC_OBJECT_MODULE )
164 psz_value = ( i_id == -1 ) ? "" : p_a_module->psz_object_name ;
165 config_PutPsz( p_intf, psz_name, strdup(psz_value) );
169 case CONFIG_ITEM_STRING:
170 case CONFIG_ITEM_FILE:
171 case CONFIG_ITEM_DIRECTORY:
176 o_value = [o_vlc_config stringValue];
177 psz_value = (char *)[o_value UTF8String];
179 config_PutPsz( p_intf, psz_name, psz_value );
183 case CONFIG_ITEM_INTEGER:
184 case CONFIG_ITEM_BOOL:
186 int i_value = [o_vlc_config intValue];
188 config_PutInt( p_intf, psz_name, i_value );
192 case CONFIG_ITEM_FLOAT:
194 float f_value = [o_vlc_config floatValue];
196 config_PutFloat( p_intf, psz_name, f_value );
203 - (void)showViewForID: (int)i_id andName: (NSString *)o_item_name
207 module_config_t *p_item;
209 int i_pos, i_module_tag, i_index;
211 NSString *o_module_name;
212 NSRect s_rc; /* rect */
213 NSView *o_view; /* view */
214 NSRect s_vrc; /* view rect */
215 VLCTextField *o_text_field; /* input field / label */
217 p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
219 /* Get a pointer to the module */
220 p_parser = (module_t *)vlc_object_get( p_intf, i_id );
221 if( p_parser->i_object_type != VLC_OBJECT_MODULE )
223 /* 0OOoo something went really bad */
227 /* Enumerate config options and add corresponding config boxes */
228 o_module_name = [NSString stringWithUTF8String: p_parser->psz_object_name];
229 p_item = p_parser->p_config;
236 #define Y_ORIGIN (X_ORIGIN - 10)
238 #define CHECK_VIEW_HEIGHT \
240 float f_new_pos = s_rc.origin.y + s_rc.size.height + X_ORIGIN; \
241 if( f_new_pos > s_vrc.size.height ) \
243 s_vrc.size.height = f_new_pos; \
244 [o_view setFrame: s_vrc]; \
248 #define CONTROL_LABEL( label ) \
250 s_rc.origin.x += s_rc.size.width + 10; \
251 s_rc.size.width = s_vrc.size.width - s_rc.origin.x - X_ORIGIN - 20; \
252 o_text_field = [[NSTextField alloc] initWithFrame: s_rc]; \
253 [o_text_field setDrawsBackground: NO]; \
254 [o_text_field setBordered: NO]; \
255 [o_text_field setEditable: NO]; \
256 [o_text_field setSelectable: NO]; \
259 [o_text_field setStringValue: \
260 [NSApp localizedString: label]]; \
262 [o_text_field sizeToFit]; \
263 [o_view addSubview: [o_text_field autorelease]]; \
266 #define INPUT_FIELD( ctype, cname, label, w, msg, param, tip ) \
268 char * psz_duptip = NULL; \
269 if ( p_item->psz_longtext != NULL ) \
270 psz_duptip = strdup( p_item->psz_longtext ); \
271 s_rc.size.height = 25; \
272 s_rc.size.width = w; \
273 s_rc.origin.y += 10; \
275 o_text_field = [[VLCTextField alloc] initWithFrame: s_rc]; \
276 [o_text_field setAlignment: NSRightTextAlignment]; \
277 CONTROL_CONFIG( o_text_field, o_module_name, ctype, cname ); \
278 [o_text_field msg: param]; \
279 if ( psz_duptip != NULL ) \
281 [o_text_field setToolTip: [NSApp wrapString: [NSApp localizedString: \
282 psz_duptip] toWidth: PREFS_WRAP ]]; \
285 [o_view addSubview: [o_text_field autorelease]]; \
286 [[NSNotificationCenter defaultCenter] addObserver: self \
287 selector: @selector(configChanged:) \
288 name: NSControlTextDidChangeNotification \
289 object: o_text_field]; \
290 CONTROL_LABEL( label ); \
291 s_rc.origin.y += s_rc.size.height; \
292 s_rc.origin.x = X_ORIGIN; \
295 #define INPUT_FIELD_INTEGER( name, label, w, param, tip ) \
296 INPUT_FIELD( CONFIG_ITEM_INTEGER, name, label, w, setIntValue, param, tip )
297 #define INPUT_FIELD_FLOAT( name, label, w, param, tip ) \
298 INPUT_FIELD( CONFIG_ITEM_FLOAT, name, label, w, setFloatValue, param, tip )
299 #define INPUT_FIELD_STRING( name, label, w, param, tip ) \
300 INPUT_FIELD( CONFIG_ITEM_STRING, name, label, w, setStringValue, param, tip )
303 s_vrc = [[o_prefs_view contentView] bounds]; s_vrc.size.height -= 4;
304 o_view = [[VLCFlippedView alloc] initWithFrame: s_vrc];
305 s_rc.origin.x = X_ORIGIN;
306 s_rc.origin.y = Y_ORIGIN;
307 BOOL b_right_cat = FALSE;
311 if( p_item->i_type == CONFIG_HINT_CATEGORY )
313 if( !strcmp( p_parser->psz_object_name, "main" ) &&
314 [o_item_name isEqualToString: [NSApp localizedString: p_item->psz_text]] )
317 } else if( strcmp( p_parser->psz_object_name, "main" ) )
320 } else b_right_cat = FALSE;
321 } else if( p_item->i_type == CONFIG_HINT_END && !strcmp( p_parser->psz_object_name, "main" ) )
326 if( (p_item->b_advanced && !b_advanced ) || !b_right_cat )
330 switch( p_item->i_type )
332 case CONFIG_ITEM_MODULE:
334 VLCPopUpButton *o_modules;
335 module_t *p_a_module;
336 char * psz_duptip = NULL;
338 if ( p_item->psz_longtext != NULL )
339 psz_duptip = strdup( p_item->psz_longtext );
341 s_rc.size.height = 30;
342 s_rc.size.width = 200;
347 o_modules = [[VLCPopUpButton alloc] initWithFrame: s_rc];
348 CONTROL_CONFIG( o_modules, o_module_name,
349 CONFIG_ITEM_MODULE, p_item->psz_name );
350 [o_modules setTarget: self];
351 [o_modules setAction: @selector(configChanged:)];
352 [o_modules sendActionOn:NSLeftMouseUpMask];
354 if ( psz_duptip != NULL )
356 [o_modules setToolTip: [NSApp wrapString: [NSApp localizedString: psz_duptip] toWidth: PREFS_WRAP]];
359 [o_view addSubview: [o_modules autorelease]];
361 [o_modules addItemWithTitle: _NS("Default")];
362 [[o_modules lastItem] setTag: -1];
363 [o_modules selectItem: [o_modules lastItem]];
365 /* build a list of available modules */
367 for( i_index = 0; i_index < p_list->i_count; i_index++ )
369 p_a_module = (module_t *)p_list->p_values[i_index].p_object ;
371 if( !strcmp( p_a_module->psz_capability,
374 NSString *o_description = [NSApp
375 localizedString: p_a_module->psz_longname];
376 [o_modules addItemWithTitle: o_description];
377 [[o_modules lastItem] setTag: p_a_module->i_object_id];
379 if( p_item->psz_value &&
380 !strcmp( p_item->psz_value, p_a_module->psz_object_name ) )
382 [o_modules selectItem:[o_modules lastItem]];
388 CONTROL_LABEL( p_item->psz_text );
389 s_rc.origin.y += s_rc.size.height;
390 s_rc.origin.x = X_ORIGIN;
394 case CONFIG_ITEM_STRING:
395 case CONFIG_ITEM_FILE:
396 case CONFIG_ITEM_DIRECTORY:
399 if( !p_item->ppsz_list )
401 char *psz_value = p_item->psz_value ?
402 p_item->psz_value : "";
404 INPUT_FIELD_STRING( p_item->psz_name, p_item->psz_text, 200,
405 [NSApp localizedString: psz_value],
406 p_item->psz_longtext );
411 VLCComboBox *o_combo_box;
412 char * psz_duptip = NULL;
413 if ( p_item->psz_longtext != NULL )
414 psz_duptip = strdup( p_item->psz_longtext );
416 s_rc.size.height = 27;
417 s_rc.size.width = 200;
422 o_combo_box = [[VLCComboBox alloc] initWithFrame: s_rc];
423 CONTROL_CONFIG( o_combo_box, o_module_name,
424 CONFIG_ITEM_STRING, p_item->psz_name );
425 [o_combo_box setTarget: self];
426 [o_combo_box setAction: @selector(configChanged:)];
427 [o_combo_box sendActionOn:NSLeftMouseUpMask];
429 if ( psz_duptip != NULL )
431 [o_combo_box setToolTip: [NSApp wrapString: [NSApp localizedString: psz_duptip] toWidth: PREFS_WRAP]];
434 [o_view addSubview: [o_combo_box autorelease]];
436 for( i=0; p_item->ppsz_list[i]; i++ )
438 [o_combo_box addItemWithObjectValue:
439 [NSApp localizedString: p_item->ppsz_list[i]]];
441 [o_combo_box setStringValue: [NSApp localizedString:
442 p_item->psz_value ? p_item->psz_value : ""]];
444 CONTROL_LABEL( p_item->psz_text );
446 s_rc.origin.y += s_rc.size.height;
447 s_rc.origin.x = X_ORIGIN;
453 case CONFIG_ITEM_INTEGER:
455 if( p_item->i_min == p_item->i_max )
457 INPUT_FIELD_INTEGER( p_item->psz_name, p_item->psz_text, 70,
458 p_item->i_value, p_item->psz_longtext );
464 char * psz_duptip = NULL;
465 if ( p_item->psz_longtext != NULL )
466 psz_duptip = strdup( p_item->psz_longtext );
468 s_rc.size.height = 27;
469 s_rc.size.width = 200;
474 o_slider = [[VLCSlider alloc] initWithFrame: s_rc];
475 [o_slider setMinValue: p_item->i_min];
476 [o_slider setMaxValue: p_item->i_max];
477 [o_slider setIntValue: p_item->i_value];
479 if ( psz_duptip != NULL )
481 [o_slider setToolTip: [NSApp wrapString: [NSApp localizedString: psz_duptip] toWidth: PREFS_WRAP]];
484 [o_slider setTarget: self];
485 [o_slider setAction: @selector(configChanged:)];
486 [o_slider sendActionOn:NSLeftMouseUpMask];
487 CONTROL_CONFIG( o_slider, o_module_name,
488 CONFIG_ITEM_INTEGER, p_item->psz_name );
489 [o_view addSubview: [o_slider autorelease]];
490 CONTROL_LABEL( p_item->psz_text );
492 s_rc.origin.y += s_rc.size.height;
493 s_rc.origin.x = X_ORIGIN;
498 case CONFIG_ITEM_FLOAT:
500 if( p_item->f_min == p_item->f_max )
502 INPUT_FIELD_FLOAT( p_item->psz_name, p_item->psz_text, 70,
503 p_item->f_value, p_item->psz_longtext );
507 /* create a slider */
509 char * psz_duptip = NULL;
510 if ( p_item->psz_longtext != NULL )
511 psz_duptip = strdup( p_item->psz_longtext );
513 s_rc.size.height = 27;
514 s_rc.size.width = 200;
519 o_slider = [[VLCSlider alloc] initWithFrame: s_rc];
520 [o_slider setMinValue: p_item->f_min];
521 [o_slider setMaxValue: p_item->f_max];
522 [o_slider setFloatValue: p_item->f_value];
524 if ( psz_duptip != NULL )
526 [o_slider setToolTip: [NSApp wrapString: [NSApp localizedString: psz_duptip] toWidth: PREFS_WRAP]];
529 [o_slider setTarget: self];
530 [o_slider setAction: @selector(configChanged:)];
531 [o_slider sendActionOn:NSLeftMouseUpMask];
532 CONTROL_CONFIG( o_slider, o_module_name,
533 CONFIG_ITEM_FLOAT, p_item->psz_name );
534 [o_view addSubview: [o_slider autorelease]];
535 CONTROL_LABEL( p_item->psz_text );
537 s_rc.origin.y += s_rc.size.height;
538 s_rc.origin.x = X_ORIGIN;
543 case CONFIG_ITEM_BOOL:
545 VLCButton *o_btn_bool;
546 char * psz_duptip = NULL;
548 if ( p_item->psz_longtext != NULL )
549 psz_duptip = strdup( p_item->psz_longtext );
551 s_rc.size.height = 27;
552 s_rc.size.width = s_vrc.size.width - X_ORIGIN * 2 - 20;
557 o_btn_bool = [[VLCButton alloc] initWithFrame: s_rc];
558 [o_btn_bool setButtonType: NSSwitchButton];
559 [o_btn_bool setIntValue: p_item->i_value];
560 [o_btn_bool setTitle: [NSApp localizedString: p_item->psz_text]];
561 if ( psz_duptip != NULL )
563 [o_btn_bool setToolTip: [NSApp wrapString: [NSApp localizedString: psz_duptip] toWidth: PREFS_WRAP]];
566 [o_btn_bool setTarget: self];
567 [o_btn_bool setAction: @selector(configChanged:)];
568 CONTROL_CONFIG( o_btn_bool, o_module_name,
569 CONFIG_ITEM_BOOL, p_item->psz_name );
570 [o_view addSubview: [o_btn_bool autorelease]];
572 s_rc.origin.y += s_rc.size.height;
578 #undef INPUT_FIELD_INTEGER
579 #undef INPUT_FIELD_FLOAT
580 #undef INPUT_FIELD_STRING
582 #undef CHECK_VIEW_HEIGHT
587 while( p_item->i_type != CONFIG_HINT_END && p_item++ );
588 vlc_list_release( p_list );
590 [o_prefs_view setDocumentView: o_view];
591 [o_prefs_view setNeedsDisplay: TRUE];
597 @implementation VLCPrefs (NSTableDataSource)
599 - (int)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item {
600 return (item == nil) ? [[VLCTreeItem rootItem] numberOfChildren] : [item numberOfChildren];
603 - (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item {
604 return (item == nil) ? YES : ([item numberOfChildren] != -1);
607 - (id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item {
608 return (item == nil) ? [[VLCTreeItem rootItem] childAtIndex:index] : [item childAtIndex:index];
611 - (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item {
612 return (item == nil) ? @"" : (id)[item getName];
617 @implementation VLCTreeItem
619 static VLCTreeItem *o_root_item = nil;
621 #define IsALeafNode ((id)-1)
623 - (id)initWithName: (NSString *)o_item_name ID: (int)i_id parent:(VLCTreeItem *)o_parent_item
629 o_name = [o_item_name copy];
631 o_parent = o_parent_item;
636 + (VLCTreeItem *)rootItem {
637 if (o_root_item == nil) o_root_item = [[VLCTreeItem alloc] initWithName:@"main" ID: 0 parent:nil];
643 if (o_children != IsALeafNode) [o_children release];
648 /* Creates and returns the array of children
649 * Loads children incrementally */
650 - (NSArray *)children {
651 if (o_children == NULL) {
652 intf_thread_t *p_intf = [NSApp getIntf];
654 module_t *p_module = NULL;
655 module_config_t *p_item;
658 /* List the plugins */
659 p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
660 if( !p_list ) return nil;
662 if( [[self getName] isEqualToString: @"main"] )
665 * Build a tree of the main options
667 for( i_index = 0; i_index < p_list->i_count; i_index++ )
669 p_module = (module_t *)p_list->p_values[i_index].p_object;
670 if( !strcmp( p_module->psz_object_name, "main" ) )
673 if( p_module == NULL )
675 msg_Err( p_intf, "Could not find the main module in our prefs" );
678 if( i_index < p_list->i_count )
680 /* We found the main module */
682 /* Enumerate config categories and store a reference so we can
683 * generate their config panel them when it is asked by the user. */
684 p_item = p_module->p_config;
685 o_children = [[NSMutableArray alloc] initWithCapacity:10];
689 NSString *o_child_name;
691 switch( p_item->i_type )
693 case CONFIG_HINT_CATEGORY:
694 o_child_name = [NSApp localizedString: p_item->psz_text];
695 [o_children addObject:[[VLCTreeItem alloc] initWithName: o_child_name
696 ID: p_module->i_object_id parent:self]];
700 while( p_item->i_type != CONFIG_HINT_END && p_item++ );
702 /* Add the plugins item */
703 [o_children addObject:[[VLCTreeItem alloc] initWithName: _NS("Modules")
708 o_children = IsALeafNode;
711 else if( [[self getName] isEqualToString: _NS("Modules")] )
713 /* Add the capabilities */
714 o_children = [[NSMutableArray alloc] initWithCapacity:10];
715 for( i_index = 0; i_index < p_list->i_count; i_index++ )
717 p_module = (module_t *)p_list->p_values[i_index].p_object;
719 /* Exclude the main module */
720 if( !strcmp( p_module->psz_object_name, "main" ) )
723 /* Exclude empty plugins */
724 p_item = p_module->p_config;
725 if( !p_item ) continue;
728 if( p_item->i_type & CONFIG_ITEM )
731 while( p_item->i_type != CONFIG_HINT_END && p_item++ );
732 if( p_item->i_type == CONFIG_HINT_END ) continue;
734 /* Create the capability tree if it doesn't already exist */
735 NSString *o_capability;
736 o_capability = [NSApp localizedString: p_module->psz_capability];
737 if( !p_module->psz_capability || !*p_module->psz_capability )
739 /* Empty capability ? Let's look at the submodules */
740 module_t * p_submodule;
741 for( j = 0; j < p_module->i_children; j++ )
743 p_submodule = (module_t*)p_module->pp_children[ j ];
744 if( p_submodule->psz_capability && *p_submodule->psz_capability )
746 o_capability = [NSApp localizedString: p_submodule->psz_capability];
747 BOOL b_found = FALSE;
748 for( j = 0; j < [o_children count]; j++ )
750 if( [[[o_children objectAtIndex:j] getName] isEqualToString: o_capability] )
758 [o_children addObject:[[VLCTreeItem alloc] initWithName: o_capability
765 BOOL b_found = FALSE;
766 for( j = 0; j < [o_children count]; j++ )
768 if( [[[o_children objectAtIndex:j] getName] isEqualToString: o_capability] )
776 [o_children addObject:[[VLCTreeItem alloc] initWithName: o_capability
781 else if( [[o_parent getName] isEqualToString: _NS("Modules")] )
783 /* Now add the modules */
784 o_children = [[NSMutableArray alloc] initWithCapacity:10];
785 for( i_index = 0; i_index < p_list->i_count; i_index++ )
787 p_module = (module_t *)p_list->p_values[i_index].p_object;
789 /* Exclude the main module */
790 if( !strcmp( p_module->psz_object_name, "main" ) )
793 /* Exclude empty plugins */
794 p_item = p_module->p_config;
795 if( !p_item ) continue;
798 if( p_item->i_type & CONFIG_ITEM )
801 while( p_item->i_type != CONFIG_HINT_END && p_item++ );
802 if( p_item->i_type == CONFIG_HINT_END ) continue;
804 /* Check the capability */
805 NSString *o_capability;
806 o_capability = [NSApp localizedString: p_module->psz_capability];
807 if( !p_module->psz_capability || !*p_module->psz_capability )
809 /* Empty capability ? Let's look at the submodules */
810 module_t * p_submodule;
811 for( j = 0; j < p_module->i_children; j++ )
813 p_submodule = (module_t*)p_module->pp_children[ j ];
814 if( p_submodule->psz_capability && *p_submodule->psz_capability )
816 o_capability = [NSApp localizedString: p_submodule->psz_capability];
817 if( [o_capability isEqualToString: [self getName]] )
819 [o_children addObject:[[VLCTreeItem alloc] initWithName:
820 [NSApp localizedString: p_module->psz_object_name ]
821 ID: p_module->i_object_id parent:self]];
826 else if( [o_capability isEqualToString: [self getName]] )
828 [o_children addObject:[[VLCTreeItem alloc] initWithName:
829 [NSApp localizedString: p_module->psz_object_name ]
830 ID: p_module->i_object_id parent:self]];
836 /* all the other stuff are leafs */
837 o_children = IsALeafNode;
848 - (NSString *)getName
853 - (VLCTreeItem *)childAtIndex:(int)i_index {
854 return [[self children] objectAtIndex:i_index];
857 - (int)numberOfChildren {
858 id i_tmp = [self children];
859 return (i_tmp == IsALeafNode) ? (-1) : [i_tmp count];
862 - (BOOL)hasPrefs:(NSString *)o_module_name
864 intf_thread_t *p_intf = [NSApp getIntf];
867 char *psz_module_name;
870 psz_module_name = (char *)[o_module_name UTF8String];
872 /* look for module */
873 p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
875 for( i_index = 0; i_index < p_list->i_count; i_index++ )
877 p_parser = (module_t *)p_list->p_values[i_index].p_object ;
879 if( !strcmp( p_parser->psz_object_name, psz_module_name ) )
881 BOOL b_has_prefs = p_parser->i_config_items != 0;
882 vlc_list_release( p_list );
883 return( b_has_prefs );
887 vlc_list_release( p_list );
895 @implementation VLCFlippedView
904 IMPL_CONTROL_CONFIG(Button);
905 IMPL_CONTROL_CONFIG(PopUpButton);
906 IMPL_CONTROL_CONFIG(ComboBox);
907 IMPL_CONTROL_CONFIG(TextField);
908 IMPL_CONTROL_CONFIG(Slider);