Commit e1c23cae authored by Manish Singh's avatar Manish Singh

Brand new python binding

svn path=/trunk/; revision=1719
parent b1ef5d17
This diff is collapsed.
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
2007-11-24 Manish Singh <yosh@gimp.org>
Complete rewrite of the python binding.
INCLUDES = $(PYTHON_INCLUDES) $(PYGOBJECT_CFLAGS) $(GEGL_CFLAGS)
AM_CFLAGS = $(PYGEGL_EXTRA_CFLAGS)
pygegldir = $(pyexecdir)/Gegl
pygegl_PYTHON = __init__.py
pygegl_LTLIBRARIES = _gegl.la
_gegl_la_LDFLAGS = -module -avoid-version -export-symbols-regex init_gegl
_gegl_la_LIBADD = $(GEGL_LIBS) $(PYTHON_LIBS)
_gegl_la_SOURCES = geglmodule.c
nodist__gegl_la_SOURCES = gegl.c
CLEANFILES = gegl.c
EXTRA_DIST = gegl.defs gegl.override geglrectangle.override
gegl.c: gegl.defs gegl.override geglrectangle.override
.defs.c:
(cd $(srcdir) \
&& $(PYGTK_CODEGEN) \
--py_ssize_t-clean \
--override $*.override \
--prefix py$* $*.defs) > gen-$*.c \
&& cp gen-$*.c $*.c \
&& rm -f gen-$*.c
# PyGEGL - Python bindings for the GEGL image processing library
# Copyright (C) 2007 Manish Singh
#
# __init__.py: initialization file for the Gegl package
#
# PyGEGL 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.
#
# PyGEGL 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 PyGEGL; if not, see <http://www.gnu.org/licenses/>.
import dl
libgegl = dl.open("libgegl-1.0.so.0", dl.RTLD_NOW|dl.RTLD_GLOBAL)
libbabl = dl.open("libbabl-0.0.so.0", dl.RTLD_NOW|dl.RTLD_GLOBAL)
from _gegl import *
import atexit
atexit.register(exit)
del exit, atexit
del _gegl
;; -*- scheme -*-
; object definitions ...
(define-object Color
(in-module "Gegl")
(parent "GObject")
(c-name "GeglColor")
(gtype-id "GEGL_TYPE_COLOR")
)
(define-object Node
(in-module "Gegl")
(parent "GObject")
(c-name "GeglNode")
(gtype-id "GEGL_TYPE_NODE")
)
(define-object Processor
(in-module "Gegl")
(parent "GObject")
(c-name "GeglProcessor")
(gtype-id "GEGL_TYPE_PROCESSOR")
)
;(define-object Curve
; (in-module "Gegl")
; (parent "GObject")
; (c-name "GeglCurve")
; (gtype-id "GEGL_TYPE_CURVE")
;)
(define-boxed Rectangle
(in-module "Gegl")
(c-name "GeglRectangle")
(gtype-id "GEGL_TYPE_RECTANGLE")
(fields
'("gint" "x")
'("gint" "y")
'("gint" "width")
'("gint" "height")
)
)
;; Enumerations and flags ...
;(define-flags BlitFlags
; (in-module "Gegl")
; (c-name "GeglBlitFlags")
; (gtype-id "GEGL_TYPE_BLIT_FLAGS")
; (values
; '("default" "GEGL_BLIT_DEFAULT")
; '("cache" "GEGL_BLIT_CACHE")
; '("dirty" "GEGL_BLIT_DIRTY")
; )
;)
;; From gegl.h
(define-function init
(c-name "gegl_init")
(return-type "none")
(parameters
'("gint*" "argc")
'("gchar***" "argv")
)
)
(define-function gegl_get_option_group
(c-name "gegl_get_option_group")
(return-type "GOptionGroup*")
)
(define-function exit
(c-name "gegl_exit")
(return-type "none")
)
(define-function list_operations
(c-name "gegl_list_operations")
(return-type "gchar**")
(parameters
'("guint*" "n_operations_p")
)
)
(define-function list_properties
(c-name "gegl_list_properties")
(return-type "GParamSpec**")
(parameters
'("const-gchar*" "operation_type")
'("guint*" "n_properties_p")
)
)
(define-function gegl_node_get_type
(c-name "gegl_node_get_type")
(return-type "GType")
)
(define-function gegl_rectangle_get_type
(c-name "gegl_rectangle_get_type")
(return-type "GType")
)
(define-function gegl_node_new
(c-name "gegl_node_new")
(is-constructor-of "GeglNode")
(return-type "GeglNode*")
)
(define-method new_child
(of-object "GeglNode")
(c-name "gegl_node_new_child")
(return-type "GeglNode*")
(parameters
'("const-gchar*" "first_property_name")
)
(varargs #t)
)
(define-method connect_from
(of-object "GeglNode")
(c-name "gegl_node_connect_from")
(return-type "gboolean")
(parameters
'("const-gchar*" "input_pad_name")
'("GeglNode*" "source")
'("const-gchar*" "output_pad_name")
)
)
(define-method connect_to
(of-object "GeglNode")
(c-name "gegl_node_connect_to")
(return-type "gboolean")
(parameters
'("const-gchar*" "output_pad_name")
'("GeglNode*" "sink")
'("const-gchar*" "input_pad_name")
)
)
(define-method link
(of-object "GeglNode")
(c-name "gegl_node_link")
(return-type "none")
(parameters
'("GeglNode*" "sink")
)
)
(define-method link_many
(of-object "GeglNode")
(c-name "gegl_node_link_many")
(return-type "none")
(parameters
'("GeglNode*" "first_sink")
)
(varargs #t)
)
(define-method disconnect
(of-object "GeglNode")
(c-name "gegl_node_disconnect")
(return-type "gboolean")
(parameters
'("const-gchar*" "input_pad")
)
)
(define-method set
(of-object "GeglNode")
(c-name "gegl_node_set")
(return-type "none")
(parameters
'("const-gchar*" "first_property_name")
)
(varargs #t)
)
(define-method get
(of-object "GeglNode")
(c-name "gegl_node_get")
(return-type "none")
(parameters
'("const-gchar*" "first_property_name")
)
(varargs #t)
)
(define-method blit
(of-object "GeglNode")
(c-name "gegl_node_blit")
(return-type "none")
(parameters
'("gdouble" "scale")
'("GeglRectangle*" "roi")
'("Babl*" "format")
'("gpointer" "destination_buf")
'("gint" "rowstride")
'("GeglBlitFlags" "flags")
)
)
(define-method process
(of-object "GeglNode")
(c-name "gegl_node_process")
(return-type "none")
)
(define-method detect
(of-object "GeglNode")
(c-name "gegl_node_detect")
(return-type "GeglNode*")
(parameters
'("gint" "x")
'("gint" "y")
)
)
(define-method find_property
(of-object "GeglNode")
(c-name "gegl_node_find_property")
(return-type "GParamSpec*")
(parameters
'("const-gchar*" "property_name")
)
)
(define-method get_bounding_box
(of-object "GeglNode")
(c-name "gegl_node_get_bounding_box")
(return-type "GeglRectangle")
)
(define-method get_children
(of-object "GeglNode")
(c-name "gegl_node_get_children")
(return-type "GSList*")
)
(define-method get_consumers
(of-object "GeglNode")
(c-name "gegl_node_get_consumers")
(return-type "gint")
(parameters
'("const-gchar*" "output_pad")
'("GeglNode***" "nodes")
'("const-gchar***" "pads")
)
)
(define-method get_input_proxy
(of-object "GeglNode")
(c-name "gegl_node_get_input_proxy")
(return-type "GeglNode*")
(parameters
'("const-gchar*" "pad_name")
)
)
(define-method get_operation
(of-object "GeglNode")
(c-name "gegl_node_get_operation")
(return-type "const-gchar*")
)
(define-method get_output_proxy
(of-object "GeglNode")
(c-name "gegl_node_get_output_proxy")
(return-type "GeglNode*")
(parameters
'("const-gchar*" "pad_name")
)
)
(define-method get_producer
(of-object "GeglNode")
(c-name "gegl_node_get_producer")
(return-type "GeglNode*")
(parameters
'("gchar*" "input_pad_name")
'("gchar**" "output_pad_name")
)
)
(define-method create_child
(of-object "GeglNode")
(c-name "gegl_node_create_child")
(return-type "GeglNode*")
(parameters
'("const-gchar*" "operation")
)
)
(define-method get_property
(of-object "GeglNode")
(c-name "gegl_node_get_property")
(return-type "none")
(parameters
'("const-gchar*" "property_name")
'("GValue*" "value")
)
)
(define-method set_property
(of-object "GeglNode")
(c-name "gegl_node_set_property")
(return-type "none")
(parameters
'("const-gchar*" "property_name")
'("const-GValue*" "value")
)
)
(define-function parse_xml
(c-name "gegl_parse_xml")
(caller-owns-return #t)
(return-type "GeglNode*")
(parameters
'("const-gchar*" "xmldata")
'("const-gchar*" "path_root")
)
)
(define-function parse_file
(c-name "gegl_parse_file")
(return-type "GeglNode*")
(parameters
'("const-gchar*" "path")
)
)
(define-function gegl_to_xml
(c-name "gegl_to_xml")
(return-type "gchar*")
(parameters
'("GeglNode*" "node")
'("const-gchar*" "path_root")
)
)
(define-function gegl_processor_get_type
(c-name "gegl_processor_get_type")
(return-type "GType")
)
(define-method new_processor
(of-object "GeglNode")
(c-name "gegl_node_new_processor")
(caller-owns-return #t)
(return-type "GeglProcessor*")
(parameters
'("GeglRectangle*" "rectangle")
)
)
(define-method set_rectangle
(of-object "GeglProcessor")
(c-name "gegl_processor_set_rectangle")
(return-type "none")
(parameters
'("GeglRectangle*" "rectangle")
)
)
(define-method work
(of-object "GeglProcessor")
(c-name "gegl_processor_work")
(return-type "gboolean")
(parameters
'("gdouble*" "progress")
)
)
(define-method destroy
(of-object "GeglProcessor")
(c-name "gegl_processor_destroy")
(return-type "none")
)
(define-function gegl_color_get_type
(c-name "gegl_color_get_type")
(return-type "GType")
)
(define-function gegl_color_new
(c-name "gegl_color_new")
(is-constructor-of "GeglColor")
(return-type "GeglColor*")
(properties
'("string" (argname "string") (optional))
)
)
(define-method get_rgba
(of-object "GeglColor")
(c-name "gegl_color_get_rgba")
(return-type "none")
(parameters
'("gfloat*" "r")
'("gfloat*" "g")
'("gfloat*" "b")
'("gfloat*" "a")
)
)
(define-method set_rgba
(of-object "GeglColor")
(c-name "gegl_color_set_rgba")
(return-type "none")
(parameters
'("gfloat" "r")
'("gfloat" "g")
'("gfloat" "b")
'("gfloat" "a")
)
)
;(define-function gegl_curve_get_type
; (c-name "gegl_curve_get_type")
; (return-type "GType")
;)
;
;(define-function gegl_curve_new
; (c-name "gegl_curve_new")
; (is-constructor-of "GeglCurve")
; (return-type "GeglCurve*")
; (parameters
; '("gfloat" "y_min")
; '("gfloat" "y_max")
; )
;)
;
;(define-function gegl_curve_default_curve
; (c-name "gegl_curve_default_curve")
; (return-type "GeglCurve*")
;)
;
;(define-method get_y_bounds
; (of-object "GeglCurve")
; (c-name "gegl_curve_get_y_bounds")
; (return-type "none")
; (parameters
; '("gfloat*" "min_y")
; '("gfloat*" "max_y")
; )
;)
;
;(define-method add_point
; (of-object "GeglCurve")
; (c-name "gegl_curve_add_point")
; (return-type "guint")
; (parameters
; '("gfloat" "x")
; '("gfloat" "y")
; )
;)
;
;(define-method remove_point_index
; (of-object "GeglCurve")
; (c-name "gegl_curve_remove_point_index")
; (return-type "none")
; (parameters
; '("guint" "index")
; )
;)
;
;(define-method get_point
; (of-object "GeglCurve")
; (c-name "gegl_curve_get_point")
; (return-type "none")
; (parameters
; '("guint" "index")
; '("gfloat*" "x")
; '("gfloat*" "y")
; )
;)
;
;(define-method set_point
; (of-object "GeglCurve")
; (c-name "gegl_curve_set_point")
; (return-type "none")
; (parameters
; '("guint" "index")
; '("gfloat" "x")
; '("gfloat" "y")
; )
;)
;
;(define-method num_points
; (of-object "GeglCurve")
; (c-name "gegl_curve_num_points")
; (return-type "guint")
;)
;
;(define-method calc_value
; (of-object "GeglCurve")
; (c-name "gegl_curve_calc_value")
; (return-type "gfloat")
; (parameters
; '("gfloat" "x")
; )
;)
;
;(define-method calc_values
; (of-object "GeglCurve")
; (c-name "gegl_curve_calc_values")
; (return-type "none")
; (parameters
; '("gfloat" "x_min")
; '("gfloat" "x_max")
; '("guint" "num_samples")
; '("gfloat*" "xs")
; '("gfloat*" "ys")
; )
;)