[vlc-devel] [PATCH v2 preview] standardise the hidden option category "hack"

Lyndon Brown jnqnfe at gmail.com
Sat Sep 26 01:08:05 CEST 2020


From: Lyndon Brown <jnqnfe at gmail.com>
Date: Sat, 23 Mar 2019 04:02:07 +0000
Subject: standardise the hidden options hack

(add common defines for specifying hidden category/subcategory)

diff --git a/include/vlc_plugin.h b/include/vlc_plugin.h
index 2ddc6cb0b1..90150a4f07 100644
--- a/include/vlc_plugin.h
+++ b/include/vlc_plugin.h
@@ -134,6 +134,12 @@ enum vlc_module_properties
 
 #define CONFIG_ITEM(x) (((x) & ~0xF) != 0)
 
+/* Hidden categories and subcategories */
+/* Any options under this will be hidden in the GUI preferences, but will be
+   listed in cmdline help output. */
+#define CAT_HIDDEN -1
+#define SUBCAT_HIDDEN -1
+
 /* Categories and subcategories */
 #define CAT_INTERFACE 1
 #define SUBCAT_INTERFACE_GENERAL 101
diff --git a/modules/gui/macosx/preferences/prefs.m b/modules/gui/macosx/preferences/prefs.m
index b8afb7cd9d..7a946a2d48 100644
--- a/modules/gui/macosx/preferences/prefs.m
+++ b/modules/gui/macosx/preferences/prefs.m
@@ -508,7 +508,7 @@
         for (unsigned int j = 0; j < confsize; j++) {
             int configType = p_configs[j].i_type;
             if (configType == CONFIG_CATEGORY) {
-                if( p_configs[j].value.i == -1 ) {
+                if( p_configs[j].value.i == CAT_HIDDEN ) {
                     categoryItem = nil;
                     continue;
                 }
@@ -521,7 +521,7 @@
             }
             else if (configType == CONFIG_SUBCATEGORY) {
                 lastsubcat = (int)p_configs[j].value.i;
-                if( lastsubcat == -1 ) {
+                if( lastsubcat == SUBCAT_HIDDEN ) {
                     subCategoryItem = nil;
                     continue;
                 }
diff --git a/modules/gui/qt/dialogs/preferences/complete_preferences.cpp b/modules/gui/qt/dialogs/preferences/complete_preferences.cpp
index dc02c1a6f1..863cf431f0 100644
--- a/modules/gui/qt/dialogs/preferences/complete_preferences.cpp
+++ b/modules/gui/qt/dialogs/preferences/complete_preferences.cpp
@@ -97,7 +97,7 @@ PrefsTree::PrefsTree( intf_thread_t *_p_intf, QWidget *_parent,
         {
         /* This is a category */
         case CONFIG_CATEGORY:
-            if( p_item->value.i == -1 ) break;
+            if( p_item->value.i == CAT_HIDDEN ) break;
 
             /* PrefsItemData Init */
             data = new PrefsItemData( this );
@@ -133,7 +133,7 @@ PrefsTree::PrefsTree( intf_thread_t *_p_intf, QWidget *_parent,
 
         /* This is a subcategory */
         case CONFIG_SUBCATEGORY:
-            if( p_item->value.i == -1 ) break;
+            if( p_item->value.i == SUBCAT_HIDDEN ) break;
 
             /* Special cases: move the main subcategories to the parent cat*/
             if( data &&
@@ -189,7 +189,7 @@ PrefsTree::PrefsTree( intf_thread_t *_p_intf, QWidget *_parent,
         if( module_is_main( p_module) ) continue;
 
         unsigned  confsize;
-        int i_subcategory = 0, i_category = 0;
+        int i_subcategory = SUBCAT_HIDDEN, i_category = CAT_HIDDEN;
 
         bool b_options = false;
         module_config_t *const p_config = module_config_get (p_module, &confsize);
@@ -207,13 +207,13 @@ PrefsTree::PrefsTree( intf_thread_t *_p_intf, QWidget *_parent,
             if( CONFIG_ITEM(p_item->i_type) )
                 b_options = true;
 
-            if( b_options && i_category && i_subcategory )
+            if( b_options && i_category != CAT_HIDDEN && i_subcategory != SUBCAT_HIDDEN )
                 break;
         }
         module_config_free (p_config);
 
         /* Dummy item, please proceed */
-        if( !b_options || i_category == 0 || i_subcategory == 0 ) continue;
+        if( !b_options || i_category == CAT_HIDDEN || i_subcategory == SUBCAT_HIDDEN ) continue;
 
 
         // Locate the category item;
diff --git a/modules/stream_out/bridge.c b/modules/stream_out/bridge.c
index 27e748bba1..cea9a966e5 100644
--- a/modules/stream_out/bridge.c
+++ b/modules/stream_out/bridge.c
@@ -94,9 +94,11 @@ vlc_module_begin ()
     set_section( N_("Bridge out"), NULL )
     set_capability( "sout output", 50 )
     add_shortcut( "bridge-out" )
-    /* Only usable with VLM. No category so not in gui preferences
-    set_category( CAT_SOUT )
-    set_subcategory( SUBCAT_SOUT_STREAM )*/
+    /* Only usable with VLM. No category so not in gui preferences */
+    set_category( CAT_HIDDEN )
+    set_subcategory( SUBCAT_HIDDEN )
+    //set_category( CAT_SOUT )
+    //set_subcategory( SUBCAT_SOUT_STREAM )
     add_integer( SOUT_CFG_PREFIX_OUT "id", 0, ID_TEXT, ID_LONGTEXT,
                  false )
     add_string( SOUT_CFG_PREFIX_OUT "in-name", "default",
@@ -107,8 +109,11 @@ vlc_module_begin ()
     set_section( N_("Bridge in"), NULL )
     set_capability( "sout filter", 50 )
     add_shortcut( "bridge-in" )
-    /*set_category( CAT_SOUT )
-    set_subcategory( SUBCAT_SOUT_STREAM )*/
+    /* Only usable with VLM. No category so not in gui preferences */
+    set_category( CAT_HIDDEN )
+    set_subcategory( SUBCAT_HIDDEN )
+    //set_category( CAT_SOUT )
+    //set_subcategory( SUBCAT_SOUT_STREAM )
     add_integer( SOUT_CFG_PREFIX_IN "delay", 0, DELAY_TEXT,
                  DELAY_LONGTEXT, false )
     add_integer( SOUT_CFG_PREFIX_IN "id-offset", 8192, ID_OFFSET_TEXT,
diff --git a/src/libvlc-module.c b/src/libvlc-module.c
index 4b346d022a..42811151a7 100644
--- a/src/libvlc-module.c
+++ b/src/libvlc-module.c
@@ -2216,8 +2216,8 @@ vlc_module_begin ()
     add_string( "services-discovery", "", SD_TEXT, SD_LONGTEXT, true )
         change_short('S')
 
-    /* HACK so these don't get displayed in the GUI */
-    set_subcategory( -1 )
+    /* Not displayed in GUI, listed in help output though */
+    set_subcategory( SUBCAT_HIDDEN )
     set_section(N_("Bookmarks"), NULL)
     add_string( "bookmark1", NULL,
              BOOKMARK1_TEXT, BOOKMARK_LONGTEXT, false )
@@ -2818,9 +2818,9 @@ vlc_module_begin ()
             SUBTEXT_SCALEDOWN_KEY_TEXT, SUBTEXT_SCALE_KEY_LONGTEXT)
 
 /* Miscellaneous */
-    /* HACK so these don't get displayed in the GUI */
-    set_category( -1 )
-    set_subcategory( -1 )
+    /* Not displayed in GUI, listed in help output though */
+    set_category( CAT_HIDDEN )
+    set_subcategory( SUBCAT_HIDDEN )
     add_category_hint(N_("Miscellaneous"), NULL)
 
 #define HELP_TEXT \



More information about the vlc-devel mailing list