[vlc-commits] [Git][videolan/vlc][master] config: get cat names from their general subcats

Hugo Beauzée-Luyssen (@chouquette) gitlab at videolan.org
Thu Jan 13 07:31:05 UTC 2022



Hugo Beauzée-Luyssen pushed to branch master at VideoLAN / VLC


Commits:
bc9e4432 by Lyndon Brown at 2022-01-13T07:06:05+00:00
config: get cat names from their general subcats

except in one pointless case, category names are identical to the names of
their 'general' subcats. if we fix that one case, as done here, we can
remove the name attributes from the category table and instead fetch the
name labels from the subcat table via general-subcat lookup, as done here..

i had to move the cat-name helper down to avoid a forward declaration. i
moved the cat-help helper down along with it for neatness.

the one case that had to be fixed for this to go ahead was the advanced
category. the tree node had the label "Advanced" while the panel title had
"Advanced settings". this inconsistency is unnecessary, especially since
the help text displayed underneath the panel title says "Advanced settings".

- - - - -


1 changed file:

- include/vlc_config_cat.h


Changes:

=====================================
include/vlc_config_cat.h
=====================================
@@ -187,8 +187,6 @@
 #define AADVANCED_TITLE N_( "Advanced" )
 #define AADVANCED_HELP N_( "Advanced settings. Use with care...")
 
-#define MISC_TITLE N_( "Advanced settings" )
-
 #define ANETWORK_TITLE N_( "Network" )
 #define ANETWORK_HELP N_( "Advanced network settings." )
 
@@ -196,7 +194,6 @@ struct config_category_t
 {
     int         id;
     int         general_subcat;
-    const char *name;
     const char *help;
 };
 
@@ -210,13 +207,13 @@ struct config_subcategory_t
 
 static const struct config_category_t categories_array[] =
 {
-    { CAT_INTERFACE,  SUBCAT_INTERFACE_GENERAL,  INTF_TITLE,       INTF_HELP      },
-    { CAT_AUDIO,      SUBCAT_AUDIO_GENERAL,      AUDIO_TITLE,      AUDIO_HELP     },
-    { CAT_VIDEO,      SUBCAT_VIDEO_GENERAL,      VIDEO_TITLE,      VIDEO_HELP     },
-    { CAT_INPUT,      SUBCAT_INPUT_GENERAL,      INPUT_TITLE,      INPUT_HELP     },
-    { CAT_SOUT,       SUBCAT_SOUT_GENERAL,       SOUT_TITLE,       SOUT_HELP      },
-    { CAT_PLAYLIST,   SUBCAT_PLAYLIST_GENERAL,   PLAYLIST_TITLE,   PLAYLIST_HELP  },
-    { CAT_ADVANCED,   SUBCAT_ADVANCED_MISC,      AADVANCED_TITLE,  AADVANCED_HELP },
+    { CAT_INTERFACE,  SUBCAT_INTERFACE_GENERAL,  INTF_HELP      },
+    { CAT_AUDIO,      SUBCAT_AUDIO_GENERAL,      AUDIO_HELP     },
+    { CAT_VIDEO,      SUBCAT_VIDEO_GENERAL,      VIDEO_HELP     },
+    { CAT_INPUT,      SUBCAT_INPUT_GENERAL,      INPUT_HELP     },
+    { CAT_SOUT,       SUBCAT_SOUT_GENERAL,       SOUT_HELP      },
+    { CAT_PLAYLIST,   SUBCAT_PLAYLIST_GENERAL,   PLAYLIST_HELP  },
+    { CAT_ADVANCED,   SUBCAT_ADVANCED_MISC,      AADVANCED_HELP },
 };
 
 static const struct config_subcategory_t subcategories_array[] =
@@ -258,7 +255,7 @@ static const struct config_subcategory_t subcategories_array[] =
     { SUBCAT_PLAYLIST_EXPORT,      CAT_PLAYLIST,   PEXPORT_TITLE,        PEXPORT_HELP       },
     { SUBCAT_PLAYLIST_SD,          CAT_PLAYLIST,   SD_TITLE,             SD_HELP            },
 
-    { SUBCAT_ADVANCED_MISC,        CAT_ADVANCED,   MISC_TITLE,           AADVANCED_HELP     },
+    { SUBCAT_ADVANCED_MISC,        CAT_ADVANCED,   AADVANCED_TITLE,      AADVANCED_HELP     },
     { SUBCAT_ADVANCED_NETWORK,     CAT_ADVANCED,   ANETWORK_TITLE,       ANETWORK_HELP      },
 
     { SUBCAT_HIDDEN,               CAT_HIDDEN,     NULL,                 NULL               },
@@ -318,22 +315,6 @@ static inline int vlc_config_cat_GetGeneralSubcat( int cat )
     return (i != -1) ? categories_array[i].general_subcat : SUBCAT_UNKNOWN;
 }
 
-/** Get the name for a category. */
-VLC_USED
-static inline const char *vlc_config_cat_GetName( int cat )
-{
-    int i = vlc_config_cat_IndexOf( cat );
-    return (i != -1) ? vlc_gettext(categories_array[i].name) : NULL;
-}
-
-/** Get the help text for a category. */
-VLC_USED
-static inline const char *vlc_config_cat_GetHelp( int cat )
-{
-    int i = vlc_config_cat_IndexOf( cat );
-    return (i != -1) ? vlc_gettext(categories_array[i].help) : NULL;
-}
-
 /** Get the name for a subcategory. */
 VLC_USED
 static inline const char *vlc_config_subcat_GetName( int subcat )
@@ -350,6 +331,22 @@ static inline const char *vlc_config_subcat_GetHelp( int subcat )
     return (i != -1) ? vlc_gettext(subcategories_array[i].help) : NULL;
 }
 
+/** Get the name for a category. */
+VLC_USED
+static inline const char *vlc_config_cat_GetName( int cat )
+{
+    int subcat = vlc_config_cat_GetGeneralSubcat( cat );
+    return vlc_config_subcat_GetName( subcat );
+}
+
+/** Get the help text for a category. */
+VLC_USED
+static inline const char *vlc_config_cat_GetHelp( int cat )
+{
+    int i = vlc_config_cat_IndexOf( cat );
+    return (i != -1) ? vlc_gettext(categories_array[i].help) : NULL;
+}
+
 /** Get the parent category for the given subcategory. */
 VLC_USED
 static inline int vlc_config_cat_FromSubcat( int subcat )



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/bc9e44320b5c953dfed92b047b2494b5c1373067

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/bc9e44320b5c953dfed92b047b2494b5c1373067
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list