From 6076c4d4a6990ebcd5affa80e72ee91cb3da0169 Mon Sep 17 00:00:00 2001 From: Jehan Date: Fri, 21 Feb 2025 22:48:02 +0100 Subject: [PATCH] Issue #12825: generate a help ID for any operation with "gimp:menu-path" key. This is an alternative implementation for issue #12825, replacing commit 424ef17bac, after further discussion with Jacob. Basically we don't need a new key "gimp:help-id" anymore. Instead, for every action we add through a "gimp:menu-path" key AND when its name is prefixed with "gegl:", we generate a help ID from the operation name. The first few operations in such case already have a help page for them, with corresponding help ID, in gimp-help repository. In the future, we may expand this help ID generation rule to any core operation (i.e. any operation prefixed with "gegl:") but for the time being, we only do for the ones with a menu path, otherwise we'd have too many missing pages. Also fix again gimp_gegl_procedure_get_help_id() so that it searches a help ID within all existing operations in the "filters" group, as I realized that this was still broken in some cases. --- app/actions/filters-actions.c | 10 +++++++--- app/actions/gimpgeglprocedure.c | 34 +++++++++++++++++++++++++++++---- 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/app/actions/filters-actions.c b/app/actions/filters-actions.c index 31578b0f4b..2f4def28fa 100644 --- a/app/actions/filters-actions.c +++ b/app/actions/filters-actions.c @@ -804,7 +804,6 @@ filters_actions_setup (GimpActionGroup *group) g_free (action_name); action_name = g_strdup_printf ("filters-%s-%d", formatted_op_name, i++); } - g_free (formatted_op_name); title = gegl_operation_class_get_key (op_class, "title"); op_name = op_class->name; @@ -824,8 +823,12 @@ filters_actions_setup (GimpActionGroup *group) entry.value = op_class->name; entry.help_id = GIMP_HELP_TOOL_GEGL; - if (gegl_operation_class_get_key (op_class, "gimp:help-id")) - entry.help_id = gegl_operation_class_get_key (op_class, "gimp:help-id"); + if (gegl_operation_class_get_key (op_class, "gimp:menu-path") && + g_str_has_prefix (op_class->name, "gegl:")) + /* We automatically create an help ID from the operation name + * for all core GEGL operations with a menu path key. + */ + entry.help_id = formatted_op_name; gimp_action_group_add_string_actions (group, "filters-action", &entry, 1, @@ -859,6 +862,7 @@ filters_actions_setup (GimpActionGroup *group) g_free (label); g_free (action_name); + g_free (formatted_op_name); } g_object_set_data_full (G_OBJECT (group), diff --git a/app/actions/gimpgeglprocedure.c b/app/actions/gimpgeglprocedure.c index c27338aa5d..a52ff7f353 100644 --- a/app/actions/gimpgeglprocedure.c +++ b/app/actions/gimpgeglprocedure.c @@ -48,7 +48,11 @@ #include "core/gimpsettings.h" #include "core/gimptoolinfo.h" +#include "widgets/gimpaction.h" +#include "widgets/gimpactiongroup.h" #include "widgets/gimphelp-ids.h" +#include "widgets/gimpstringaction.h" +#include "widgets/gimpuimanager.h" #include "tools/gimpoperationtool.h" #include "tools/tool_manager.h" @@ -161,13 +165,35 @@ static const gchar * gimp_gegl_procedure_get_help_id (GimpProcedure *procedure) { GimpGeglProcedure *proc = GIMP_GEGL_PROCEDURE (procedure); + GList *managers; + GimpActionGroup *group; + const gchar *help_id = NULL; + + managers = gimp_ui_managers_from_name (""); + group = gimp_ui_manager_get_action_group (managers->data, "filters"); if (procedure->help_id) - return procedure->help_id; - else if (gegl_operation_get_key (proc->operation, "gimp:help-id")) - return gegl_operation_get_key (proc->operation, "gimp:help-id"); + { + return procedure->help_id; + } + else if (group) + { + GList *actions; + GList *iter; - return GIMP_HELP_TOOL_GEGL; + actions = gimp_action_group_list_actions (group); + for (iter = actions; iter; iter = iter->next) + if (GIMP_IS_STRING_ACTION (iter->data) && + g_strcmp0 (GIMP_STRING_ACTION (iter->data)->value, proc->operation) == 0) + { + help_id = gimp_action_get_help_id (iter->data); + break; + } + + g_list_free (actions); + } + + return help_id == NULL ? GIMP_HELP_TOOL_GEGL : help_id; } static const gchar *