[vlc-commits] [Git][videolan/vlc][master] 2 commits: core: Add config_GetLabel convenience function

Felix Paul Kühne (@fkuehne) gitlab at videolan.org
Sun Feb 9 07:17:15 UTC 2025



Felix Paul Kühne pushed to branch master at VideoLAN / VLC


Commits:
058e0a3a by Claudio Cambra at 2025-02-09T06:06:04+00:00
core: Add config_GetLabel convenience function

We have a static function that implements this in a similar way in the
macosx UI but it makes more sense to move it here so that other UIs can
make use of this too

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
70eb7c70 by Claudio Cambra at 2025-02-09T06:06:04+00:00
macosx: Make use of config_GetLabel from core

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -


2 changed files:

- include/vlc_configuration.h
- modules/gui/macosx/preferences/VLCSimplePrefsController.m


Changes:

=====================================
include/vlc_configuration.h
=====================================
@@ -251,6 +251,26 @@ VLC_API void config_ResetAll(void);
  */
 VLC_API module_config_t *config_FindConfig(const char *name) VLC_USED;
 
+/**
+ * Gets the config label string for a configuration item, acquired by name.
+ * A valid configuration item name is required.
+ *
+ * \param name Configuration item name
+ */
+static inline const char *config_GetLabel(const char *const psz_name)
+{
+    module_config_t *const p_config = config_FindConfig(psz_name);
+
+    /* sanity checks */
+    if (p_config == NULL)
+        return NULL;
+    if (p_config->psz_longtext)
+        return p_config->psz_longtext;
+    if (p_config->psz_text)
+        return p_config->psz_text;
+    return NULL;
+}
+
 /**
  * System directory identifiers
  */


=====================================
modules/gui/macosx/preferences/VLCSimplePrefsController.m
=====================================
@@ -475,28 +475,6 @@ create_toolbar_item(NSString *itemIdent, NSString *name, NSString *desc, NSStrin
     [self.window setTitle: _NS("Preferences")];
 }
 
-/* TODO: move this part to core */
-#define config_GetLabel(a,b) __config_GetLabel(VLC_OBJECT(a),b)
-static inline const char * __config_GetLabel(vlc_object_t *p_this, const char *psz_name)
-{
-    module_config_t *p_config = config_FindConfig(psz_name);
-
-    /* sanity checks */
-    if (!p_config) {
-        msg_Err(p_this, "option %s does not exist", psz_name);
-        return NULL;
-    }
-
-    if (p_config->psz_longtext)
-        return p_config->psz_longtext;
-    else if (p_config->psz_text)
-        return p_config->psz_text;
-    else
-        msg_Warn(p_this, "option %s does not include any help", psz_name);
-
-    return NULL;
-}
-
 #pragma mark -
 #pragma mark Setup controls
 
@@ -579,14 +557,14 @@ static inline const char * __config_GetLabel(vlc_object_t *p_this, const char *p
 - (void)setupButton: (NSButton *)object forBoolValue: (const char *)name
 {
     [object setState: config_GetInt(name)];
-    [object setToolTip: NSTR(config_GetLabel(p_intf, name))];
+    [object setToolTip: NSTR(config_GetLabel(name))];
 }
 
 - (void)setupField:(NSTextField *)object forOption:(const char *)psz_option
 {
     char *psz_tmp = config_GetPsz(psz_option);
     [object setStringValue: toNSStr(psz_tmp)];
-    [object setToolTip: NSTR(config_GetLabel(p_intf, psz_option))];
+    [object setToolTip: NSTR(config_GetLabel(psz_option))];
     free(psz_tmp);
 }
 
@@ -816,7 +794,7 @@ static inline const char * __config_GetLabel(vlc_object_t *p_this, const char *p
     i = config_GetInt("freetype-opacity") * 100.0 / 255.0 + 0.5;
     [_osd_opacityTextField setIntValue: i];
     [_osd_opacitySlider setIntValue: i];
-    [_osd_opacitySlider setToolTip: NSTR(config_GetLabel(p_intf, "freetype-opacity"))];
+    [_osd_opacitySlider setToolTip: NSTR(config_GetLabel("freetype-opacity"))];
     [_osd_opacityTextField setToolTip: [_osd_opacitySlider toolTip]];
     [self setupButton:_osd_forceboldCheckbox forBoolValue: "freetype-bold"];
     [self setupButton:_osd_outline_colorPopup forIntList: "freetype-outline-color"];



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/d0100b92ac9997fece08052b2abb90e4f519ae3a...70eb7c70ec2678a6f84fef89c7914ad4999191e0

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/d0100b92ac9997fece08052b2abb90e4f519ae3a...70eb7c70ec2678a6f84fef89c7914ad4999191e0
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list