Skip to content

Instantly share code, notes, and snippets.

@bellbind
Created Jul 2, 2009
Embed
What would you like to do?
[C][gegl][tool] show list of gegl operations
/* list operations by gegl: http://gegl.org/
*
* build:
* gcc -Wall `pkg-config --cflags --libs gegl` geglops.c -o geglops
*
* usage:
* ./geglops
*/
#include <glib.h>
#include <glib-object.h>
#include <glib/gprintf.h>
#include <gegl.h>
static void print_pspec(GParamSpec * pspec)
{
GParamFlags flags = pspec->flags;
GType vtype = pspec->value_type;
g_printf("* %s : %s (",
g_param_spec_get_name(pspec),
g_type_name(vtype));
if (flags & G_PARAM_READABLE) g_printf("R");
if (flags & G_PARAM_WRITABLE) g_printf("W");
if (flags & G_PARAM_CONSTRUCT) g_printf("C");
if (flags & G_PARAM_CONSTRUCT_ONLY) g_printf("O");
if (flags & G_PARAM_LAX_VALIDATION) g_printf("V");
g_printf(")\n");
g_printf(" <%s> %s\n",
g_param_spec_get_nick(pspec),
g_param_spec_get_blurb(pspec));
}
gint main(gint argc, gchar * argv[])
{
gchar ** ops;
guint oplen;
gint i;
gegl_init(&argc, &argv);
ops = gegl_list_operations(&oplen);
for (i=0; i < oplen; i++) {
GParamSpec ** pspecs;
guint pspeclen;
gchar * op = ops[i];
gboolean do_print = TRUE;
gint j;
for (j = 1; j < argc; j++) {
do_print = (g_strcmp0(op, argv[j]) == 0);
if (do_print) break;
}
if (!do_print) continue;
pspecs = gegl_list_properties(op, &pspeclen);
g_printf("[%s]\n", op);
for (j = 0; j < pspeclen; j++) {
print_pspec(pspecs[j]);
}
g_printf("\n");
}
g_free(ops);
gegl_exit();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment