mirror of https://github.com/GNOME/gimp.git
app: move gimp_get_geglopclasses() to gegl/gimp-gegl-utils.[ch]
and rename it to gimp_gegl_get_op_classes(). This looks much cleaner, just don't look at the internal op blacklisting code...
This commit is contained in:
parent
e9e09ceec4
commit
ea83d54cb1
|
@ -33,6 +33,32 @@
|
|||
#include "gimp-gegl-utils.h"
|
||||
|
||||
|
||||
/* local function prototypes */
|
||||
|
||||
static gboolean gimp_gegl_op_blacklisted (const gchar *name,
|
||||
const gchar *categories);
|
||||
static GList * gimp_gegl_get_op_subclasses (GType type,
|
||||
GList *classes);
|
||||
static gint gimp_gegl_compare_op_names (GeglOperationClass *a,
|
||||
GeglOperationClass *b);
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
||||
GList *
|
||||
gimp_gegl_get_op_classes (void)
|
||||
{
|
||||
GList *operations;
|
||||
|
||||
operations = gimp_gegl_get_op_subclasses (GEGL_TYPE_OPERATION, NULL);
|
||||
|
||||
operations = g_list_sort (operations,
|
||||
(GCompareFunc)
|
||||
gimp_gegl_compare_op_names);
|
||||
|
||||
return operations;
|
||||
}
|
||||
|
||||
GType
|
||||
gimp_gegl_get_op_enum_type (const gchar *operation,
|
||||
const gchar *property)
|
||||
|
@ -349,3 +375,258 @@ gimp_gegl_buffer_set_extent (GeglBuffer *buffer,
|
|||
|
||||
return gegl_buffer_set_extent (buffer, extent);
|
||||
}
|
||||
|
||||
|
||||
/* private functions */
|
||||
|
||||
static gboolean
|
||||
gimp_gegl_op_blacklisted (const gchar *name,
|
||||
const gchar *categories_str)
|
||||
{
|
||||
static const gchar * const category_blacklist[] =
|
||||
{
|
||||
"compositors",
|
||||
"core",
|
||||
"debug",
|
||||
"display",
|
||||
"hidden",
|
||||
"input",
|
||||
"output",
|
||||
"programming",
|
||||
"transform",
|
||||
"video"
|
||||
};
|
||||
static const gchar * const name_blacklist[] =
|
||||
{
|
||||
/* these ops are already added to the menus via filters-actions */
|
||||
"gegl:alien-map",
|
||||
"gegl:antialias",
|
||||
"gegl:apply-lens",
|
||||
"gegl:bayer-matrix",
|
||||
"gegl:bloom",
|
||||
"gegl:bump-map",
|
||||
"gegl:c2g",
|
||||
"gegl:cartoon",
|
||||
"gegl:cell-noise",
|
||||
"gegl:channel-mixer",
|
||||
"gegl:checkerboard",
|
||||
"gegl:color",
|
||||
"gegl:color-enhance",
|
||||
"gegl:color-exchange",
|
||||
"gegl:color-rotate",
|
||||
"gegl:color-temperature",
|
||||
"gegl:color-to-alpha",
|
||||
"gegl:component-extract",
|
||||
"gegl:convolution-matrix",
|
||||
"gegl:cubism",
|
||||
"gegl:deinterlace",
|
||||
"gegl:difference-of-gaussians",
|
||||
"gegl:diffraction-patterns",
|
||||
"gegl:displace",
|
||||
"gegl:distance-transform",
|
||||
"gegl:dither",
|
||||
"gegl:dropshadow",
|
||||
"gegl:edge",
|
||||
"gegl:edge-laplace",
|
||||
"gegl:edge-neon",
|
||||
"gegl:edge-sobel",
|
||||
"gegl:emboss",
|
||||
"gegl:engrave",
|
||||
"gegl:exposure",
|
||||
"gegl:fattal02",
|
||||
"gegl:focus-blur",
|
||||
"gegl:fractal-trace",
|
||||
"gegl:gaussian-blur",
|
||||
"gegl:gaussian-blur-selective",
|
||||
"gegl:gegl",
|
||||
"gegl:grid",
|
||||
"gegl:high-pass",
|
||||
"gegl:hue-chroma",
|
||||
"gegl:illusion",
|
||||
"gegl:image-gradient",
|
||||
"gegl:invert-linear",
|
||||
"gegl:invert-gamma",
|
||||
"gegl:lens-blur",
|
||||
"gegl:lens-distortion",
|
||||
"gegl:lens-flare",
|
||||
"gegl:linear-sinusoid",
|
||||
"gegl:long-shadow",
|
||||
"gegl:mantiuk06",
|
||||
"gegl:maze",
|
||||
"gegl:mean-curvature-blur",
|
||||
"gegl:median-blur",
|
||||
"gegl:mirrors",
|
||||
"gegl:mono-mixer",
|
||||
"gegl:mosaic",
|
||||
"gegl:motion-blur-circular",
|
||||
"gegl:motion-blur-linear",
|
||||
"gegl:motion-blur-zoom",
|
||||
"gegl:newsprint",
|
||||
"gegl:noise-cie-lch",
|
||||
"gegl:noise-hsv",
|
||||
"gegl:noise-hurl",
|
||||
"gegl:noise-pick",
|
||||
"gegl:noise-reduction",
|
||||
"gegl:noise-rgb",
|
||||
"gegl:noise-slur",
|
||||
"gegl:noise-solid",
|
||||
"gegl:noise-spread",
|
||||
"gegl:normal-map",
|
||||
"gegl:oilify",
|
||||
"gegl:panorama-projection",
|
||||
"gegl:perlin-noise",
|
||||
"gegl:photocopy",
|
||||
"gegl:pixelize",
|
||||
"gegl:plasma",
|
||||
"gegl:polar-coordinates",
|
||||
"gegl:recursive-transform",
|
||||
"gegl:red-eye-removal",
|
||||
"gegl:reinhard05",
|
||||
"gegl:rgb-clip",
|
||||
"gegl:ripple",
|
||||
"gegl:saturation",
|
||||
"gegl:sepia",
|
||||
"gegl:shadows-highlights",
|
||||
"gegl:shift",
|
||||
"gegl:simplex-noise",
|
||||
"gegl:sinus",
|
||||
"gegl:slic",
|
||||
"gegl:snn-mean",
|
||||
"gegl:softglow",
|
||||
"gegl:spherize",
|
||||
"gegl:spiral",
|
||||
"gegl:stereographic-projection",
|
||||
"gegl:stretch-contrast",
|
||||
"gegl:stretch-contrast-hsv",
|
||||
"gegl:stress",
|
||||
"gegl:supernova",
|
||||
"gegl:texturize-canvas",
|
||||
"gegl:tile-glass",
|
||||
"gegl:tile-paper",
|
||||
"gegl:tile-seamless",
|
||||
"gegl:unsharp-mask",
|
||||
"gegl:value-invert",
|
||||
"gegl:value-propagate",
|
||||
"gegl:variable-blur",
|
||||
"gegl:video-degradation",
|
||||
"gegl:vignette",
|
||||
"gegl:waterpixels",
|
||||
"gegl:wavelet-blur",
|
||||
"gegl:waves",
|
||||
"gegl:whirl-pinch",
|
||||
"gegl:wind",
|
||||
|
||||
/* these ops are blacklisted for other reasons */
|
||||
"gegl:contrast-curve",
|
||||
"gegl:convert-format", /* pointless */
|
||||
"gegl:ditto", /* pointless */
|
||||
"gegl:fill-path",
|
||||
"gegl:gray", /* we use gimp's op */
|
||||
"gegl:hstack", /* pointless */
|
||||
"gegl:introspect", /* pointless */
|
||||
"gegl:layer", /* we use gimp's ops */
|
||||
"gegl:lcms-from-profile", /* not usable here */
|
||||
"gegl:linear-gradient", /* we use the blend tool */
|
||||
"gegl:map-absolute", /* pointless */
|
||||
"gegl:map-relative", /* pointless */
|
||||
"gegl:matting-global", /* used in the foreground select tool */
|
||||
"gegl:matting-levin", /* used in the foreground select tool */
|
||||
"gegl:opacity", /* poinless */
|
||||
"gegl:path",
|
||||
"gegl:posterize", /* we use gimp's op */
|
||||
"gegl:radial-gradient", /* we use the blend tool */
|
||||
"gegl:rectangle", /* pointless */
|
||||
"gegl:seamless-clone", /* used in the seamless clone tool */
|
||||
"gegl:text", /* we use gimp's text rendering */
|
||||
"gegl:threshold", /* we use gimp's op */
|
||||
"gegl:tile", /* pointless */
|
||||
"gegl:unpremul", /* pointless */
|
||||
"gegl:vector-stroke",
|
||||
};
|
||||
|
||||
gchar **categories;
|
||||
gint i;
|
||||
|
||||
/* Operations with no name are abstract base classes */
|
||||
if (! name)
|
||||
return TRUE;
|
||||
|
||||
/* use this flag to include all ops for testing */
|
||||
if (g_getenv ("GIMP_TESTING_NO_GEGL_BLACKLIST"))
|
||||
return FALSE;
|
||||
|
||||
if (g_str_has_prefix (name, "gimp"))
|
||||
return TRUE;
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (name_blacklist); i++)
|
||||
{
|
||||
if (! strcmp (name, name_blacklist[i]))
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (! categories_str)
|
||||
return FALSE;
|
||||
|
||||
categories = g_strsplit (categories_str, ":", 0);
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (category_blacklist); i++)
|
||||
{
|
||||
gint j;
|
||||
|
||||
for (j = 0; categories[j]; j++)
|
||||
if (! strcmp (categories[j], category_blacklist[i]))
|
||||
{
|
||||
g_strfreev (categories);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
g_strfreev (categories);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Builds a GList of the class structures of all subtypes of type.
|
||||
*/
|
||||
static GList *
|
||||
gimp_gegl_get_op_subclasses (GType type,
|
||||
GList *classes)
|
||||
{
|
||||
GeglOperationClass *klass;
|
||||
GType *ops;
|
||||
const gchar *categories;
|
||||
guint n_ops;
|
||||
gint i;
|
||||
|
||||
if (! type)
|
||||
return classes;
|
||||
|
||||
klass = GEGL_OPERATION_CLASS (g_type_class_ref (type));
|
||||
ops = g_type_children (type, &n_ops);
|
||||
|
||||
categories = gegl_operation_class_get_key (klass, "categories");
|
||||
|
||||
if (! gimp_gegl_op_blacklisted (klass->name, categories))
|
||||
classes = g_list_prepend (classes, klass);
|
||||
|
||||
for (i = 0; i < n_ops; i++)
|
||||
classes = gimp_gegl_get_op_subclasses (ops[i], classes);
|
||||
|
||||
if (ops)
|
||||
g_free (ops);
|
||||
|
||||
return classes;
|
||||
}
|
||||
|
||||
static gint
|
||||
gimp_gegl_compare_op_names (GeglOperationClass *a,
|
||||
GeglOperationClass *b)
|
||||
{
|
||||
const gchar *name_a = gegl_operation_class_get_key (a, "title");
|
||||
const gchar *name_b = gegl_operation_class_get_key (b, "title");
|
||||
|
||||
if (! name_a) name_a = a->name;
|
||||
if (! name_b) name_b = b->name;
|
||||
|
||||
return strcmp (name_a, name_b);
|
||||
}
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
#define __GIMP_GEGL_UTILS_H__
|
||||
|
||||
|
||||
GList * gimp_gegl_get_op_classes (void);
|
||||
|
||||
GType gimp_gegl_get_op_enum_type (const gchar *operation,
|
||||
const gchar *property);
|
||||
|
||||
|
|
|
@ -29,6 +29,8 @@
|
|||
|
||||
#include "tools-types.h"
|
||||
|
||||
#include "gegl/gimp-gegl-utils.h"
|
||||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimp-filter.h"
|
||||
#include "core/gimptoolinfo.h"
|
||||
|
@ -58,8 +60,6 @@ static void gimp_gegl_tool_control (GimpTool *tool,
|
|||
GimpToolAction action,
|
||||
GimpDisplay *display);
|
||||
|
||||
static GList * gimp_get_geglopclasses (void);
|
||||
|
||||
static void gimp_gegl_tool_dialog (GimpFilterTool *filter_tool);
|
||||
|
||||
static void gimp_gegl_tool_halt (GimpGeglTool *gegl_tool);
|
||||
|
@ -96,7 +96,7 @@ gimp_gegl_tool_register (GimpToolRegisterCallback callback,
|
|||
/* We generate hidden tools for every non-ignored GEGL operation, allowing
|
||||
* people to easily access their custom GEGL operations.
|
||||
*/
|
||||
opclasses = gimp_get_geglopclasses ();
|
||||
opclasses = gimp_gegl_get_op_classes ();
|
||||
|
||||
for (iter = opclasses; iter; iter = iter->next)
|
||||
{
|
||||
|
@ -204,275 +204,6 @@ gimp_gegl_tool_control (GimpTool *tool,
|
|||
GIMP_TOOL_CLASS (parent_class)->control (tool, action, display);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_gegl_tool_operation_blacklisted (const gchar *name,
|
||||
const gchar *categories_str)
|
||||
{
|
||||
static const gchar * const category_blacklist[] =
|
||||
{
|
||||
"compositors",
|
||||
"core",
|
||||
"debug",
|
||||
"display",
|
||||
"hidden",
|
||||
"input",
|
||||
"output",
|
||||
"programming",
|
||||
"transform",
|
||||
"video"
|
||||
};
|
||||
static const gchar * const name_blacklist[] =
|
||||
{
|
||||
/* these ops are already added to the menus via
|
||||
* filters-actions or drawable-actions
|
||||
*/
|
||||
"gegl:alien-map",
|
||||
"gegl:antialias",
|
||||
"gegl:apply-lens",
|
||||
"gegl:bayer-matrix",
|
||||
"gegl:bloom",
|
||||
"gegl:bump-map",
|
||||
"gegl:c2g",
|
||||
"gegl:cartoon",
|
||||
"gegl:cell-noise",
|
||||
"gegl:channel-mixer",
|
||||
"gegl:checkerboard",
|
||||
"gegl:color",
|
||||
"gegl:color-enhance",
|
||||
"gegl:color-exchange",
|
||||
"gegl:color-rotate",
|
||||
"gegl:color-temperature",
|
||||
"gegl:color-to-alpha",
|
||||
"gegl:component-extract",
|
||||
"gegl:convolution-matrix",
|
||||
"gegl:cubism",
|
||||
"gegl:deinterlace",
|
||||
"gegl:difference-of-gaussians",
|
||||
"gegl:diffraction-patterns",
|
||||
"gegl:displace",
|
||||
"gegl:distance-transform",
|
||||
"gegl:dither",
|
||||
"gegl:dropshadow",
|
||||
"gegl:edge",
|
||||
"gegl:edge-laplace",
|
||||
"gegl:edge-neon",
|
||||
"gegl:edge-sobel",
|
||||
"gegl:emboss",
|
||||
"gegl:engrave",
|
||||
"gegl:exposure",
|
||||
"gegl:fattal02",
|
||||
"gegl:focus-blur",
|
||||
"gegl:fractal-trace",
|
||||
"gegl:gaussian-blur",
|
||||
"gegl:gaussian-blur-selective",
|
||||
"gegl:gegl",
|
||||
"gegl:grid",
|
||||
"gegl:high-pass",
|
||||
"gegl:hue-chroma",
|
||||
"gegl:illusion",
|
||||
"gegl:image-gradient",
|
||||
"gegl:invert-linear",
|
||||
"gegl:invert-gamma",
|
||||
"gegl:lens-blur",
|
||||
"gegl:lens-distortion",
|
||||
"gegl:lens-flare",
|
||||
"gegl:linear-sinusoid",
|
||||
"gegl:long-shadow",
|
||||
"gegl:mantiuk06",
|
||||
"gegl:maze",
|
||||
"gegl:mean-curvature-blur",
|
||||
"gegl:median-blur",
|
||||
"gegl:mirrors",
|
||||
"gegl:mono-mixer",
|
||||
"gegl:mosaic",
|
||||
"gegl:motion-blur-circular",
|
||||
"gegl:motion-blur-linear",
|
||||
"gegl:motion-blur-zoom",
|
||||
"gegl:newsprint",
|
||||
"gegl:noise-cie-lch",
|
||||
"gegl:noise-hsv",
|
||||
"gegl:noise-hurl",
|
||||
"gegl:noise-pick",
|
||||
"gegl:noise-reduction",
|
||||
"gegl:noise-rgb",
|
||||
"gegl:noise-slur",
|
||||
"gegl:noise-solid",
|
||||
"gegl:noise-spread",
|
||||
"gegl:normal-map",
|
||||
"gegl:oilify",
|
||||
"gegl:panorama-projection",
|
||||
"gegl:perlin-noise",
|
||||
"gegl:photocopy",
|
||||
"gegl:pixelize",
|
||||
"gegl:plasma",
|
||||
"gegl:polar-coordinates",
|
||||
"gegl:recursive-transform",
|
||||
"gegl:red-eye-removal",
|
||||
"gegl:reinhard05",
|
||||
"gegl:rgb-clip",
|
||||
"gegl:ripple",
|
||||
"gegl:saturation",
|
||||
"gegl:sepia",
|
||||
"gegl:shadows-highlights",
|
||||
"gegl:shift",
|
||||
"gegl:simplex-noise",
|
||||
"gegl:sinus",
|
||||
"gegl:slic",
|
||||
"gegl:snn-mean",
|
||||
"gegl:softglow",
|
||||
"gegl:spherize",
|
||||
"gegl:spiral",
|
||||
"gegl:stereographic-projection",
|
||||
"gegl:stretch-contrast",
|
||||
"gegl:stretch-contrast-hsv",
|
||||
"gegl:stress",
|
||||
"gegl:supernova",
|
||||
"gegl:texturize-canvas",
|
||||
"gegl:tile-glass",
|
||||
"gegl:tile-paper",
|
||||
"gegl:tile-seamless",
|
||||
"gegl:unsharp-mask",
|
||||
"gegl:value-invert",
|
||||
"gegl:value-propagate",
|
||||
"gegl:variable-blur",
|
||||
"gegl:video-degradation",
|
||||
"gegl:vignette",
|
||||
"gegl:waterpixels",
|
||||
"gegl:wavelet-blur",
|
||||
"gegl:waves",
|
||||
"gegl:whirl-pinch",
|
||||
"gegl:wind",
|
||||
|
||||
/* these ops are blacklisted for other reasons */
|
||||
"gegl:contrast-curve",
|
||||
"gegl:convert-format", /* pointless */
|
||||
"gegl:ditto", /* pointless */
|
||||
"gegl:fill-path",
|
||||
"gegl:gray", /* we use gimp's op */
|
||||
"gegl:hstack", /* pointless */
|
||||
"gegl:introspect", /* pointless */
|
||||
"gegl:layer", /* we use gimp's ops */
|
||||
"gegl:lcms-from-profile", /* not usable here */
|
||||
"gegl:linear-gradient", /* we use the blend tool */
|
||||
"gegl:map-absolute", /* pointless */
|
||||
"gegl:map-relative", /* pointless */
|
||||
"gegl:matting-global", /* used in the foreground select tool */
|
||||
"gegl:matting-levin", /* used in the foreground select tool */
|
||||
"gegl:opacity", /* poinless */
|
||||
"gegl:path",
|
||||
"gegl:posterize", /* we use gimp's op */
|
||||
"gegl:radial-gradient", /* we use the blend tool */
|
||||
"gegl:rectangle", /* pointless */
|
||||
"gegl:seamless-clone", /* used in the seamless clone tool */
|
||||
"gegl:text", /* we use gimp's text rendering */
|
||||
"gegl:threshold", /* we use gimp's op */
|
||||
"gegl:tile", /* pointless */
|
||||
"gegl:unpremul", /* pointless */
|
||||
"gegl:vector-stroke",
|
||||
};
|
||||
|
||||
gchar **categories;
|
||||
gint i;
|
||||
|
||||
/* Operations with no name are abstract base classes */
|
||||
if (! name)
|
||||
return TRUE;
|
||||
|
||||
/* use this flag to include all ops for testing */
|
||||
if (g_getenv ("GIMP_TESTING_NO_GEGL_BLACKLIST"))
|
||||
return FALSE;
|
||||
|
||||
if (g_str_has_prefix (name, "gimp"))
|
||||
return TRUE;
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (name_blacklist); i++)
|
||||
{
|
||||
if (! strcmp (name, name_blacklist[i]))
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (! categories_str)
|
||||
return FALSE;
|
||||
|
||||
categories = g_strsplit (categories_str, ":", 0);
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (category_blacklist); i++)
|
||||
{
|
||||
gint j;
|
||||
|
||||
for (j = 0; categories[j]; j++)
|
||||
if (! strcmp (categories[j], category_blacklist[i]))
|
||||
{
|
||||
g_strfreev (categories);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
g_strfreev (categories);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/* Builds a GList of the class structures of all subtypes of type.
|
||||
*/
|
||||
static GList *
|
||||
gimp_get_subtype_classes (GType type,
|
||||
GList *classes)
|
||||
{
|
||||
GeglOperationClass *klass;
|
||||
GType *ops;
|
||||
const gchar *categories;
|
||||
guint n_ops;
|
||||
gint i;
|
||||
|
||||
if (! type)
|
||||
return classes;
|
||||
|
||||
klass = GEGL_OPERATION_CLASS (g_type_class_ref (type));
|
||||
ops = g_type_children (type, &n_ops);
|
||||
|
||||
categories = gegl_operation_class_get_key (klass, "categories");
|
||||
|
||||
if (! gimp_gegl_tool_operation_blacklisted (klass->name, categories))
|
||||
classes = g_list_prepend (classes, klass);
|
||||
|
||||
for (i = 0; i < n_ops; i++)
|
||||
classes = gimp_get_subtype_classes (ops[i], classes);
|
||||
|
||||
if (ops)
|
||||
g_free (ops);
|
||||
|
||||
return classes;
|
||||
}
|
||||
|
||||
static gint
|
||||
gimp_gegl_tool_compare_operation_names (GeglOperationClass *a,
|
||||
GeglOperationClass *b)
|
||||
{
|
||||
const gchar *name_a = gegl_operation_class_get_key (a, "title");
|
||||
const gchar *name_b = gegl_operation_class_get_key (b, "title");
|
||||
|
||||
if (! name_a) name_a = a->name;
|
||||
if (! name_b) name_b = b->name;
|
||||
|
||||
return strcmp (name_a, name_b);
|
||||
}
|
||||
|
||||
static GList *
|
||||
gimp_get_geglopclasses (void)
|
||||
{
|
||||
GList *opclasses;
|
||||
|
||||
opclasses = gimp_get_subtype_classes (GEGL_TYPE_OPERATION, NULL);
|
||||
|
||||
opclasses = g_list_sort (opclasses,
|
||||
(GCompareFunc)
|
||||
gimp_gegl_tool_compare_operation_names);
|
||||
|
||||
return opclasses;
|
||||
}
|
||||
|
||||
|
||||
/*****************/
|
||||
/* Gegl dialog */
|
||||
|
@ -517,7 +248,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_get_geglopclasses ();
|
||||
opclasses = gimp_gegl_get_op_classes ();
|
||||
|
||||
for (iter = opclasses; iter; iter = iter->next)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue