Ejemplo n.º 1
0
gint
main (gint argc, gchar **argv)
{
  GList      *operations;
  GList      *iter;
  gboolean first = TRUE;

  gegl_init (&argc, &argv);

  g_object_set (gegl_config (),
                "application-license", "GPL3",
                NULL);


  operations = gegl_operations ();

  g_print ("window.opdb=[\n");

  for (iter=operations;iter;iter = g_list_next (iter))
    {
      GeglOperationClass *klass = iter->data;

      const char *name = gegl_operation_class_get_key (klass, "name");
      const char *categoris = gegl_operation_class_get_key (klass, "categories");

      if (first)
        first = FALSE;
      else
        g_print (",");

      g_print ("{'op':'%s'\n", name);

      if (klass->compat_name)
        g_print (",'compat-op':'%s'\n", klass->compat_name);

      if (klass->opencl_support)
        g_print (",'opencl-support':'true'\n");

      g_print (",'parent':'%s'\n", 
          g_type_name (g_type_parent(G_OBJECT_CLASS_TYPE(klass))));

      {
        char *image = operation_to_path (name);

        if (g_file_test (image, G_FILE_TEST_EXISTS))
          g_print (",'image':'%s'\n", image);
        g_free (image);
      }

      {
        gchar *commandline = g_strdup_printf (
            "sh -c \"(cd " TOP_SRCDIR ";grep -r '\\\"%s\\\"' operations) | grep operations | grep -v '~:' | grep '\\\"name\\\"' | cut -f 1 -d ':'\"",
             name);
        gchar *output = NULL;
        
        if (g_spawn_command_line_sync (commandline, &output, NULL, NULL, NULL))
        {
          if (strlen(output))
            {
              output[strlen(output)-1] = 0;
              g_print (
      ",'source':'https://git.gnome.org/browse/gegl/tree/%s'\n", output);
            }
          g_free (output);
        }

        g_free (commandline);
      }

      if (categoris)
      {
        const gchar *ptr = categoris;
          gboolean first = TRUE;
        g_print (",'categories':[");

        while (ptr && *ptr)
          {
            gchar category[64]="";
            gint i=0;
            while (*ptr && *ptr!=':' && i<63)
              {
                category[i++]=*(ptr++);
                category[i]='\0';
              }
            if (*ptr==':')
              ptr++;
            {
              if (first)
                first = FALSE;
              else
                g_print (",");
              g_print ("'%s'", category);
            }
          }
        g_print ("]\n");
      }

      json_list_properties (G_OBJECT_CLASS_TYPE (klass), name);
      json_list_pads (G_OBJECT_CLASS_TYPE (klass), name);

      {
        guint nkeys;
        gchar **keys = gegl_operation_list_keys (name, &nkeys);

        if (keys)
          {
            for (gint i = 0; keys[i]; i++)
              {
                const gchar *value = gegl_operation_get_key (name, keys[i]);

                if (g_str_equal (keys[i], "categories") ||
                    g_str_equal (keys[i], "cl-source") ||
                    g_str_equal (keys[i], "source") ||
                    g_str_equal (keys[i], "name")
                    )
                  continue;

                g_print (",\"%s\":\"", keys[i]);
                json_escape_string (value);
                g_print ("\"\n");
              }
            g_free (keys);
          }
      }

      g_print (" }\n");
    }
  g_print ("]\n");

  return 0;
}
Ejemplo n.º 2
0
gint
main (gint    argc,
      gchar **argv)
{
  GList      *operations;
  GList      *iter;
  GHashTable *categories = NULL;
  gboolean    comma;

  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, comma=FALSE;iter;iter = g_list_next (iter))
    {
      GeglOperationClass *klass = iter->data;
      const gchar *ptr = klass->categories;
      while (*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 ("<div id='toc'>\n<ul>\n");
  g_print ("<li><a href='index.html'>GEGL</a></li><li>&nbsp;</li>\n");
  g_print ("<li><a href='index.html#Documentation'>Documentation</a></li>\n");
  g_print ("<li><a href='index.html#Glossary'>&nbsp;&nbsp;Glossary</a></li>\n");
  g_print ("<li><a href='operations.html#'>&nbsp;&nbsp;Operations</a></li>\n");
  g_print ("<li><a href='api.html'>&nbsp;&nbsp;API reference</a></li>\n");
  g_print ("<li><a href=''>&nbsp;</a></li>\n");
  g_print ("<li><a href='#Categories'>Categories</a></li>\n");
  g_print ("<li><a href=''>&nbsp;</a></li>\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 ("</ul>\n</div>\n");

    g_print ("<h1>GEGL operation reference</h1>");
    g_print ("<p>Image processing operations are shared objects (plug-ins) loaded when GEGL initializes. "
             "This page is generated from information registered by the plug-ins themselves.</p>"
              "<a name='Categories'><h2>Categories</h2></a><p>A plug-in can "
             "belong in multiple categories. Below is indexes broken down into the various available categories.</p>");

  /*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 ("<table>\n");
  for (iter=operations;iter;iter = g_list_next (iter))
    {
      GeglOperationClass *klass = iter->data;
      if (strstr (klass->categories, "hidden"))
        continue;

      g_print ("<tr>\n  <td colspan='1'>&nbsp;</td>\n  <td class='op_name' colspan='4'><a name='op_%s'>%s</a></td>\n</tr>\n", klass->name, klass->name);
      if (klass->description)
        g_print ("<tr>\n  <td colspan='1'>&nbsp;</td>\n  <td class='op_description' colspan='4'>%s</td>\n</tr>\n", klass->description);
      list_properties (G_OBJECT_CLASS_TYPE (klass), 2, TRUE);
    }
  g_print ("</table>\n");


  g_print ("%s", html_bottom);

  g_list_free (operations);
  gegl_exit ();
  return 0;
}