]> git.sesse.net Git - vlc/commitdiff
macosx: advanced prefs: add support for config sections
authorDavid Fuhrmann <david.fuhrmann@googlemail.com>
Mon, 18 Feb 2013 18:12:33 +0000 (19:12 +0100)
committerDavid Fuhrmann <david.fuhrmann@googlemail.com>
Mon, 18 Feb 2013 18:27:28 +0000 (19:27 +0100)
close #7971

modules/gui/macosx/prefs.m
modules/gui/macosx/prefs_widgets.h
modules/gui/macosx/prefs_widgets.m

index 2174551ff0b4cdc95cf21c5179a1845118991d6c..e2ef53718245e4d575603ca3a1a6575417146b96 100644 (file)
@@ -385,13 +385,13 @@ static VLCPrefs *_o_sharedMainInstance = nil;
                 }
             }
 
-            if (module_is_main(p_module) && CONFIG_ITEM(configType)) {
+            if (module_is_main(p_module) && (CONFIG_ITEM(configType) || configType == CONFIG_SECTION)) {
                 if (categoryItem && [self isSubCategoryGeneral:lastsubcat])
                     [[categoryItem options] addObject:[[VLCTreeLeafItem alloc] initWithConfigItem:&p_configs[j]]];
                 else if (subCategoryItem)
                     [[subCategoryItem options] addObject:[[VLCTreeLeafItem alloc] initWithConfigItem:&p_configs[j]]];
             }
-            else if (!module_is_main(p_module) && CONFIG_ITEM(configType)) {
+            else if (!module_is_main(p_module) && (CONFIG_ITEM(configType) || configType == CONFIG_SECTION)) {
                 if (![[subCategoryItem children] containsObject: pluginItem])
                     [[subCategoryItem children] addObject:pluginItem];
 
index 6397f81d2f6e3360b80b300e2d4f6d502761f6f3..d3e00db9fd4c6d04bf3ebf6b8f46668d8f01d13e 100644 (file)
@@ -208,6 +208,15 @@ static NSMenu   *o_keys_menu = nil;
 
 @end
 
+@interface SectionControl : VLCConfigControl
+{
+}
+
+- (id) initWithItem: (module_config_t *)_p_item
+           withView: (NSView *)o_parent_view;
+
+@end
+
 //#undef CONFIG_ITEM_LIST_STRING
 //#undef CONFIG_ITEM_RANGED_INTEGER
 
index 7820f11b32f8cbde0d1fc8f01149302abfd84648..af296f15a44a19b77641c40cb882e8197889a00d 100644 (file)
@@ -838,6 +838,9 @@ o_textfield = [[[NSSecureTextField alloc] initWithFrame: s_rc] retain];     \
     case CONFIG_ITEM_MODULE_LIST_CAT:
         p_control = [[ModuleListConfigControl alloc] initWithItem: _p_item withView: o_parent_view];
         break;
+    case CONFIG_SECTION:
+        p_control = [[SectionControl alloc] initWithItem: _p_item withView: o_parent_view];
+        break;
     default:
         break;
     }
@@ -2315,3 +2318,44 @@ o_textfield = [[[NSSecureTextField alloc] initWithFrame: s_rc] retain];     \
         withObject: anObject];
 }
 @end
+
+@implementation SectionControl
+
+- (id) initWithItem: (module_config_t *)_p_item
+           withView: (NSView *)o_parent_view
+{
+    NSRect mainFrame = [o_parent_view frame];
+    NSString *o_labelString, *o_tooltip;
+    mainFrame.size.height = 17;
+    mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
+    mainFrame.origin.x = LEFTMARGIN;
+    mainFrame.origin.y = 0;
+
+    if ([super initWithFrame: mainFrame item: _p_item] != nil) {
+        
+        /* add the label */
+        if (p_item->psz_text)
+            o_labelString = _NS((char *)p_item->psz_text);
+        else
+            o_labelString = @"";
+
+        NSDictionary *boldAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
+                        [NSFont boldSystemFontOfSize:[NSFont systemFontSize]],
+                        NSFontAttributeName,
+                        nil];
+        NSAttributedString *o_bold_string = [[NSAttributedString alloc] initWithString: o_labelString attributes: boldAttributes];
+
+        ADD_LABEL(o_label, mainFrame, 1, 0, @"", @"")
+        [o_label setAttributedStringValue: o_bold_string];
+        [o_label sizeToFit];
+
+        [o_bold_string release];
+        
+        [o_label setAutoresizingMask:NSViewNotSizable];
+        [self addSubview: o_label];
+    }
+    return self;
+}
+
+@end
+