~ubuntu-branches/ubuntu/maverick/vlc/maverick

« back to all changes in this revision

Viewing changes to modules/gui/macosx/prefs.m

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2008-09-17 21:56:14 UTC
  • mfrom: (1.1.17 upstream)
  • Revision ID: james.westby@ubuntu.com-20080917215614-tj0vx8xzd57e52t8
Tags: 0.9.2-1ubuntu1
* New Upstream Release, exception granted by
    - dktrkranz, norsetto, Hobbsee (via irc). LP: #270404

Changes done in ubuntu:

* add libxul-dev to build-depends
* make sure that vlc is build against libxul in configure. This doesn't
  change anything in the package, but makes it more robust if building
  in an 'unclean' chroot or when modifying the package.
* debian/control: make Vcs-* fields point to the motumedia branch
* add libx264-dev and libass-dev to build-depends
  LP: #210354, #199870
* actually enable libass support by passing --enable-libass to configure
* enable libdca: add libdca-dev to build depends and --enable-libdca
* install the x264 plugin.

Changes already in the pkg-multimedia branch in debian:

* don't install usr/share/vlc/mozilla in debian/mozilla-plugin-vlc.install  
* new upstream .desktop file now registers flash video mimetype LP: #261567
* add Xb-Npp-Applications to mozilla-plugin-vlc
* remove duplicate entries in debian/vlc-nox.install

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * prefs.m: MacOS X module for vlc
3
3
 *****************************************************************************
4
4
 * Copyright (C) 2002-2006 the VideoLAN team
5
 
 * $Id: 8833c2d31d5b7c7f341b6be2f3db49b3c3d83c5c $
 
5
 * $Id: 0e25e9af6770c8e113c3b8c067bc8d570b79a3c5 $
6
6
 *
7
7
 * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
8
8
 *          Derk-Jan Hartman <hartman at videolan dot org>
22
22
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23
23
 *****************************************************************************/
24
24
 
25
 
/* VLCPrefs manages the main preferences dialog 
 
25
/* VLCPrefs manages the main preferences dialog
26
26
   the class is related to wxwindows intf, PrefsPanel */
27
27
/* VLCTreeItem should contain:
28
28
   - the children of the treeitem
30
30
   - the documentview with all the prefs widgets in it
31
31
   - a saveChanges action
32
32
   - a revertChanges action
33
 
   - an advanced action (to hide/show advanced options)
34
33
   - a redraw view action
35
34
   - the children action should generate a list of the treeitems children (to be used by VLCPrefs datasource)
36
35
 
46
45
#include <sys/param.h>                                    /* for MAXPATHLEN */
47
46
#include <string.h>
48
47
 
49
 
#include <vlc/vlc.h>
 
48
#ifdef HAVE_CONFIG_H
 
49
# include "config.h"
 
50
#endif
 
51
 
 
52
#include <vlc_common.h>
50
53
#include <vlc_config_cat.h>
51
54
 
52
 
#include "intf.h"
53
 
#include "prefs.h"
54
 
#include "prefs_widgets.h"
55
 
#include "vlc_keys.h"
 
55
#import "intf.h"
 
56
#import "prefs.h"
 
57
#import "simple_prefs.h"
 
58
#import "prefs_widgets.h"
 
59
#import "vlc_keys.h"
 
60
 
 
61
/* /!\ Warning: Unreadable code :/ */
56
62
 
57
63
/*****************************************************************************
58
64
 * VLCPrefs implementation
90
96
- (void)awakeFromNib
91
97
{
92
98
    p_intf = VLCIntf;
93
 
    b_advanced = config_GetInt( p_intf, "advanced" );
94
99
 
95
100
    [self initStrings];
96
 
    [o_advanced_ckb setState: b_advanced];
97
101
    [o_prefs_view setBorderType: NSGrooveBorder];
98
102
    [o_prefs_view setHasVerticalScroller: YES];
99
103
    [o_prefs_view setDrawsBackground: NO];
108
112
 
109
113
- (void)showPrefs
110
114
{
 
115
    [[o_basicFull_matrix cellAtRow:0 column:0] setState: NSOffState];
 
116
    [[o_basicFull_matrix cellAtRow:0 column:1] setState: NSOnState];
 
117
    
111
118
    [o_prefs_window center];
112
119
    [o_prefs_window makeKeyAndOrderFront:self];
113
120
}
118
125
    [o_save_btn setTitle: _NS("Save")];
119
126
    [o_cancel_btn setTitle: _NS("Cancel")];
120
127
    [o_reset_btn setTitle: _NS("Reset All")];
121
 
    [o_advanced_ckb setTitle: _NS("Advanced")];
 
128
    [[o_basicFull_matrix cellAtRow: 0 column: 0] setStringValue: _NS("Basic")];
 
129
    [[o_basicFull_matrix cellAtRow: 0 column: 1] setStringValue: _NS("All")];
122
130
}
123
131
 
124
132
- (IBAction)savePrefs: (id)sender
152
160
        config_ResetAll( p_intf );
153
161
        [[VLCTreeItem rootItem] resetView];
154
162
        [[o_tree itemAtRow:[o_tree selectedRow]]
155
 
            showView:o_prefs_view advancedView:
156
 
            ( [o_advanced_ckb state] == NSOnState ) ? VLC_TRUE : VLC_FALSE];
 
163
            showView:o_prefs_view];
157
164
    }
158
165
}
159
166
 
160
 
- (IBAction)advancedToggle: (id)sender
 
167
- (IBAction)buttonAction: (id)sender
161
168
{
162
 
    b_advanced = !b_advanced;
163
 
    [o_advanced_ckb setState: b_advanced];
164
 
    /* refresh the view of the current treeitem */
165
 
    [[o_tree itemAtRow:[o_tree selectedRow]] showView:o_prefs_view advancedView:
166
 
        ( [o_advanced_ckb state] == NSOnState ) ? VLC_TRUE : VLC_FALSE];
 
169
    [o_prefs_window orderOut: self];
 
170
    [[o_basicFull_matrix cellAtRow:0 column:0] setState: NSOnState];
 
171
    [[o_basicFull_matrix cellAtRow:0 column:1] setState: NSOffState];
 
172
    [[[VLCMain sharedInstance] getSimplePreferences] showSimplePrefs];
167
173
}
168
174
 
169
175
- (void)loadConfigTree
177
183
/* update the document view to the view of the selected tree item */
178
184
- (void)outlineViewSelectionDidChange:(NSNotification *)o_notification
179
185
{
180
 
    [[o_tree itemAtRow:[o_tree selectedRow]] showView: o_prefs_view
181
 
        advancedView:( [o_advanced_ckb state] == NSOnState ) ?
182
 
        VLC_TRUE : VLC_FALSE];
 
186
    [[o_tree itemAtRow:[o_tree selectedRow]] showView: o_prefs_view];
183
187
}
184
188
 
185
189
@end
193
197
 
194
198
- (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item
195
199
{
196
 
    return (item == nil) ? YES : ( ([item numberOfChildren] != -1) && 
 
200
    return (item == nil) ? YES : ( ([item numberOfChildren] != -1) &&
197
201
                                   ([item numberOfChildren] != 0));
198
202
}
199
203
 
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;
273
 
        int             i_index;
274
 
 
275
 
        /* List the modules */
276
 
        p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
277
 
        if( !p_list ) return nil;
278
 
 
 
276
        module_t        *p_main_module;
 
277
        module_config_t *p_items;
 
278
        int             i = 0;
279
279
        if( [[self getName] isEqualToString: @"main"] )
280
280
        {
281
 
            /*
282
 
            * Find the main module
283
 
            */
284
 
            for( i_index = 0; i_index < p_list->i_count; i_index++ )
285
 
            {
286
 
                p_module = (module_t *)p_list->p_values[i_index].p_object;
287
 
                if( !strcmp( p_module->psz_object_name, "main" ) )
288
 
                    break;
289
 
            }
290
 
            if( p_module == NULL )
291
 
            {
292
 
                msg_Err( p_intf,
293
 
                    "could not load the preferences" );
294
 
                return nil;
295
 
            }
296
 
            if( i_index < p_list->i_count )
297
 
            {
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];
304
 
                if( p_item ) do
 
281
            p_main_module = module_GetMainModule( p_intf );
 
282
            assert( p_main_module );
 
283
 
 
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++ )
 
292
            {
 
293
                NSString *o_child_name;
 
294
                NSString *o_child_title;
 
295
                NSString *o_child_help;
 
296
                switch( p_items[i].i_type )
305
297
                {
306
 
                    NSString *o_child_name;
307
 
                    NSString *o_child_title;
308
 
                    NSString *o_child_help;
309
 
                    switch( p_item->i_type )
310
 
                    {
311
298
                    case CONFIG_CATEGORY:
312
 
                                    if( p_item->i_value == -1 ) break;
 
299
                        if( p_items[i].value.i == -1 ) break;
313
300
 
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
324
 
                            ID: p_item->i_value
 
311
                            ID: ((vlc_object_t*)p_main_module)->i_object_id
325
312
                            parent:self
326
313
                            children:[[NSMutableArray alloc]
327
314
                                initWithCapacity:10]
328
 
                            whithCategory: p_item - p_module->p_config]];
 
315
                            whithCategory: p_items[i].value.i]];
329
316
                        break;
330
317
                    case CONFIG_SUBCATEGORY:
331
 
                                    if( p_item->i_value == -1 ) break;
 
318
                        if( p_items[i].value.i == -1 ) break;
332
319
 
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 )
340
327
                        {
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 ) ];
346
333
 
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
352
 
                                ID: p_item->i_value
 
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]];
357
344
                        }
358
 
                        
 
345
 
359
346
                        break;
360
347
                    default:
361
348
                        break;
362
 
                    }
363
 
                } while( p_item->i_type != CONFIG_HINT_END && p_item++ );
 
349
                }
364
350
            }
365
351
 
 
352
            vlc_object_release( (vlc_object_t *)p_main_module );
 
353
 
 
354
            /* List the modules */
 
355
            p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
 
356
            if( !p_list ) return nil;
 
357
 
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++ )
369
361
            {
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;
371
364
 
372
365
                /* Exclude the main module */
373
 
                if( !strcmp( p_module->psz_object_name, "main" ) )
 
366
                if( module_IsMainModule( p_module ) )
374
367
                    continue;
375
368
 
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 )
379
 
                    continue;
380
 
                else
381
 
                    p_item = p_module->p_config;
382
 
 
383
 
                if( !p_item ) continue;
 
371
                p_items = module_GetConfig( p_module, &confsize );
 
372
 
 
373
                unsigned int j;
 
374
 
384
375
                int i_category = -1;
385
376
                int i_subcategory = -1;
386
 
                int i_options = 0;
387
 
                do
 
377
                bool b_item = false;
 
378
 
 
379
                for( j = 0; j < confsize; j++ )
388
380
                {
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;
393
385
 
394
 
                    if( p_item->i_type & CONFIG_ITEM )
395
 
                        i_options ++;
396
 
                    if( i_options > 0 && i_category >= 0 && i_subcategory >= 0 )
 
386
                    if( p_items[j].i_type & CONFIG_ITEM )
 
387
                        b_item = true;
 
388
            
 
389
                    if( b_item && i_category >= 0 && i_subcategory >= 0 )
397
390
                        break;
398
 
                } while( p_item->i_type != CONFIG_HINT_END && p_item++ );
399
 
                if( !i_options ) continue;
 
391
                }
 
392
    
 
393
                if( !b_item ) continue;
400
394
 
401
395
                /* Find the right category item */
402
396
 
403
397
                long cookie;
404
 
                vlc_bool_t b_found = VLC_FALSE;
405
 
                unsigned int i;
 
398
                bool b_found = false;
 
399
 
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++)
408
402
                {
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 )
411
405
                    {
412
 
                        b_found = VLC_TRUE;
 
406
                        b_found = true;
413
407
                        break;
414
408
                    }
415
409
                }
416
410
                if( !b_found ) continue;
417
411
 
418
412
                /* Find subcategory item */
419
 
                b_found = VLC_FALSE;
 
413
                b_found = false;
420
414
                cookie = -1;
421
 
                for (i = 0 ; i < [p_category_item->o_children count] ; i++)
 
415
                for (j = 0 ; j < [p_category_item->o_children count] ; j++)
422
416
                {
423
417
                    p_subcategory_item = [p_category_item->o_children
424
 
                                            objectAtIndex: i];
425
 
                    if( p_subcategory_item->i_object_id == i_subcategory )
 
418
                                            objectAtIndex: j];
 
419
                    if( p_subcategory_item->i_object_category == i_subcategory )
426
420
                    {
427
 
                        b_found = VLC_TRUE;
 
421
                        b_found = true;
428
422
                        break;
429
423
                    }
430
424
                }
433
427
 
434
428
                [p_subcategory_item->o_children addObject:[[VLCTreeItem alloc]
435
429
                    initWithName:[[VLCMain sharedInstance]
436
 
                        localizedString: p_module->psz_shortname ?
437
 
                        p_module->psz_shortname : p_module->psz_object_name ]
 
430
                        localizedString: module_GetName( p_module, false ) ]
438
431
                    withTitle:[[VLCMain sharedInstance]
439
 
                        localizedString: p_module->psz_longname ?
440
 
                        p_module->psz_longname : p_module->psz_object_name ]
 
432
                        localizedString:  module_GetLongName( p_module ) ]
441
433
                    withHelp: @""
442
 
                    ID: p_module->i_object_id
 
434
                    ID: ((vlc_object_t*)p_module)->i_object_id
443
435
                    parent:p_subcategory_item
444
436
                    children:IsALeafNode
445
437
                    whithCategory: -1]];
446
438
                }
 
439
            vlc_list_release( p_list );
447
440
        }
448
 
        vlc_list_release( p_list );
449
441
    }
450
442
    return o_children;
451
443
}
497
489
    {
498
490
        p_parser = (module_t *)p_list->p_values[i_index].p_object ;
499
491
 
500
 
        if( !strcmp( p_parser->psz_object_name, psz_module_name ) )
 
492
        if( !strcmp( module_GetObjName( p_parser ), psz_module_name ) )
501
493
        {
502
 
            BOOL b_has_prefs = p_parser->i_config_items != 0;
 
494
            unsigned int confsize;
 
495
            module_GetConfig( p_parser, &confsize );
 
496
            BOOL b_has_prefs = confsize != 0;
503
497
            vlc_list_release( p_list );
504
498
            return( b_has_prefs );
505
499
        }
511
505
}
512
506
 
513
507
- (NSView *)showView:(NSScrollView *)o_prefs_view
514
 
    advancedView:(vlc_bool_t) b_advanced
515
508
{
516
509
    NSRect          s_vrc;
517
510
    NSView          *o_view;
518
511
 
519
512
    [[VLCPrefs sharedInstance] setTitle: [self getTitle]];
520
 
    /* NSLog( [self getHelp] ); */ 
 
513
    /* NSLog( [self getHelp] ); */
521
514
    s_vrc = [[o_prefs_view contentView] bounds]; s_vrc.size.height -= 4;
522
515
    o_view = [[VLCFlippedView alloc] initWithFrame: s_vrc];
523
516
    [o_view setAutoresizingMask: NSViewWidthSizable | NSViewMinYMargin |
529
522
    {
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;
534
529
 
535
530
        o_subviews = [[NSMutableArray alloc] initWithCapacity:10];
536
531
        /* Get a pointer to the module */
537
532
        if( i_object_category == -1 )
538
533
        {
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 )
541
 
            {
542
 
                /* 0OOoo something went really bad */
543
 
                return nil;
544
 
            }
545
 
            p_item = p_parser->p_config;
546
 
 
547
 
            p_item = p_parser->p_config + 1;
548
 
 
549
 
            do
550
 
            {
551
 
                if( !p_item )
552
 
                {
553
 
                    msg_Err( p_intf, "invalid preference item found" );
554
 
                    break;
555
 
                }
556
 
                switch(p_item->i_type)
557
 
                {
558
 
                case CONFIG_SUBCATEGORY:
559
 
                    break;
560
 
                case CONFIG_CATEGORY:
561
 
                    break;
562
 
                case CONFIG_SECTION:
563
 
                    break;
564
 
                case CONFIG_HINT_END:
565
 
                    break;
566
 
                case CONFIG_HINT_USAGE:
567
 
                    break;
568
 
                default:
569
 
                {
570
 
                    VLCConfigControl *o_control = nil;
571
 
                    o_control = [VLCConfigControl newControl:p_item
572
 
                                                  withView:o_view];
573
 
                    if( o_control != nil )
 
534
            p_module = (module_t *) vlc_object_get( i_object_id );
 
535
            assert( p_module );
 
536
 
 
537
            p_items = module_GetConfig( p_module, &confsize );
 
538
 
 
539
            for( unsigned int i = 0; i < confsize; i++ )
 
540
            {
 
541
                switch( p_items[i].i_type )
 
542
                {
 
543
                    case CONFIG_SUBCATEGORY:
 
544
                    case CONFIG_CATEGORY:
 
545
                    case CONFIG_SECTION:
 
546
                    case CONFIG_HINT_USAGE:
 
547
                        break;
 
548
                    default:
574
549
                    {
575
 
                        [o_control setAutoresizingMask: NSViewMaxYMargin |
576
 
                            NSViewWidthSizable];
577
 
                        [o_subviews addObject: o_control];
 
550
                        VLCConfigControl *o_control = nil;
 
551
                        o_control = [VLCConfigControl newControl:&p_items[i]
 
552
                                                      withView:o_view];
 
553
                        if( o_control )
 
554
                        {
 
555
                            [o_control setAutoresizingMask: NSViewMaxYMargin |
 
556
                                NSViewWidthSizable];
 
557
                            [o_subviews addObject: o_control];
 
558
                        }
578
559
                    }
579
 
                }
580
560
                    break;
581
561
                }
582
 
            } while( p_item++->i_type != CONFIG_HINT_END );
583
 
 
584
 
            vlc_object_release( p_parser );
 
562
            }
 
563
            vlc_object_release( (vlc_object_t*)p_module );
585
564
        }
586
565
        else
587
566
        {
588
 
            int i_index;
589
 
            p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
590
 
            if( !p_list ) return o_view;
591
 
 
592
 
            /*
593
 
            * Find the main module
594
 
            */
595
 
            for( i_index = 0; i_index < p_list->i_count; i_index++ )
596
 
            {
597
 
                p_parser = (module_t *)p_list->p_values[i_index].p_object;
598
 
                if( !strcmp( p_parser->psz_object_name, "main" ) )
599
 
                    break;
600
 
            }
601
 
            if( p_parser == NULL )
602
 
            {
603
 
                msg_Err( p_intf, "could not load preferences" );
604
 
                return o_view;
605
 
            }
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 ) ) )
614
 
                p_item++;
615
 
 
616
 
            do
617
 
            {
618
 
                p_item++;
619
 
                if( !p_item )
 
567
            p_main_module = module_GetMainModule( p_intf );
 
568
            assert( p_main_module );
 
569
            module_config_t *p_items;
 
570
 
 
571
            unsigned int i, confsize;
 
572
            p_items = module_GetConfig( p_main_module, &confsize );
 
573
 
 
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;
 
578
            bool done = false;
 
579
            for( i = 0; i < confsize; i++ )
 
580
            {
 
581
                if( !p_items[i].i_type )
620
582
                {
621
583
                    msg_Err( p_intf, "invalid preference item found" );
622
584
                    break;
623
585
                }
624
 
                switch( p_item->i_type )
625
 
                {
626
 
                case CONFIG_SUBCATEGORY:
627
 
                    break;
628
 
                case CONFIG_CATEGORY:
629
 
                    break;
630
 
                case CONFIG_SECTION:
631
 
                    break;
632
 
                case CONFIG_HINT_END:
633
 
                    break;
634
 
                case CONFIG_HINT_USAGE:
635
 
                    break;
636
 
                default:
637
 
                {
638
 
                    VLCConfigControl *o_control = nil;
639
 
                    o_control = [VLCConfigControl newControl:p_item
640
 
                                                  withView:o_view];
641
 
                    if( o_control != nil )
 
586
 
 
587
                switch( p_items[i].i_type )
 
588
                {
 
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)
 
593
                            done = true;
 
594
                        break;
 
595
                    case CONFIG_SUBCATEGORY:
 
596
                        if(!in_right_category && p_items[i].value.i == i_object_category)
 
597
                        {
 
598
                            in_right_category = true;
 
599
                            in_subcategory = true;
 
600
                        }
 
601
                        else if(in_right_category && in_subcategory)
 
602
                            done = true;
 
603
                        break;
 
604
                    case CONFIG_SECTION:
 
605
                    case CONFIG_HINT_USAGE:
 
606
                        break;
 
607
                    default:
642
608
                    {
643
 
                        [o_control setAutoresizingMask: NSViewMaxYMargin |
644
 
                                                        NSViewWidthSizable];
645
 
                        [o_subviews addObject: o_control];
 
609
                        if(!in_right_category) break;
 
610
 
 
611
                        VLCConfigControl *o_control = nil;
 
612
                        o_control = [VLCConfigControl newControl:&p_items[i]
 
613
                                                      withView:o_view];
 
614
                        if( o_control != nil )
 
615
                        {
 
616
                            [o_control setAutoresizingMask: NSViewMaxYMargin |
 
617
                                                            NSViewWidthSizable];
 
618
                            [o_subviews addObject: o_control];
 
619
                        }
 
620
                        break;
646
621
                    }
647
 
                    break;
648
 
                }
649
 
                }
650
 
            } while ( ( p_item->i_type != CONFIG_HINT_END ) &&
651
 
                      ( p_item->i_type != CONFIG_SUBCATEGORY ) );
652
 
 
653
 
            vlc_list_release( p_list );
 
622
                }
 
623
                if( done ) break;
 
624
            }
 
625
            vlc_object_release( (vlc_object_t*)p_main_module );
654
626
        }
655
627
    }
656
628
 
659
631
        int i_lastItem = 0;
660
632
        int i_yPos = -2;
661
633
        int i_max_label = 0;
662
 
        int i_show_advanced = 0;
663
634
 
664
635
        NSEnumerator *enumerator = [o_subviews objectEnumerator];
665
636
        VLCConfigControl *o_widget;
666
637
        NSRect o_frame;
667
 
        
 
638
 
668
639
        while( ( o_widget = [enumerator nextObject] ) )
669
 
            if( ( [o_widget isAdvanced] ) && (! b_advanced) )
670
 
                continue;
671
 
            else if( i_max_label < [o_widget getLabelSize] )
 
640
            if( i_max_label < [o_widget getLabelSize] )
672
641
                i_max_label = [o_widget getLabelSize];
673
642
 
674
643
        enumerator = [o_subviews objectEnumerator];
675
644
        while( ( o_widget = [enumerator nextObject] ) )
676
645
        {
677
646
            int i_widget;
678
 
            if( ( [o_widget isAdvanced] ) && (! b_advanced) )
679
 
            {
680
 
                i_show_advanced++;
681
 
                continue;
682
 
            }
683
647
 
684
648
            i_widget = [o_widget getViewType];
685
649
            i_yPos += [VLCConfigControl calcVerticalMargin:i_widget
694
658
            i_lastItem = i_widget;
695
659
            [o_view addSubview:o_widget];
696
660
         }
697
 
        if( i_show_advanced != 0 )
698
 
        {
699
 
            /* We add the advanced notice... */
700
 
            NSRect s_rc = [o_view frame];
701
 
            NSTextField *o_label;
702
 
            s_rc.size.height = 17;
703
 
            s_rc.origin.x = LEFTMARGIN;
704
 
            s_rc.origin.y = i_yPos += [VLCConfigControl
705
 
                                        calcVerticalMargin:CONFIG_ITEM_STRING
706
 
                                        lastItem:i_lastItem];
707
 
            o_label = [[[NSTextField alloc] initWithFrame: s_rc] retain];
708
 
            [o_label setDrawsBackground: NO];
709
 
            [o_label setBordered: NO];
710
 
            [o_label setEditable: NO];
711
 
            [o_label setSelectable: NO];
712
 
            [o_label setStringValue: _NS("Some options are hidden. " \
713
 
                                "Check \"Advanced\" to display them.")];
714
 
            [o_label setFont:[NSFont systemFontOfSize:10]];
715
 
            [o_label sizeToFit];
716
 
            [o_view addSubview:o_label];
717
 
            i_yPos += [o_label frame].size.height;
718
 
        }
 
661
 
719
662
        o_frame = [o_view frame];
720
663
        o_frame.size.height = i_yPos;
721
664
        [o_view setFrame:o_frame];