gegl.c 3.07 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/* This file is an image processing operation for GEGL
 *
 * GEGL is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 3 of the License, or (at your option) any later version.
 *
 * GEGL is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with GEGL; if not, see <http://www.gnu.org/licenses/>.
 *
16
 * Copyright 2016 Øyvind Kolås <pippin@gimp.org>
17 18 19 20 21 22 23
 */

#include "config.h"
#include <glib/gi18n-lib.h>

#ifdef GEGL_PROPERTIES

24
property_string (string, _("pipeline"), "gaussian-blur std-dev-x=0.3rel std-dev-y=0.3rel")
25
    description(_("[op [property=value] [property=value]] [[op] [property=value]"))
26
    ui_meta ("multiline", "true")
27

28 29
property_string (error, _("Eeeeeek"), "")
    description (_("There is a problem in the syntax or in the application of parsed property values. Things might mostly work nevertheless."))
30
    ui_meta ("error", "true")
31

32 33 34
#else

#define GEGL_OP_META
35
#define GEGL_OP_NAME     gegl
36 37 38 39
#define GEGL_OP_C_SOURCE gegl.c

#include "gegl-op.h"

40 41
/* XXX: leaking o->user_data */

42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
static void
attach (GeglOperation *operation)
{
  GeglNode *gegl, *input, *output;

  gegl = operation->node;

  input    = gegl_node_get_input_proxy (gegl, "input");
  output   = gegl_node_get_output_proxy (gegl, "output");

  gegl_node_link_many (input, output, NULL);
}

#include <stdio.h>

static void
prepare (GeglOperation *operation)
{
  GeglProperties *o = GEGL_PROPERTIES (operation);
  GeglNode *gegl, *input, *output;
62
  GError *error = NULL;
63 64 65

  gegl = operation->node;

66
  if (!o->user_data || !g_str_equal (o->user_data, o->string))
67
  {
68 69 70
    if (o->user_data)
      g_free (o->user_data);
    o->user_data = g_strdup (o->string);
71

72 73
  input  = gegl_node_get_input_proxy (gegl,  "input");
  output = gegl_node_get_output_proxy (gegl, "output");
74

75
  gegl_node_link_many (input, output, NULL);
76 77 78
  gegl_create_chain (o->string, input, output, 0.0,
                     gegl_node_get_bounding_box (input).height,
                     &error);
79 80 81

  if (error)
  {
82
    gegl_node_set (gegl, "error", error->message, NULL);
83 84 85
    g_error_free (error);
    error = NULL;
  }
86 87
  else
    g_object_set (operation, "error", "", NULL);
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
  }
}

static void
gegl_op_class_init (GeglOpClass *klass)
{
  GeglOperationClass *operation_class;

  operation_class = GEGL_OPERATION_CLASS (klass);

  operation_class->attach = attach;
  operation_class->prepare = prepare;

  gegl_operation_class_set_keys (operation_class,
    "name",        "gegl:gegl",
    "title",       _("GEGL graph"),
104 105
    "categories",  "generic",
    "description", _("Do a chain of operations, with key=value pairs after each operation name to set properties. And aux=[ source filter ] for specifying a chain with a source as something connected to an aux pad."),
106 107 108 109
    NULL);
}

#endif