#include "config.h" #include /* needed to do full introspection */ #include #include #ifdef HAVE_UNISTD_H #include #endif static GList * gegl_operations_build (GList *list, GType type) { GeglOperationClass *klass; GType *ops; guint children; gint no; if (!type) return list; klass = g_type_class_ref (type); if (klass->name != NULL) list = g_list_prepend (list, klass); ops = g_type_children (type, &children); for (no=0; noname, klassB->name); } static GList *gegl_operations (void) { static GList *operations = NULL; if (!operations) { operations = gegl_operations_build (NULL, GEGL_TYPE_OPERATION); operations = g_list_sort (operations, compare_operation_names); } return operations; } GeglColor * gegl_param_spec_color_get_default (GParamSpec *self); static void list_properties (GType type, gint indent, gboolean html) { GParamSpec **self; GParamSpec **parent; guint n_self; guint n_parent; gint prop_no; if (!type) return; self = g_object_class_list_properties ( G_OBJECT_CLASS (g_type_class_ref (type)), &n_self); parent = g_object_class_list_properties ( /*G_OBJECT_CLASS (g_type_class_peek_parent (g_type_class_ref (type))),*/ G_OBJECT_CLASS (g_type_class_ref (GEGL_TYPE_OPERATION)), &n_parent); for (prop_no=0;prop_no  %s
", type_name); if (g_type_is_a (G_PARAM_SPEC_VALUE_TYPE (self[prop_no]), G_TYPE_DOUBLE)) { gdouble default_value = G_PARAM_SPEC_DOUBLE (self[prop_no])->default_value; gdouble min = G_PARAM_SPEC_DOUBLE (self[prop_no])->minimum; gdouble max = G_PARAM_SPEC_DOUBLE (self[prop_no])->maximum; if (default_value<-10000000) g_print ("-inf "); else if (default_value>10000000) g_print ("+inf"); else g_print ("%2.2f", default_value); g_print ("
"); if (min<-10000000) g_print ("-inf "); else g_print ("%2.2f", min); g_print ("-"); if (max>10000000) g_print (" +inf"); else g_print ("%2.2f", max); } else if (g_type_is_a (G_PARAM_SPEC_VALUE_TYPE (self[prop_no]), G_TYPE_INT)) { gint default_value = G_PARAM_SPEC_INT (self[prop_no])->default_value; gint min = G_PARAM_SPEC_INT (self[prop_no])->minimum; gint max = G_PARAM_SPEC_INT (self[prop_no])->maximum; if (default_value<-10000000) g_print ("-inf "); else if (default_value>10000000) g_print ("+inf"); else g_print ("%i", default_value); g_print ("
"); if (min<-10000000) g_print ("-inf "); else g_print ("%i", min); g_print ("-"); if (max>10000000) g_print (" +inf"); else g_print ("%i", max); } else if (g_type_is_a (G_PARAM_SPEC_VALUE_TYPE (self[prop_no]), G_TYPE_FLOAT)) { gfloat default_value = G_PARAM_SPEC_FLOAT (self[prop_no])->default_value; gfloat min = G_PARAM_SPEC_FLOAT (self[prop_no])->minimum; gfloat max = G_PARAM_SPEC_FLOAT (self[prop_no])->maximum; if (default_value<-10000000) g_print ("-inf "); else if (default_value>10000000) g_print ("+inf"); else g_print ("%2.2f", default_value); g_print ("
"); if (min<-10000000) g_print ("-inf "); else g_print ("%2.2f", min); g_print ("-"); if (max>10000000) g_print (" +inf"); else g_print ("%2.2f", max); } else if (g_type_is_a (G_PARAM_SPEC_VALUE_TYPE (self[prop_no]), G_TYPE_BOOLEAN)) { g_print ("%s", G_PARAM_SPEC_BOOLEAN (self[prop_no])->default_value?"True":"False"); } else if (g_type_is_a (G_PARAM_SPEC_VALUE_TYPE (self[prop_no]), G_TYPE_STRING)) { const gchar *string = G_PARAM_SPEC_STRING (self[prop_no])->default_value; if (strlen (string) > 8) { gchar copy[16]; g_snprintf (copy, 12, "%s..", string); g_print ("%s", copy); } else g_print ("%s", string); } else if (g_type_is_a (G_PARAM_SPEC_VALUE_TYPE (self[prop_no]), GEGL_TYPE_COLOR)) { GeglColor *color = gegl_param_spec_color_get_default (self[prop_no]); if (color) { gchar *string; g_object_get (color, "string", &string, NULL); g_print ("%s", string); g_free (string); g_object_unref (color); } } else { g_print ("\n"); } g_print ("
"); g_print("%s\n", g_param_spec_get_name (self[prop_no])); if (g_param_spec_get_blurb (self[prop_no]) && g_param_spec_get_blurb (self[prop_no])[0]!='\0') g_print ("%s\n", g_param_spec_get_blurb (self[prop_no])); else g_print ("not documented\n\n"); g_print ("\n"); } } if (self) g_free (self); if (parent) g_free (parent); } static gchar *html_top = "\n\nGEGL operations\n\n\n\n\n\n
\n
\n"; static gchar *html_bottom = "
\n
\n\n\n"; static void category_index (gpointer key, gpointer value, gpointer user_data) { gchar *category = key; GList *operations = value; GList *iter; gboolean comma; if (!strcmp (category, "hidden")) return; g_print ("

%s

\n", category, category); g_print ("
\n"); for (iter=operations, comma=FALSE;iter;iter = g_list_next (iter)) { GeglOperationClass *klass = iter->data; const char *categories = gegl_operation_class_get_key (klass, "categories"); if (strstr (categories, "hidden")) continue; g_print ("%s%s\n", comma?"":"", klass->name, klass->name); comma = TRUE; } g_print ("
\n"); } static void category_menu_index (gpointer key, gpointer value, gpointer user_data) { gchar *category = key; GList *operations = value; GList *iter; if (!strcmp (category, "hidden")) return; for (iter=operations;iter;iter = g_list_next (iter)) { GeglOperationClass *klass = iter->data; const char *categories = gegl_operation_class_get_key (klass, "categories"); if (!categories || strstr (categories, "hidden")) continue; g_print ("
  • %s
  • \n", klass->name, klass->name); } } gint main (gint argc, gchar **argv) { GList *operations; GList *iter; GHashTable *categories = NULL; gegl_init (&argc, &argv); operations = gegl_operations (); /* Collect categories */ categories = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); for (iter=operations;iter;iter = g_list_next (iter)) { GeglOperationClass *klass = iter->data; const char *categoris = gegl_operation_class_get_key (klass, "categories"); const gchar *ptr = categoris; while (ptr && *ptr) { gchar category[64]=""; gint i=0; while (*ptr && *ptr!=':' && i<63) { category[i++]=*(ptr++); category[i]='\0'; } if (*ptr==':') ptr++; { GList *items = g_hash_table_lookup (categories, category); g_hash_table_insert (categories, g_strdup (category), g_list_append (items, klass)); } } } g_print ("%s", html_top); g_print ("
    \n
      \n"); g_print ("
    • GEGL
    •  
    • \n"); g_print ("
    • Documentation
    • \n"); g_print ("
    •   Glossary
    • \n"); g_print ("
    •   Operations
    • \n"); g_print ("
    •   API reference
    • \n"); g_print ("
    •  
    • \n"); g_print ("
    • Categories
    • \n"); g_print ("
    •  
    • \n"); /*category_menu_item ("All", NULL, NULL); g_hash_table_foreach (categories, category_menu_item, NULL);*/ /*border: 0.1em dashed rgb(210,210,210); */ category_menu_index("All", operations, NULL); g_print ("
    \n
    \n"); g_print ("

    GEGL operation reference

    "); g_print ("

    Image processing operations are shared objects (plug-ins) loaded when GEGL initializes. " "This page is generated from information registered by the plug-ins themselves.

    " "

    Categories

    A plug-in can " "belong in multiple categories. Below is indexes broken down into the various available categories.

    "); /*category_index ("All", operations, NULL);*/ /* create menus for each of the categories */ g_hash_table_foreach (categories, category_index, NULL); /* list all operations */ g_print ("\n"); for (iter=operations;iter;iter = g_list_next (iter)) { GeglOperationClass *klass = iter->data; const char *categoris = gegl_operation_class_get_key (klass, "categories"); const char *description = gegl_operation_class_get_key (klass, "description"); if (categoris && strstr (categoris, "hidden")) continue; g_print ("\n \n \n\n", klass->name, klass->name); if (description) g_print ("\n \n \n\n", description); list_properties (G_OBJECT_CLASS_TYPE (klass), 2, TRUE); } g_print ("
     %s
     %s
    \n"); g_print ("%s", html_bottom); g_list_free (operations); gegl_exit (); return 0; }