]> git.sesse.net Git - vlc/blobdiff - modules/gui/macosx/prefs.m
macosx: Assert on cases that should never happen.
[vlc] / modules / gui / macosx / prefs.m
index ae2533656510183278c9e06552943f270ecb2505..0e25e9af6770c8e113c3b8c067bc8d570b79a3c5 100644 (file)
@@ -30,7 +30,6 @@
    - the documentview with all the prefs widgets in it
    - a saveChanges action
    - a revertChanges action
-   - an advanced action (to hide/show advanced options)
    - a redraw view action
    - the children action should generate a list of the treeitems children (to be used by VLCPrefs datasource)
 
@@ -97,10 +96,8 @@ static VLCPrefs *_o_sharedMainInstance = nil;
 - (void)awakeFromNib
 {
     p_intf = VLCIntf;
-    b_advanced = config_GetInt( p_intf, "advanced" );
 
     [self initStrings];
-    [o_advanced_ckb setState: b_advanced];
     [o_prefs_view setBorderType: NSGrooveBorder];
     [o_prefs_view setHasVerticalScroller: YES];
     [o_prefs_view setDrawsBackground: NO];
@@ -128,7 +125,6 @@ static VLCPrefs *_o_sharedMainInstance = nil;
     [o_save_btn setTitle: _NS("Save")];
     [o_cancel_btn setTitle: _NS("Cancel")];
     [o_reset_btn setTitle: _NS("Reset All")];
-    [o_advanced_ckb setTitle: _NS("Advanced")];
     [[o_basicFull_matrix cellAtRow: 0 column: 0] setStringValue: _NS("Basic")];
     [[o_basicFull_matrix cellAtRow: 0 column: 1] setStringValue: _NS("All")];
 }
@@ -164,20 +160,10 @@ static VLCPrefs *_o_sharedMainInstance = nil;
         config_ResetAll( p_intf );
         [[VLCTreeItem rootItem] resetView];
         [[o_tree itemAtRow:[o_tree selectedRow]]
-            showView:o_prefs_view advancedView:
-            ( [o_advanced_ckb state] == NSOnState ) ? true : false];
+            showView:o_prefs_view];
     }
 }
 
-- (IBAction)advancedToggle: (id)sender
-{
-    b_advanced = !b_advanced;
-    [o_advanced_ckb setState: b_advanced];
-    /* refresh the view of the current treeitem */
-    [[o_tree itemAtRow:[o_tree selectedRow]] showView:o_prefs_view advancedView:
-        ( [o_advanced_ckb state] == NSOnState ) ? true : false];
-}
-
 - (IBAction)buttonAction: (id)sender
 {
     [o_prefs_window orderOut: self];
@@ -197,9 +183,7 @@ static VLCPrefs *_o_sharedMainInstance = nil;
 /* update the document view to the view of the selected tree item */
 - (void)outlineViewSelectionDidChange:(NSNotification *)o_notification
 {
-    [[o_tree itemAtRow:[o_tree selectedRow]] showView: o_prefs_view
-        advancedView:( [o_advanced_ckb state] == NSOnState ) ?
-        true : false];
+    [[o_tree itemAtRow:[o_tree selectedRow]] showView: o_prefs_view];
 }
 
 @end
@@ -324,11 +308,11 @@ static VLCTreeItem *o_root_item = nil;
                             initWithName: o_child_name
                             withTitle: o_child_title
                             withHelp: o_child_help
-                            ID: p_items[i].value.i
+                            ID: ((vlc_object_t*)p_main_module)->i_object_id
                             parent:self
                             children:[[NSMutableArray alloc]
                                 initWithCapacity:10]
-                            whithCategory: p_items[i].i_type]];
+                            whithCategory: p_items[i].value.i]];
                         break;
                     case CONFIG_SUBCATEGORY:
                         if( p_items[i].value.i == -1 ) break;
@@ -352,11 +336,11 @@ static VLCTreeItem *o_root_item = nil;
                                 initWithName: o_child_name
                                 withTitle: o_child_title
                                 withHelp: o_child_help
-                                ID: p_items[i].value.i
+                                ID: ((vlc_object_t*)p_main_module)->i_object_id
                                 parent:p_last_category
                                 children:[[NSMutableArray alloc]
                                     initWithCapacity:10]
-                                whithCategory: p_items[i].i_type]];
+                                whithCategory: p_items[i].value.i]];
                         }
 
                         break;
@@ -384,9 +368,6 @@ static VLCTreeItem *o_root_item = nil;
 
                 /* Exclude empty plugins (submodules don't have config */
                 /* options, they are stored in the parent module) */
-// Does not work
-//                if( modules_IsSubModule( p_module ) )
-//                    continue;
                 p_items = module_GetConfig( p_module, &confsize );
 
                 unsigned int j;
@@ -415,12 +396,12 @@ static VLCTreeItem *o_root_item = nil;
 
                 long cookie;
                 bool b_found = false;
-                unsigned int i;
+
                 VLCTreeItem* p_category_item, * p_subcategory_item;
-                for (i = 0 ; i < [o_children count] ; i++)
+                for (j = 0 ; j < [o_children count] ; j++)
                 {
-                    p_category_item = [o_children objectAtIndex: i];
-                    if( p_category_item->i_object_id == i_category )
+                    p_category_item = [o_children objectAtIndex: j];
+                    if( p_category_item->i_object_category == i_category )
                     {
                         b_found = true;
                         break;
@@ -431,11 +412,11 @@ static VLCTreeItem *o_root_item = nil;
                 /* Find subcategory item */
                 b_found = false;
                 cookie = -1;
-                for (i = 0 ; i < [p_category_item->o_children count] ; i++)
+                for (j = 0 ; j < [p_category_item->o_children count] ; j++)
                 {
                     p_subcategory_item = [p_category_item->o_children
-                                            objectAtIndex: i];
-                    if( p_subcategory_item->i_object_id == i_subcategory )
+                                            objectAtIndex: j];
+                    if( p_subcategory_item->i_object_category == i_subcategory )
                     {
                         b_found = true;
                         break;
@@ -455,8 +436,8 @@ static VLCTreeItem *o_root_item = nil;
                     children:IsALeafNode
                     whithCategory: -1]];
                 }
+            vlc_list_release( p_list );
         }
-        vlc_list_release( p_list );
     }
     return o_children;
 }
@@ -524,7 +505,6 @@ static VLCTreeItem *o_root_item = nil;
 }
 
 - (NSView *)showView:(NSScrollView *)o_prefs_view
-    advancedView:(bool) b_advanced
 {
     NSRect          s_vrc;
     NSView          *o_view;
@@ -591,6 +571,11 @@ static VLCTreeItem *o_root_item = nil;
             unsigned int i, confsize;
             p_items = module_GetConfig( p_main_module, &confsize );
 
+            /* We need to first, find the right (sub)category,
+             * and then abort when we find a new (sub)category. Part of the Ugliness. */
+            bool in_right_category = false;
+            bool in_subcategory = false;
+            bool done = false;
             for( i = 0; i < confsize; i++ )
             {
                 if( !p_items[i].i_type )
@@ -601,13 +586,28 @@ static VLCTreeItem *o_root_item = nil;
 
                 switch( p_items[i].i_type )
                 {
-                    case CONFIG_SUBCATEGORY:
                     case CONFIG_CATEGORY:
+                        if(!in_right_category && p_items[i].value.i == i_object_category)
+                            in_right_category = true;
+                        else if(in_right_category)
+                            done = true;
+                        break;
+                    case CONFIG_SUBCATEGORY:
+                        if(!in_right_category && p_items[i].value.i == i_object_category)
+                        {
+                            in_right_category = true;
+                            in_subcategory = true;
+                        }
+                        else if(in_right_category && in_subcategory)
+                            done = true;
+                        break;
                     case CONFIG_SECTION:
                     case CONFIG_HINT_USAGE:
                         break;
                     default:
                     {
+                        if(!in_right_category) break;
+
                         VLCConfigControl *o_control = nil;
                         o_control = [VLCConfigControl newControl:&p_items[i]
                                                       withView:o_view];
@@ -620,6 +620,7 @@ static VLCTreeItem *o_root_item = nil;
                         break;
                     }
                 }
+                if( done ) break;
             }
             vlc_object_release( (vlc_object_t*)p_main_module );
         }
@@ -630,27 +631,19 @@ static VLCTreeItem *o_root_item = nil;
         int i_lastItem = 0;
         int i_yPos = -2;
         int i_max_label = 0;
-        int i_show_advanced = 0;
 
         NSEnumerator *enumerator = [o_subviews objectEnumerator];
         VLCConfigControl *o_widget;
         NSRect o_frame;
  
         while( ( o_widget = [enumerator nextObject] ) )
-            if( ( [o_widget isAdvanced] ) && (! b_advanced) )
-                continue;
-            else if( i_max_label < [o_widget getLabelSize] )
+            if( i_max_label < [o_widget getLabelSize] )
                 i_max_label = [o_widget getLabelSize];
 
         enumerator = [o_subviews objectEnumerator];
         while( ( o_widget = [enumerator nextObject] ) )
         {
             int i_widget;
-            if( ( [o_widget isAdvanced] ) && (! b_advanced) )
-            {
-                i_show_advanced++;
-                continue;
-            }
 
             i_widget = [o_widget getViewType];
             i_yPos += [VLCConfigControl calcVerticalMargin:i_widget
@@ -665,28 +658,7 @@ static VLCTreeItem *o_root_item = nil;
             i_lastItem = i_widget;
             [o_view addSubview:o_widget];
          }
-        if( i_show_advanced != 0 )
-        {
-            /* We add the advanced notice... */
-            NSRect s_rc = [o_view frame];
-            NSTextField *o_label;
-            s_rc.size.height = 17;
-            s_rc.origin.x = LEFTMARGIN;
-            s_rc.origin.y = i_yPos += [VLCConfigControl
-                                        calcVerticalMargin:CONFIG_ITEM_STRING
-                                        lastItem:i_lastItem];
-            o_label = [[[NSTextField alloc] initWithFrame: s_rc] retain];
-            [o_label setDrawsBackground: NO];
-            [o_label setBordered: NO];
-            [o_label setEditable: NO];
-            [o_label setSelectable: NO];
-            [o_label setStringValue: _NS("Some options are hidden. " \
-                                "Check \"Advanced\" to display them.")];
-            [o_label setFont:[NSFont systemFontOfSize:10]];
-            [o_label sizeToFit];
-            [o_view addSubview:o_label];
-            i_yPos += [o_label frame].size.height;
-        }
+
         o_frame = [o_view frame];
         o_frame.size.height = i_yPos;
         [o_view setFrame:o_frame];