app: Make block-listing of GIMP operations optional

In an upcoming commit a new user of gimp_gegl_get_op_classes will expect
a list of all operations supported/allowed in GIMP and not just the ones
that are not exposed in the GUI.
This commit is contained in:
Ondřej Míchal 2025-06-12 14:48:06 +03:00 committed by Jehan
parent caa61e5925
commit 00c08e81d4
4 changed files with 17 additions and 13 deletions

View file

@ -777,7 +777,7 @@ filters_actions_setup (GimpActionGroup *group)
G_N_ELEMENTS (filters_interactive_actions));
gegl_actions = g_strv_builder_new ();
op_classes = gimp_gegl_get_op_classes ();
op_classes = gimp_gegl_get_op_classes (TRUE);
for (iter = op_classes; iter; iter = iter->next)
{

View file

@ -42,9 +42,11 @@
/* local function prototypes */
static gboolean gimp_gegl_op_blacklisted (const gchar *name,
const gchar *categories);
const gchar *categories,
gboolean block_gimp_ops);
static GList * gimp_gegl_get_op_subclasses (GType type,
GList *classes);
GList *classes,
gboolean block_gimp_ops);
static gint gimp_gegl_compare_op_names (GeglOperationClass *a,
GeglOperationClass *b);
@ -52,11 +54,11 @@ static gint gimp_gegl_compare_op_names (GeglOperationClass *a,
/* public functions */
GList *
gimp_gegl_get_op_classes (void)
gimp_gegl_get_op_classes (gboolean block_gimp_ops)
{
GList *operations;
operations = gimp_gegl_get_op_subclasses (GEGL_TYPE_OPERATION, NULL);
operations = gimp_gegl_get_op_subclasses (GEGL_TYPE_OPERATION, NULL, block_gimp_ops);
operations = g_list_sort (operations,
(GCompareFunc)
@ -473,7 +475,8 @@ gimp_gegl_buffer_set_extent (GeglBuffer *buffer,
static gboolean
gimp_gegl_op_blacklisted (const gchar *name,
const gchar *categories_str)
const gchar *categories_str,
gboolean block_gimp_ops)
{
static const gchar * const category_blacklist[] =
{
@ -534,7 +537,7 @@ gimp_gegl_op_blacklisted (const gchar *name,
if (g_getenv ("GIMP_TESTING_NO_GEGL_BLACKLIST"))
return FALSE;
if (g_str_has_prefix (name, "gimp"))
if (block_gimp_ops && g_str_has_prefix (name, "gimp"))
return TRUE;
for (i = 0; i < G_N_ELEMENTS (name_blacklist); i++)
@ -568,8 +571,9 @@ gimp_gegl_op_blacklisted (const gchar *name,
/* Builds a GList of the class structures of all subtypes of type.
*/
static GList *
gimp_gegl_get_op_subclasses (GType type,
GList *classes)
gimp_gegl_get_op_subclasses (GType type,
GList *classes,
gboolean block_gimp_ops)
{
GeglOperationClass *klass;
GType *ops;
@ -585,11 +589,11 @@ gimp_gegl_get_op_subclasses (GType type,
categories = gegl_operation_class_get_key (klass, "categories");
if (! gimp_gegl_op_blacklisted (klass->name, categories))
if (! gimp_gegl_op_blacklisted (klass->name, categories, block_gimp_ops))
classes = g_list_prepend (classes, klass);
for (i = 0; i < n_ops; i++)
classes = gimp_gegl_get_op_subclasses (ops[i], classes);
classes = gimp_gegl_get_op_subclasses (ops[i], classes, block_gimp_ops);
if (ops)
g_free (ops);

View file

@ -21,7 +21,7 @@
#pragma once
GList * gimp_gegl_get_op_classes (void);
GList * gimp_gegl_get_op_classes (gboolean block_gimp_ops);
GType gimp_gegl_get_op_enum_type (const gchar *operation,
const gchar *property);

View file

@ -166,7 +166,7 @@ gimp_gegl_tool_dialog (GimpFilterTool *filter_tool)
store = gtk_list_store_new (N_COLUMNS,
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
opclasses = gimp_gegl_get_op_classes ();
opclasses = gimp_gegl_get_op_classes (TRUE);
for (iter = opclasses; iter; iter = iter->next)
{