[vlc-commits] macosx: advanced prefs: add support for config sections

David Fuhrmann git at videolan.org
Mon Feb 18 19:27:44 CET 2013


vlc | branch: master | David Fuhrmann <david.fuhrmann at googlemail.com> | Mon Feb 18 19:12:33 2013 +0100| [d496ba57cd4749cd5842e04921732b51d67705dc] | committer: David Fuhrmann

macosx: advanced prefs: add support for config sections

close #7971

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d496ba57cd4749cd5842e04921732b51d67705dc
---

 modules/gui/macosx/prefs.m         |    4 ++--
 modules/gui/macosx/prefs_widgets.h |    9 ++++++++
 modules/gui/macosx/prefs_widgets.m |   44 ++++++++++++++++++++++++++++++++++++
 3 files changed, 55 insertions(+), 2 deletions(-)

diff --git a/modules/gui/macosx/prefs.m b/modules/gui/macosx/prefs.m
index 2174551..e2ef537 100644
--- a/modules/gui/macosx/prefs.m
+++ b/modules/gui/macosx/prefs.m
@@ -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];
 
diff --git a/modules/gui/macosx/prefs_widgets.h b/modules/gui/macosx/prefs_widgets.h
index 6397f81..d3e00db 100644
--- a/modules/gui/macosx/prefs_widgets.h
+++ b/modules/gui/macosx/prefs_widgets.h
@@ -208,6 +208,15 @@ static NSMenu   *o_keys_menu = nil;
 
 @end
 
+ at interface SectionControl : VLCConfigControl
+{
+}
+
+- (id) initWithItem: (module_config_t *)_p_item
+           withView: (NSView *)o_parent_view;
+
+ at end
+
 //#undef CONFIG_ITEM_LIST_STRING
 //#undef CONFIG_ITEM_RANGED_INTEGER
 
diff --git a/modules/gui/macosx/prefs_widgets.m b/modules/gui/macosx/prefs_widgets.m
index 7820f11..af296f1 100644
--- a/modules/gui/macosx/prefs_widgets.m
+++ b/modules/gui/macosx/prefs_widgets.m
@@ -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
+
+ at 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;
+}
+
+ at end
+



More information about the vlc-commits mailing list