app: add --show-debug-menu command-line option

The debug menu is currently not included in stable versions.

Include the menu unconditionally, but hide it, and its associated
actions, by default in stable versions.  Allow enabling the menu
using a new --show-debug-menu command-line option, in the same vein
as --show-playground.
This commit is contained in:
Ell 2018-03-29 05:20:20 -04:00
parent c3efb1b0de
commit 53c145c0be
11 changed files with 28 additions and 30 deletions

View File

@ -32,8 +32,6 @@
#include "debug-commands.h"
#ifdef ENABLE_DEBUG_MENU
static const GimpActionEntry debug_actions[] =
{
{ "debug-menu", NULL, "_Debug" },
@ -78,16 +76,22 @@ static const GimpActionEntry debug_actions[] =
NULL }
};
#endif
void
debug_actions_setup (GimpActionGroup *group)
{
#ifdef ENABLE_DEBUG_MENU
gint i;
gimp_action_group_add_actions (group, NULL,
debug_actions,
G_N_ELEMENTS (debug_actions));
#endif
#define SET_VISIBLE(action,condition) \
gimp_action_group_set_action_visible (group, action, (condition) != 0)
for (i = 0; i < G_N_ELEMENTS (debug_actions); i++)
SET_VISIBLE (debug_actions[i].name, group->gimp->show_debug_menu);
#undef SET_VISIBLE
}
void

View File

@ -49,8 +49,6 @@
#include "debug-commands.h"
#ifdef ENABLE_DEBUG_MENU
/* local function prototypes */
static gboolean debug_benchmark_projection (GimpDisplay *display);
@ -425,6 +423,3 @@ debug_accel_find_func (GtkAccelKey *key,
{
return (GClosure *) data == closure;
}
#endif /* ENABLE_DEBUG_MENU */

View File

@ -19,13 +19,6 @@
#define __DEBUG_COMMANDS_H__
#ifdef GIMP_UNSTABLE
#define ENABLE_DEBUG_MENU 1
#endif
#ifdef ENABLE_DEBUG_MENU
void debug_mem_profile_cmd_callback (GtkAction *action,
gpointer data);
void debug_benchmark_projection_cmd_callback (GtkAction *action,
@ -43,7 +36,4 @@ void debug_dump_attached_data_cmd_callback (GtkAction *action,
void debug_benchmark_projection_cmd_callback (GtkAction *action,
gpointer data);
#endif /* ENABLE_DEBUG_MENU */
#endif /* __DEBUG_COMMANDS_H__ */

View File

@ -176,6 +176,7 @@ app_run (const gchar *full_prog_name,
gboolean console_messages,
gboolean use_debug_handler,
gboolean show_playground,
gboolean show_debug_menu,
GimpStackTraceMode stack_trace_mode,
GimpPDBCompatMode pdb_compat_mode,
const gchar *backtrace_file)
@ -244,6 +245,7 @@ app_run (const gchar *full_prog_name,
use_cpu_accel,
console_messages,
show_playground,
show_debug_menu,
stack_trace_mode,
pdb_compat_mode);

View File

@ -48,6 +48,7 @@ void app_run (const gchar *full_prog_name,
gboolean console_messages,
gboolean use_debug_handler,
gboolean show_playground,
gboolean show_debug_menu,
GimpStackTraceMode stack_trace_mode,
GimpPDBCompatMode pdb_compat_mode,
const gchar *backtrace_file);

View File

@ -576,6 +576,7 @@ gimp_new (const gchar *name,
gboolean use_cpu_accel,
gboolean console_messages,
gboolean show_playground,
gboolean show_debug_menu,
GimpStackTraceMode stack_trace_mode,
GimpPDBCompatMode pdb_compat_mode)
{
@ -599,6 +600,7 @@ gimp_new (const gchar *name,
gimp->use_cpu_accel = use_cpu_accel ? TRUE : FALSE;
gimp->console_messages = console_messages ? TRUE : FALSE;
gimp->show_playground = show_playground ? TRUE : FALSE;
gimp->show_debug_menu = show_debug_menu ? TRUE : FALSE;
gimp->stack_trace_mode = stack_trace_mode;
gimp->pdb_compat_mode = pdb_compat_mode;

View File

@ -53,6 +53,7 @@ struct _Gimp
GimpMessageHandlerType message_handler;
gboolean console_messages;
gboolean show_playground;
gboolean show_debug_menu;
GimpStackTraceMode stack_trace_mode;
GimpPDBCompatMode pdb_compat_mode;
@ -161,6 +162,7 @@ Gimp * gimp_new (const gchar *name,
gboolean use_cpu_accel,
gboolean console_messages,
gboolean show_playground,
gboolean show_debug_menu,
GimpStackTraceMode stack_trace_mode,
GimpPDBCompatMode pdb_compat_mode);
void gimp_set_show_gui (Gimp *gimp,

View File

@ -139,10 +139,12 @@ static gboolean use_debug_handler = FALSE;
#ifdef GIMP_UNSTABLE
static gboolean show_playground = TRUE;
static gboolean show_debug_menu = TRUE;
static GimpStackTraceMode stack_trace_mode = GIMP_STACK_TRACE_QUERY;
static GimpPDBCompatMode pdb_compat_mode = GIMP_PDB_COMPAT_WARN;
#else
static gboolean show_playground = FALSE;
static gboolean show_debug_menu = FALSE;
static GimpStackTraceMode stack_trace_mode = GIMP_STACK_TRACE_NEVER;
static GimpPDBCompatMode pdb_compat_mode = GIMP_PDB_COMPAT_ON;
#endif
@ -282,6 +284,11 @@ static const GOptionEntry main_entries[] =
G_OPTION_ARG_NONE, &show_playground,
N_("Show a preferences page with experimental features"), NULL
},
{
"show-debug-menu", 0, G_OPTION_FLAG_HIDDEN,
G_OPTION_ARG_NONE, &show_debug_menu,
N_("Show an image submenu with debug actions"), NULL
},
{
G_OPTION_REMAINING, 0, 0,
G_OPTION_ARG_FILENAME_ARRAY, &filenames,
@ -532,6 +539,7 @@ main (int argc,
console_messages,
use_debug_handler,
show_playground,
show_debug_menu,
stack_trace_mode,
pdb_compat_mode,
backtrace_file);

View File

@ -65,7 +65,7 @@ gimp_init_for_testing (void)
gegl_init (NULL, NULL);
gimp = gimp_new ("Unit Tested GIMP", NULL, NULL, FALSE, TRUE, TRUE, TRUE,
FALSE, FALSE, TRUE, FALSE,
FALSE, FALSE, TRUE, FALSE, FALSE,
GIMP_STACK_TRACE_QUERY, GIMP_PDB_COMPAT_OFF);
gimp_load_config (gimp, NULL, NULL);
@ -119,7 +119,7 @@ gimp_init_for_gui_testing_internal (gboolean show_gui,
/* from app_run() */
gimp = gimp_new ("Unit Tested GIMP", NULL, NULL, FALSE, TRUE, TRUE, !show_gui,
FALSE, FALSE, TRUE, FALSE,
FALSE, FALSE, TRUE, FALSE, FALSE,
GIMP_STACK_TRACE_QUERY, GIMP_PDB_COMPAT_OFF);
gimp_set_show_gui (gimp, show_gui);

View File

@ -23,7 +23,7 @@
<menuitem action="dialogs-document-history" />
</menu>
<!-- The debug-menu is automatically excluded for stable releases -->
<!-- The debug-menu is hidden by default for stable releases -->
<menu action="debug-menu" name="Debug">
<menuitem action="debug-mem-profile" />
<menuitem action="debug-benchmark-projection" />

View File

@ -38,12 +38,6 @@
<xsl:apply-templates />
</xsl:template>
<xsl:template match="menu[@action='debug-menu']">
<xsl:if test="$unstable-menus='yes'">
<xsl:call-template name="identity" />
</xsl:if>
</xsl:template>
<!-- need to strip the XInclude namespace declaration from the ui element -->
<xsl:template match="ui">
<ui>