269
273
intf_thread_t *p_intf = VLCIntf;
270
274
vlc_list_t *p_list;
271
275
module_t *p_module = NULL;
272
module_config_t *p_item;
275
/* List the modules */
276
p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
277
if( !p_list ) return nil;
276
module_t *p_main_module;
277
module_config_t *p_items;
279
279
if( [[self getName] isEqualToString: @"main"] )
282
* Find the main module
284
for( i_index = 0; i_index < p_list->i_count; i_index++ )
286
p_module = (module_t *)p_list->p_values[i_index].p_object;
287
if( !strcmp( p_module->psz_object_name, "main" ) )
290
if( p_module == NULL )
293
"could not load the preferences" );
296
if( i_index < p_list->i_count )
298
/* We found the main module */
299
/* Enumerate config categories and store a reference so we can
300
* generate their config panel them when it is asked by the user. */
301
VLCTreeItem *p_last_category = NULL;
302
p_item = p_module->p_config;
303
o_children = [[NSMutableArray alloc] initWithCapacity:10];
281
p_main_module = module_GetMainModule( p_intf );
282
assert( p_main_module );
284
/* We found the main module */
285
/* Enumerate config categories and store a reference so we can
286
* generate their config panel them when it is asked by the user. */
287
VLCTreeItem *p_last_category = NULL;
288
unsigned int i_confsize;
289
p_items = module_GetConfig( p_main_module, &i_confsize );
290
o_children = [[NSMutableArray alloc] initWithCapacity:10];
291
for( int i = 0; i < i_confsize; i++ )
293
NSString *o_child_name;
294
NSString *o_child_title;
295
NSString *o_child_help;
296
switch( p_items[i].i_type )
306
NSString *o_child_name;
307
NSString *o_child_title;
308
NSString *o_child_help;
309
switch( p_item->i_type )
311
298
case CONFIG_CATEGORY:
312
if( p_item->i_value == -1 ) break;
299
if( p_items[i].value.i == -1 ) break;
314
301
o_child_name = [[VLCMain sharedInstance]
315
localizedString: config_CategoryNameGet( p_item->i_value )];
302
localizedString: config_CategoryNameGet( p_items[i].value.i )];
316
303
o_child_title = o_child_name;
317
304
o_child_help = [[VLCMain sharedInstance]
318
localizedString: config_CategoryHelpGet( p_item->i_value )];
305
localizedString: config_CategoryHelpGet( p_items[i].value.i )];
319
306
p_last_category = [VLCTreeItem alloc];
320
307
[o_children addObject:[p_last_category
321
308
initWithName: o_child_name
322
309
withTitle: o_child_title
323
310
withHelp: o_child_help
311
ID: ((vlc_object_t*)p_main_module)->i_object_id
326
313
children:[[NSMutableArray alloc]
327
314
initWithCapacity:10]
328
whithCategory: p_item - p_module->p_config]];
315
whithCategory: p_items[i].value.i]];
330
317
case CONFIG_SUBCATEGORY:
331
if( p_item->i_value == -1 ) break;
318
if( p_items[i].value.i == -1 ) break;
333
if( p_item->i_value != SUBCAT_PLAYLIST_GENERAL &&
334
p_item->i_value != SUBCAT_VIDEO_GENERAL &&
335
p_item->i_value != SUBCAT_INPUT_GENERAL &&
336
p_item->i_value != SUBCAT_INTERFACE_GENERAL &&
337
p_item->i_value != SUBCAT_SOUT_GENERAL &&
338
p_item->i_value != SUBCAT_ADVANCED_MISC &&
339
p_item->i_value != SUBCAT_AUDIO_GENERAL )
320
if( p_items[i].value.i != SUBCAT_PLAYLIST_GENERAL &&
321
p_items[i].value.i != SUBCAT_VIDEO_GENERAL &&
322
p_items[i].value.i != SUBCAT_INPUT_GENERAL &&
323
p_items[i].value.i != SUBCAT_INTERFACE_GENERAL &&
324
p_items[i].value.i != SUBCAT_SOUT_GENERAL &&
325
p_items[i].value.i != SUBCAT_ADVANCED_MISC &&
326
p_items[i].value.i != SUBCAT_AUDIO_GENERAL )
341
328
o_child_name = [[VLCMain sharedInstance]
342
localizedString: config_CategoryNameGet( p_item->i_value ) ];
329
localizedString: config_CategoryNameGet( p_items[i].value.i ) ];
343
330
o_child_title = o_child_name;
344
331
o_child_help = [[VLCMain sharedInstance]
345
localizedString: config_CategoryHelpGet( p_item->i_value ) ];
332
localizedString: config_CategoryHelpGet( p_items[i].value.i ) ];
347
334
[p_last_category->o_children
348
335
addObject:[[VLCTreeItem alloc]
349
336
initWithName: o_child_name
350
337
withTitle: o_child_title
351
338
withHelp: o_child_help
339
ID: ((vlc_object_t*)p_main_module)->i_object_id
353
340
parent:p_last_category
354
341
children:[[NSMutableArray alloc]
355
342
initWithCapacity:10]
356
whithCategory: p_item - p_module->p_config]];
343
whithCategory: p_items[i].value.i]];
363
} while( p_item->i_type != CONFIG_HINT_END && p_item++ );
352
vlc_object_release( (vlc_object_t *)p_main_module );
354
/* List the modules */
355
p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
356
if( !p_list ) return nil;
366
358
/* Build a tree of the plugins */
367
359
/* Add the capabilities */
368
for( i_index = 0; i_index < p_list->i_count; i_index++ )
360
for( i = 0; i < p_list->i_count; i++ )
370
p_module = (module_t *)p_list->p_values[i_index].p_object;
362
unsigned int confsize;
363
p_module = (module_t *)p_list->p_values[i].p_object;
372
365
/* Exclude the main module */
373
if( !strcmp( p_module->psz_object_name, "main" ) )
366
if( module_IsMainModule( p_module ) )
376
369
/* Exclude empty plugins (submodules don't have config */
377
370
/* options, they are stored in the parent module) */
378
if( p_module->b_submodule )
381
p_item = p_module->p_config;
383
if( !p_item ) continue;
371
p_items = module_GetConfig( p_module, &confsize );
384
375
int i_category = -1;
385
376
int i_subcategory = -1;
379
for( j = 0; j < confsize; j++ )
389
if( p_item->i_type == CONFIG_CATEGORY )
390
i_category = p_item->i_value;
391
else if( p_item->i_type == CONFIG_SUBCATEGORY )
392
i_subcategory = p_item->i_value;
381
if( p_items[j].i_type == CONFIG_CATEGORY )
382
i_category = p_items[j].value.i;
383
else if( p_items[j].i_type == CONFIG_SUBCATEGORY )
384
i_subcategory = p_items[j].value.i;
394
if( p_item->i_type & CONFIG_ITEM )
396
if( i_options > 0 && i_category >= 0 && i_subcategory >= 0 )
386
if( p_items[j].i_type & CONFIG_ITEM )
389
if( b_item && i_category >= 0 && i_subcategory >= 0 )
398
} while( p_item->i_type != CONFIG_HINT_END && p_item++ );
399
if( !i_options ) continue;
393
if( !b_item ) continue;
401
395
/* Find the right category item */
404
vlc_bool_t b_found = VLC_FALSE;
398
bool b_found = false;
406
400
VLCTreeItem* p_category_item, * p_subcategory_item;
407
for (i = 0 ; i < [o_children count] ; i++)
401
for (j = 0 ; j < [o_children count] ; j++)
409
p_category_item = [o_children objectAtIndex: i];
410
if( p_category_item->i_object_id == i_category )
403
p_category_item = [o_children objectAtIndex: j];
404
if( p_category_item->i_object_category == i_category )
416
410
if( !b_found ) continue;
418
412
/* Find subcategory item */
421
for (i = 0 ; i < [p_category_item->o_children count] ; i++)
415
for (j = 0 ; j < [p_category_item->o_children count] ; j++)
423
417
p_subcategory_item = [p_category_item->o_children
425
if( p_subcategory_item->i_object_id == i_subcategory )
419
if( p_subcategory_item->i_object_category == i_subcategory )
530
523
intf_thread_t *p_intf = VLCIntf;
531
524
vlc_list_t *p_list;
532
module_t *p_parser = NULL;
533
module_config_t *p_item;
525
module_t *p_module = NULL;
526
module_t *p_main_module;
527
module_config_t *p_items;
528
unsigned int confsize;
535
530
o_subviews = [[NSMutableArray alloc] initWithCapacity:10];
536
531
/* Get a pointer to the module */
537
532
if( i_object_category == -1 )
539
p_parser = (module_t *) vlc_object_get( p_intf, i_object_id );
540
if( !p_parser || p_parser->i_object_type != VLC_OBJECT_MODULE )
542
/* 0OOoo something went really bad */
545
p_item = p_parser->p_config;
547
p_item = p_parser->p_config + 1;
553
msg_Err( p_intf, "invalid preference item found" );
556
switch(p_item->i_type)
558
case CONFIG_SUBCATEGORY:
560
case CONFIG_CATEGORY:
564
case CONFIG_HINT_END:
566
case CONFIG_HINT_USAGE:
570
VLCConfigControl *o_control = nil;
571
o_control = [VLCConfigControl newControl:p_item
573
if( o_control != nil )
534
p_module = (module_t *) vlc_object_get( i_object_id );
537
p_items = module_GetConfig( p_module, &confsize );
539
for( unsigned int i = 0; i < confsize; i++ )
541
switch( p_items[i].i_type )
543
case CONFIG_SUBCATEGORY:
544
case CONFIG_CATEGORY:
546
case CONFIG_HINT_USAGE:
575
[o_control setAutoresizingMask: NSViewMaxYMargin |
577
[o_subviews addObject: o_control];
550
VLCConfigControl *o_control = nil;
551
o_control = [VLCConfigControl newControl:&p_items[i]
555
[o_control setAutoresizingMask: NSViewMaxYMargin |
557
[o_subviews addObject: o_control];
582
} while( p_item++->i_type != CONFIG_HINT_END );
584
vlc_object_release( p_parser );
563
vlc_object_release( (vlc_object_t*)p_module );
589
p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
590
if( !p_list ) return o_view;
593
* Find the main module
595
for( i_index = 0; i_index < p_list->i_count; i_index++ )
597
p_parser = (module_t *)p_list->p_values[i_index].p_object;
598
if( !strcmp( p_parser->psz_object_name, "main" ) )
601
if( p_parser == NULL )
603
msg_Err( p_intf, "could not load preferences" );
606
p_item = (p_parser->p_config + i_object_category);
607
if( ( p_item->i_type == CONFIG_CATEGORY ) &&
608
( ( p_item->i_value == CAT_PLAYLIST ) ||
609
( p_item->i_value == CAT_AUDIO ) ||
610
( p_item->i_value == CAT_VIDEO ) ||
611
( p_item->i_value == CAT_INTERFACE ) ||
612
( p_item->i_value == CAT_INPUT ) ||
613
( p_item->i_value == CAT_SOUT ) ) )
567
p_main_module = module_GetMainModule( p_intf );
568
assert( p_main_module );
569
module_config_t *p_items;
571
unsigned int i, confsize;
572
p_items = module_GetConfig( p_main_module, &confsize );
574
/* We need to first, find the right (sub)category,
575
* and then abort when we find a new (sub)category. Part of the Ugliness. */
576
bool in_right_category = false;
577
bool in_subcategory = false;
579
for( i = 0; i < confsize; i++ )
581
if( !p_items[i].i_type )
621
583
msg_Err( p_intf, "invalid preference item found" );
624
switch( p_item->i_type )
626
case CONFIG_SUBCATEGORY:
628
case CONFIG_CATEGORY:
632
case CONFIG_HINT_END:
634
case CONFIG_HINT_USAGE:
638
VLCConfigControl *o_control = nil;
639
o_control = [VLCConfigControl newControl:p_item
641
if( o_control != nil )
587
switch( p_items[i].i_type )
589
case CONFIG_CATEGORY:
590
if(!in_right_category && p_items[i].value.i == i_object_category)
591
in_right_category = true;
592
else if(in_right_category)
595
case CONFIG_SUBCATEGORY:
596
if(!in_right_category && p_items[i].value.i == i_object_category)
598
in_right_category = true;
599
in_subcategory = true;
601
else if(in_right_category && in_subcategory)
605
case CONFIG_HINT_USAGE:
643
[o_control setAutoresizingMask: NSViewMaxYMargin |
645
[o_subviews addObject: o_control];
609
if(!in_right_category) break;
611
VLCConfigControl *o_control = nil;
612
o_control = [VLCConfigControl newControl:&p_items[i]
614
if( o_control != nil )
616
[o_control setAutoresizingMask: NSViewMaxYMargin |
618
[o_subviews addObject: o_control];
650
} while ( ( p_item->i_type != CONFIG_HINT_END ) &&
651
( p_item->i_type != CONFIG_SUBCATEGORY ) );
653
vlc_list_release( p_list );
625
vlc_object_release( (vlc_object_t*)p_main_module );